All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mike Rapoport <rppt@kernel.org>
To: shengminghu512 <shengminghu512@qq.com>
Cc: akpm <akpm@linux-foundation.org>, david <david@kernel.org>,
	"lorenzo.stoakes" <lorenzo.stoakes@oracle.com>,
	"Liam.Howlett" <Liam.Howlett@oracle.com>, vbabka <vbabka@suse.cz>,
	surenb <surenb@google.com>, mhocko <mhocko@suse.com>,
	linux-mm <linux-mm@kvack.org>,
	linux-kernel <linux-kernel@vger.kernel.org>,
	"hu.shengming" <hu.shengming@zte.com.cn>,
	"zhang.run" <zhang.run@zte.com.cn>
Subject: Re: [PATCH] mm/memblock: drop redundant 'struct page *' argument from memblock_free_pages()
Date: Sun, 28 Dec 2025 21:20:35 +0200	[thread overview]
Message-ID: <aVGDA8Vydmh6bT6u@kernel.org> (raw)
In-Reply-To: <tencent_600D1BCC5E1B5DB4DDD98679DA7DC3123C06@qq.com>

On Sun, Dec 28, 2025 at 07:38:50PM +0800, shengminghu512 wrote:
> From: Shengming Hu <hu.shengming@zte.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@zte.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.


      reply	other threads:[~2025-12-28 19:20 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-28 11:38 [PATCH] mm/memblock: drop redundant 'struct page *' argument from memblock_free_pages() shengminghu512
2025-12-28 19:20 ` Mike Rapoport [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aVGDA8Vydmh6bT6u@kernel.org \
    --to=rppt@kernel.org \
    --cc=Liam.Howlett@oracle.com \
    --cc=akpm@linux-foundation.org \
    --cc=david@kernel.org \
    --cc=hu.shengming@zte.com.cn \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=lorenzo.stoakes@oracle.com \
    --cc=mhocko@suse.com \
    --cc=shengminghu512@qq.com \
    --cc=surenb@google.com \
    --cc=vbabka@suse.cz \
    --cc=zhang.run@zte.com.cn \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.