#author("2025-09-13T01:57:16+09:00","default:guest","guest") #author("2025-09-13T01:57:29+09:00","default:guest","guest") *参照元 [#l49c0976] #backlinks *説明 [#j34cf960] -パス: [[linux-5.15/mm/page_alloc.c]] -FIXME: これは何? --説明 **引数 [#tce46665] -struct zone *zone -- --[[linux-5.15/]] --[[linux-5.15/zone]] -unsigned int order -- -unsigned long count -- -struct list_head *list -- --[[linux-5.15/]] --[[linux-5.15/list_head]] -int migratetype -- -unsigned int alloc_flags -- **返り値 [#y5ae8725] -int -- **参考 [#g379cdea] *実装 [#ed86e9ab] /* * Obtain a specified number of elements from the buddy allocator, all under * a single hold of the lock, for efficiency. Add them to the supplied list. * Returns the number of new pages which were placed at *list. */ static int rmqueue_bulk(struct zone *zone, unsigned int order, unsigned long count, struct list_head *list, int migratetype, unsigned int alloc_flags) { int i, allocated = 0; /* * local_lock_irq held so equivalent to spin_lock_irqsave for * both PREEMPT_RT and non-PREEMPT_RT configurations. */ spin_lock(&zone->lock); - --[[linux-5.15/spin_lock()]] for (i = 0; i < count; ++i) { struct page *page = __rmqueue(zone, order, migratetype, alloc_flags); if (unlikely(page == NULL)) break; if (unlikely(check_pcp_refill(page))) continue; - --[[linux-5.15/page]] --[[linux-5.15/__rmqueue()]] --[[linux-5.15/unlikely()]] --[[linux-5.15/check_pcp_refill()]] /* * Split buddy pages returned by expand() are received here in * physical page order. The page is added to the tail of * caller's list. From the callers perspective, the linked list * is ordered by page number under some conditions. This is * useful for IO devices that can forward direction from the * head, thus also in the physical page order. This is useful * for IO devices that can merge IO requests if the physical * pages are ordered properly. */ list_add_tail(&page->lru, list); allocated++; if (is_migrate_cma(get_pcppage_migratetype(page))) __mod_zone_page_state(zone, NR_FREE_CMA_PAGES, -(1 << order)); } - --[[linux-5.15/list_add_tail()]] --[[linux-5.15/is_migrate_cma()]] --[[linux-5.15/get_pcppage_migratetype()]] --[[linux-5.15/__mod_zone_page_state()]] /* * i pages were removed from the buddy list even if some leak due * to check_pcp_refill failing so adjust NR_FREE_PAGES based * on i. Do not confuse with 'allocated' which is the number of * pages added to the pcp list. */ __mod_zone_page_state(zone, NR_FREE_PAGES, -(i << order)); spin_unlock(&zone->lock); return allocated; } - --[[linux-5.15/__mod_zone_page_state()]] --[[linux-5.15/spin_unlock()]] *コメント [#j5d36c0d]