Skip to content

Commit ee66e9c

Browse files
Matthew Wilcox (Oracle)akpm00
authored andcommitted
mm/page_alloc: move set_page_refcounted() to callers of prep_new_page()
In preparation for allocating frozen pages, stop initialising the page refcount in prep_new_page(). Link: https://lkml.kernel.org/r/20241125210149.2976098-6-willy@infradead.org Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org> Reviewed-by: Zi Yan <ziy@nvidia.com> Acked-by: David Hildenbrand <david@redhat.com> Reviewed-by: Vlastimil Babka <vbabka@suse.cz> 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>
1 parent 8fd10a8 commit ee66e9c

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

mm/page_alloc.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1563,7 +1563,6 @@ static void prep_new_page(struct page *page, unsigned int order, gfp_t gfp_flags
15631563
unsigned int alloc_flags)
15641564
{
15651565
post_alloc_hook(page, order, gfp_flags);
1566-
set_page_refcounted(page);
15671566

15681567
if (order && (gfp_flags & __GFP_COMP))
15691568
prep_compound_page(page, order);
@@ -3474,6 +3473,7 @@ get_page_from_freelist(gfp_t gfp_mask, unsigned int order, int alloc_flags,
34743473
gfp_mask, alloc_flags, ac->migratetype);
34753474
if (page) {
34763475
prep_new_page(page, order, gfp_mask, alloc_flags);
3476+
set_page_refcounted(page);
34773477

34783478
/*
34793479
* If this is a high-order atomic allocation then check
@@ -3698,8 +3698,10 @@ __alloc_pages_direct_compact(gfp_t gfp_mask, unsigned int order,
36983698
count_vm_event(COMPACTSTALL);
36993699

37003700
/* Prep a captured page if available */
3701-
if (page)
3701+
if (page) {
37023702
prep_new_page(page, order, gfp_mask, alloc_flags);
3703+
set_page_refcounted(page);
3704+
}
37033705

37043706
/* Try get a page from the freelist if available */
37053707
if (!page)
@@ -4678,6 +4680,7 @@ unsigned long alloc_pages_bulk_noprof(gfp_t gfp, int preferred_nid,
46784680
nr_account++;
46794681

46804682
prep_new_page(page, 0, gfp, 0);
4683+
set_page_refcounted(page);
46814684
if (page_list)
46824685
list_add(&page->lru, page_list);
46834686
else
@@ -6500,6 +6503,7 @@ int alloc_contig_range_noprof(unsigned long start, unsigned long end,
65006503

65016504
check_new_pages(head, order);
65026505
prep_new_page(head, order, gfp_mask, 0);
6506+
set_page_refcounted(head);
65036507
} else {
65046508
ret = -EINVAL;
65056509
WARN(true, "PFN range: requested [%lu, %lu), allocated [%lu, %lu)\n",

0 commit comments

Comments
 (0)