From: Muchun Song <songmuchun@bytedance.com>
To: David Hildenbrand <david@kernel.org>,
Madhavan Srinivasan <maddy@linux.ibm.com>,
Mike Rapoport <rppt@kernel.org>,
Andrew Morton <akpm@linux-foundation.org>
Cc: Lance Yang <lance.yang@linux.dev>,
Michael Ellerman <mpe@ellerman.id.au>,
Nicholas Piggin <npiggin@gmail.com>,
Christophe Leroy <chleroy@kernel.org>,
Ritesh Harjani <ritesh.list@gmail.com>,
Shrikanth Hegde <sshegde@linux.ibm.com>,
Oscar Salvador <osalvador@suse.de>, Qi Zheng <qi.zheng@linux.dev>,
Muchun Song <muchun.song@linux.dev>,
Huacai Chen <chenhuacai@kernel.org>,
WANG Xuerui <kernel@xen0n.name>,
linux-mm@kvack.org, linuxppc-dev@lists.ozlabs.org,
linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-riscv@lists.infradead.org, x86@kernel.org,
loongarch@lists.linux.dev, linux-s390@vger.kernel.org,
Muchun Song <songmuchun@bytedance.com>
Subject: [PATCH v2 2/5] powerpc/mm: drop powerpc vmemmap_can_optimize()
Date: Thu, 5 Nov 2026 14:12:14 +0800 [thread overview]
Message-ID: <20261105061217.13302-3-songmuchun@bytedance.com> (raw)
In-Reply-To: <20261105061217.13302-1-songmuchun@bytedance.com>
Whether the optimized mapping can be used is now decided in the
architecture-specific vmemmap_populate() path. When PowerPC has to fall
back, such as on Hash MMU, it can disable optimization for the populated
vmemmap range there.
Add section_vmemmap_optimization_disable() to centralize this fallback,
use it in the Hash MMU path, and drop the radix-specific
vmemmap_can_optimize() override.
Signed-off-by: Muchun Song <songmuchun@bytedance.com>
---
v2:
- Add section_vmemmap_optimization_disable() for architecture fallbacks
- Use the helper for the PowerPC Hash MMU path
- Include vmemmap-optimization.h directly (reported by Sashiko)
---
arch/powerpc/include/asm/book3s/64/radix.h | 5 ----
arch/powerpc/mm/book3s64/radix_pgtable.c | 10 -------
arch/powerpc/mm/init_64.c | 2 ++
include/linux/vmemmap-optimization.h | 31 ++++++++++++++++++++++
mm/sparse.h | 5 ----
5 files changed, 33 insertions(+), 20 deletions(-)
diff --git a/arch/powerpc/include/asm/book3s/64/radix.h b/arch/powerpc/include/asm/book3s/64/radix.h
index 8452a2714cb1..df67209b0c5b 100644
--- a/arch/powerpc/include/asm/book3s/64/radix.h
+++ b/arch/powerpc/include/asm/book3s/64/radix.h
@@ -351,10 +351,5 @@ int radix__create_section_mapping(unsigned long start, unsigned long end,
int nid, pgprot_t prot);
int radix__remove_section_mapping(unsigned long start, unsigned long end);
#endif /* CONFIG_MEMORY_HOTPLUG */
-
-#ifdef CONFIG_ARCH_WANT_OPTIMIZE_DAX_VMEMMAP
-#define vmemmap_can_optimize vmemmap_can_optimize
-bool vmemmap_can_optimize(struct vmem_altmap *altmap, struct dev_pagemap *pgmap);
-#endif
#endif /* __ASSEMBLER__ */
#endif
diff --git a/arch/powerpc/mm/book3s64/radix_pgtable.c b/arch/powerpc/mm/book3s64/radix_pgtable.c
index 2924604fbb38..63f369d296b4 100644
--- a/arch/powerpc/mm/book3s64/radix_pgtable.c
+++ b/arch/powerpc/mm/book3s64/radix_pgtable.c
@@ -978,16 +978,6 @@ int __meminit radix__vmemmap_create_mapping(unsigned long start,
return 0;
}
-#ifdef CONFIG_ARCH_WANT_OPTIMIZE_DAX_VMEMMAP
-bool vmemmap_can_optimize(struct vmem_altmap *altmap, struct dev_pagemap *pgmap)
-{
- if (radix_enabled())
- return __vmemmap_can_optimize(altmap, pgmap);
-
- return false;
-}
-#endif
-
int __meminit vmemmap_check_pmd(pmd_t *pmdp, int node,
unsigned long addr, unsigned long next)
{
diff --git a/arch/powerpc/mm/init_64.c b/arch/powerpc/mm/init_64.c
index 0e777d7dc332..4d6928f717cf 100644
--- a/arch/powerpc/mm/init_64.c
+++ b/arch/powerpc/mm/init_64.c
@@ -24,6 +24,7 @@
#include <linux/types.h>
#include <linux/mman.h>
#include <linux/mm.h>
+#include <linux/vmemmap-optimization.h>
#include <linux/swap.h>
#include <linux/stddef.h>
#include <linux/vmalloc.h>
@@ -282,6 +283,7 @@ int __meminit vmemmap_populate(unsigned long start, unsigned long end, int node,
return radix__vmemmap_populate(start, end, node, altmap);
#endif
+ section_vmemmap_optimization_disable(start, end);
return __vmemmap_populate(start, end, node, altmap);
}
diff --git a/include/linux/vmemmap-optimization.h b/include/linux/vmemmap-optimization.h
index 858311a71b0c..5c09da4df4d8 100644
--- a/include/linux/vmemmap-optimization.h
+++ b/include/linux/vmemmap-optimization.h
@@ -57,6 +57,27 @@ static inline void section_set_compound_order_range(unsigned long pfn,
section_set_compound_order(__nr_to_section(section_nr + i), order);
}
+static inline bool section_vmemmap_optimizable(const struct mem_section *section)
+{
+ return vmemmap_optimizable_order(section_compound_order(section));
+}
+
+static inline void section_vmemmap_optimization_disable(unsigned long start,
+ unsigned long end)
+{
+ unsigned long pfn = page_to_pfn((struct page *)start);
+ unsigned long nr_pages = (end - start) / sizeof(struct page);
+ struct mem_section *section = __pfn_to_section(pfn);
+
+ if (nr_pages < PAGES_PER_SECTION) {
+ VM_WARN_ON_ONCE(section_vmemmap_optimizable(section));
+ return;
+ }
+
+ VM_WARN_ON_ONCE(!IS_ALIGNED(pfn | nr_pages, PAGES_PER_SECTION));
+ section_set_compound_order(section, 0);
+}
+
static inline unsigned int pfn_to_section_compound_order(unsigned long pfn)
{
return section_compound_order(__pfn_to_section(pfn));
@@ -79,6 +100,16 @@ static inline void section_set_compound_order_range(unsigned long pfn,
{
}
+static inline bool section_vmemmap_optimizable(const struct mem_section *section)
+{
+ return false;
+}
+
+static inline void section_vmemmap_optimization_disable(unsigned long start,
+ unsigned long end)
+{
+}
+
static inline unsigned int pfn_to_section_compound_order(unsigned long pfn)
{
return 0;
diff --git a/mm/sparse.h b/mm/sparse.h
index fdbc4cacf91d..9b81a549d928 100644
--- a/mm/sparse.h
+++ b/mm/sparse.h
@@ -46,11 +46,6 @@ static inline size_t mem_section_usage_size(void)
return struct_size_t(struct mem_section_usage, pageblock_flags,
BITS_TO_LONGS(SECTION_BLOCKFLAGS_BITS));
}
-
-static inline bool section_vmemmap_optimizable(const struct mem_section *ms)
-{
- return vmemmap_optimizable_order(section_compound_order(ms));
-}
#else
static inline void sparse_init(void) {}
static inline void sparse_sections_init(void) {}
--
2.54.0
next prev parent reply other threads:[~2026-11-05 6:12 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-05 6:12 [PATCH v2 0/5] mm: Simplify device DAX vmemmap optimization plumbing Muchun Song
2026-11-05 6:12 ` [PATCH v2 1/5] powerpc/mm: make vmemmap_populate_compound_pages() static Muchun Song
2026-11-05 6:12 ` Muchun Song [this message]
2026-11-05 12:13 ` [PATCH v2 2/5] powerpc/mm: drop powerpc vmemmap_can_optimize() kernel test robot
2026-11-05 6:12 ` [PATCH v2 3/5] loongarch/mm: disable device DAX vmemmap optimization Muchun Song
2026-11-05 6:12 ` [PATCH v2 4/5] mm/sparse-vmemmap: drop vmemmap_can_optimize() Muchun Song
2026-11-05 6:12 ` [PATCH v2 5/5] mm/sparse-vmemmap: drop @pgmap from vmemmap population APIs Muchun Song
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=20261105061217.13302-3-songmuchun@bytedance.com \
--to=songmuchun@bytedance.com \
--cc=akpm@linux-foundation.org \
--cc=chenhuacai@kernel.org \
--cc=chleroy@kernel.org \
--cc=david@kernel.org \
--cc=kernel@xen0n.name \
--cc=lance.yang@linux.dev \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux-riscv@lists.infradead.org \
--cc=linux-s390@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=loongarch@lists.linux.dev \
--cc=maddy@linux.ibm.com \
--cc=mpe@ellerman.id.au \
--cc=muchun.song@linux.dev \
--cc=npiggin@gmail.com \
--cc=osalvador@suse.de \
--cc=qi.zheng@linux.dev \
--cc=ritesh.list@gmail.com \
--cc=rppt@kernel.org \
--cc=sshegde@linux.ibm.com \
--cc=x86@kernel.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®