Skip to content

Commit 8fd10a8

Browse files
Matthew Wilcox (Oracle)akpm00
authored andcommitted
mm/page_alloc: move set_page_refcounted() to callers of post_alloc_hook()
In preparation for allocating frozen pages, stop initialising the page refcount in post_alloc_hook(). Link: https://lkml.kernel.org/r/20241125210149.2976098-5-willy@infradead.org Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org> Reviewed-by: Miaohe Lin <linmiaohe@huawei.com> 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: Muchun Song <songmuchun@bytedance.com> Cc: William Kucharski <william.kucharski@oracle.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
1 parent 520128a commit 8fd10a8

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

mm/compaction.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ static inline bool is_via_compact_memory(int order) { return false; }
8383
static struct page *mark_allocated_noprof(struct page *page, unsigned int order, gfp_t gfp_flags)
8484
{
8585
post_alloc_hook(page, order, __GFP_MOVABLE);
86+
set_page_refcounted(page);
8687
return page;
8788
}
8889
#define mark_allocated(...) alloc_hooks(mark_allocated_noprof(__VA_ARGS__))
@@ -1868,6 +1869,7 @@ static struct folio *compaction_alloc_noprof(struct folio *src, unsigned long da
18681869
dst = (struct folio *)freepage;
18691870

18701871
post_alloc_hook(&dst->page, order, __GFP_MOVABLE);
1872+
set_page_refcounted(&dst->page);
18711873
if (order)
18721874
prep_compound_page(&dst->page, order);
18731875
cc->nr_freepages -= 1 << order;

mm/internal.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -735,8 +735,7 @@ static inline void prep_compound_tail(struct page *head, int tail_idx)
735735

736736
extern void prep_compound_page(struct page *page, unsigned int order);
737737

738-
extern void post_alloc_hook(struct page *page, unsigned int order,
739-
gfp_t gfp_flags);
738+
void post_alloc_hook(struct page *page, unsigned int order, gfp_t gfp_flags);
740739
extern bool free_pages_prepare(struct page *page, unsigned int order);
741740

742741
extern int user_min_free_kbytes;

mm/page_alloc.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1508,7 +1508,6 @@ inline void post_alloc_hook(struct page *page, unsigned int order,
15081508
int i;
15091509

15101510
set_page_private(page, 0);
1511-
set_page_refcounted(page);
15121511

15131512
arch_alloc_page(page, order);
15141513
debug_pagealloc_map_pages(page, 1 << order);
@@ -1564,6 +1563,7 @@ static void prep_new_page(struct page *page, unsigned int order, gfp_t gfp_flags
15641563
unsigned int alloc_flags)
15651564
{
15661565
post_alloc_hook(page, order, gfp_flags);
1566+
set_page_refcounted(page);
15671567

15681568
if (order && (gfp_flags & __GFP_COMP))
15691569
prep_compound_page(page, order);
@@ -6360,6 +6360,7 @@ static void split_free_pages(struct list_head *list)
63606360
int i;
63616361

63626362
post_alloc_hook(page, order, __GFP_MOVABLE);
6363+
set_page_refcounted(page);
63636364
if (!order)
63646365
continue;
63656366

0 commit comments

Comments
 (0)