Skip to content

Commit 58e3e52

Browse files
HSM6236rppt
authored andcommitted
memblock: drop redundant 'struct page *' argument from memblock_free_pages()
memblock_free_pages() currently takes both a struct page * and the corresponding PFN. The page pointer is always derived from the PFN at call sites (pfn_to_page(pfn)), making the parameter redundant and also allowing accidental mismatches between the two arguments. Simplify the interface by removing the struct page * argument and deriving the page locally from the PFN, after the deferred struct page initialization check. This keeps the behavior unchanged while making the helper harder to misuse. Signed-off-by: Shengming Hu <hu.shengming@zte.com.cn> Reviewed-by: David Hildenbrand (Red Hat) <david@kernel.org> Link: https://patch.msgid.link/tencent_F741CE6ECC49EE099736685E60C0DBD4A209@qq.com Signed-off-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
1 parent be05f57 commit 58e3e52

4 files changed

Lines changed: 7 additions & 8 deletions

File tree

mm/internal.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -742,8 +742,7 @@ static inline void clear_zone_contiguous(struct zone *zone)
742742
extern int __isolate_free_page(struct page *page, unsigned int order);
743743
extern void __putback_isolated_page(struct page *page, unsigned int order,
744744
int mt);
745-
extern void memblock_free_pages(struct page *page, unsigned long pfn,
746-
unsigned int order);
745+
extern void memblock_free_pages(unsigned long pfn, unsigned int order);
747746
extern void __free_pages_core(struct page *page, unsigned int order,
748747
enum meminit_context context);
749748

mm/memblock.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1771,7 +1771,7 @@ void __init memblock_free_late(phys_addr_t base, phys_addr_t size)
17711771
end = PFN_DOWN(base + size);
17721772

17731773
for (; cursor < end; cursor++) {
1774-
memblock_free_pages(pfn_to_page(cursor), cursor, 0);
1774+
memblock_free_pages(cursor, 0);
17751775
totalram_pages_inc();
17761776
}
17771777
}
@@ -2216,7 +2216,7 @@ static void __init __free_pages_memory(unsigned long start, unsigned long end)
22162216
while (start + (1UL << order) > end)
22172217
order--;
22182218

2219-
memblock_free_pages(pfn_to_page(start), start, order);
2219+
memblock_free_pages(start, order);
22202220

22212221
start += (1UL << order);
22222222
}

mm/mm_init.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2480,9 +2480,10 @@ void *__init alloc_large_system_hash(const char *tablename,
24802480
return table;
24812481
}
24822482

2483-
void __init memblock_free_pages(struct page *page, unsigned long pfn,
2484-
unsigned int order)
2483+
void __init memblock_free_pages(unsigned long pfn, unsigned int order)
24852484
{
2485+
struct page *page = pfn_to_page(pfn);
2486+
24862487
if (IS_ENABLED(CONFIG_DEFERRED_STRUCT_PAGE_INIT)) {
24872488
int nid = early_pfn_to_nid(pfn);
24882489

tools/testing/memblock/internal.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@ bool mirrored_kernelcore = false;
1515

1616
struct page {};
1717

18-
void memblock_free_pages(struct page *page, unsigned long pfn,
19-
unsigned int order)
18+
void memblock_free_pages(unsigned long pfn, unsigned int order)
2019
{
2120
}
2221

0 commit comments

Comments
 (0)