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_may_oom()

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

Link: https://lkml.kernel.org/r/20241125210149.2976098-9-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
df544c5e 4c9017cc

+4 -6
+4 -6
mm/page_alloc.c
··· 3604 3604 page = get_page_from_freelist((gfp_mask | __GFP_HARDWALL) & 3605 3605 ~__GFP_DIRECT_RECLAIM, order, 3606 3606 ALLOC_WMARK_HIGH|ALLOC_CPUSET, ac); 3607 - if (page) { 3608 - set_page_refcounted(page); 3607 + if (page) 3609 3608 goto out; 3610 - } 3611 3609 3612 3610 /* Coredumps can quickly deplete all memory reserves */ 3613 3611 if (current->flags & PF_DUMPCORE) ··· 3650 3652 if (gfp_mask & __GFP_NOFAIL) 3651 3653 page = __alloc_pages_cpuset_fallback(gfp_mask, order, 3652 3654 ALLOC_NO_WATERMARKS, ac); 3653 - if (page) 3654 - set_page_refcounted(page); 3655 3655 } 3656 3656 out: 3657 3657 mutex_unlock(&oom_lock); ··· 4433 4437 4434 4438 /* Reclaim has failed us, start killing things */ 4435 4439 page = __alloc_pages_may_oom(gfp_mask, order, ac, &did_some_progress); 4436 - if (page) 4440 + if (page) { 4441 + set_page_refcounted(page); 4437 4442 goto got_pg; 4443 + } 4438 4444 4439 4445 /* Avoid allocations with no watermarks from looping endlessly */ 4440 4446 if (tsk_is_oom_victim(current) &&