init_compound_tail() is only used in mm/sparse-vmemmap.c, so there is no
need to keep it in mm/internal.h.

The helper is only used for SPARSEMEM_VMEMMAP_OPTIMIZATION, where passing
NULL as the compound head is valid. Keeping it visible outside makes that
usage look more generally applicable than it really is, which increases
the chance of misuse.

Move it into mm/sparse-vmemmap.c so the helper stays tied to the only
context where its NULL head argument is valid.

No functional change intended.

Signed-off-by: Muchun Song <[email protected]>
---
 mm/internal.h       |  9 ---------
 mm/sparse-vmemmap.c | 12 +++++++++++-
 2 files changed, 11 insertions(+), 10 deletions(-)

diff --git a/mm/internal.h b/mm/internal.h
index afdae79640b5..aff7cebb1da4 100644
--- a/mm/internal.h
+++ b/mm/internal.h
@@ -907,15 +907,6 @@ static inline void prep_compound_tail(struct page *tail,
        set_page_private(tail, 0);
 }
 
-static inline void init_compound_tail(struct page *tail,
-               const struct page *head, unsigned int order, struct zone *zone)
-{
-       atomic_set(&tail->_mapcount, -1);
-       set_page_node(tail, zone_to_nid(zone));
-       set_page_zone(tail, zone_idx(zone));
-       prep_compound_tail(tail, head, order);
-}
-
 void post_alloc_hook(struct page *page, unsigned int order, gfp_t gfp_flags);
 extern bool free_pages_prepare(struct page *page, unsigned int order);
 
diff --git a/mm/sparse-vmemmap.c b/mm/sparse-vmemmap.c
index 667424aadd6b..38777e4952e1 100644
--- a/mm/sparse-vmemmap.c
+++ b/mm/sparse-vmemmap.c
@@ -265,6 +265,16 @@ int __meminit vmemmap_populate_basepages(unsigned long 
start, unsigned long end,
        return 0;
 }
 
+static void init_compound_tail(struct page *page, unsigned int order, struct 
zone *zone)
+{
+       BUILD_BUG_ON(!IS_ENABLED(SPARSEMEM_VMEMMAP_OPTIMIZATION));
+
+       atomic_set(&page->_mapcount, -1);
+       set_page_node(page, zone_to_nid(zone));
+       set_page_zone(page, zone_idx(zone));
+       prep_compound_tail(page, NULL, order);
+}
+
 struct page __ref *vmemmap_shared_tail_page(unsigned int order, struct zone 
*zone)
 {
        void *addr;
@@ -286,7 +296,7 @@ struct page __ref *vmemmap_shared_tail_page(unsigned int 
order, struct zone *zon
                page = (struct page *)addr + i;
                if (zone_is_zone_device(zone))
                        __SetPageReserved(page);
-               init_compound_tail(page, NULL, order, zone);
+               init_compound_tail(page, order, zone);
        }
 
        page = virt_to_page(addr);
-- 
2.54.0


Reply via email to