From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EF7FF2571A5 for ; Sun, 28 Dec 2025 19:20:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766949644; cv=none; b=fFqej9cBuFB4e/8vUgwbqb4FzjOQeMUbYeHaER5+80F+/WyI2RWfSfLtdZmnb4DmPNPnv0J6BW4aEW7uS7mv9uCGn8QcxAovOrRHc/H81VrWRSMeiF8zTPUWfo2k+7whbaNXA7VeGCr4zlLZj6b0oOvYMlXhutAIL/yUAqG8o24= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766949644; c=relaxed/simple; bh=IhyMm2V7Mz+czGr4Iy5eh9IjUPja8iB0XGAF1orLhiw=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=EZM3/IMAnkMyZNxmR5gcAXNInLUuFvZJr/6rS5OJEdORGKZxmiV/YHdhXEzKJVFUFFPF01Z0xkCKjfwqmXs5LGpVWuC+j6hdnevqiHIEC4zkAptdPY5e7bl2JHTuY0jeiwvyPS44tue+JfqngLioJz50Vb7rWRF1h2ijYKqovxY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ccOhWjzz; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ccOhWjzz" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 92C05C4CEFB; Sun, 28 Dec 2025 19:20:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1766949643; bh=IhyMm2V7Mz+czGr4Iy5eh9IjUPja8iB0XGAF1orLhiw=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=ccOhWjzzblKGls3obvK88De2u73Btq8NicABADZf0Ujq52o6NfnybpWNuTXIEwxSU Z2vWIVoVq0l42B/MEU6QJXiNcS0tCoCCPwK5ENqzdrRZBYw6jKa5TsDuedb3Yn2aRq KpmVih3KacttyKTLbkn3713nS7nNHO5c0OHtdbFWK8OyV51a6dcGDAixn5Gj4Z67ep BTY0z1JmMiYldzSeUg58+jFjLYFXIBPDGnmB8EtsHJSCG1yEjRVxT4LBIcTs8zpapP Dq4DY9MNwmg13BA3rkI9W0BTXODAsWyuaUNAbi5EP/bPtpi0pUk9Gbfbu+DUENm/L1 7utVDHlnpXWhA== Date: Sun, 28 Dec 2025 21:20:35 +0200 From: Mike Rapoport To: shengminghu512 Cc: akpm , david , "lorenzo.stoakes" , "Liam.Howlett" , vbabka , surenb , mhocko , linux-mm , linux-kernel , "hu.shengming" , "zhang.run" Subject: Re: [PATCH] mm/memblock: drop redundant 'struct page *' argument from memblock_free_pages() Message-ID: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: On Sun, Dec 28, 2025 at 07:38:50PM +0800, shengminghu512 wrote: > From: Shengming Hu > > 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 > --- > 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.