lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <aVGDA8Vydmh6bT6u@kernel.org>
Date: Sun, 28 Dec 2025 21:20:35 +0200
From: Mike Rapoport <rppt@...nel.org>
To: shengminghu512 <shengminghu512@...com>
Cc: akpm <akpm@...ux-foundation.org>, david <david@...nel.org>,
	"lorenzo.stoakes" <lorenzo.stoakes@...cle.com>,
	"Liam.Howlett" <Liam.Howlett@...cle.com>, vbabka <vbabka@...e.cz>,
	surenb <surenb@...gle.com>, mhocko <mhocko@...e.com>,
	linux-mm <linux-mm@...ck.org>,
	linux-kernel <linux-kernel@...r.kernel.org>,
	"hu.shengming" <hu.shengming@....com.cn>,
	"zhang.run" <zhang.run@....com.cn>
Subject: Re: [PATCH] mm/memblock: drop redundant 'struct page *' argument
 from memblock_free_pages()

On Sun, Dec 28, 2025 at 07:38:50PM +0800, shengminghu512 wrote:
> From: Shengming Hu <hu.shengming@....com.cn>
> 
> 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@....com.cn>
> ---
>  mm/internal.h                     | 3 +--
>  mm/memblock.c                     | 4 ++--
>  mm/mm_init.c                      | 7 +++++--
>  tools/testing/memblock/internal.h | 3 +--
>  4 files changed, 9 insertions(+), 8 deletions(-)
> 
> --- a/mm/mm_init.c
> +++ b/mm/mm_init.c
> @@ -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;

page can be initialized here, the compiler should figure out how to avoid
extra instructions.

> +
>  	if (IS_ENABLED(CONFIG_DEFERRED_STRUCT_PAGE_INIT)) {
>  		int nid = early_pfn_to_nid(pfn);
>  
> @@ -2490,6 +2491,8 @@ void __init memblock_free_pages(struct page *page, unsigned long pfn,
>  			return;
>  	}
>  
> +	page = pfn_to_page(pfn);
> +
>  	if (!kmsan_memblock_free_pages(page, order)) {
>  		/* KMSAN will take care of these pages. */
>  		return;

-- 
Sincerely yours,
Mike.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ