Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

mm/page_alloc: move set_page_refcounted() to callers of __alloc_pages_slowpath()

In preparation for allocating frozen pages, stop initialising the page
refcount in __alloc_pages_slowpath().

Link: https://lkml.kernel.org/r/20241125210149.2976098-12-willy@infradead.org
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Reviewed-by: Zi Yan <ziy@nvidia.com>
Reviewed-by: Vlastimil Babka <vbabka@suse.cz>
Cc: David Hildenbrand <david@redhat.com>
Cc: Hyeonggon Yoo <42.hyeyoo@gmail.com>
Cc: Mel Gorman <mgorman@techsingularity.net>
Cc: Miaohe Lin <linmiaohe@huawei.com>
Cc: Muchun Song <songmuchun@bytedance.com>
Cc: William Kucharski <william.kucharski@oracle.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Matthew Wilcox (Oracle) and committed by
Andrew Morton
a88de400 30fdb6df

+9 -21
+9 -21
mm/page_alloc.c
··· 4284 4284 * that first 4285 4285 */ 4286 4286 page = get_page_from_freelist(gfp_mask, order, alloc_flags, ac); 4287 - if (page) { 4288 - set_page_refcounted(page); 4287 + if (page) 4289 4288 goto got_pg; 4290 - } 4291 4289 4292 4290 /* 4293 4291 * For costly allocations, try direct compaction first, as it's likely ··· 4304 4306 alloc_flags, ac, 4305 4307 INIT_COMPACT_PRIORITY, 4306 4308 &compact_result); 4307 - if (page) { 4308 - set_page_refcounted(page); 4309 + if (page) 4309 4310 goto got_pg; 4310 - } 4311 4311 4312 4312 /* 4313 4313 * Checks for costly allocations with __GFP_NORETRY, which ··· 4365 4369 4366 4370 /* Attempt with potentially adjusted zonelist and alloc_flags */ 4367 4371 page = get_page_from_freelist(gfp_mask, order, alloc_flags, ac); 4368 - if (page) { 4369 - set_page_refcounted(page); 4372 + if (page) 4370 4373 goto got_pg; 4371 - } 4372 4374 4373 4375 /* Caller is not willing to reclaim, we can't balance anything */ 4374 4376 if (!can_direct_reclaim) ··· 4379 4385 /* Try direct reclaim and then allocating */ 4380 4386 page = __alloc_pages_direct_reclaim(gfp_mask, order, alloc_flags, ac, 4381 4387 &did_some_progress); 4382 - if (page) { 4383 - set_page_refcounted(page); 4388 + if (page) 4384 4389 goto got_pg; 4385 - } 4386 4390 4387 4391 /* Try direct compaction and then allocating */ 4388 4392 page = __alloc_pages_direct_compact(gfp_mask, order, alloc_flags, ac, 4389 4393 compact_priority, &compact_result); 4390 - if (page) { 4391 - set_page_refcounted(page); 4394 + if (page) 4392 4395 goto got_pg; 4393 - } 4394 4396 4395 4397 /* Do not loop if specifically requested */ 4396 4398 if (gfp_mask & __GFP_NORETRY) ··· 4427 4437 4428 4438 /* Reclaim has failed us, start killing things */ 4429 4439 page = __alloc_pages_may_oom(gfp_mask, order, ac, &did_some_progress); 4430 - if (page) { 4431 - set_page_refcounted(page); 4440 + if (page) 4432 4441 goto got_pg; 4433 - } 4434 4442 4435 4443 /* Avoid allocations with no watermarks from looping endlessly */ 4436 4444 if (tsk_is_oom_victim(current) && ··· 4472 4484 * the situation worse. 4473 4485 */ 4474 4486 page = __alloc_pages_cpuset_fallback(gfp_mask, order, ALLOC_MIN_RESERVE, ac); 4475 - if (page) { 4476 - set_page_refcounted(page); 4487 + if (page) 4477 4488 goto got_pg; 4478 - } 4479 4489 4480 4490 cond_resched(); 4481 4491 goto retry; ··· 4765 4779 ac.nodemask = nodemask; 4766 4780 4767 4781 page = __alloc_pages_slowpath(alloc_gfp, order, &ac); 4782 + if (page) 4783 + set_page_refcounted(page); 4768 4784 4769 4785 out: 4770 4786 if (memcg_kmem_online() && (gfp & __GFP_ACCOUNT) && page &&