Commit 58e3e526 authored by Shengming Hu's avatar Shengming Hu Committed by Mike Rapoport (Microsoft)
Browse files

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: default avatarShengming Hu <hu.shengming@zte.com.cn>
Reviewed-by: default avatarDavid Hildenbrand (Red Hat) <david@kernel.org>
Link: https://patch.msgid.link/tencent_F741CE6ECC49EE099736685E60C0DBD4A209@qq.com


Signed-off-by: default avatarMike Rapoport (Microsoft) <rppt@kernel.org>
parent be05f571
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -742,8 +742,7 @@ static inline void clear_zone_contiguous(struct zone *zone)
extern int __isolate_free_page(struct page *page, unsigned int order);
extern void __putback_isolated_page(struct page *page, unsigned int order,
				    int mt);
extern void memblock_free_pages(struct page *page, unsigned long pfn,
					unsigned int order);
extern void memblock_free_pages(unsigned long pfn, unsigned int order);
extern void __free_pages_core(struct page *page, unsigned int order,
		enum meminit_context context);

+2 −2
Original line number Diff line number Diff line
@@ -1771,7 +1771,7 @@ void __init memblock_free_late(phys_addr_t base, phys_addr_t size)
	end = PFN_DOWN(base + size);

	for (; cursor < end; cursor++) {
		memblock_free_pages(pfn_to_page(cursor), cursor, 0);
		memblock_free_pages(cursor, 0);
		totalram_pages_inc();
	}
}
@@ -2216,7 +2216,7 @@ static void __init __free_pages_memory(unsigned long start, unsigned long end)
		while (start + (1UL << order) > end)
			order--;

		memblock_free_pages(pfn_to_page(start), start, order);
		memblock_free_pages(start, order);

		start += (1UL << order);
	}
+3 −2
Original line number Diff line number Diff line
@@ -2480,9 +2480,10 @@ void *__init alloc_large_system_hash(const char *tablename,
	return table;
}

void __init memblock_free_pages(struct page *page, unsigned long pfn,
							unsigned int order)
void __init memblock_free_pages(unsigned long pfn, unsigned int order)
{
	struct page *page = pfn_to_page(pfn);

	if (IS_ENABLED(CONFIG_DEFERRED_STRUCT_PAGE_INIT)) {
		int nid = early_pfn_to_nid(pfn);

+1 −2
Original line number Diff line number Diff line
@@ -15,8 +15,7 @@ bool mirrored_kernelcore = false;

struct page {};

void memblock_free_pages(struct page *page, unsigned long pfn,
			 unsigned int order)
void memblock_free_pages(unsigned long pfn, unsigned int order)
{
}