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 EFCD0537E9 for ; Sat, 10 May 2025 00:37:04 +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=1746837426; cv=none; b=OBKYNq59VuGi8k+7XFzgGFXT+a8TErXPcF3NINkauBvY7Y6Qlw8DoSCh2pPcRZw9mZiuFf5XZqsLLxxp4BHE8ggYv3tfSMfh6d/s8MBbvGp6HgATJLXpelYMhycnUeLklA1rPHLOifooowVpk1r3PEz75QTOSIoDtV0v4SJc6+M= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746837426; c=relaxed/simple; bh=Ctxa7V2nknxqbRPAssc8wUcidbZ7mEuaoBiM04IePEI=; h=Date:To:From:Subject:Message-Id; b=HpGMMRx475mes9+BN+GIbz6hX3sOez3r0U5UVIaf6cYlaTRgaPYyYFW6H337sf/PLcaeNriDSSSSAzQCh3XPF+o/DXUWy4X5soVtyzpRaQxuN6y79p+uaEu6hJfVfyhxg779U35O4o4HjtE/HfrkhOwn+EmkyZ3sl5OfO29z/Rc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b=o6d+aJRX; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b="o6d+aJRX" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3DB89C4CEED; Sat, 10 May 2025 00:37:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1746837424; bh=Ctxa7V2nknxqbRPAssc8wUcidbZ7mEuaoBiM04IePEI=; h=Date:To:From:Subject:From; b=o6d+aJRXGwQhICKwyxqABBS2dx5UwFrveeiDz4qwpkRqi8Ya4+TfvWT3hxp3zQ1rz 4lz0k+yr1n7UYiE01oYshy7B29MDgxkFvf3rLjLnM06dlKIHFdp3L/sizIffU6zIzZ ol66ynccylU2DKXdQ6ghgY6E3nFQtQQpjE9MRp8w= Date: Fri, 09 May 2025 17:37:03 -0700 To: mm-commits@vger.kernel.org,will@kernel.org,thomas.lendacky@amd.com,tglx@linutronix.de,skinsburskii@linux.microsoft.com,saravanak@google.com,rostedt@goodmis.org,robh@kernel.org,ptyadav@amazon.de,peterz@infradead.org,pbonzini@redhat.com,pasha.tatashin@soleen.com,mingo@redhat.com,mark.rutland@arm.com,luto@kernel.org,krzk@kernel.org,jgowans@amazon.com,jgg@nvidia.com,hpa@zytor.com,graf@amazon.com,ebiederm@xmission.com,dwmw2@infradead.org,dave.hansen@linux.intel.com,corbet@lwn.net,changyuanl@google.com,catalin.marinas@arm.com,bp@alien8.de,benh@kernel.crashing.org,ashish.kalra@amd.com,arnd@arndb.de,anthony.yznaga@oracle.com,rppt@kernel.org,akpm@linux-foundation.org From: Andrew Morton Subject: + memblock-introduce-memmap_init_kho_scratch.patch added to mm-unstable branch Message-Id: <20250510003704.3DB89C4CEED@smtp.kernel.org> Precedence: bulk X-Mailing-List: mm-commits@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: The patch titled Subject: memblock: introduce memmap_init_kho_scratch() has been added to the -mm mm-unstable branch. Its filename is memblock-introduce-memmap_init_kho_scratch.patch This patch will shortly appear at https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/memblock-introduce-memmap_init_kho_scratch.patch This patch will later appear in the mm-unstable branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next via the mm-everything branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm and is updated there every 2-3 working days ------------------------------------------------------ From: "Mike Rapoport (Microsoft)" Subject: memblock: introduce memmap_init_kho_scratch() Date: Fri, 9 May 2025 00:46:21 -0700 With deferred initialization of struct page it will be necessary to initialize memory map for KHO scratch regions early. Add memmap_init_kho_scratch() method that will allow such initialization in upcoming patches. Link: https://lkml.kernel.org/r/20250509074635.3187114-4-changyuanl@google.com Signed-off-by: Mike Rapoport (Microsoft) Signed-off-by: Changyuan Lyu Cc: Alexander Graf Cc: Andy Lutomirski Cc: Anthony Yznaga Cc: Arnd Bergmann Cc: Ashish Kalra Cc: Ben Herrenschmidt Cc: Borislav Betkov Cc: Catalin Marinas Cc: Dave Hansen Cc: David Woodhouse Cc: Eric Biederman Cc: "H. Peter Anvin" Cc: Ingo Molnar Cc: James Gowans Cc: Jason Gunthorpe Cc: Jonathan Corbet Cc: Krzysztof Kozlowski Cc: Marc Rutland Cc: Paolo Bonzini Cc: Pasha Tatashin Cc: Peter Zijlstra Cc: Pratyush Yadav Cc: Rob Herring Cc: Saravana Kannan Cc: Stanislav Kinsburskii Cc: Steven Rostedt Cc: Thomas Gleinxer Cc: Thomas Lendacky Cc: Will Deacon Signed-off-by: Andrew Morton --- include/linux/memblock.h | 2 ++ mm/internal.h | 2 ++ mm/memblock.c | 22 ++++++++++++++++++++++ mm/mm_init.c | 11 ++++++++--- 4 files changed, 34 insertions(+), 3 deletions(-) --- a/include/linux/memblock.h~memblock-introduce-memmap_init_kho_scratch +++ a/include/linux/memblock.h @@ -635,9 +635,11 @@ static inline void memtest_report_meminf #ifdef CONFIG_MEMBLOCK_KHO_SCRATCH void memblock_set_kho_scratch_only(void); void memblock_clear_kho_scratch_only(void); +void memmap_init_kho_scratch_pages(void); #else static inline void memblock_set_kho_scratch_only(void) { } static inline void memblock_clear_kho_scratch_only(void) { } +static inline void memmap_init_kho_scratch_pages(void) {} #endif #endif /* _LINUX_MEMBLOCK_H */ --- a/mm/internal.h~memblock-introduce-memmap_init_kho_scratch +++ a/mm/internal.h @@ -1119,6 +1119,8 @@ DECLARE_STATIC_KEY_TRUE(deferred_pages); bool __init deferred_grow_zone(struct zone *zone, unsigned int order); #endif /* CONFIG_DEFERRED_STRUCT_PAGE_INIT */ +void init_deferred_page(unsigned long pfn, int nid); + enum mminit_level { MMINIT_WARNING, MMINIT_VERIFY, --- a/mm/memblock.c~memblock-introduce-memmap_init_kho_scratch +++ a/mm/memblock.c @@ -946,6 +946,28 @@ __init void memblock_clear_kho_scratch_o { kho_scratch_only = false; } + +__init void memmap_init_kho_scratch_pages(void) +{ + phys_addr_t start, end; + unsigned long pfn; + int nid; + u64 i; + + if (!IS_ENABLED(CONFIG_DEFERRED_STRUCT_PAGE_INIT)) + return; + + /* + * Initialize struct pages for free scratch memory. + * The struct pages for reserved scratch memory will be set up in + * reserve_bootmem_region() + */ + __for_each_mem_range(i, &memblock.memory, NULL, NUMA_NO_NODE, + MEMBLOCK_KHO_SCRATCH, &start, &end, &nid) { + for (pfn = PFN_UP(start); pfn < PFN_DOWN(end); pfn++) + init_deferred_page(pfn, nid); + } +} #endif /** --- a/mm/mm_init.c~memblock-introduce-memmap_init_kho_scratch +++ a/mm/mm_init.c @@ -743,7 +743,7 @@ defer_init(int nid, unsigned long pfn, u return false; } -static void __meminit init_deferred_page(unsigned long pfn, int nid) +static void __meminit __init_deferred_page(unsigned long pfn, int nid) { if (early_page_initialised(pfn, nid)) return; @@ -763,11 +763,16 @@ static inline bool defer_init(int nid, u return false; } -static inline void init_deferred_page(unsigned long pfn, int nid) +static inline void __init_deferred_page(unsigned long pfn, int nid) { } #endif /* CONFIG_DEFERRED_STRUCT_PAGE_INIT */ +void __meminit init_deferred_page(unsigned long pfn, int nid) +{ + __init_deferred_page(pfn, nid); +} + /* * Initialised pages do not have PageReserved set. This function is * called for each range allocated by the bootmem allocator and @@ -784,7 +789,7 @@ void __meminit reserve_bootmem_region(ph if (pfn_valid(start_pfn)) { struct page *page = pfn_to_page(start_pfn); - init_deferred_page(start_pfn, nid); + __init_deferred_page(start_pfn, nid); /* * no need for atomic set_bit because the struct _ Patches currently in -mm which might be from rppt@kernel.org are execmem-enforce-allocation-size-aligment-to-page_size.patch memblock-add-memblock_rsrv_kern-flag.patch memblock-introduce-memmap_init_kho_scratch.patch kexec-enable-kho-support-for-memory-preservation.patch x86-setup-use-memblock_reserve_kern-for-memory-used-by-kernel.patch documentation-kho-add-memblock-bindings.patch