When rodata=full is specified, kernel linear mapping has to be mapped at
PTE level since large page table can't be split due to break-before-make
rule on ARM64.
This resulted in a couple of problems:
- performance degradation
- more TLB pressure
- memory waste for kernel page table
With FEAT_BBM level 2 support, splitting large block page table to
smaller ones doesn't need to make the page table entry invalid anymore.
This allows kernel split large block mapping on the fly.
Add kernel page table split support and use large block mapping by
default when FEAT_BBM level 2 is supported for rodata=full. When
changing permissions for kernel linear mapping, the page table will be
split to smaller size.
The machine without FEAT_BBM level 2 will fallback to have kernel linear
mapping PTE-mapped when rodata=full.
With this we saw significant performance boost with some benchmarks and
much less memory consumption on my AmpereOne machine (192 cores, 1P)
with 256GB memory.
* Memory use after boot
Before:
MemTotal: 258988984 kB
MemFree: 254821700 kB
After:
MemTotal: 259505132 kB
MemFree: 255410264 kB
Around 500MB more memory are free to use. The larger the machine, the
more memory saved.
* Memcached
We saw performance degradation when running Memcached benchmark with
rodata=full vs rodata=on. Our profiling pointed to kernel TLB pressure.
With this patchset we saw ops/sec is increased by around 3.5%, P99
latency is reduced by around 9.6%.
The gain mainly came from reduced kernel TLB misses. The kernel TLB
MPKI is reduced by 28.5%.
The benchmark data is now on par with rodata=on too.
* Disk encryption (dm-crypt) benchmark
Ran fio benchmark with the below command on a 128G ramdisk (ext4) with
disk encryption (by dm-crypt).
fio --directory=/data --random_generator=lfsr --norandommap \
--randrepeat 1 --status-interval=999 --rw=write --bs=4k --loops=1 \
--ioengine=sync --iodepth=1 --numjobs=1 --fsync_on_close=1 \
--group_reporting --thread --name=iops-test-job --eta-newline=1 \
--size 100G
The IOPS is increased by 90% - 150% (the variance is high, but the worst
number of good case is around 90% more than the best number of bad
case). The bandwidth is increased and the avg clat is reduced
proportionally.
* Sequential file read
Read 100G file sequentially on XFS (xfs_io read with page cache
populated). The bandwidth is increased by 150%.
Co-developed-by: Ryan Roberts <ryan.roberts@arm.com>
Signed-off-by: Ryan Roberts <ryan.roberts@arm.com>
Reviewed-by: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Yang Shi <yang@os.amperecomputing.com>
---
arch/arm64/include/asm/cpufeature.h | 2 +
arch/arm64/include/asm/mmu.h | 1 +
arch/arm64/include/asm/pgtable.h | 5 +
arch/arm64/kernel/cpufeature.c | 7 +-
arch/arm64/mm/mmu.c | 264 +++++++++++++++++++++++++++-
arch/arm64/mm/pageattr.c | 4 +
6 files changed, 277 insertions(+), 6 deletions(-)
diff --git a/arch/arm64/include/asm/cpufeature.h b/arch/arm64/include/asm/cpufeature.h
index bf13d676aae2..e223cbf350e4 100644
--- a/arch/arm64/include/asm/cpufeature.h
+++ b/arch/arm64/include/asm/cpufeature.h
@@ -871,6 +871,8 @@ static inline bool system_supports_pmuv3(void)
return cpus_have_final_cap(ARM64_HAS_PMUV3);
}
+bool cpu_supports_bbml2_noabort(void);
+
static inline bool system_supports_bbml2_noabort(void)
{
return alternative_has_cap_unlikely(ARM64_HAS_BBML2_NOABORT);
diff --git a/arch/arm64/include/asm/mmu.h b/arch/arm64/include/asm/mmu.h
index 49f1a810df16..a7cc95d97ceb 100644
--- a/arch/arm64/include/asm/mmu.h
+++ b/arch/arm64/include/asm/mmu.h
@@ -78,6 +78,7 @@ extern void create_pgd_mapping(struct mm_struct *mm, phys_addr_t phys,
pgprot_t prot, bool page_mappings_only);
extern void *fixmap_remap_fdt(phys_addr_t dt_phys, int *size, pgprot_t prot);
extern void mark_linear_text_alias_ro(void);
+extern int split_kernel_leaf_mapping(unsigned long start, unsigned long end);
/*
* This check is triggered during the early boot before the cpufeature
diff --git a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgtable.h
index abd2dee416b3..aa89c2e67ebc 100644
--- a/arch/arm64/include/asm/pgtable.h
+++ b/arch/arm64/include/asm/pgtable.h
@@ -371,6 +371,11 @@ static inline pmd_t pmd_mkcont(pmd_t pmd)
return __pmd(pmd_val(pmd) | PMD_SECT_CONT);
}
+static inline pmd_t pmd_mknoncont(pmd_t pmd)
+{
+ return __pmd(pmd_val(pmd) & ~PMD_SECT_CONT);
+}
+
#ifdef CONFIG_HAVE_ARCH_USERFAULTFD_WP
static inline int pte_uffd_wp(pte_t pte)
{
diff --git a/arch/arm64/kernel/cpufeature.c b/arch/arm64/kernel/cpufeature.c
index ba07eeff2a8d..7dc092e33fcc 100644
--- a/arch/arm64/kernel/cpufeature.c
+++ b/arch/arm64/kernel/cpufeature.c
@@ -2218,7 +2218,7 @@ static bool hvhe_possible(const struct arm64_cpu_capabilities *entry,
return arm64_test_sw_feature_override(ARM64_SW_FEATURE_OVERRIDE_HVHE);
}
-static bool has_bbml2_noabort(const struct arm64_cpu_capabilities *caps, int scope)
+bool cpu_supports_bbml2_noabort(void)
{
/*
* We want to allow usage of BBML2 in as wide a range of kernel contexts
@@ -2252,6 +2252,11 @@ static bool has_bbml2_noabort(const struct arm64_cpu_capabilities *caps, int sco
return true;
}
+static bool has_bbml2_noabort(const struct arm64_cpu_capabilities *caps, int scope)
+{
+ return cpu_supports_bbml2_noabort();
+}
+
#ifdef CONFIG_ARM64_PAN
static void cpu_enable_pan(const struct arm64_cpu_capabilities *__unused)
{
diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c
index 183801520740..fa09dd120626 100644
--- a/arch/arm64/mm/mmu.c
+++ b/arch/arm64/mm/mmu.c
@@ -474,6 +474,8 @@ void create_kpti_ng_temp_pgd(pgd_t *pgdir, phys_addr_t phys, unsigned long virt,
int flags);
#endif
+#define INVALID_PHYS_ADDR (-1ULL)
+
static phys_addr_t __pgd_pgtable_alloc(struct mm_struct *mm,
enum pgtable_type pgtable_type)
{
@@ -481,7 +483,9 @@ static phys_addr_t __pgd_pgtable_alloc(struct mm_struct *mm,
struct ptdesc *ptdesc = pagetable_alloc(GFP_PGTABLE_KERNEL & ~__GFP_ZERO, 0);
phys_addr_t pa;
- BUG_ON(!ptdesc);
+ if (!ptdesc)
+ return INVALID_PHYS_ADDR;
+
pa = page_to_phys(ptdesc_page(ptdesc));
switch (pgtable_type) {
@@ -502,16 +506,256 @@ static phys_addr_t __pgd_pgtable_alloc(struct mm_struct *mm,
return pa;
}
+static phys_addr_t
+try_pgd_pgtable_alloc_init_mm(enum pgtable_type pgtable_type)
+{
+ return __pgd_pgtable_alloc(&init_mm, pgtable_type);
+}
+
static phys_addr_t __maybe_unused
pgd_pgtable_alloc_init_mm(enum pgtable_type pgtable_type)
{
- return __pgd_pgtable_alloc(&init_mm, pgtable_type);
+ phys_addr_t pa;
+
+ pa = __pgd_pgtable_alloc(&init_mm, pgtable_type);
+ BUG_ON(pa == INVALID_PHYS_ADDR);
+ return pa;
}
static phys_addr_t
pgd_pgtable_alloc_special_mm(enum pgtable_type pgtable_type)
{
- return __pgd_pgtable_alloc(NULL, pgtable_type);
+ phys_addr_t pa;
+
+ pa = __pgd_pgtable_alloc(NULL, pgtable_type);
+ BUG_ON(pa == INVALID_PHYS_ADDR);
+ return pa;
+}
+
+static void split_contpte(pte_t *ptep)
+{
+ int i;
+
+ ptep = PTR_ALIGN_DOWN(ptep, sizeof(*ptep) * CONT_PTES);
+ for (i = 0; i < CONT_PTES; i++, ptep++)
+ __set_pte(ptep, pte_mknoncont(__ptep_get(ptep)));
+}
+
+static int split_pmd(pmd_t *pmdp, pmd_t pmd)
+{
+ pmdval_t tableprot = PMD_TYPE_TABLE | PMD_TABLE_UXN | PMD_TABLE_AF;
+ unsigned long pfn = pmd_pfn(pmd);
+ pgprot_t prot = pmd_pgprot(pmd);
+ phys_addr_t pte_phys;
+ pte_t *ptep;
+ int i;
+
+ pte_phys = try_pgd_pgtable_alloc_init_mm(TABLE_PTE);
+ if (pte_phys == INVALID_PHYS_ADDR)
+ return -ENOMEM;
+ ptep = (pte_t *)phys_to_virt(pte_phys);
+
+ if (pgprot_val(prot) & PMD_SECT_PXN)
+ tableprot |= PMD_TABLE_PXN;
+
+ prot = __pgprot((pgprot_val(prot) & ~PTE_TYPE_MASK) | PTE_TYPE_PAGE);
+ prot = __pgprot(pgprot_val(prot) | PTE_CONT);
+
+ for (i = 0; i < PTRS_PER_PTE; i++, ptep++, pfn++)
+ __set_pte(ptep, pfn_pte(pfn, prot));
+
+ /*
+ * Ensure the pte entries are visible to the table walker by the time
+ * the pmd entry that points to the ptes is visible.
+ */
+ dsb(ishst);
+ __pmd_populate(pmdp, pte_phys, tableprot);
+
+ return 0;
+}
+
+static void split_contpmd(pmd_t *pmdp)
+{
+ int i;
+
+ pmdp = PTR_ALIGN_DOWN(pmdp, sizeof(*pmdp) * CONT_PMDS);
+ for (i = 0; i < CONT_PMDS; i++, pmdp++)
+ set_pmd(pmdp, pmd_mknoncont(pmdp_get(pmdp)));
+}
+
+static int split_pud(pud_t *pudp, pud_t pud)
+{
+ pudval_t tableprot = PUD_TYPE_TABLE | PUD_TABLE_UXN | PUD_TABLE_AF;
+ unsigned int step = PMD_SIZE >> PAGE_SHIFT;
+ unsigned long pfn = pud_pfn(pud);
+ pgprot_t prot = pud_pgprot(pud);
+ phys_addr_t pmd_phys;
+ pmd_t *pmdp;
+ int i;
+
+ pmd_phys = try_pgd_pgtable_alloc_init_mm(TABLE_PMD);
+ if (pmd_phys == INVALID_PHYS_ADDR)
+ return -ENOMEM;
+ pmdp = (pmd_t *)phys_to_virt(pmd_phys);
+
+ if (pgprot_val(prot) & PMD_SECT_PXN)
+ tableprot |= PUD_TABLE_PXN;
+
+ prot = __pgprot((pgprot_val(prot) & ~PMD_TYPE_MASK) | PMD_TYPE_SECT);
+ prot = __pgprot(pgprot_val(prot) | PTE_CONT);
+
+ for (i = 0; i < PTRS_PER_PMD; i++, pmdp++, pfn += step)
+ set_pmd(pmdp, pfn_pmd(pfn, prot));
+
+ /*
+ * Ensure the pmd entries are visible to the table walker by the time
+ * the pud entry that points to the pmds is visible.
+ */
+ dsb(ishst);
+ __pud_populate(pudp, pmd_phys, tableprot);
+
+ return 0;
+}
+
+static int split_kernel_leaf_mapping_locked(unsigned long addr)
+{
+ pgd_t *pgdp, pgd;
+ p4d_t *p4dp, p4d;
+ pud_t *pudp, pud;
+ pmd_t *pmdp, pmd;
+ pte_t *ptep, pte;
+ int ret = 0;
+
+ /*
+ * PGD: If addr is PGD aligned then addr already describes a leaf
+ * boundary. If not present then there is nothing to split.
+ */
+ if (ALIGN_DOWN(addr, PGDIR_SIZE) == addr)
+ goto out;
+ pgdp = pgd_offset_k(addr);
+ pgd = pgdp_get(pgdp);
+ if (!pgd_present(pgd))
+ goto out;
+
+ /*
+ * P4D: If addr is P4D aligned then addr already describes a leaf
+ * boundary. If not present then there is nothing to split.
+ */
+ if (ALIGN_DOWN(addr, P4D_SIZE) == addr)
+ goto out;
+ p4dp = p4d_offset(pgdp, addr);
+ p4d = p4dp_get(p4dp);
+ if (!p4d_present(p4d))
+ goto out;
+
+ /*
+ * PUD: If addr is PUD aligned then addr already describes a leaf
+ * boundary. If not present then there is nothing to split. Otherwise,
+ * if we have a pud leaf, split to contpmd.
+ */
+ if (ALIGN_DOWN(addr, PUD_SIZE) == addr)
+ goto out;
+ pudp = pud_offset(p4dp, addr);
+ pud = pudp_get(pudp);
+ if (!pud_present(pud))
+ goto out;
+ if (pud_leaf(pud)) {
+ ret = split_pud(pudp, pud);
+ if (ret)
+ goto out;
+ }
+
+ /*
+ * CONTPMD: If addr is CONTPMD aligned then addr already describes a
+ * leaf boundary. If not present then there is nothing to split.
+ * Otherwise, if we have a contpmd leaf, split to pmd.
+ */
+ if (ALIGN_DOWN(addr, CONT_PMD_SIZE) == addr)
+ goto out;
+ pmdp = pmd_offset(pudp, addr);
+ pmd = pmdp_get(pmdp);
+ if (!pmd_present(pmd))
+ goto out;
+ if (pmd_leaf(pmd)) {
+ if (pmd_cont(pmd))
+ split_contpmd(pmdp);
+ /*
+ * PMD: If addr is PMD aligned then addr already describes a
+ * leaf boundary. Otherwise, split to contpte.
+ */
+ if (ALIGN_DOWN(addr, PMD_SIZE) == addr)
+ goto out;
+ ret = split_pmd(pmdp, pmd);
+ if (ret)
+ goto out;
+ }
+
+ /*
+ * CONTPTE: If addr is CONTPTE aligned then addr already describes a
+ * leaf boundary. If not present then there is nothing to split.
+ * Otherwise, if we have a contpte leaf, split to pte.
+ */
+ if (ALIGN_DOWN(addr, CONT_PTE_SIZE) == addr)
+ goto out;
+ ptep = pte_offset_kernel(pmdp, addr);
+ pte = __ptep_get(ptep);
+ if (!pte_present(pte))
+ goto out;
+ if (pte_cont(pte))
+ split_contpte(ptep);
+
+out:
+ return ret;
+}
+
+static DEFINE_MUTEX(pgtable_split_lock);
+
+int split_kernel_leaf_mapping(unsigned long start, unsigned long end)
+{
+ int ret;
+
+ /*
+ * !BBML2_NOABORT systems should not be trying to change permissions on
+ * anything that is not pte-mapped in the first place. Just return early
+ * and let the permission change code raise a warning if not already
+ * pte-mapped.
+ */
+ if (!system_supports_bbml2_noabort())
+ return 0;
+
+ /*
+ * Ensure start and end are at least page-aligned since this is the
+ * finest granularity we can split to.
+ */
+ if (start != PAGE_ALIGN(start) || end != PAGE_ALIGN(end))
+ return -EINVAL;
+
+ mutex_lock(&pgtable_split_lock);
+ arch_enter_lazy_mmu_mode();
+
+ /*
+ * The split_kernel_leaf_mapping_locked() may sleep, it is not a
+ * problem for ARM64 since ARM64's lazy MMU implementation allows
+ * sleeping.
+ *
+ * Optimize for the common case of splitting out a single page from a
+ * larger mapping. Here we can just split on the "least aligned" of
+ * start and end and this will guarantee that there must also be a split
+ * on the more aligned address since the both addresses must be in the
+ * same contpte block and it must have been split to ptes.
+ */
+ if (end - start == PAGE_SIZE) {
+ start = __ffs(start) < __ffs(end) ? start : end;
+ ret = split_kernel_leaf_mapping_locked(start);
+ } else {
+ ret = split_kernel_leaf_mapping_locked(start);
+ if (!ret)
+ ret = split_kernel_leaf_mapping_locked(end);
+ }
+
+ arch_leave_lazy_mmu_mode();
+ mutex_unlock(&pgtable_split_lock);
+ return ret;
}
/*
@@ -633,6 +877,16 @@ static inline void arm64_kfence_map_pool(phys_addr_t kfence_pool, pgd_t *pgdp) {
#endif /* CONFIG_KFENCE */
+static inline bool force_pte_mapping(void)
+{
+ bool bbml2 = system_capabilities_finalized() ?
+ system_supports_bbml2_noabort() : cpu_supports_bbml2_noabort();
+
+ return (!bbml2 && (rodata_full || arm64_kfence_can_set_direct_map() ||
+ is_realm_world())) ||
+ debug_pagealloc_enabled();
+}
+
static void __init map_mem(pgd_t *pgdp)
{
static const u64 direct_map_end = _PAGE_END(VA_BITS_MIN);
@@ -658,7 +912,7 @@ static void __init map_mem(pgd_t *pgdp)
early_kfence_pool = arm64_kfence_alloc_pool();
- if (can_set_direct_map())
+ if (force_pte_mapping())
flags |= NO_BLOCK_MAPPINGS | NO_CONT_MAPPINGS;
/*
@@ -1360,7 +1614,7 @@ int arch_add_memory(int nid, u64 start, u64 size,
VM_BUG_ON(!mhp_range_allowed(start, size, true));
- if (can_set_direct_map())
+ if (force_pte_mapping())
flags |= NO_BLOCK_MAPPINGS | NO_CONT_MAPPINGS;
__create_pgd_mapping(swapper_pg_dir, start, __phys_to_virt(start),
diff --git a/arch/arm64/mm/pageattr.c b/arch/arm64/mm/pageattr.c
index c0648764c403..5135f2d66958 100644
--- a/arch/arm64/mm/pageattr.c
+++ b/arch/arm64/mm/pageattr.c
@@ -106,6 +106,10 @@ static int update_range_prot(unsigned long start, unsigned long size,
data.set_mask = set_mask;
data.clear_mask = clear_mask;
+ ret = split_kernel_leaf_mapping(start, start + size);
+ if (WARN_ON_ONCE(ret))
+ return ret;
+
arch_enter_lazy_mmu_mode();
/*
--
2.47.0
Hi,
On Wed, Sep 17, 2025 at 12:02:09PM -0700, Yang Shi wrote:
> When rodata=full is specified, kernel linear mapping has to be mapped at
> PTE level since large page table can't be split due to break-before-make
> rule on ARM64.
>
> This resulted in a couple of problems:
> - performance degradation
> - more TLB pressure
> - memory waste for kernel page table
>
> With FEAT_BBM level 2 support, splitting large block page table to
> smaller ones doesn't need to make the page table entry invalid anymore.
> This allows kernel split large block mapping on the fly.
>
> Add kernel page table split support and use large block mapping by
> default when FEAT_BBM level 2 is supported for rodata=full. When
> changing permissions for kernel linear mapping, the page table will be
> split to smaller size.
>
> The machine without FEAT_BBM level 2 will fallback to have kernel linear
> mapping PTE-mapped when rodata=full.
>
> With this we saw significant performance boost with some benchmarks and
> much less memory consumption on my AmpereOne machine (192 cores, 1P)
> with 256GB memory.
>
> * Memory use after boot
> Before:
> MemTotal: 258988984 kB
> MemFree: 254821700 kB
>
> After:
> MemTotal: 259505132 kB
> MemFree: 255410264 kB
>
> Around 500MB more memory are free to use. The larger the machine, the
> more memory saved.
>
> * Memcached
> We saw performance degradation when running Memcached benchmark with
> rodata=full vs rodata=on. Our profiling pointed to kernel TLB pressure.
> With this patchset we saw ops/sec is increased by around 3.5%, P99
> latency is reduced by around 9.6%.
> The gain mainly came from reduced kernel TLB misses. The kernel TLB
> MPKI is reduced by 28.5%.
>
> The benchmark data is now on par with rodata=on too.
>
> * Disk encryption (dm-crypt) benchmark
> Ran fio benchmark with the below command on a 128G ramdisk (ext4) with
> disk encryption (by dm-crypt).
> fio --directory=/data --random_generator=lfsr --norandommap \
> --randrepeat 1 --status-interval=999 --rw=write --bs=4k --loops=1 \
> --ioengine=sync --iodepth=1 --numjobs=1 --fsync_on_close=1 \
> --group_reporting --thread --name=iops-test-job --eta-newline=1 \
> --size 100G
>
> The IOPS is increased by 90% - 150% (the variance is high, but the worst
> number of good case is around 90% more than the best number of bad
> case). The bandwidth is increased and the avg clat is reduced
> proportionally.
>
> * Sequential file read
> Read 100G file sequentially on XFS (xfs_io read with page cache
> populated). The bandwidth is increased by 150%.
>
With lock debugging enabled, we see a large number of "BUG: sleeping
function called from invalid context at kernel/locking/mutex.c:580"
and "BUG: Invalid wait context:" backtraces when running v6.18-rc3.
Please see example below.
Bisect points to this patch.
Please let me know if there is anything I can do to help tracking
down the problem.
Thanks,
Guenter
---
Example log:
[ 0.537499] BUG: sleeping function called from invalid context at kernel/locking/mutex.c:580
[ 0.537501] in_atomic(): 1, irqs_disabled(): 0, non_block: 0, pid: 1, name: swapper/0
[ 0.537502] preempt_count: 1, expected: 0
[ 0.537504] 2 locks held by swapper/0/1:
[ 0.537505] #0: ffffb60b01211960 (sched_domains_mutex){+.+.}-{4:4}, at: sched_domains_mutex_lock+0x24/0x38
[ 0.537510] #1: ffffb60b01595838 (rcu_read_lock){....}-{1:3}, at: rcu_lock_acquire+0x0/0x40
[ 0.537516] CPU: 0 UID: 0 PID: 1 Comm: swapper/0 Not tainted 6.18.0-dbg-DEV #1 NONE
[ 0.537517] Call trace:
[ 0.537518] show_stack+0x20/0x38 (C)
[ 0.537520] __dump_stack+0x28/0x38
[ 0.537522] dump_stack_lvl+0xac/0xf0
[ 0.537525] dump_stack+0x18/0x3c
[ 0.537527] __might_resched+0x248/0x2a0
[ 0.537529] __might_sleep+0x40/0x90
[ 0.537531] __mutex_lock_common+0x70/0x1818
[ 0.537533] mutex_lock_nested+0x34/0x48
[ 0.537534] split_kernel_leaf_mapping+0x74/0x1a0
[ 0.537536] update_range_prot+0x40/0x150
[ 0.537537] __change_memory_common+0x30/0x148
[ 0.537538] __kernel_map_pages+0x70/0x88
[ 0.537540] __free_frozen_pages+0x6e4/0x7b8
[ 0.537542] free_frozen_pages+0x1c/0x30
[ 0.537544] __free_slab+0xf0/0x168
[ 0.537547] free_slab+0x2c/0xf8
[ 0.537549] free_to_partial_list+0x4e0/0x620
[ 0.537551] __slab_free+0x228/0x250
[ 0.537553] kfree+0x3c4/0x4c0
[ 0.537555] destroy_sched_domain+0xf8/0x140
[ 0.537557] cpu_attach_domain+0x17c/0x610
[ 0.537558] build_sched_domains+0x15a4/0x1718
[ 0.537560] sched_init_domains+0xbc/0xf8
[ 0.537561] sched_init_smp+0x30/0x98
[ 0.537562] kernel_init_freeable+0x148/0x230
[ 0.537564] kernel_init+0x28/0x148
[ 0.537566] ret_from_fork+0x10/0x20
[ 0.537569] =============================
[ 0.537569] [ BUG: Invalid wait context ]
[ 0.537571] 6.18.0-dbg-DEV #1 Tainted: G W
[ 0.537572] -----------------------------
[ 0.537572] swapper/0/1 is trying to lock:
[ 0.537573] ffffb60b011f3830 (pgtable_split_lock){+.+.}-{4:4}, at: split_kernel_leaf_mapping+0x74/0x1a0
[ 0.537576] other info that might help us debug this:
[ 0.537577] context-{5:5}
[ 0.537578] 2 locks held by swapper/0/1:
[ 0.537579] #0: ffffb60b01211960 (sched_domains_mutex){+.+.}-{4:4}, at: sched_domains_mutex_lock+0x24/0x38
[ 0.537582] #1: ffffb60b01595838 (rcu_read_lock){....}-{1:3}, at: rcu_lock_acquire+0x0/0x40
[ 0.537585] stack backtrace:
[ 0.537585] CPU: 0 UID: 0 PID: 1 Comm: swapper/0 Tainted: G W 6.18.0-dbg-DEV #1 NONE
[ 0.537587] Tainted: [W]=WARN
[ 0.537588] Call trace:
[ 0.537589] show_stack+0x20/0x38 (C)
[ 0.537591] __dump_stack+0x28/0x38
[ 0.537593] dump_stack_lvl+0xac/0xf0
[ 0.537596] dump_stack+0x18/0x3c
[ 0.537598] __lock_acquire+0x980/0x2a20
[ 0.537600] lock_acquire+0x124/0x2b8
[ 0.537602] __mutex_lock_common+0xd8/0x1818
[ 0.537604] mutex_lock_nested+0x34/0x48
[ 0.537605] split_kernel_leaf_mapping+0x74/0x1a0
[ 0.537607] update_range_prot+0x40/0x150
[ 0.537608] __change_memory_common+0x30/0x148
[ 0.537609] __kernel_map_pages+0x70/0x88
[ 0.537610] __free_frozen_pages+0x6e4/0x7b8
[ 0.537613] free_frozen_pages+0x1c/0x30
[ 0.537615] __free_slab+0xf0/0x168
[ 0.537617] free_slab+0x2c/0xf8
[ 0.537619] free_to_partial_list+0x4e0/0x620
[ 0.537621] __slab_free+0x228/0x250
[ 0.537623] kfree+0x3c4/0x4c0
[ 0.537625] destroy_sched_domain+0xf8/0x140
[ 0.537627] cpu_attach_domain+0x17c/0x610
[ 0.537628] build_sched_domains+0x15a4/0x1718
[ 0.537630] sched_init_domains+0xbc/0xf8
[ 0.537631] sched_init_smp+0x30/0x98
[ 0.537632] kernel_init_freeable+0x148/0x230
[ 0.537633] kernel_init+0x28/0x148
[ 0.537635] ret_from_fork+0x10/0x20
---
bisect:
# bad: [3a8660878839faadb4f1a6dd72c3179c1df56787] Linux 6.18-rc1
# good: [e5f0a698b34ed76002dc5cff3804a61c80233a7a] Linux 6.17
git bisect start 'v6.18-rc1' 'v6.17'
# bad: [58809f614e0e3f4e12b489bddf680bfeb31c0a20] Merge tag 'drm-next-2025-10-01' of https://gitlab.freedesktop.org/drm/kernel
git bisect bad 58809f614e0e3f4e12b489bddf680bfeb31c0a20
# bad: [a8253f807760e9c80eada9e5354e1240ccf325f9] Merge tag 'soc-newsoc-6.18' of git://git.kernel.org/pub/scm/linux/kernel/git/soc/soc
git bisect bad a8253f807760e9c80eada9e5354e1240ccf325f9
# bad: [4b81e2eb9e4db8f6094c077d0c8b27c264901c1b] Merge tag 'timers-vdso-2025-09-29' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
git bisect bad 4b81e2eb9e4db8f6094c077d0c8b27c264901c1b
# bad: [f1004b2f19d7e9add9d707f64d9fcbc50f67921b] Merge tag 'm68k-for-v6.18-tag1' of git://git.kernel.org/pub/scm/linux/kernel/git/geert/linux-m68k
git bisect bad f1004b2f19d7e9add9d707f64d9fcbc50f67921b
# good: [a9401710a5f5681abd2a6f21f9e76bc9f2e81891] Merge tag 'v6.18-rc-part1-smb3-common' of git://git.samba.org/ksmbd
git bisect good a9401710a5f5681abd2a6f21f9e76bc9f2e81891
# good: [fe68bb2861808ed5c48d399bd7e670ab76829d55] Merge tag 'microblaze-v6.18' of git://git.monstr.eu/linux-2.6-microblaze
git bisect good fe68bb2861808ed5c48d399bd7e670ab76829d55
# bad: [f2d64a22faeeecff385b4c91fab5fe036ab00162] Merge branch 'for-next/perf' into for-next/core
git bisect bad f2d64a22faeeecff385b4c91fab5fe036ab00162
# good: [30f9386820cddbba59b48ae0670c3a1646dd440e] Merge branch 'for-next/misc' into for-next/core
git bisect good 30f9386820cddbba59b48ae0670c3a1646dd440e
# good: [43de0ac332b815cf56dbdce63687de9acfd35d49] drivers/perf: hisi: Relax the event ID check in the framework
git bisect good 43de0ac332b815cf56dbdce63687de9acfd35d49
# good: [5973a62efa34c80c9a4e5eac1fca6f6209b902af] arm64: map [_text, _stext) virtual address range non-executable+read-only
git bisect good 5973a62efa34c80c9a4e5eac1fca6f6209b902af
# good: [b3abb08d6f628a76c36bf7da9508e1a67bf186a0] drivers/perf: hisi: Refactor the event configuration of L3C PMU
git bisect good b3abb08d6f628a76c36bf7da9508e1a67bf186a0
# good: [6d2f913fda5683fbd4c3580262e10386c1263dfb] Documentation: hisi-pmu: Add introduction to HiSilicon V3 PMU
git bisect good 6d2f913fda5683fbd4c3580262e10386c1263dfb
# good: [2084660ad288c998b6f0c885e266deb364f65fba] perf/dwc_pcie: Fix use of uninitialized variable
git bisect good 2084660ad288c998b6f0c885e266deb364f65fba
# bad: [77dfca70baefcb988318a72fe69eb99f6dabbbb1] Merge branch 'for-next/mm' into for-next/core
git bisect bad 77dfca70baefcb988318a72fe69eb99f6dabbbb1
# first bad commit: [77dfca70baefcb988318a72fe69eb99f6dabbbb1] Merge branch 'for-next/mm' into for-next/core
---
bisect into branch:
- git checkout -b testing 77dfca70baefcb988318a72fe69eb99f6dabbbb1
- git rebase 77dfca70baefcb988318a72fe69eb99f6dabbbb1~1
[ fix minor conflict similar to the conflict resolution in 77dfca70baefc]
- git diff 77dfca70baefcb988318a72fe69eb99f6dabbbb1
[ confirmed that there are no differences ]
- confirm that the problem is still seen at the tip of the rebase
- git bisect start HEAD 77dfca70baefcb988318a72fe69eb99f6dabbbb1~1
- run bisect
Results:
# bad: [47fc25df1ae3ae8412f1b812fb586c714d04a5e6] arm64: map [_text, _stext) virtual address range non-executable+read-only
# good: [30f9386820cddbba59b48ae0670c3a1646dd440e] Merge branch 'for-next/misc' into for-next/core
git bisect start 'HEAD' '77dfca70baefcb988318a72fe69eb99f6dabbbb1~1'
# good: [805491d19fc21271b5c27f4602f8f66b625c110f] arm64/Kconfig: Remove CONFIG_RODATA_FULL_DEFAULT_ENABLED
git bisect good 805491d19fc21271b5c27f4602f8f66b625c110f
# bad: [13c7d7426232cc4489df7cd2e1f646a22d3f6172] arm64: mm: support large block mapping when rodata=full
git bisect bad 13c7d7426232cc4489df7cd2e1f646a22d3f6172
# good: [a4d9c67e503f2b73c2d89d8e8209dfd241bdc8d8] arm64: Enable permission change on arm64 kernel block mappings
git bisect good a4d9c67e503f2b73c2d89d8e8209dfd241bdc8d8
# first bad commit: [13c7d7426232cc4489df7cd2e1f646a22d3f6172] arm64: mm: support large block mapping when rodata=full
On 01/11/2025 16:14, Guenter Roeck wrote:
> Hi,
>
> On Wed, Sep 17, 2025 at 12:02:09PM -0700, Yang Shi wrote:
>> When rodata=full is specified, kernel linear mapping has to be mapped at
>> PTE level since large page table can't be split due to break-before-make
>> rule on ARM64.
>>
>> This resulted in a couple of problems:
>> - performance degradation
>> - more TLB pressure
>> - memory waste for kernel page table
>>
>> With FEAT_BBM level 2 support, splitting large block page table to
>> smaller ones doesn't need to make the page table entry invalid anymore.
>> This allows kernel split large block mapping on the fly.
>>
>> Add kernel page table split support and use large block mapping by
>> default when FEAT_BBM level 2 is supported for rodata=full. When
>> changing permissions for kernel linear mapping, the page table will be
>> split to smaller size.
>>
>> The machine without FEAT_BBM level 2 will fallback to have kernel linear
>> mapping PTE-mapped when rodata=full.
>>
>> With this we saw significant performance boost with some benchmarks and
>> much less memory consumption on my AmpereOne machine (192 cores, 1P)
>> with 256GB memory.
>>
>> * Memory use after boot
>> Before:
>> MemTotal: 258988984 kB
>> MemFree: 254821700 kB
>>
>> After:
>> MemTotal: 259505132 kB
>> MemFree: 255410264 kB
>>
>> Around 500MB more memory are free to use. The larger the machine, the
>> more memory saved.
>>
>> * Memcached
>> We saw performance degradation when running Memcached benchmark with
>> rodata=full vs rodata=on. Our profiling pointed to kernel TLB pressure.
>> With this patchset we saw ops/sec is increased by around 3.5%, P99
>> latency is reduced by around 9.6%.
>> The gain mainly came from reduced kernel TLB misses. The kernel TLB
>> MPKI is reduced by 28.5%.
>>
>> The benchmark data is now on par with rodata=on too.
>>
>> * Disk encryption (dm-crypt) benchmark
>> Ran fio benchmark with the below command on a 128G ramdisk (ext4) with
>> disk encryption (by dm-crypt).
>> fio --directory=/data --random_generator=lfsr --norandommap \
>> --randrepeat 1 --status-interval=999 --rw=write --bs=4k --loops=1 \
>> --ioengine=sync --iodepth=1 --numjobs=1 --fsync_on_close=1 \
>> --group_reporting --thread --name=iops-test-job --eta-newline=1 \
>> --size 100G
>>
>> The IOPS is increased by 90% - 150% (the variance is high, but the worst
>> number of good case is around 90% more than the best number of bad
>> case). The bandwidth is increased and the avg clat is reduced
>> proportionally.
>>
>> * Sequential file read
>> Read 100G file sequentially on XFS (xfs_io read with page cache
>> populated). The bandwidth is increased by 150%.
>>
>
> With lock debugging enabled, we see a large number of "BUG: sleeping
> function called from invalid context at kernel/locking/mutex.c:580"
> and "BUG: Invalid wait context:" backtraces when running v6.18-rc3.
> Please see example below.
>
> Bisect points to this patch.
>
> Please let me know if there is anything I can do to help tracking
> down the problem.
Thanks for the report - ouch!
I expect you're running on a system that supports BBML2_NOABORT, based on the
stack trace, I expect you have CONFIG_DEBUG_PAGEALLOC enabled? That will cause
permission tricks to be played on the linear map at page allocation and free
time, which can happen in non-sleepable contexts. And with this patch we are
taking pgtable_split_lock (a mutex) in split_kernel_leaf_mapping(), which is
called as a result of the permission change request.
However, when CONFIG_DEBUG_PAGEALLOC enabled we always force-map the linear map
by PTE so split_kernel_leaf_mapping() is actually unneccessary and will return
without actually having to split anything. So we could add an early "if
(force_pte_mapping()) return 0;" to bypass the function entirely in this case,
and I *think* that should solve it.
But I'm also concerned about KFENCE. I can't remember it's exact semantics off
the top of my head, so I'm concerned we could see similar problems there (where
we only force pte mapping for the KFENCE pool).
I'll investigate fully tomorrow and hopefully provide a fix.
Yang Shi, Do you have any additional thoughts?
Thanks,
Ryan
>
> Thanks,
> Guenter
>
> ---
> Example log:
>
> [ 0.537499] BUG: sleeping function called from invalid context at kernel/locking/mutex.c:580
> [ 0.537501] in_atomic(): 1, irqs_disabled(): 0, non_block: 0, pid: 1, name: swapper/0
> [ 0.537502] preempt_count: 1, expected: 0
> [ 0.537504] 2 locks held by swapper/0/1:
> [ 0.537505] #0: ffffb60b01211960 (sched_domains_mutex){+.+.}-{4:4}, at: sched_domains_mutex_lock+0x24/0x38
> [ 0.537510] #1: ffffb60b01595838 (rcu_read_lock){....}-{1:3}, at: rcu_lock_acquire+0x0/0x40
> [ 0.537516] CPU: 0 UID: 0 PID: 1 Comm: swapper/0 Not tainted 6.18.0-dbg-DEV #1 NONE
> [ 0.537517] Call trace:
> [ 0.537518] show_stack+0x20/0x38 (C)
> [ 0.537520] __dump_stack+0x28/0x38
> [ 0.537522] dump_stack_lvl+0xac/0xf0
> [ 0.537525] dump_stack+0x18/0x3c
> [ 0.537527] __might_resched+0x248/0x2a0
> [ 0.537529] __might_sleep+0x40/0x90
> [ 0.537531] __mutex_lock_common+0x70/0x1818
> [ 0.537533] mutex_lock_nested+0x34/0x48
> [ 0.537534] split_kernel_leaf_mapping+0x74/0x1a0
> [ 0.537536] update_range_prot+0x40/0x150
> [ 0.537537] __change_memory_common+0x30/0x148
> [ 0.537538] __kernel_map_pages+0x70/0x88
> [ 0.537540] __free_frozen_pages+0x6e4/0x7b8
> [ 0.537542] free_frozen_pages+0x1c/0x30
> [ 0.537544] __free_slab+0xf0/0x168
> [ 0.537547] free_slab+0x2c/0xf8
> [ 0.537549] free_to_partial_list+0x4e0/0x620
> [ 0.537551] __slab_free+0x228/0x250
> [ 0.537553] kfree+0x3c4/0x4c0
> [ 0.537555] destroy_sched_domain+0xf8/0x140
> [ 0.537557] cpu_attach_domain+0x17c/0x610
> [ 0.537558] build_sched_domains+0x15a4/0x1718
> [ 0.537560] sched_init_domains+0xbc/0xf8
> [ 0.537561] sched_init_smp+0x30/0x98
> [ 0.537562] kernel_init_freeable+0x148/0x230
> [ 0.537564] kernel_init+0x28/0x148
> [ 0.537566] ret_from_fork+0x10/0x20
> [ 0.537569] =============================
> [ 0.537569] [ BUG: Invalid wait context ]
> [ 0.537571] 6.18.0-dbg-DEV #1 Tainted: G W
> [ 0.537572] -----------------------------
> [ 0.537572] swapper/0/1 is trying to lock:
> [ 0.537573] ffffb60b011f3830 (pgtable_split_lock){+.+.}-{4:4}, at: split_kernel_leaf_mapping+0x74/0x1a0
> [ 0.537576] other info that might help us debug this:
> [ 0.537577] context-{5:5}
> [ 0.537578] 2 locks held by swapper/0/1:
> [ 0.537579] #0: ffffb60b01211960 (sched_domains_mutex){+.+.}-{4:4}, at: sched_domains_mutex_lock+0x24/0x38
> [ 0.537582] #1: ffffb60b01595838 (rcu_read_lock){....}-{1:3}, at: rcu_lock_acquire+0x0/0x40
> [ 0.537585] stack backtrace:
> [ 0.537585] CPU: 0 UID: 0 PID: 1 Comm: swapper/0 Tainted: G W 6.18.0-dbg-DEV #1 NONE
> [ 0.537587] Tainted: [W]=WARN
> [ 0.537588] Call trace:
> [ 0.537589] show_stack+0x20/0x38 (C)
> [ 0.537591] __dump_stack+0x28/0x38
> [ 0.537593] dump_stack_lvl+0xac/0xf0
> [ 0.537596] dump_stack+0x18/0x3c
> [ 0.537598] __lock_acquire+0x980/0x2a20
> [ 0.537600] lock_acquire+0x124/0x2b8
> [ 0.537602] __mutex_lock_common+0xd8/0x1818
> [ 0.537604] mutex_lock_nested+0x34/0x48
> [ 0.537605] split_kernel_leaf_mapping+0x74/0x1a0
> [ 0.537607] update_range_prot+0x40/0x150
> [ 0.537608] __change_memory_common+0x30/0x148
> [ 0.537609] __kernel_map_pages+0x70/0x88
> [ 0.537610] __free_frozen_pages+0x6e4/0x7b8
> [ 0.537613] free_frozen_pages+0x1c/0x30
> [ 0.537615] __free_slab+0xf0/0x168
> [ 0.537617] free_slab+0x2c/0xf8
> [ 0.537619] free_to_partial_list+0x4e0/0x620
> [ 0.537621] __slab_free+0x228/0x250
> [ 0.537623] kfree+0x3c4/0x4c0
> [ 0.537625] destroy_sched_domain+0xf8/0x140
> [ 0.537627] cpu_attach_domain+0x17c/0x610
> [ 0.537628] build_sched_domains+0x15a4/0x1718
> [ 0.537630] sched_init_domains+0xbc/0xf8
> [ 0.537631] sched_init_smp+0x30/0x98
> [ 0.537632] kernel_init_freeable+0x148/0x230
> [ 0.537633] kernel_init+0x28/0x148
> [ 0.537635] ret_from_fork+0x10/0x20
>
> ---
> bisect:
>
> # bad: [3a8660878839faadb4f1a6dd72c3179c1df56787] Linux 6.18-rc1
> # good: [e5f0a698b34ed76002dc5cff3804a61c80233a7a] Linux 6.17
> git bisect start 'v6.18-rc1' 'v6.17'
> # bad: [58809f614e0e3f4e12b489bddf680bfeb31c0a20] Merge tag 'drm-next-2025-10-01' of https://gitlab.freedesktop.org/drm/kernel
> git bisect bad 58809f614e0e3f4e12b489bddf680bfeb31c0a20
> # bad: [a8253f807760e9c80eada9e5354e1240ccf325f9] Merge tag 'soc-newsoc-6.18' of git://git.kernel.org/pub/scm/linux/kernel/git/soc/soc
> git bisect bad a8253f807760e9c80eada9e5354e1240ccf325f9
> # bad: [4b81e2eb9e4db8f6094c077d0c8b27c264901c1b] Merge tag 'timers-vdso-2025-09-29' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
> git bisect bad 4b81e2eb9e4db8f6094c077d0c8b27c264901c1b
> # bad: [f1004b2f19d7e9add9d707f64d9fcbc50f67921b] Merge tag 'm68k-for-v6.18-tag1' of git://git.kernel.org/pub/scm/linux/kernel/git/geert/linux-m68k
> git bisect bad f1004b2f19d7e9add9d707f64d9fcbc50f67921b
> # good: [a9401710a5f5681abd2a6f21f9e76bc9f2e81891] Merge tag 'v6.18-rc-part1-smb3-common' of git://git.samba.org/ksmbd
> git bisect good a9401710a5f5681abd2a6f21f9e76bc9f2e81891
> # good: [fe68bb2861808ed5c48d399bd7e670ab76829d55] Merge tag 'microblaze-v6.18' of git://git.monstr.eu/linux-2.6-microblaze
> git bisect good fe68bb2861808ed5c48d399bd7e670ab76829d55
> # bad: [f2d64a22faeeecff385b4c91fab5fe036ab00162] Merge branch 'for-next/perf' into for-next/core
> git bisect bad f2d64a22faeeecff385b4c91fab5fe036ab00162
> # good: [30f9386820cddbba59b48ae0670c3a1646dd440e] Merge branch 'for-next/misc' into for-next/core
> git bisect good 30f9386820cddbba59b48ae0670c3a1646dd440e
> # good: [43de0ac332b815cf56dbdce63687de9acfd35d49] drivers/perf: hisi: Relax the event ID check in the framework
> git bisect good 43de0ac332b815cf56dbdce63687de9acfd35d49
> # good: [5973a62efa34c80c9a4e5eac1fca6f6209b902af] arm64: map [_text, _stext) virtual address range non-executable+read-only
> git bisect good 5973a62efa34c80c9a4e5eac1fca6f6209b902af
> # good: [b3abb08d6f628a76c36bf7da9508e1a67bf186a0] drivers/perf: hisi: Refactor the event configuration of L3C PMU
> git bisect good b3abb08d6f628a76c36bf7da9508e1a67bf186a0
> # good: [6d2f913fda5683fbd4c3580262e10386c1263dfb] Documentation: hisi-pmu: Add introduction to HiSilicon V3 PMU
> git bisect good 6d2f913fda5683fbd4c3580262e10386c1263dfb
> # good: [2084660ad288c998b6f0c885e266deb364f65fba] perf/dwc_pcie: Fix use of uninitialized variable
> git bisect good 2084660ad288c998b6f0c885e266deb364f65fba
> # bad: [77dfca70baefcb988318a72fe69eb99f6dabbbb1] Merge branch 'for-next/mm' into for-next/core
> git bisect bad 77dfca70baefcb988318a72fe69eb99f6dabbbb1
> # first bad commit: [77dfca70baefcb988318a72fe69eb99f6dabbbb1] Merge branch 'for-next/mm' into for-next/core
>
> ---
> bisect into branch:
>
> - git checkout -b testing 77dfca70baefcb988318a72fe69eb99f6dabbbb1
> - git rebase 77dfca70baefcb988318a72fe69eb99f6dabbbb1~1
> [ fix minor conflict similar to the conflict resolution in 77dfca70baefc]
> - git diff 77dfca70baefcb988318a72fe69eb99f6dabbbb1
> [ confirmed that there are no differences ]
> - confirm that the problem is still seen at the tip of the rebase
> - git bisect start HEAD 77dfca70baefcb988318a72fe69eb99f6dabbbb1~1
> - run bisect
>
> Results:
>
> # bad: [47fc25df1ae3ae8412f1b812fb586c714d04a5e6] arm64: map [_text, _stext) virtual address range non-executable+read-only
> # good: [30f9386820cddbba59b48ae0670c3a1646dd440e] Merge branch 'for-next/misc' into for-next/core
> git bisect start 'HEAD' '77dfca70baefcb988318a72fe69eb99f6dabbbb1~1'
> # good: [805491d19fc21271b5c27f4602f8f66b625c110f] arm64/Kconfig: Remove CONFIG_RODATA_FULL_DEFAULT_ENABLED
> git bisect good 805491d19fc21271b5c27f4602f8f66b625c110f
> # bad: [13c7d7426232cc4489df7cd2e1f646a22d3f6172] arm64: mm: support large block mapping when rodata=full
> git bisect bad 13c7d7426232cc4489df7cd2e1f646a22d3f6172
> # good: [a4d9c67e503f2b73c2d89d8e8209dfd241bdc8d8] arm64: Enable permission change on arm64 kernel block mappings
> git bisect good a4d9c67e503f2b73c2d89d8e8209dfd241bdc8d8
> # first bad commit: [13c7d7426232cc4489df7cd2e1f646a22d3f6172] arm64: mm: support large block mapping when rodata=full
On 02/11/2025 10:31, Ryan Roberts wrote:
> On 01/11/2025 16:14, Guenter Roeck wrote:
>> Hi,
>>
>> On Wed, Sep 17, 2025 at 12:02:09PM -0700, Yang Shi wrote:
>>> When rodata=full is specified, kernel linear mapping has to be mapped at
>>> PTE level since large page table can't be split due to break-before-make
>>> rule on ARM64.
>>>
>>> This resulted in a couple of problems:
>>> - performance degradation
>>> - more TLB pressure
>>> - memory waste for kernel page table
>>>
>>> With FEAT_BBM level 2 support, splitting large block page table to
>>> smaller ones doesn't need to make the page table entry invalid anymore.
>>> This allows kernel split large block mapping on the fly.
>>>
>>> Add kernel page table split support and use large block mapping by
>>> default when FEAT_BBM level 2 is supported for rodata=full. When
>>> changing permissions for kernel linear mapping, the page table will be
>>> split to smaller size.
>>>
>>> The machine without FEAT_BBM level 2 will fallback to have kernel linear
>>> mapping PTE-mapped when rodata=full.
>>>
>>> With this we saw significant performance boost with some benchmarks and
>>> much less memory consumption on my AmpereOne machine (192 cores, 1P)
>>> with 256GB memory.
>>>
>>> * Memory use after boot
>>> Before:
>>> MemTotal: 258988984 kB
>>> MemFree: 254821700 kB
>>>
>>> After:
>>> MemTotal: 259505132 kB
>>> MemFree: 255410264 kB
>>>
>>> Around 500MB more memory are free to use. The larger the machine, the
>>> more memory saved.
>>>
>>> * Memcached
>>> We saw performance degradation when running Memcached benchmark with
>>> rodata=full vs rodata=on. Our profiling pointed to kernel TLB pressure.
>>> With this patchset we saw ops/sec is increased by around 3.5%, P99
>>> latency is reduced by around 9.6%.
>>> The gain mainly came from reduced kernel TLB misses. The kernel TLB
>>> MPKI is reduced by 28.5%.
>>>
>>> The benchmark data is now on par with rodata=on too.
>>>
>>> * Disk encryption (dm-crypt) benchmark
>>> Ran fio benchmark with the below command on a 128G ramdisk (ext4) with
>>> disk encryption (by dm-crypt).
>>> fio --directory=/data --random_generator=lfsr --norandommap \
>>> --randrepeat 1 --status-interval=999 --rw=write --bs=4k --loops=1 \
>>> --ioengine=sync --iodepth=1 --numjobs=1 --fsync_on_close=1 \
>>> --group_reporting --thread --name=iops-test-job --eta-newline=1 \
>>> --size 100G
>>>
>>> The IOPS is increased by 90% - 150% (the variance is high, but the worst
>>> number of good case is around 90% more than the best number of bad
>>> case). The bandwidth is increased and the avg clat is reduced
>>> proportionally.
>>>
>>> * Sequential file read
>>> Read 100G file sequentially on XFS (xfs_io read with page cache
>>> populated). The bandwidth is increased by 150%.
>>>
>>
>> With lock debugging enabled, we see a large number of "BUG: sleeping
>> function called from invalid context at kernel/locking/mutex.c:580"
>> and "BUG: Invalid wait context:" backtraces when running v6.18-rc3.
>> Please see example below.
>>
>> Bisect points to this patch.
>>
>> Please let me know if there is anything I can do to help tracking
>> down the problem.
>
> Thanks for the report - ouch!
>
> I expect you're running on a system that supports BBML2_NOABORT, based on the
> stack trace, I expect you have CONFIG_DEBUG_PAGEALLOC enabled? That will cause
> permission tricks to be played on the linear map at page allocation and free
> time, which can happen in non-sleepable contexts. And with this patch we are
> taking pgtable_split_lock (a mutex) in split_kernel_leaf_mapping(), which is
> called as a result of the permission change request.
>
> However, when CONFIG_DEBUG_PAGEALLOC enabled we always force-map the linear map
> by PTE so split_kernel_leaf_mapping() is actually unneccessary and will return
> without actually having to split anything. So we could add an early "if
> (force_pte_mapping()) return 0;" to bypass the function entirely in this case,
> and I *think* that should solve it.
>
> But I'm also concerned about KFENCE. I can't remember it's exact semantics off
> the top of my head, so I'm concerned we could see similar problems there (where
> we only force pte mapping for the KFENCE pool).
>
> I'll investigate fully tomorrow and hopefully provide a fix.
Here's a proposed fix, although I can't get access to a system with BBML2 until
tomorrow at the earliest. Guenter, I wonder if you could check that this
resolves your issue?
---8<---
commit 602ec2db74e5abfb058bd03934475ead8558eb72
Author: Ryan Roberts <ryan.roberts@arm.com>
Date: Sun Nov 2 11:45:18 2025 +0000
arm64: mm: Don't attempt to split known pte-mapped regions
It has been reported that split_kernel_leaf_mapping() is trying to sleep
in non-sleepable context. It does this when acquiring the
pgtable_split_lock mutex, when either CONFIG_DEBUG_ALLOC or
CONFIG_KFENCE are enabled, which change linear map permissions within
softirq context during memory allocation and/or freeing.
But it turns out that the memory for which these features may attempt to
modify the permissions is always mapped by pte, so there is no need to
attempt to split the mapping. So let's exit early in these cases and
avoid attempting to take the mutex.
Closes: https://lore.kernel.org/all/f24b9032-0ec9-47b1-8b95-c0eeac7a31c5@roeck-us.net/
Fixes: a166563e7ec3 ("arm64: mm: support large block mapping when rodata=full")
Signed-off-by: Ryan Roberts <ryan.roberts@arm.com>
diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c
index b8d37eb037fc..6e26f070bb49 100644
--- a/arch/arm64/mm/mmu.c
+++ b/arch/arm64/mm/mmu.c
@@ -708,6 +708,16 @@ static int split_kernel_leaf_mapping_locked(unsigned long addr)
return ret;
}
+static inline bool force_pte_mapping(void)
+{
+ bool bbml2 = system_capabilities_finalized() ?
+ system_supports_bbml2_noabort() : cpu_supports_bbml2_noabort();
+
+ return (!bbml2 && (rodata_full || arm64_kfence_can_set_direct_map() ||
+ is_realm_world())) ||
+ debug_pagealloc_enabled();
+}
+
static DEFINE_MUTEX(pgtable_split_lock);
int split_kernel_leaf_mapping(unsigned long start, unsigned long end)
@@ -723,6 +733,16 @@ int split_kernel_leaf_mapping(unsigned long start, unsigned long end)
if (!system_supports_bbml2_noabort())
return 0;
+ /*
+ * If the region is within a pte-mapped area, there is no need to try to
+ * split. Additionally, CONFIG_DEBUG_ALLOC and CONFIG_KFENCE may change
+ * permissions from softirq context so for those cases (which are always
+ * pte-mapped), we must not go any further because taking the mutex
+ * below may sleep.
+ */
+ if (force_pte_mapping() || is_kfence_address((void *)start))
+ return 0;
+
/*
* Ensure start and end are at least page-aligned since this is the
* finest granularity we can split to.
@@ -1009,16 +1029,6 @@ static inline void arm64_kfence_map_pool(phys_addr_t kfence_pool, pgd_t *pgdp) {
#endif /* CONFIG_KFENCE */
-static inline bool force_pte_mapping(void)
-{
- bool bbml2 = system_capabilities_finalized() ?
- system_supports_bbml2_noabort() : cpu_supports_bbml2_noabort();
-
- return (!bbml2 && (rodata_full || arm64_kfence_can_set_direct_map() ||
- is_realm_world())) ||
- debug_pagealloc_enabled();
-}
-
static void __init map_mem(pgd_t *pgdp)
{
static const u64 direct_map_end = _PAGE_END(VA_BITS_MIN);
---8<---
Thanks,
Ryan
>
> Yang Shi, Do you have any additional thoughts?
>
> Thanks,
> Ryan
>
>>
>> Thanks,
>> Guenter
>>
>> ---
>> Example log:
>>
>> [ 0.537499] BUG: sleeping function called from invalid context at kernel/locking/mutex.c:580
>> [ 0.537501] in_atomic(): 1, irqs_disabled(): 0, non_block: 0, pid: 1, name: swapper/0
>> [ 0.537502] preempt_count: 1, expected: 0
>> [ 0.537504] 2 locks held by swapper/0/1:
>> [ 0.537505] #0: ffffb60b01211960 (sched_domains_mutex){+.+.}-{4:4}, at: sched_domains_mutex_lock+0x24/0x38
>> [ 0.537510] #1: ffffb60b01595838 (rcu_read_lock){....}-{1:3}, at: rcu_lock_acquire+0x0/0x40
>> [ 0.537516] CPU: 0 UID: 0 PID: 1 Comm: swapper/0 Not tainted 6.18.0-dbg-DEV #1 NONE
>> [ 0.537517] Call trace:
>> [ 0.537518] show_stack+0x20/0x38 (C)
>> [ 0.537520] __dump_stack+0x28/0x38
>> [ 0.537522] dump_stack_lvl+0xac/0xf0
>> [ 0.537525] dump_stack+0x18/0x3c
>> [ 0.537527] __might_resched+0x248/0x2a0
>> [ 0.537529] __might_sleep+0x40/0x90
>> [ 0.537531] __mutex_lock_common+0x70/0x1818
>> [ 0.537533] mutex_lock_nested+0x34/0x48
>> [ 0.537534] split_kernel_leaf_mapping+0x74/0x1a0
>> [ 0.537536] update_range_prot+0x40/0x150
>> [ 0.537537] __change_memory_common+0x30/0x148
>> [ 0.537538] __kernel_map_pages+0x70/0x88
>> [ 0.537540] __free_frozen_pages+0x6e4/0x7b8
>> [ 0.537542] free_frozen_pages+0x1c/0x30
>> [ 0.537544] __free_slab+0xf0/0x168
>> [ 0.537547] free_slab+0x2c/0xf8
>> [ 0.537549] free_to_partial_list+0x4e0/0x620
>> [ 0.537551] __slab_free+0x228/0x250
>> [ 0.537553] kfree+0x3c4/0x4c0
>> [ 0.537555] destroy_sched_domain+0xf8/0x140
>> [ 0.537557] cpu_attach_domain+0x17c/0x610
>> [ 0.537558] build_sched_domains+0x15a4/0x1718
>> [ 0.537560] sched_init_domains+0xbc/0xf8
>> [ 0.537561] sched_init_smp+0x30/0x98
>> [ 0.537562] kernel_init_freeable+0x148/0x230
>> [ 0.537564] kernel_init+0x28/0x148
>> [ 0.537566] ret_from_fork+0x10/0x20
>> [ 0.537569] =============================
>> [ 0.537569] [ BUG: Invalid wait context ]
>> [ 0.537571] 6.18.0-dbg-DEV #1 Tainted: G W
>> [ 0.537572] -----------------------------
>> [ 0.537572] swapper/0/1 is trying to lock:
>> [ 0.537573] ffffb60b011f3830 (pgtable_split_lock){+.+.}-{4:4}, at: split_kernel_leaf_mapping+0x74/0x1a0
>> [ 0.537576] other info that might help us debug this:
>> [ 0.537577] context-{5:5}
>> [ 0.537578] 2 locks held by swapper/0/1:
>> [ 0.537579] #0: ffffb60b01211960 (sched_domains_mutex){+.+.}-{4:4}, at: sched_domains_mutex_lock+0x24/0x38
>> [ 0.537582] #1: ffffb60b01595838 (rcu_read_lock){....}-{1:3}, at: rcu_lock_acquire+0x0/0x40
>> [ 0.537585] stack backtrace:
>> [ 0.537585] CPU: 0 UID: 0 PID: 1 Comm: swapper/0 Tainted: G W 6.18.0-dbg-DEV #1 NONE
>> [ 0.537587] Tainted: [W]=WARN
>> [ 0.537588] Call trace:
>> [ 0.537589] show_stack+0x20/0x38 (C)
>> [ 0.537591] __dump_stack+0x28/0x38
>> [ 0.537593] dump_stack_lvl+0xac/0xf0
>> [ 0.537596] dump_stack+0x18/0x3c
>> [ 0.537598] __lock_acquire+0x980/0x2a20
>> [ 0.537600] lock_acquire+0x124/0x2b8
>> [ 0.537602] __mutex_lock_common+0xd8/0x1818
>> [ 0.537604] mutex_lock_nested+0x34/0x48
>> [ 0.537605] split_kernel_leaf_mapping+0x74/0x1a0
>> [ 0.537607] update_range_prot+0x40/0x150
>> [ 0.537608] __change_memory_common+0x30/0x148
>> [ 0.537609] __kernel_map_pages+0x70/0x88
>> [ 0.537610] __free_frozen_pages+0x6e4/0x7b8
>> [ 0.537613] free_frozen_pages+0x1c/0x30
>> [ 0.537615] __free_slab+0xf0/0x168
>> [ 0.537617] free_slab+0x2c/0xf8
>> [ 0.537619] free_to_partial_list+0x4e0/0x620
>> [ 0.537621] __slab_free+0x228/0x250
>> [ 0.537623] kfree+0x3c4/0x4c0
>> [ 0.537625] destroy_sched_domain+0xf8/0x140
>> [ 0.537627] cpu_attach_domain+0x17c/0x610
>> [ 0.537628] build_sched_domains+0x15a4/0x1718
>> [ 0.537630] sched_init_domains+0xbc/0xf8
>> [ 0.537631] sched_init_smp+0x30/0x98
>> [ 0.537632] kernel_init_freeable+0x148/0x230
>> [ 0.537633] kernel_init+0x28/0x148
>> [ 0.537635] ret_from_fork+0x10/0x20
>>
>> ---
>> bisect:
>>
>> # bad: [3a8660878839faadb4f1a6dd72c3179c1df56787] Linux 6.18-rc1
>> # good: [e5f0a698b34ed76002dc5cff3804a61c80233a7a] Linux 6.17
>> git bisect start 'v6.18-rc1' 'v6.17'
>> # bad: [58809f614e0e3f4e12b489bddf680bfeb31c0a20] Merge tag 'drm-next-2025-10-01' of https://gitlab.freedesktop.org/drm/kernel
>> git bisect bad 58809f614e0e3f4e12b489bddf680bfeb31c0a20
>> # bad: [a8253f807760e9c80eada9e5354e1240ccf325f9] Merge tag 'soc-newsoc-6.18' of git://git.kernel.org/pub/scm/linux/kernel/git/soc/soc
>> git bisect bad a8253f807760e9c80eada9e5354e1240ccf325f9
>> # bad: [4b81e2eb9e4db8f6094c077d0c8b27c264901c1b] Merge tag 'timers-vdso-2025-09-29' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
>> git bisect bad 4b81e2eb9e4db8f6094c077d0c8b27c264901c1b
>> # bad: [f1004b2f19d7e9add9d707f64d9fcbc50f67921b] Merge tag 'm68k-for-v6.18-tag1' of git://git.kernel.org/pub/scm/linux/kernel/git/geert/linux-m68k
>> git bisect bad f1004b2f19d7e9add9d707f64d9fcbc50f67921b
>> # good: [a9401710a5f5681abd2a6f21f9e76bc9f2e81891] Merge tag 'v6.18-rc-part1-smb3-common' of git://git.samba.org/ksmbd
>> git bisect good a9401710a5f5681abd2a6f21f9e76bc9f2e81891
>> # good: [fe68bb2861808ed5c48d399bd7e670ab76829d55] Merge tag 'microblaze-v6.18' of git://git.monstr.eu/linux-2.6-microblaze
>> git bisect good fe68bb2861808ed5c48d399bd7e670ab76829d55
>> # bad: [f2d64a22faeeecff385b4c91fab5fe036ab00162] Merge branch 'for-next/perf' into for-next/core
>> git bisect bad f2d64a22faeeecff385b4c91fab5fe036ab00162
>> # good: [30f9386820cddbba59b48ae0670c3a1646dd440e] Merge branch 'for-next/misc' into for-next/core
>> git bisect good 30f9386820cddbba59b48ae0670c3a1646dd440e
>> # good: [43de0ac332b815cf56dbdce63687de9acfd35d49] drivers/perf: hisi: Relax the event ID check in the framework
>> git bisect good 43de0ac332b815cf56dbdce63687de9acfd35d49
>> # good: [5973a62efa34c80c9a4e5eac1fca6f6209b902af] arm64: map [_text, _stext) virtual address range non-executable+read-only
>> git bisect good 5973a62efa34c80c9a4e5eac1fca6f6209b902af
>> # good: [b3abb08d6f628a76c36bf7da9508e1a67bf186a0] drivers/perf: hisi: Refactor the event configuration of L3C PMU
>> git bisect good b3abb08d6f628a76c36bf7da9508e1a67bf186a0
>> # good: [6d2f913fda5683fbd4c3580262e10386c1263dfb] Documentation: hisi-pmu: Add introduction to HiSilicon V3 PMU
>> git bisect good 6d2f913fda5683fbd4c3580262e10386c1263dfb
>> # good: [2084660ad288c998b6f0c885e266deb364f65fba] perf/dwc_pcie: Fix use of uninitialized variable
>> git bisect good 2084660ad288c998b6f0c885e266deb364f65fba
>> # bad: [77dfca70baefcb988318a72fe69eb99f6dabbbb1] Merge branch 'for-next/mm' into for-next/core
>> git bisect bad 77dfca70baefcb988318a72fe69eb99f6dabbbb1
>> # first bad commit: [77dfca70baefcb988318a72fe69eb99f6dabbbb1] Merge branch 'for-next/mm' into for-next/core
>>
>> ---
>> bisect into branch:
>>
>> - git checkout -b testing 77dfca70baefcb988318a72fe69eb99f6dabbbb1
>> - git rebase 77dfca70baefcb988318a72fe69eb99f6dabbbb1~1
>> [ fix minor conflict similar to the conflict resolution in 77dfca70baefc]
>> - git diff 77dfca70baefcb988318a72fe69eb99f6dabbbb1
>> [ confirmed that there are no differences ]
>> - confirm that the problem is still seen at the tip of the rebase
>> - git bisect start HEAD 77dfca70baefcb988318a72fe69eb99f6dabbbb1~1
>> - run bisect
>>
>> Results:
>>
>> # bad: [47fc25df1ae3ae8412f1b812fb586c714d04a5e6] arm64: map [_text, _stext) virtual address range non-executable+read-only
>> # good: [30f9386820cddbba59b48ae0670c3a1646dd440e] Merge branch 'for-next/misc' into for-next/core
>> git bisect start 'HEAD' '77dfca70baefcb988318a72fe69eb99f6dabbbb1~1'
>> # good: [805491d19fc21271b5c27f4602f8f66b625c110f] arm64/Kconfig: Remove CONFIG_RODATA_FULL_DEFAULT_ENABLED
>> git bisect good 805491d19fc21271b5c27f4602f8f66b625c110f
>> # bad: [13c7d7426232cc4489df7cd2e1f646a22d3f6172] arm64: mm: support large block mapping when rodata=full
>> git bisect bad 13c7d7426232cc4489df7cd2e1f646a22d3f6172
>> # good: [a4d9c67e503f2b73c2d89d8e8209dfd241bdc8d8] arm64: Enable permission change on arm64 kernel block mappings
>> git bisect good a4d9c67e503f2b73c2d89d8e8209dfd241bdc8d8
>> # first bad commit: [13c7d7426232cc4489df7cd2e1f646a22d3f6172] arm64: mm: support large block mapping when rodata=full
>
>>>>
>>> With lock debugging enabled, we see a large number of "BUG: sleeping
>>> function called from invalid context at kernel/locking/mutex.c:580"
>>> and "BUG: Invalid wait context:" backtraces when running v6.18-rc3.
>>> Please see example below.
>>>
>>> Bisect points to this patch.
>>>
>>> Please let me know if there is anything I can do to help tracking
>>> down the problem.
>> Thanks for the report - ouch!
>>
>> I expect you're running on a system that supports BBML2_NOABORT, based on the
>> stack trace, I expect you have CONFIG_DEBUG_PAGEALLOC enabled? That will cause
>> permission tricks to be played on the linear map at page allocation and free
>> time, which can happen in non-sleepable contexts. And with this patch we are
>> taking pgtable_split_lock (a mutex) in split_kernel_leaf_mapping(), which is
>> called as a result of the permission change request.
>>
>> However, when CONFIG_DEBUG_PAGEALLOC enabled we always force-map the linear map
>> by PTE so split_kernel_leaf_mapping() is actually unneccessary and will return
>> without actually having to split anything. So we could add an early "if
>> (force_pte_mapping()) return 0;" to bypass the function entirely in this case,
>> and I *think* that should solve it.
>>
>> But I'm also concerned about KFENCE. I can't remember it's exact semantics off
>> the top of my head, so I'm concerned we could see similar problems there (where
>> we only force pte mapping for the KFENCE pool).
>>
>> I'll investigate fully tomorrow and hopefully provide a fix.
> Here's a proposed fix, although I can't get access to a system with BBML2 until
> tomorrow at the earliest. Guenter, I wonder if you could check that this
> resolves your issue?
>
> ---8<---
> commit 602ec2db74e5abfb058bd03934475ead8558eb72
> Author: Ryan Roberts <ryan.roberts@arm.com>
> Date: Sun Nov 2 11:45:18 2025 +0000
>
> arm64: mm: Don't attempt to split known pte-mapped regions
>
> It has been reported that split_kernel_leaf_mapping() is trying to sleep
> in non-sleepable context. It does this when acquiring the
> pgtable_split_lock mutex, when either CONFIG_DEBUG_ALLOC or
> CONFIG_KFENCE are enabled, which change linear map permissions within
> softirq context during memory allocation and/or freeing.
>
> But it turns out that the memory for which these features may attempt to
> modify the permissions is always mapped by pte, so there is no need to
> attempt to split the mapping. So let's exit early in these cases and
> avoid attempting to take the mutex.
>
> Closes: https://lore.kernel.org/all/f24b9032-0ec9-47b1-8b95-c0eeac7a31c5@roeck-us.net/
> Fixes: a166563e7ec3 ("arm64: mm: support large block mapping when rodata=full")
> Signed-off-by: Ryan Roberts <ryan.roberts@arm.com>
>
> diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c
> index b8d37eb037fc..6e26f070bb49 100644
> --- a/arch/arm64/mm/mmu.c
> +++ b/arch/arm64/mm/mmu.c
> @@ -708,6 +708,16 @@ static int split_kernel_leaf_mapping_locked(unsigned long addr)
> return ret;
> }
>
> +static inline bool force_pte_mapping(void)
> +{
> + bool bbml2 = system_capabilities_finalized() ?
> + system_supports_bbml2_noabort() : cpu_supports_bbml2_noabort();
> +
> + return (!bbml2 && (rodata_full || arm64_kfence_can_set_direct_map() ||
> + is_realm_world())) ||
> + debug_pagealloc_enabled();
> +}
> +
> static DEFINE_MUTEX(pgtable_split_lock);
>
> int split_kernel_leaf_mapping(unsigned long start, unsigned long end)
> @@ -723,6 +733,16 @@ int split_kernel_leaf_mapping(unsigned long start, unsigned long end)
> if (!system_supports_bbml2_noabort())
> return 0;
>
> + /*
> + * If the region is within a pte-mapped area, there is no need to try to
> + * split. Additionally, CONFIG_DEBUG_ALLOC and CONFIG_KFENCE may change
Nit: CONFIG_DEBUG_PAGEALLOC.
> + * permissions from softirq context so for those cases (which are always
> + * pte-mapped), we must not go any further because taking the mutex
> + * below may sleep.
> + */
> + if (force_pte_mapping() || is_kfence_address((void *)start))
> + return 0;
> +
> /*
> * Ensure start and end are at least page-aligned since this is the
> * finest granularity we can split to.
> @@ -1009,16 +1029,6 @@ static inline void arm64_kfence_map_pool(phys_addr_t kfence_pool, pgd_t *pgdp) {
>
> #endif /* CONFIG_KFENCE */
>
> -static inline bool force_pte_mapping(void)
> -{
> - bool bbml2 = system_capabilities_finalized() ?
> - system_supports_bbml2_noabort() : cpu_supports_bbml2_noabort();
> -
> - return (!bbml2 && (rodata_full || arm64_kfence_can_set_direct_map() ||
> - is_realm_world())) ||
> - debug_pagealloc_enabled();
> -}
> -
Otherwise LGTM.
Reviewed-by: Dev Jain <dev.jain@arm.com>
> static void __init map_mem(pgd_t *pgdp)
> {
> static const u64 direct_map_end = _PAGE_END(VA_BITS_MIN);
> ---8<---
>
> Thanks,
> Ryan
>
>> Yang Shi, Do you have any additional thoughts?
>>
>> Thanks,
>> Ryan
>>
On 11/2/25 4:11 AM, Ryan Roberts wrote:
> On 02/11/2025 10:31, Ryan Roberts wrote:
>> On 01/11/2025 16:14, Guenter Roeck wrote:
>>> Hi,
>>>
>>> On Wed, Sep 17, 2025 at 12:02:09PM -0700, Yang Shi wrote:
>>>> When rodata=full is specified, kernel linear mapping has to be mapped at
>>>> PTE level since large page table can't be split due to break-before-make
>>>> rule on ARM64.
>>>>
>>>> This resulted in a couple of problems:
>>>> - performance degradation
>>>> - more TLB pressure
>>>> - memory waste for kernel page table
>>>>
>>>> With FEAT_BBM level 2 support, splitting large block page table to
>>>> smaller ones doesn't need to make the page table entry invalid anymore.
>>>> This allows kernel split large block mapping on the fly.
>>>>
>>>> Add kernel page table split support and use large block mapping by
>>>> default when FEAT_BBM level 2 is supported for rodata=full. When
>>>> changing permissions for kernel linear mapping, the page table will be
>>>> split to smaller size.
>>>>
>>>> The machine without FEAT_BBM level 2 will fallback to have kernel linear
>>>> mapping PTE-mapped when rodata=full.
>>>>
>>>> With this we saw significant performance boost with some benchmarks and
>>>> much less memory consumption on my AmpereOne machine (192 cores, 1P)
>>>> with 256GB memory.
>>>>
>>>> * Memory use after boot
>>>> Before:
>>>> MemTotal: 258988984 kB
>>>> MemFree: 254821700 kB
>>>>
>>>> After:
>>>> MemTotal: 259505132 kB
>>>> MemFree: 255410264 kB
>>>>
>>>> Around 500MB more memory are free to use. The larger the machine, the
>>>> more memory saved.
>>>>
>>>> * Memcached
>>>> We saw performance degradation when running Memcached benchmark with
>>>> rodata=full vs rodata=on. Our profiling pointed to kernel TLB pressure.
>>>> With this patchset we saw ops/sec is increased by around 3.5%, P99
>>>> latency is reduced by around 9.6%.
>>>> The gain mainly came from reduced kernel TLB misses. The kernel TLB
>>>> MPKI is reduced by 28.5%.
>>>>
>>>> The benchmark data is now on par with rodata=on too.
>>>>
>>>> * Disk encryption (dm-crypt) benchmark
>>>> Ran fio benchmark with the below command on a 128G ramdisk (ext4) with
>>>> disk encryption (by dm-crypt).
>>>> fio --directory=/data --random_generator=lfsr --norandommap \
>>>> --randrepeat 1 --status-interval=999 --rw=write --bs=4k --loops=1 \
>>>> --ioengine=sync --iodepth=1 --numjobs=1 --fsync_on_close=1 \
>>>> --group_reporting --thread --name=iops-test-job --eta-newline=1 \
>>>> --size 100G
>>>>
>>>> The IOPS is increased by 90% - 150% (the variance is high, but the worst
>>>> number of good case is around 90% more than the best number of bad
>>>> case). The bandwidth is increased and the avg clat is reduced
>>>> proportionally.
>>>>
>>>> * Sequential file read
>>>> Read 100G file sequentially on XFS (xfs_io read with page cache
>>>> populated). The bandwidth is increased by 150%.
>>>>
>>> With lock debugging enabled, we see a large number of "BUG: sleeping
>>> function called from invalid context at kernel/locking/mutex.c:580"
>>> and "BUG: Invalid wait context:" backtraces when running v6.18-rc3.
>>> Please see example below.
>>>
>>> Bisect points to this patch.
>>>
>>> Please let me know if there is anything I can do to help tracking
>>> down the problem.
>> Thanks for the report - ouch!
>>
>> I expect you're running on a system that supports BBML2_NOABORT, based on the
>> stack trace, I expect you have CONFIG_DEBUG_PAGEALLOC enabled? That will cause
>> permission tricks to be played on the linear map at page allocation and free
>> time, which can happen in non-sleepable contexts. And with this patch we are
>> taking pgtable_split_lock (a mutex) in split_kernel_leaf_mapping(), which is
>> called as a result of the permission change request.
>>
>> However, when CONFIG_DEBUG_PAGEALLOC enabled we always force-map the linear map
>> by PTE so split_kernel_leaf_mapping() is actually unneccessary and will return
>> without actually having to split anything. So we could add an early "if
>> (force_pte_mapping()) return 0;" to bypass the function entirely in this case,
>> and I *think* that should solve it.
>>
>> But I'm also concerned about KFENCE. I can't remember it's exact semantics off
>> the top of my head, so I'm concerned we could see similar problems there (where
>> we only force pte mapping for the KFENCE pool).
>>
>> I'll investigate fully tomorrow and hopefully provide a fix.
Hi Ryan,
Thanks a lot for the quick fix. I have some comments about kfence below.
> Here's a proposed fix, although I can't get access to a system with BBML2 until
> tomorrow at the earliest. Guenter, I wonder if you could check that this
> resolves your issue?
>
> ---8<---
> commit 602ec2db74e5abfb058bd03934475ead8558eb72
> Author: Ryan Roberts <ryan.roberts@arm.com>
> Date: Sun Nov 2 11:45:18 2025 +0000
>
> arm64: mm: Don't attempt to split known pte-mapped regions
>
> It has been reported that split_kernel_leaf_mapping() is trying to sleep
> in non-sleepable context. It does this when acquiring the
> pgtable_split_lock mutex, when either CONFIG_DEBUG_ALLOC or
> CONFIG_KFENCE are enabled, which change linear map permissions within
> softirq context during memory allocation and/or freeing.
>
> But it turns out that the memory for which these features may attempt to
> modify the permissions is always mapped by pte, so there is no need to
> attempt to split the mapping. So let's exit early in these cases and
> avoid attempting to take the mutex.
>
> Closes: https://lore.kernel.org/all/f24b9032-0ec9-47b1-8b95-c0eeac7a31c5@roeck-us.net/
> Fixes: a166563e7ec3 ("arm64: mm: support large block mapping when rodata=full")
> Signed-off-by: Ryan Roberts <ryan.roberts@arm.com>
>
> diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c
> index b8d37eb037fc..6e26f070bb49 100644
> --- a/arch/arm64/mm/mmu.c
> +++ b/arch/arm64/mm/mmu.c
> @@ -708,6 +708,16 @@ static int split_kernel_leaf_mapping_locked(unsigned long addr)
> return ret;
> }
>
> +static inline bool force_pte_mapping(void)
> +{
> + bool bbml2 = system_capabilities_finalized() ?
> + system_supports_bbml2_noabort() : cpu_supports_bbml2_noabort();
> +
> + return (!bbml2 && (rodata_full || arm64_kfence_can_set_direct_map() ||
> + is_realm_world())) ||
> + debug_pagealloc_enabled();
> +}
> +
> static DEFINE_MUTEX(pgtable_split_lock);
>
> int split_kernel_leaf_mapping(unsigned long start, unsigned long end)
> @@ -723,6 +733,16 @@ int split_kernel_leaf_mapping(unsigned long start, unsigned long end)
> if (!system_supports_bbml2_noabort())
> return 0;
>
> + /*
> + * If the region is within a pte-mapped area, there is no need to try to
> + * split. Additionally, CONFIG_DEBUG_ALLOC and CONFIG_KFENCE may change
> + * permissions from softirq context so for those cases (which are always
> + * pte-mapped), we must not go any further because taking the mutex
> + * below may sleep.
> + */
> + if (force_pte_mapping() || is_kfence_address((void *)start))
IIUC this may break kfence late init? The kfence_late_init() allocates
pages from buddy allocator, then protects them (setting them to
invalid). But the protection requires split page table, this check will
prevent kernel from splitting page table because __kfence_pool is
initialized before doing protection. So there is kind of circular
dependency.
The below fix may work?
if (force_pte_mapping() || (READ_ONCE(kfence_enabled) &&
is_kfence_address((void *)start)))
The kfence_enabled won't be set until protection is done. So if it is
set, we know kfence address must be mapped by PTE.
Thanks,
Yang
> + return 0;
> +
> /*
> * Ensure start and end are at least page-aligned since this is the
> * finest granularity we can split to.
> @@ -1009,16 +1029,6 @@ static inline void arm64_kfence_map_pool(phys_addr_t kfence_pool, pgd_t *pgdp) {
>
> #endif /* CONFIG_KFENCE */
>
> -static inline bool force_pte_mapping(void)
> -{
> - bool bbml2 = system_capabilities_finalized() ?
> - system_supports_bbml2_noabort() : cpu_supports_bbml2_noabort();
> -
> - return (!bbml2 && (rodata_full || arm64_kfence_can_set_direct_map() ||
> - is_realm_world())) ||
> - debug_pagealloc_enabled();
> -}
> -
> static void __init map_mem(pgd_t *pgdp)
> {
> static const u64 direct_map_end = _PAGE_END(VA_BITS_MIN);
> ---8<---
>
> Thanks,
> Ryan
>
>> Yang Shi, Do you have any additional thoughts?
>>
>> Thanks,
>> Ryan
>>
>>> Thanks,
>>> Guenter
>>>
>>> ---
>>> Example log:
>>>
>>> [ 0.537499] BUG: sleeping function called from invalid context at kernel/locking/mutex.c:580
>>> [ 0.537501] in_atomic(): 1, irqs_disabled(): 0, non_block: 0, pid: 1, name: swapper/0
>>> [ 0.537502] preempt_count: 1, expected: 0
>>> [ 0.537504] 2 locks held by swapper/0/1:
>>> [ 0.537505] #0: ffffb60b01211960 (sched_domains_mutex){+.+.}-{4:4}, at: sched_domains_mutex_lock+0x24/0x38
>>> [ 0.537510] #1: ffffb60b01595838 (rcu_read_lock){....}-{1:3}, at: rcu_lock_acquire+0x0/0x40
>>> [ 0.537516] CPU: 0 UID: 0 PID: 1 Comm: swapper/0 Not tainted 6.18.0-dbg-DEV #1 NONE
>>> [ 0.537517] Call trace:
>>> [ 0.537518] show_stack+0x20/0x38 (C)
>>> [ 0.537520] __dump_stack+0x28/0x38
>>> [ 0.537522] dump_stack_lvl+0xac/0xf0
>>> [ 0.537525] dump_stack+0x18/0x3c
>>> [ 0.537527] __might_resched+0x248/0x2a0
>>> [ 0.537529] __might_sleep+0x40/0x90
>>> [ 0.537531] __mutex_lock_common+0x70/0x1818
>>> [ 0.537533] mutex_lock_nested+0x34/0x48
>>> [ 0.537534] split_kernel_leaf_mapping+0x74/0x1a0
>>> [ 0.537536] update_range_prot+0x40/0x150
>>> [ 0.537537] __change_memory_common+0x30/0x148
>>> [ 0.537538] __kernel_map_pages+0x70/0x88
>>> [ 0.537540] __free_frozen_pages+0x6e4/0x7b8
>>> [ 0.537542] free_frozen_pages+0x1c/0x30
>>> [ 0.537544] __free_slab+0xf0/0x168
>>> [ 0.537547] free_slab+0x2c/0xf8
>>> [ 0.537549] free_to_partial_list+0x4e0/0x620
>>> [ 0.537551] __slab_free+0x228/0x250
>>> [ 0.537553] kfree+0x3c4/0x4c0
>>> [ 0.537555] destroy_sched_domain+0xf8/0x140
>>> [ 0.537557] cpu_attach_domain+0x17c/0x610
>>> [ 0.537558] build_sched_domains+0x15a4/0x1718
>>> [ 0.537560] sched_init_domains+0xbc/0xf8
>>> [ 0.537561] sched_init_smp+0x30/0x98
>>> [ 0.537562] kernel_init_freeable+0x148/0x230
>>> [ 0.537564] kernel_init+0x28/0x148
>>> [ 0.537566] ret_from_fork+0x10/0x20
>>> [ 0.537569] =============================
>>> [ 0.537569] [ BUG: Invalid wait context ]
>>> [ 0.537571] 6.18.0-dbg-DEV #1 Tainted: G W
>>> [ 0.537572] -----------------------------
>>> [ 0.537572] swapper/0/1 is trying to lock:
>>> [ 0.537573] ffffb60b011f3830 (pgtable_split_lock){+.+.}-{4:4}, at: split_kernel_leaf_mapping+0x74/0x1a0
>>> [ 0.537576] other info that might help us debug this:
>>> [ 0.537577] context-{5:5}
>>> [ 0.537578] 2 locks held by swapper/0/1:
>>> [ 0.537579] #0: ffffb60b01211960 (sched_domains_mutex){+.+.}-{4:4}, at: sched_domains_mutex_lock+0x24/0x38
>>> [ 0.537582] #1: ffffb60b01595838 (rcu_read_lock){....}-{1:3}, at: rcu_lock_acquire+0x0/0x40
>>> [ 0.537585] stack backtrace:
>>> [ 0.537585] CPU: 0 UID: 0 PID: 1 Comm: swapper/0 Tainted: G W 6.18.0-dbg-DEV #1 NONE
>>> [ 0.537587] Tainted: [W]=WARN
>>> [ 0.537588] Call trace:
>>> [ 0.537589] show_stack+0x20/0x38 (C)
>>> [ 0.537591] __dump_stack+0x28/0x38
>>> [ 0.537593] dump_stack_lvl+0xac/0xf0
>>> [ 0.537596] dump_stack+0x18/0x3c
>>> [ 0.537598] __lock_acquire+0x980/0x2a20
>>> [ 0.537600] lock_acquire+0x124/0x2b8
>>> [ 0.537602] __mutex_lock_common+0xd8/0x1818
>>> [ 0.537604] mutex_lock_nested+0x34/0x48
>>> [ 0.537605] split_kernel_leaf_mapping+0x74/0x1a0
>>> [ 0.537607] update_range_prot+0x40/0x150
>>> [ 0.537608] __change_memory_common+0x30/0x148
>>> [ 0.537609] __kernel_map_pages+0x70/0x88
>>> [ 0.537610] __free_frozen_pages+0x6e4/0x7b8
>>> [ 0.537613] free_frozen_pages+0x1c/0x30
>>> [ 0.537615] __free_slab+0xf0/0x168
>>> [ 0.537617] free_slab+0x2c/0xf8
>>> [ 0.537619] free_to_partial_list+0x4e0/0x620
>>> [ 0.537621] __slab_free+0x228/0x250
>>> [ 0.537623] kfree+0x3c4/0x4c0
>>> [ 0.537625] destroy_sched_domain+0xf8/0x140
>>> [ 0.537627] cpu_attach_domain+0x17c/0x610
>>> [ 0.537628] build_sched_domains+0x15a4/0x1718
>>> [ 0.537630] sched_init_domains+0xbc/0xf8
>>> [ 0.537631] sched_init_smp+0x30/0x98
>>> [ 0.537632] kernel_init_freeable+0x148/0x230
>>> [ 0.537633] kernel_init+0x28/0x148
>>> [ 0.537635] ret_from_fork+0x10/0x20
>>>
>>> ---
>>> bisect:
>>>
>>> # bad: [3a8660878839faadb4f1a6dd72c3179c1df56787] Linux 6.18-rc1
>>> # good: [e5f0a698b34ed76002dc5cff3804a61c80233a7a] Linux 6.17
>>> git bisect start 'v6.18-rc1' 'v6.17'
>>> # bad: [58809f614e0e3f4e12b489bddf680bfeb31c0a20] Merge tag 'drm-next-2025-10-01' of https://gitlab.freedesktop.org/drm/kernel
>>> git bisect bad 58809f614e0e3f4e12b489bddf680bfeb31c0a20
>>> # bad: [a8253f807760e9c80eada9e5354e1240ccf325f9] Merge tag 'soc-newsoc-6.18' of git://git.kernel.org/pub/scm/linux/kernel/git/soc/soc
>>> git bisect bad a8253f807760e9c80eada9e5354e1240ccf325f9
>>> # bad: [4b81e2eb9e4db8f6094c077d0c8b27c264901c1b] Merge tag 'timers-vdso-2025-09-29' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
>>> git bisect bad 4b81e2eb9e4db8f6094c077d0c8b27c264901c1b
>>> # bad: [f1004b2f19d7e9add9d707f64d9fcbc50f67921b] Merge tag 'm68k-for-v6.18-tag1' of git://git.kernel.org/pub/scm/linux/kernel/git/geert/linux-m68k
>>> git bisect bad f1004b2f19d7e9add9d707f64d9fcbc50f67921b
>>> # good: [a9401710a5f5681abd2a6f21f9e76bc9f2e81891] Merge tag 'v6.18-rc-part1-smb3-common' of git://git.samba.org/ksmbd
>>> git bisect good a9401710a5f5681abd2a6f21f9e76bc9f2e81891
>>> # good: [fe68bb2861808ed5c48d399bd7e670ab76829d55] Merge tag 'microblaze-v6.18' of git://git.monstr.eu/linux-2.6-microblaze
>>> git bisect good fe68bb2861808ed5c48d399bd7e670ab76829d55
>>> # bad: [f2d64a22faeeecff385b4c91fab5fe036ab00162] Merge branch 'for-next/perf' into for-next/core
>>> git bisect bad f2d64a22faeeecff385b4c91fab5fe036ab00162
>>> # good: [30f9386820cddbba59b48ae0670c3a1646dd440e] Merge branch 'for-next/misc' into for-next/core
>>> git bisect good 30f9386820cddbba59b48ae0670c3a1646dd440e
>>> # good: [43de0ac332b815cf56dbdce63687de9acfd35d49] drivers/perf: hisi: Relax the event ID check in the framework
>>> git bisect good 43de0ac332b815cf56dbdce63687de9acfd35d49
>>> # good: [5973a62efa34c80c9a4e5eac1fca6f6209b902af] arm64: map [_text, _stext) virtual address range non-executable+read-only
>>> git bisect good 5973a62efa34c80c9a4e5eac1fca6f6209b902af
>>> # good: [b3abb08d6f628a76c36bf7da9508e1a67bf186a0] drivers/perf: hisi: Refactor the event configuration of L3C PMU
>>> git bisect good b3abb08d6f628a76c36bf7da9508e1a67bf186a0
>>> # good: [6d2f913fda5683fbd4c3580262e10386c1263dfb] Documentation: hisi-pmu: Add introduction to HiSilicon V3 PMU
>>> git bisect good 6d2f913fda5683fbd4c3580262e10386c1263dfb
>>> # good: [2084660ad288c998b6f0c885e266deb364f65fba] perf/dwc_pcie: Fix use of uninitialized variable
>>> git bisect good 2084660ad288c998b6f0c885e266deb364f65fba
>>> # bad: [77dfca70baefcb988318a72fe69eb99f6dabbbb1] Merge branch 'for-next/mm' into for-next/core
>>> git bisect bad 77dfca70baefcb988318a72fe69eb99f6dabbbb1
>>> # first bad commit: [77dfca70baefcb988318a72fe69eb99f6dabbbb1] Merge branch 'for-next/mm' into for-next/core
>>>
>>> ---
>>> bisect into branch:
>>>
>>> - git checkout -b testing 77dfca70baefcb988318a72fe69eb99f6dabbbb1
>>> - git rebase 77dfca70baefcb988318a72fe69eb99f6dabbbb1~1
>>> [ fix minor conflict similar to the conflict resolution in 77dfca70baefc]
>>> - git diff 77dfca70baefcb988318a72fe69eb99f6dabbbb1
>>> [ confirmed that there are no differences ]
>>> - confirm that the problem is still seen at the tip of the rebase
>>> - git bisect start HEAD 77dfca70baefcb988318a72fe69eb99f6dabbbb1~1
>>> - run bisect
>>>
>>> Results:
>>>
>>> # bad: [47fc25df1ae3ae8412f1b812fb586c714d04a5e6] arm64: map [_text, _stext) virtual address range non-executable+read-only
>>> # good: [30f9386820cddbba59b48ae0670c3a1646dd440e] Merge branch 'for-next/misc' into for-next/core
>>> git bisect start 'HEAD' '77dfca70baefcb988318a72fe69eb99f6dabbbb1~1'
>>> # good: [805491d19fc21271b5c27f4602f8f66b625c110f] arm64/Kconfig: Remove CONFIG_RODATA_FULL_DEFAULT_ENABLED
>>> git bisect good 805491d19fc21271b5c27f4602f8f66b625c110f
>>> # bad: [13c7d7426232cc4489df7cd2e1f646a22d3f6172] arm64: mm: support large block mapping when rodata=full
>>> git bisect bad 13c7d7426232cc4489df7cd2e1f646a22d3f6172
>>> # good: [a4d9c67e503f2b73c2d89d8e8209dfd241bdc8d8] arm64: Enable permission change on arm64 kernel block mappings
>>> git bisect good a4d9c67e503f2b73c2d89d8e8209dfd241bdc8d8
>>> # first bad commit: [13c7d7426232cc4489df7cd2e1f646a22d3f6172] arm64: mm: support large block mapping when rodata=full
On 03/11/2025 00:47, Yang Shi wrote:
>
>
[...]
>> @@ -723,6 +733,16 @@ int split_kernel_leaf_mapping(unsigned long start,
>> unsigned long end)
>> if (!system_supports_bbml2_noabort())
>> return 0;
>> + /*
>> + * If the region is within a pte-mapped area, there is no need to try to
>> + * split. Additionally, CONFIG_DEBUG_ALLOC and CONFIG_KFENCE may change
>> + * permissions from softirq context so for those cases (which are always
>> + * pte-mapped), we must not go any further because taking the mutex
>> + * below may sleep.
>> + */
>> + if (force_pte_mapping() || is_kfence_address((void *)start))
>
> IIUC this may break kfence late init? The kfence_late_init() allocates pages
> from buddy allocator, then protects them (setting them to invalid). But the
> protection requires split page table, this check will prevent kernel from
> splitting page table because __kfence_pool is initialized before doing
> protection. So there is kind of circular dependency.
I hadn't considered late init. But I guess the requirement is that the kfence
pool needs to be pte mapped whenever kfence is enabled.
For early init; that requirement is clearly met since we pte map it in the arch
code. For late init, as far as I can tell, the memory is initially block mapped,
is allocarted from the buddy then every other page is protected via
kfence_init_pool() from kfence_init_pool(). This will have the effect of
splitting every page in the pool to pte mappings (as long as your suggested fix
below is applied).
It all feels a bit accidental though.
>
> The below fix may work?
>
> if (force_pte_mapping() || (READ_ONCE(kfence_enabled) && is_kfence_address((void
> *)start)))
>
> The kfence_enabled won't be set until protection is done. So if it is set, we
> know kfence address must be mapped by PTE.
I think it will work, but it feels a bit hacky, and kfence_enabled is currently
static in core.c.
I wonder if it would be preferable to explicitly do the pte mapping in
arch_kfence_init_pool()? It looks like that's how x86 does it...
>
> Thanks,
> Yang
>
>
>
>
>
>> + return 0;
>> +
>> /*
>> * Ensure start and end are at least page-aligned since this is the
>> * finest granularity we can split to.
>> @@ -1009,16 +1029,6 @@ static inline void arm64_kfence_map_pool(phys_addr_t
>> kfence_pool, pgd_t *pgdp) {
>> #endif /* CONFIG_KFENCE */
>> -static inline bool force_pte_mapping(void)
>> -{
>> - bool bbml2 = system_capabilities_finalized() ?
>> - system_supports_bbml2_noabort() : cpu_supports_bbml2_noabort();
>> -
>> - return (!bbml2 && (rodata_full || arm64_kfence_can_set_direct_map() ||
>> - is_realm_world())) ||
>> - debug_pagealloc_enabled();
>> -}
>> -
>> static void __init map_mem(pgd_t *pgdp)
>> {
>> static const u64 direct_map_end = _PAGE_END(VA_BITS_MIN);
>> ---8<---
>>
>> Thanks,
>> Ryan
>>
>>> Yang Shi, Do you have any additional thoughts?
>>>
>>> Thanks,
>>> Ryan
>>>
>>>> Thanks,
>>>> Guenter
>>>>
>>>> ---
>>>> Example log:
>>>>
>>>> [ 0.537499] BUG: sleeping function called from invalid context at kernel/
>>>> locking/mutex.c:580
>>>> [ 0.537501] in_atomic(): 1, irqs_disabled(): 0, non_block: 0, pid: 1,
>>>> name: swapper/0
>>>> [ 0.537502] preempt_count: 1, expected: 0
>>>> [ 0.537504] 2 locks held by swapper/0/1:
>>>> [ 0.537505] #0: ffffb60b01211960 (sched_domains_mutex){+.+.}-{4:4}, at:
>>>> sched_domains_mutex_lock+0x24/0x38
>>>> [ 0.537510] #1: ffffb60b01595838 (rcu_read_lock){....}-{1:3}, at:
>>>> rcu_lock_acquire+0x0/0x40
>>>> [ 0.537516] CPU: 0 UID: 0 PID: 1 Comm: swapper/0 Not tainted 6.18.0-dbg-
>>>> DEV #1 NONE
>>>> [ 0.537517] Call trace:
>>>> [ 0.537518] show_stack+0x20/0x38 (C)
>>>> [ 0.537520] __dump_stack+0x28/0x38
>>>> [ 0.537522] dump_stack_lvl+0xac/0xf0
>>>> [ 0.537525] dump_stack+0x18/0x3c
>>>> [ 0.537527] __might_resched+0x248/0x2a0
>>>> [ 0.537529] __might_sleep+0x40/0x90
>>>> [ 0.537531] __mutex_lock_common+0x70/0x1818
>>>> [ 0.537533] mutex_lock_nested+0x34/0x48
>>>> [ 0.537534] split_kernel_leaf_mapping+0x74/0x1a0
>>>> [ 0.537536] update_range_prot+0x40/0x150
>>>> [ 0.537537] __change_memory_common+0x30/0x148
>>>> [ 0.537538] __kernel_map_pages+0x70/0x88
>>>> [ 0.537540] __free_frozen_pages+0x6e4/0x7b8
>>>> [ 0.537542] free_frozen_pages+0x1c/0x30
>>>> [ 0.537544] __free_slab+0xf0/0x168
>>>> [ 0.537547] free_slab+0x2c/0xf8
>>>> [ 0.537549] free_to_partial_list+0x4e0/0x620
>>>> [ 0.537551] __slab_free+0x228/0x250
>>>> [ 0.537553] kfree+0x3c4/0x4c0
>>>> [ 0.537555] destroy_sched_domain+0xf8/0x140
>>>> [ 0.537557] cpu_attach_domain+0x17c/0x610
>>>> [ 0.537558] build_sched_domains+0x15a4/0x1718
>>>> [ 0.537560] sched_init_domains+0xbc/0xf8
>>>> [ 0.537561] sched_init_smp+0x30/0x98
>>>> [ 0.537562] kernel_init_freeable+0x148/0x230
>>>> [ 0.537564] kernel_init+0x28/0x148
>>>> [ 0.537566] ret_from_fork+0x10/0x20
>>>> [ 0.537569] =============================
>>>> [ 0.537569] [ BUG: Invalid wait context ]
>>>> [ 0.537571] 6.18.0-dbg-DEV #1 Tainted: G W
>>>> [ 0.537572] -----------------------------
>>>> [ 0.537572] swapper/0/1 is trying to lock:
>>>> [ 0.537573] ffffb60b011f3830 (pgtable_split_lock){+.+.}-{4:4}, at:
>>>> split_kernel_leaf_mapping+0x74/0x1a0
>>>> [ 0.537576] other info that might help us debug this:
>>>> [ 0.537577] context-{5:5}
>>>> [ 0.537578] 2 locks held by swapper/0/1:
>>>> [ 0.537579] #0: ffffb60b01211960 (sched_domains_mutex){+.+.}-{4:4}, at:
>>>> sched_domains_mutex_lock+0x24/0x38
>>>> [ 0.537582] #1: ffffb60b01595838 (rcu_read_lock){....}-{1:3}, at:
>>>> rcu_lock_acquire+0x0/0x40
>>>> [ 0.537585] stack backtrace:
>>>> [ 0.537585] CPU: 0 UID: 0 PID: 1 Comm: swapper/0 Tainted: G
>>>> W 6.18.0-dbg-DEV #1 NONE
>>>> [ 0.537587] Tainted: [W]=WARN
>>>> [ 0.537588] Call trace:
>>>> [ 0.537589] show_stack+0x20/0x38 (C)
>>>> [ 0.537591] __dump_stack+0x28/0x38
>>>> [ 0.537593] dump_stack_lvl+0xac/0xf0
>>>> [ 0.537596] dump_stack+0x18/0x3c
>>>> [ 0.537598] __lock_acquire+0x980/0x2a20
>>>> [ 0.537600] lock_acquire+0x124/0x2b8
>>>> [ 0.537602] __mutex_lock_common+0xd8/0x1818
>>>> [ 0.537604] mutex_lock_nested+0x34/0x48
>>>> [ 0.537605] split_kernel_leaf_mapping+0x74/0x1a0
>>>> [ 0.537607] update_range_prot+0x40/0x150
>>>> [ 0.537608] __change_memory_common+0x30/0x148
>>>> [ 0.537609] __kernel_map_pages+0x70/0x88
>>>> [ 0.537610] __free_frozen_pages+0x6e4/0x7b8
>>>> [ 0.537613] free_frozen_pages+0x1c/0x30
>>>> [ 0.537615] __free_slab+0xf0/0x168
>>>> [ 0.537617] free_slab+0x2c/0xf8
>>>> [ 0.537619] free_to_partial_list+0x4e0/0x620
>>>> [ 0.537621] __slab_free+0x228/0x250
>>>> [ 0.537623] kfree+0x3c4/0x4c0
>>>> [ 0.537625] destroy_sched_domain+0xf8/0x140
>>>> [ 0.537627] cpu_attach_domain+0x17c/0x610
>>>> [ 0.537628] build_sched_domains+0x15a4/0x1718
>>>> [ 0.537630] sched_init_domains+0xbc/0xf8
>>>> [ 0.537631] sched_init_smp+0x30/0x98
>>>> [ 0.537632] kernel_init_freeable+0x148/0x230
>>>> [ 0.537633] kernel_init+0x28/0x148
>>>> [ 0.537635] ret_from_fork+0x10/0x20
>>>>
>>>> ---
>>>> bisect:
>>>>
>>>> # bad: [3a8660878839faadb4f1a6dd72c3179c1df56787] Linux 6.18-rc1
>>>> # good: [e5f0a698b34ed76002dc5cff3804a61c80233a7a] Linux 6.17
>>>> git bisect start 'v6.18-rc1' 'v6.17'
>>>> # bad: [58809f614e0e3f4e12b489bddf680bfeb31c0a20] Merge tag 'drm-
>>>> next-2025-10-01' of https://gitlab.freedesktop.org/drm/kernel
>>>> git bisect bad 58809f614e0e3f4e12b489bddf680bfeb31c0a20
>>>> # bad: [a8253f807760e9c80eada9e5354e1240ccf325f9] Merge tag 'soc-
>>>> newsoc-6.18' of git://git.kernel.org/pub/scm/linux/kernel/git/soc/soc
>>>> git bisect bad a8253f807760e9c80eada9e5354e1240ccf325f9
>>>> # bad: [4b81e2eb9e4db8f6094c077d0c8b27c264901c1b] Merge tag 'timers-
>>>> vdso-2025-09-29' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
>>>> git bisect bad 4b81e2eb9e4db8f6094c077d0c8b27c264901c1b
>>>> # bad: [f1004b2f19d7e9add9d707f64d9fcbc50f67921b] Merge tag 'm68k-for-v6.18-
>>>> tag1' of git://git.kernel.org/pub/scm/linux/kernel/git/geert/linux-m68k
>>>> git bisect bad f1004b2f19d7e9add9d707f64d9fcbc50f67921b
>>>> # good: [a9401710a5f5681abd2a6f21f9e76bc9f2e81891] Merge tag 'v6.18-rc-
>>>> part1-smb3-common' of git://git.samba.org/ksmbd
>>>> git bisect good a9401710a5f5681abd2a6f21f9e76bc9f2e81891
>>>> # good: [fe68bb2861808ed5c48d399bd7e670ab76829d55] Merge tag 'microblaze-
>>>> v6.18' of git://git.monstr.eu/linux-2.6-microblaze
>>>> git bisect good fe68bb2861808ed5c48d399bd7e670ab76829d55
>>>> # bad: [f2d64a22faeeecff385b4c91fab5fe036ab00162] Merge branch 'for-next/
>>>> perf' into for-next/core
>>>> git bisect bad f2d64a22faeeecff385b4c91fab5fe036ab00162
>>>> # good: [30f9386820cddbba59b48ae0670c3a1646dd440e] Merge branch 'for-next/
>>>> misc' into for-next/core
>>>> git bisect good 30f9386820cddbba59b48ae0670c3a1646dd440e
>>>> # good: [43de0ac332b815cf56dbdce63687de9acfd35d49] drivers/perf: hisi: Relax
>>>> the event ID check in the framework
>>>> git bisect good 43de0ac332b815cf56dbdce63687de9acfd35d49
>>>> # good: [5973a62efa34c80c9a4e5eac1fca6f6209b902af] arm64: map [_text,
>>>> _stext) virtual address range non-executable+read-only
>>>> git bisect good 5973a62efa34c80c9a4e5eac1fca6f6209b902af
>>>> # good: [b3abb08d6f628a76c36bf7da9508e1a67bf186a0] drivers/perf: hisi:
>>>> Refactor the event configuration of L3C PMU
>>>> git bisect good b3abb08d6f628a76c36bf7da9508e1a67bf186a0
>>>> # good: [6d2f913fda5683fbd4c3580262e10386c1263dfb] Documentation: hisi-pmu:
>>>> Add introduction to HiSilicon V3 PMU
>>>> git bisect good 6d2f913fda5683fbd4c3580262e10386c1263dfb
>>>> # good: [2084660ad288c998b6f0c885e266deb364f65fba] perf/dwc_pcie: Fix use of
>>>> uninitialized variable
>>>> git bisect good 2084660ad288c998b6f0c885e266deb364f65fba
>>>> # bad: [77dfca70baefcb988318a72fe69eb99f6dabbbb1] Merge branch 'for-next/mm'
>>>> into for-next/core
>>>> git bisect bad 77dfca70baefcb988318a72fe69eb99f6dabbbb1
>>>> # first bad commit: [77dfca70baefcb988318a72fe69eb99f6dabbbb1] Merge branch
>>>> 'for-next/mm' into for-next/core
>>>>
>>>> ---
>>>> bisect into branch:
>>>>
>>>> - git checkout -b testing 77dfca70baefcb988318a72fe69eb99f6dabbbb1
>>>> - git rebase 77dfca70baefcb988318a72fe69eb99f6dabbbb1~1
>>>> [ fix minor conflict similar to the conflict resolution in 77dfca70baefc]
>>>> - git diff 77dfca70baefcb988318a72fe69eb99f6dabbbb1
>>>> [ confirmed that there are no differences ]
>>>> - confirm that the problem is still seen at the tip of the rebase
>>>> - git bisect start HEAD 77dfca70baefcb988318a72fe69eb99f6dabbbb1~1
>>>> - run bisect
>>>>
>>>> Results:
>>>>
>>>> # bad: [47fc25df1ae3ae8412f1b812fb586c714d04a5e6] arm64: map [_text, _stext)
>>>> virtual address range non-executable+read-only
>>>> # good: [30f9386820cddbba59b48ae0670c3a1646dd440e] Merge branch 'for-next/
>>>> misc' into for-next/core
>>>> git bisect start 'HEAD' '77dfca70baefcb988318a72fe69eb99f6dabbbb1~1'
>>>> # good: [805491d19fc21271b5c27f4602f8f66b625c110f] arm64/Kconfig: Remove
>>>> CONFIG_RODATA_FULL_DEFAULT_ENABLED
>>>> git bisect good 805491d19fc21271b5c27f4602f8f66b625c110f
>>>> # bad: [13c7d7426232cc4489df7cd2e1f646a22d3f6172] arm64: mm: support large
>>>> block mapping when rodata=full
>>>> git bisect bad 13c7d7426232cc4489df7cd2e1f646a22d3f6172
>>>> # good: [a4d9c67e503f2b73c2d89d8e8209dfd241bdc8d8] arm64: Enable permission
>>>> change on arm64 kernel block mappings
>>>> git bisect good a4d9c67e503f2b73c2d89d8e8209dfd241bdc8d8
>>>> # first bad commit: [13c7d7426232cc4489df7cd2e1f646a22d3f6172] arm64: mm:
>>>> support large block mapping when rodata=full
>
On 11/3/25 2:07 AM, Ryan Roberts wrote:
> On 03/11/2025 00:47, Yang Shi wrote:
>>
> [...]
>
>>> @@ -723,6 +733,16 @@ int split_kernel_leaf_mapping(unsigned long start,
>>> unsigned long end)
>>> if (!system_supports_bbml2_noabort())
>>> return 0;
>>> + /*
>>> + * If the region is within a pte-mapped area, there is no need to try to
>>> + * split. Additionally, CONFIG_DEBUG_ALLOC and CONFIG_KFENCE may change
>>> + * permissions from softirq context so for those cases (which are always
>>> + * pte-mapped), we must not go any further because taking the mutex
>>> + * below may sleep.
>>> + */
>>> + if (force_pte_mapping() || is_kfence_address((void *)start))
>> IIUC this may break kfence late init? The kfence_late_init() allocates pages
>> from buddy allocator, then protects them (setting them to invalid). But the
>> protection requires split page table, this check will prevent kernel from
>> splitting page table because __kfence_pool is initialized before doing
>> protection. So there is kind of circular dependency.
> I hadn't considered late init. But I guess the requirement is that the kfence
> pool needs to be pte mapped whenever kfence is enabled.
>
> For early init; that requirement is clearly met since we pte map it in the arch
> code. For late init, as far as I can tell, the memory is initially block mapped,
> is allocarted from the buddy then every other page is protected via
> kfence_init_pool() from kfence_init_pool(). This will have the effect of
> splitting every page in the pool to pte mappings (as long as your suggested fix
> below is applied).
>
> It all feels a bit accidental though.
Yeah, it is not that explicit and obvious.
>
>> The below fix may work?
>>
>> if (force_pte_mapping() || (READ_ONCE(kfence_enabled) && is_kfence_address((void
>> *)start)))
>>
>> The kfence_enabled won't be set until protection is done. So if it is set, we
>> know kfence address must be mapped by PTE.
> I think it will work, but it feels a bit hacky, and kfence_enabled is currently
> static in core.c.
>
> I wonder if it would be preferable to explicitly do the pte mapping in
> arch_kfence_init_pool()? It looks like that's how x86 does it...
I agree, this looks better and strongly and explicitly convey the
PTE-mapping for kfence pool requirement.
Thanks,
Yang
>
>> Thanks,
>> Yang
>>
>>
>>
>>
>>
>>> + return 0;
>>> +
>>> /*
>>> * Ensure start and end are at least page-aligned since this is the
>>> * finest granularity we can split to.
>>> @@ -1009,16 +1029,6 @@ static inline void arm64_kfence_map_pool(phys_addr_t
>>> kfence_pool, pgd_t *pgdp) {
>>> #endif /* CONFIG_KFENCE */
>>> -static inline bool force_pte_mapping(void)
>>> -{
>>> - bool bbml2 = system_capabilities_finalized() ?
>>> - system_supports_bbml2_noabort() : cpu_supports_bbml2_noabort();
>>> -
>>> - return (!bbml2 && (rodata_full || arm64_kfence_can_set_direct_map() ||
>>> - is_realm_world())) ||
>>> - debug_pagealloc_enabled();
>>> -}
>>> -
>>> static void __init map_mem(pgd_t *pgdp)
>>> {
>>> static const u64 direct_map_end = _PAGE_END(VA_BITS_MIN);
>>> ---8<---
>>>
>>> Thanks,
>>> Ryan
>>>
>>>> Yang Shi, Do you have any additional thoughts?
>>>>
>>>> Thanks,
>>>> Ryan
>>>>
>>>>> Thanks,
>>>>> Guenter
>>>>>
>>>>> ---
>>>>> Example log:
>>>>>
>>>>> [ 0.537499] BUG: sleeping function called from invalid context at kernel/
>>>>> locking/mutex.c:580
>>>>> [ 0.537501] in_atomic(): 1, irqs_disabled(): 0, non_block: 0, pid: 1,
>>>>> name: swapper/0
>>>>> [ 0.537502] preempt_count: 1, expected: 0
>>>>> [ 0.537504] 2 locks held by swapper/0/1:
>>>>> [ 0.537505] #0: ffffb60b01211960 (sched_domains_mutex){+.+.}-{4:4}, at:
>>>>> sched_domains_mutex_lock+0x24/0x38
>>>>> [ 0.537510] #1: ffffb60b01595838 (rcu_read_lock){....}-{1:3}, at:
>>>>> rcu_lock_acquire+0x0/0x40
>>>>> [ 0.537516] CPU: 0 UID: 0 PID: 1 Comm: swapper/0 Not tainted 6.18.0-dbg-
>>>>> DEV #1 NONE
>>>>> [ 0.537517] Call trace:
>>>>> [ 0.537518] show_stack+0x20/0x38 (C)
>>>>> [ 0.537520] __dump_stack+0x28/0x38
>>>>> [ 0.537522] dump_stack_lvl+0xac/0xf0
>>>>> [ 0.537525] dump_stack+0x18/0x3c
>>>>> [ 0.537527] __might_resched+0x248/0x2a0
>>>>> [ 0.537529] __might_sleep+0x40/0x90
>>>>> [ 0.537531] __mutex_lock_common+0x70/0x1818
>>>>> [ 0.537533] mutex_lock_nested+0x34/0x48
>>>>> [ 0.537534] split_kernel_leaf_mapping+0x74/0x1a0
>>>>> [ 0.537536] update_range_prot+0x40/0x150
>>>>> [ 0.537537] __change_memory_common+0x30/0x148
>>>>> [ 0.537538] __kernel_map_pages+0x70/0x88
>>>>> [ 0.537540] __free_frozen_pages+0x6e4/0x7b8
>>>>> [ 0.537542] free_frozen_pages+0x1c/0x30
>>>>> [ 0.537544] __free_slab+0xf0/0x168
>>>>> [ 0.537547] free_slab+0x2c/0xf8
>>>>> [ 0.537549] free_to_partial_list+0x4e0/0x620
>>>>> [ 0.537551] __slab_free+0x228/0x250
>>>>> [ 0.537553] kfree+0x3c4/0x4c0
>>>>> [ 0.537555] destroy_sched_domain+0xf8/0x140
>>>>> [ 0.537557] cpu_attach_domain+0x17c/0x610
>>>>> [ 0.537558] build_sched_domains+0x15a4/0x1718
>>>>> [ 0.537560] sched_init_domains+0xbc/0xf8
>>>>> [ 0.537561] sched_init_smp+0x30/0x98
>>>>> [ 0.537562] kernel_init_freeable+0x148/0x230
>>>>> [ 0.537564] kernel_init+0x28/0x148
>>>>> [ 0.537566] ret_from_fork+0x10/0x20
>>>>> [ 0.537569] =============================
>>>>> [ 0.537569] [ BUG: Invalid wait context ]
>>>>> [ 0.537571] 6.18.0-dbg-DEV #1 Tainted: G W
>>>>> [ 0.537572] -----------------------------
>>>>> [ 0.537572] swapper/0/1 is trying to lock:
>>>>> [ 0.537573] ffffb60b011f3830 (pgtable_split_lock){+.+.}-{4:4}, at:
>>>>> split_kernel_leaf_mapping+0x74/0x1a0
>>>>> [ 0.537576] other info that might help us debug this:
>>>>> [ 0.537577] context-{5:5}
>>>>> [ 0.537578] 2 locks held by swapper/0/1:
>>>>> [ 0.537579] #0: ffffb60b01211960 (sched_domains_mutex){+.+.}-{4:4}, at:
>>>>> sched_domains_mutex_lock+0x24/0x38
>>>>> [ 0.537582] #1: ffffb60b01595838 (rcu_read_lock){....}-{1:3}, at:
>>>>> rcu_lock_acquire+0x0/0x40
>>>>> [ 0.537585] stack backtrace:
>>>>> [ 0.537585] CPU: 0 UID: 0 PID: 1 Comm: swapper/0 Tainted: G
>>>>> W 6.18.0-dbg-DEV #1 NONE
>>>>> [ 0.537587] Tainted: [W]=WARN
>>>>> [ 0.537588] Call trace:
>>>>> [ 0.537589] show_stack+0x20/0x38 (C)
>>>>> [ 0.537591] __dump_stack+0x28/0x38
>>>>> [ 0.537593] dump_stack_lvl+0xac/0xf0
>>>>> [ 0.537596] dump_stack+0x18/0x3c
>>>>> [ 0.537598] __lock_acquire+0x980/0x2a20
>>>>> [ 0.537600] lock_acquire+0x124/0x2b8
>>>>> [ 0.537602] __mutex_lock_common+0xd8/0x1818
>>>>> [ 0.537604] mutex_lock_nested+0x34/0x48
>>>>> [ 0.537605] split_kernel_leaf_mapping+0x74/0x1a0
>>>>> [ 0.537607] update_range_prot+0x40/0x150
>>>>> [ 0.537608] __change_memory_common+0x30/0x148
>>>>> [ 0.537609] __kernel_map_pages+0x70/0x88
>>>>> [ 0.537610] __free_frozen_pages+0x6e4/0x7b8
>>>>> [ 0.537613] free_frozen_pages+0x1c/0x30
>>>>> [ 0.537615] __free_slab+0xf0/0x168
>>>>> [ 0.537617] free_slab+0x2c/0xf8
>>>>> [ 0.537619] free_to_partial_list+0x4e0/0x620
>>>>> [ 0.537621] __slab_free+0x228/0x250
>>>>> [ 0.537623] kfree+0x3c4/0x4c0
>>>>> [ 0.537625] destroy_sched_domain+0xf8/0x140
>>>>> [ 0.537627] cpu_attach_domain+0x17c/0x610
>>>>> [ 0.537628] build_sched_domains+0x15a4/0x1718
>>>>> [ 0.537630] sched_init_domains+0xbc/0xf8
>>>>> [ 0.537631] sched_init_smp+0x30/0x98
>>>>> [ 0.537632] kernel_init_freeable+0x148/0x230
>>>>> [ 0.537633] kernel_init+0x28/0x148
>>>>> [ 0.537635] ret_from_fork+0x10/0x20
>>>>>
>>>>> ---
>>>>> bisect:
>>>>>
>>>>> # bad: [3a8660878839faadb4f1a6dd72c3179c1df56787] Linux 6.18-rc1
>>>>> # good: [e5f0a698b34ed76002dc5cff3804a61c80233a7a] Linux 6.17
>>>>> git bisect start 'v6.18-rc1' 'v6.17'
>>>>> # bad: [58809f614e0e3f4e12b489bddf680bfeb31c0a20] Merge tag 'drm-
>>>>> next-2025-10-01' of https://gitlab.freedesktop.org/drm/kernel
>>>>> git bisect bad 58809f614e0e3f4e12b489bddf680bfeb31c0a20
>>>>> # bad: [a8253f807760e9c80eada9e5354e1240ccf325f9] Merge tag 'soc-
>>>>> newsoc-6.18' of git://git.kernel.org/pub/scm/linux/kernel/git/soc/soc
>>>>> git bisect bad a8253f807760e9c80eada9e5354e1240ccf325f9
>>>>> # bad: [4b81e2eb9e4db8f6094c077d0c8b27c264901c1b] Merge tag 'timers-
>>>>> vdso-2025-09-29' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
>>>>> git bisect bad 4b81e2eb9e4db8f6094c077d0c8b27c264901c1b
>>>>> # bad: [f1004b2f19d7e9add9d707f64d9fcbc50f67921b] Merge tag 'm68k-for-v6.18-
>>>>> tag1' of git://git.kernel.org/pub/scm/linux/kernel/git/geert/linux-m68k
>>>>> git bisect bad f1004b2f19d7e9add9d707f64d9fcbc50f67921b
>>>>> # good: [a9401710a5f5681abd2a6f21f9e76bc9f2e81891] Merge tag 'v6.18-rc-
>>>>> part1-smb3-common' of git://git.samba.org/ksmbd
>>>>> git bisect good a9401710a5f5681abd2a6f21f9e76bc9f2e81891
>>>>> # good: [fe68bb2861808ed5c48d399bd7e670ab76829d55] Merge tag 'microblaze-
>>>>> v6.18' of git://git.monstr.eu/linux-2.6-microblaze
>>>>> git bisect good fe68bb2861808ed5c48d399bd7e670ab76829d55
>>>>> # bad: [f2d64a22faeeecff385b4c91fab5fe036ab00162] Merge branch 'for-next/
>>>>> perf' into for-next/core
>>>>> git bisect bad f2d64a22faeeecff385b4c91fab5fe036ab00162
>>>>> # good: [30f9386820cddbba59b48ae0670c3a1646dd440e] Merge branch 'for-next/
>>>>> misc' into for-next/core
>>>>> git bisect good 30f9386820cddbba59b48ae0670c3a1646dd440e
>>>>> # good: [43de0ac332b815cf56dbdce63687de9acfd35d49] drivers/perf: hisi: Relax
>>>>> the event ID check in the framework
>>>>> git bisect good 43de0ac332b815cf56dbdce63687de9acfd35d49
>>>>> # good: [5973a62efa34c80c9a4e5eac1fca6f6209b902af] arm64: map [_text,
>>>>> _stext) virtual address range non-executable+read-only
>>>>> git bisect good 5973a62efa34c80c9a4e5eac1fca6f6209b902af
>>>>> # good: [b3abb08d6f628a76c36bf7da9508e1a67bf186a0] drivers/perf: hisi:
>>>>> Refactor the event configuration of L3C PMU
>>>>> git bisect good b3abb08d6f628a76c36bf7da9508e1a67bf186a0
>>>>> # good: [6d2f913fda5683fbd4c3580262e10386c1263dfb] Documentation: hisi-pmu:
>>>>> Add introduction to HiSilicon V3 PMU
>>>>> git bisect good 6d2f913fda5683fbd4c3580262e10386c1263dfb
>>>>> # good: [2084660ad288c998b6f0c885e266deb364f65fba] perf/dwc_pcie: Fix use of
>>>>> uninitialized variable
>>>>> git bisect good 2084660ad288c998b6f0c885e266deb364f65fba
>>>>> # bad: [77dfca70baefcb988318a72fe69eb99f6dabbbb1] Merge branch 'for-next/mm'
>>>>> into for-next/core
>>>>> git bisect bad 77dfca70baefcb988318a72fe69eb99f6dabbbb1
>>>>> # first bad commit: [77dfca70baefcb988318a72fe69eb99f6dabbbb1] Merge branch
>>>>> 'for-next/mm' into for-next/core
>>>>>
>>>>> ---
>>>>> bisect into branch:
>>>>>
>>>>> - git checkout -b testing 77dfca70baefcb988318a72fe69eb99f6dabbbb1
>>>>> - git rebase 77dfca70baefcb988318a72fe69eb99f6dabbbb1~1
>>>>> [ fix minor conflict similar to the conflict resolution in 77dfca70baefc]
>>>>> - git diff 77dfca70baefcb988318a72fe69eb99f6dabbbb1
>>>>> [ confirmed that there are no differences ]
>>>>> - confirm that the problem is still seen at the tip of the rebase
>>>>> - git bisect start HEAD 77dfca70baefcb988318a72fe69eb99f6dabbbb1~1
>>>>> - run bisect
>>>>>
>>>>> Results:
>>>>>
>>>>> # bad: [47fc25df1ae3ae8412f1b812fb586c714d04a5e6] arm64: map [_text, _stext)
>>>>> virtual address range non-executable+read-only
>>>>> # good: [30f9386820cddbba59b48ae0670c3a1646dd440e] Merge branch 'for-next/
>>>>> misc' into for-next/core
>>>>> git bisect start 'HEAD' '77dfca70baefcb988318a72fe69eb99f6dabbbb1~1'
>>>>> # good: [805491d19fc21271b5c27f4602f8f66b625c110f] arm64/Kconfig: Remove
>>>>> CONFIG_RODATA_FULL_DEFAULT_ENABLED
>>>>> git bisect good 805491d19fc21271b5c27f4602f8f66b625c110f
>>>>> # bad: [13c7d7426232cc4489df7cd2e1f646a22d3f6172] arm64: mm: support large
>>>>> block mapping when rodata=full
>>>>> git bisect bad 13c7d7426232cc4489df7cd2e1f646a22d3f6172
>>>>> # good: [a4d9c67e503f2b73c2d89d8e8209dfd241bdc8d8] arm64: Enable permission
>>>>> change on arm64 kernel block mappings
>>>>> git bisect good a4d9c67e503f2b73c2d89d8e8209dfd241bdc8d8
>>>>> # first bad commit: [13c7d7426232cc4489df7cd2e1f646a22d3f6172] arm64: mm:
>>>>> support large block mapping when rodata=full
On Sun, Nov 2, 2025 at 7:09 AM Ryan Roberts <linux@roeck-us.net> wrote:
...
> commit 602ec2db74e5abfb058bd03934475ead8558eb72
> Author: Ryan Roberts <ryan.roberts@arm.com>
> Date: Sun Nov 2 11:45:18 2025 +0000
>
> arm64: mm: Don't attempt to split known pte-mapped regions
>
> It has been reported that split_kernel_leaf_mapping() is trying to sleep
> in non-sleepable context. It does this when acquiring the
> pgtable_split_lock mutex, when either CONFIG_DEBUG_ALLOC or
> CONFIG_KFENCE are enabled, which change linear map permissions within
> softirq context during memory allocation and/or freeing.
>
> But it turns out that the memory for which these features may attempt to
> modify the permissions is always mapped by pte, so there is no need to
> attempt to split the mapping. So let's exit early in these cases and
> avoid attempting to take the mutex.
>
> Closes: https://lore.kernel.org/all/f24b9032-0ec9-47b1-8b95-c0eeac7a31c5@roeck-us.net/
> Fixes: a166563e7ec3 ("arm64: mm: support large block mapping when rodata=full")
> Signed-off-by: Ryan Roberts <ryan.roberts@arm.com>
Tested-by: Guenter Roeck <groeck@google.com>
Thanks a lot for the quick turnaround!
Guenter
On 11/2/25 09:49, Guenter Roeck wrote:
> On Sun, Nov 2, 2025 at 7:09 AM Ryan Roberts <linux@roeck-us.net> wrote:
Oops. That was sent from my Google address and got messed up.
Copying Ryan this time. Sorry for the noise.
Guenter
> ...
>> commit 602ec2db74e5abfb058bd03934475ead8558eb72
>> Author: Ryan Roberts <ryan.roberts@arm.com>
>> Date: Sun Nov 2 11:45:18 2025 +0000
>>
>> arm64: mm: Don't attempt to split known pte-mapped regions
>>
>> It has been reported that split_kernel_leaf_mapping() is trying to sleep
>> in non-sleepable context. It does this when acquiring the
>> pgtable_split_lock mutex, when either CONFIG_DEBUG_ALLOC or
>> CONFIG_KFENCE are enabled, which change linear map permissions within
>> softirq context during memory allocation and/or freeing.
>>
>> But it turns out that the memory for which these features may attempt to
>> modify the permissions is always mapped by pte, so there is no need to
>> attempt to split the mapping. So let's exit early in these cases and
>> avoid attempting to take the mutex.
>>
>> Closes: https://lore.kernel.org/all/f24b9032-0ec9-47b1-8b95-c0eeac7a31c5@roeck-us.net/
>> Fixes: a166563e7ec3 ("arm64: mm: support large block mapping when rodata=full")
>> Signed-off-by: Ryan Roberts <ryan.roberts@arm.com>
>
> Tested-by: Guenter Roeck <groeck@google.com>
>
> Thanks a lot for the quick turnaround!
>
> Guenter
On Sun, Nov 2, 2025 at 7:09 AM Ryan Roberts <linux@roeck-us.net> wrote:
>
> On 02/11/2025 10:31, Ryan Roberts wrote:
> > On 01/11/2025 16:14, Guenter Roeck wrote:
> >> Hi,
> >>
> >> On Wed, Sep 17, 2025 at 12:02:09PM -0700, Yang Shi wrote:
> >>> When rodata=full is specified, kernel linear mapping has to be mapped at
> >>> PTE level since large page table can't be split due to break-before-make
> >>> rule on ARM64.
> >>>
> >>> This resulted in a couple of problems:
> >>> - performance degradation
> >>> - more TLB pressure
> >>> - memory waste for kernel page table
> >>>
> >>> With FEAT_BBM level 2 support, splitting large block page table to
> >>> smaller ones doesn't need to make the page table entry invalid anymore.
> >>> This allows kernel split large block mapping on the fly.
> >>>
> >>> Add kernel page table split support and use large block mapping by
> >>> default when FEAT_BBM level 2 is supported for rodata=full. When
> >>> changing permissions for kernel linear mapping, the page table will be
> >>> split to smaller size.
> >>>
> >>> The machine without FEAT_BBM level 2 will fallback to have kernel linear
> >>> mapping PTE-mapped when rodata=full.
> >>>
> >>> With this we saw significant performance boost with some benchmarks and
> >>> much less memory consumption on my AmpereOne machine (192 cores, 1P)
> >>> with 256GB memory.
> >>>
> >>> * Memory use after boot
> >>> Before:
> >>> MemTotal: 258988984 kB
> >>> MemFree: 254821700 kB
> >>>
> >>> After:
> >>> MemTotal: 259505132 kB
> >>> MemFree: 255410264 kB
> >>>
> >>> Around 500MB more memory are free to use. The larger the machine, the
> >>> more memory saved.
> >>>
> >>> * Memcached
> >>> We saw performance degradation when running Memcached benchmark with
> >>> rodata=full vs rodata=on. Our profiling pointed to kernel TLB pressure.
> >>> With this patchset we saw ops/sec is increased by around 3.5%, P99
> >>> latency is reduced by around 9.6%.
> >>> The gain mainly came from reduced kernel TLB misses. The kernel TLB
> >>> MPKI is reduced by 28.5%.
> >>>
> >>> The benchmark data is now on par with rodata=on too.
> >>>
> >>> * Disk encryption (dm-crypt) benchmark
> >>> Ran fio benchmark with the below command on a 128G ramdisk (ext4) with
> >>> disk encryption (by dm-crypt).
> >>> fio --directory=/data --random_generator=lfsr --norandommap \
> >>> --randrepeat 1 --status-interval=999 --rw=write --bs=4k --loops=1 \
> >>> --ioengine=sync --iodepth=1 --numjobs=1 --fsync_on_close=1 \
> >>> --group_reporting --thread --name=iops-test-job --eta-newline=1 \
> >>> --size 100G
> >>>
> >>> The IOPS is increased by 90% - 150% (the variance is high, but the worst
> >>> number of good case is around 90% more than the best number of bad
> >>> case). The bandwidth is increased and the avg clat is reduced
> >>> proportionally.
> >>>
> >>> * Sequential file read
> >>> Read 100G file sequentially on XFS (xfs_io read with page cache
> >>> populated). The bandwidth is increased by 150%.
> >>>
> >>
> >> With lock debugging enabled, we see a large number of "BUG: sleeping
> >> function called from invalid context at kernel/locking/mutex.c:580"
> >> and "BUG: Invalid wait context:" backtraces when running v6.18-rc3.
> >> Please see example below.
> >>
> >> Bisect points to this patch.
> >>
> >> Please let me know if there is anything I can do to help tracking
> >> down the problem.
> >
> > Thanks for the report - ouch!
> >
> > I expect you're running on a system that supports BBML2_NOABORT, based on the
> > stack trace, I expect you have CONFIG_DEBUG_PAGEALLOC enabled? That will cause
> > permission tricks to be played on the linear map at page allocation and free
> > time, which can happen in non-sleepable contexts. And with this patch we are
> > taking pgtable_split_lock (a mutex) in split_kernel_leaf_mapping(), which is
> > called as a result of the permission change request.
> >
> > However, when CONFIG_DEBUG_PAGEALLOC enabled we always force-map the linear map
> > by PTE so split_kernel_leaf_mapping() is actually unneccessary and will return
> > without actually having to split anything. So we could add an early "if
> > (force_pte_mapping()) return 0;" to bypass the function entirely in this case,
> > and I *think* that should solve it.
> >
> > But I'm also concerned about KFENCE. I can't remember it's exact semantics off
> > the top of my head, so I'm concerned we could see similar problems there (where
> > we only force pte mapping for the KFENCE pool).
> >
> > I'll investigate fully tomorrow and hopefully provide a fix.
>
> Here's a proposed fix, although I can't get access to a system with BBML2 until
> tomorrow at the earliest. Guenter, I wonder if you could check that this
> resolves your issue?
>
> ---8<---
> commit 602ec2db74e5abfb058bd03934475ead8558eb72
> Author: Ryan Roberts <ryan.roberts@arm.com>
> Date: Sun Nov 2 11:45:18 2025 +0000
>
> arm64: mm: Don't attempt to split known pte-mapped regions
>
> It has been reported that split_kernel_leaf_mapping() is trying to sleep
> in non-sleepable context. It does this when acquiring the
> pgtable_split_lock mutex, when either CONFIG_DEBUG_ALLOC or
> CONFIG_KFENCE are enabled, which change linear map permissions within
> softirq context during memory allocation and/or freeing.
>
> But it turns out that the memory for which these features may attempt to
> modify the permissions is always mapped by pte, so there is no need to
> attempt to split the mapping. So let's exit early in these cases and
> avoid attempting to take the mutex.
>
> Closes: https://lore.kernel.org/all/f24b9032-0ec9-47b1-8b95-c0eeac7a31c5@roeck-us.net/
> Fixes: a166563e7ec3 ("arm64: mm: support large block mapping when rodata=full")
> Signed-off-by: Ryan Roberts <ryan.roberts@arm.com>
>
> diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c
> index b8d37eb037fc..6e26f070bb49 100644
> --- a/arch/arm64/mm/mmu.c
> +++ b/arch/arm64/mm/mmu.c
> @@ -708,6 +708,16 @@ static int split_kernel_leaf_mapping_locked(unsigned long addr)
> return ret;
> }
>
> +static inline bool force_pte_mapping(void)
> +{
> + bool bbml2 = system_capabilities_finalized() ?
> + system_supports_bbml2_noabort() : cpu_supports_bbml2_noabort();
> +
> + return (!bbml2 && (rodata_full || arm64_kfence_can_set_direct_map() ||
> + is_realm_world())) ||
> + debug_pagealloc_enabled();
> +}
> +
> static DEFINE_MUTEX(pgtable_split_lock);
>
> int split_kernel_leaf_mapping(unsigned long start, unsigned long end)
> @@ -723,6 +733,16 @@ int split_kernel_leaf_mapping(unsigned long start, unsigned long end)
> if (!system_supports_bbml2_noabort())
> return 0;
>
> + /*
> + * If the region is within a pte-mapped area, there is no need to try to
> + * split. Additionally, CONFIG_DEBUG_ALLOC and CONFIG_KFENCE may change
> + * permissions from softirq context so for those cases (which are always
> + * pte-mapped), we must not go any further because taking the mutex
> + * below may sleep.
> + */
> + if (force_pte_mapping() || is_kfence_address((void *)start))
> + return 0;
> +
> /*
> * Ensure start and end are at least page-aligned since this is the
> * finest granularity we can split to.
> @@ -1009,16 +1029,6 @@ static inline void arm64_kfence_map_pool(phys_addr_t kfence_pool, pgd_t *pgdp) {
>
> #endif /* CONFIG_KFENCE */
>
> -static inline bool force_pte_mapping(void)
> -{
> - bool bbml2 = system_capabilities_finalized() ?
> - system_supports_bbml2_noabort() : cpu_supports_bbml2_noabort();
> -
> - return (!bbml2 && (rodata_full || arm64_kfence_can_set_direct_map() ||
> - is_realm_world())) ||
> - debug_pagealloc_enabled();
> -}
> -
> static void __init map_mem(pgd_t *pgdp)
> {
> static const u64 direct_map_end = _PAGE_END(VA_BITS_MIN);
> ---8<---
>
> Thanks,
> Ryan
>
> >
> > Yang Shi, Do you have any additional thoughts?
> >
> > Thanks,
> > Ryan
> >
> >>
> >> Thanks,
> >> Guenter
> >>
> >> ---
> >> Example log:
> >>
> >> [ 0.537499] BUG: sleeping function called from invalid context at kernel/locking/mutex.c:580
> >> [ 0.537501] in_atomic(): 1, irqs_disabled(): 0, non_block: 0, pid: 1, name: swapper/0
> >> [ 0.537502] preempt_count: 1, expected: 0
> >> [ 0.537504] 2 locks held by swapper/0/1:
> >> [ 0.537505] #0: ffffb60b01211960 (sched_domains_mutex){+.+.}-{4:4}, at: sched_domains_mutex_lock+0x24/0x38
> >> [ 0.537510] #1: ffffb60b01595838 (rcu_read_lock){....}-{1:3}, at: rcu_lock_acquire+0x0/0x40
> >> [ 0.537516] CPU: 0 UID: 0 PID: 1 Comm: swapper/0 Not tainted 6.18.0-dbg-DEV #1 NONE
> >> [ 0.537517] Call trace:
> >> [ 0.537518] show_stack+0x20/0x38 (C)
> >> [ 0.537520] __dump_stack+0x28/0x38
> >> [ 0.537522] dump_stack_lvl+0xac/0xf0
> >> [ 0.537525] dump_stack+0x18/0x3c
> >> [ 0.537527] __might_resched+0x248/0x2a0
> >> [ 0.537529] __might_sleep+0x40/0x90
> >> [ 0.537531] __mutex_lock_common+0x70/0x1818
> >> [ 0.537533] mutex_lock_nested+0x34/0x48
> >> [ 0.537534] split_kernel_leaf_mapping+0x74/0x1a0
> >> [ 0.537536] update_range_prot+0x40/0x150
> >> [ 0.537537] __change_memory_common+0x30/0x148
> >> [ 0.537538] __kernel_map_pages+0x70/0x88
> >> [ 0.537540] __free_frozen_pages+0x6e4/0x7b8
> >> [ 0.537542] free_frozen_pages+0x1c/0x30
> >> [ 0.537544] __free_slab+0xf0/0x168
> >> [ 0.537547] free_slab+0x2c/0xf8
> >> [ 0.537549] free_to_partial_list+0x4e0/0x620
> >> [ 0.537551] __slab_free+0x228/0x250
> >> [ 0.537553] kfree+0x3c4/0x4c0
> >> [ 0.537555] destroy_sched_domain+0xf8/0x140
> >> [ 0.537557] cpu_attach_domain+0x17c/0x610
> >> [ 0.537558] build_sched_domains+0x15a4/0x1718
> >> [ 0.537560] sched_init_domains+0xbc/0xf8
> >> [ 0.537561] sched_init_smp+0x30/0x98
> >> [ 0.537562] kernel_init_freeable+0x148/0x230
> >> [ 0.537564] kernel_init+0x28/0x148
> >> [ 0.537566] ret_from_fork+0x10/0x20
> >> [ 0.537569] =============================
> >> [ 0.537569] [ BUG: Invalid wait context ]
> >> [ 0.537571] 6.18.0-dbg-DEV #1 Tainted: G W
> >> [ 0.537572] -----------------------------
> >> [ 0.537572] swapper/0/1 is trying to lock:
> >> [ 0.537573] ffffb60b011f3830 (pgtable_split_lock){+.+.}-{4:4}, at: split_kernel_leaf_mapping+0x74/0x1a0
> >> [ 0.537576] other info that might help us debug this:
> >> [ 0.537577] context-{5:5}
> >> [ 0.537578] 2 locks held by swapper/0/1:
> >> [ 0.537579] #0: ffffb60b01211960 (sched_domains_mutex){+.+.}-{4:4}, at: sched_domains_mutex_lock+0x24/0x38
> >> [ 0.537582] #1: ffffb60b01595838 (rcu_read_lock){....}-{1:3}, at: rcu_lock_acquire+0x0/0x40
> >> [ 0.537585] stack backtrace:
> >> [ 0.537585] CPU: 0 UID: 0 PID: 1 Comm: swapper/0 Tainted: G W 6.18.0-dbg-DEV #1 NONE
> >> [ 0.537587] Tainted: [W]=WARN
> >> [ 0.537588] Call trace:
> >> [ 0.537589] show_stack+0x20/0x38 (C)
> >> [ 0.537591] __dump_stack+0x28/0x38
> >> [ 0.537593] dump_stack_lvl+0xac/0xf0
> >> [ 0.537596] dump_stack+0x18/0x3c
> >> [ 0.537598] __lock_acquire+0x980/0x2a20
> >> [ 0.537600] lock_acquire+0x124/0x2b8
> >> [ 0.537602] __mutex_lock_common+0xd8/0x1818
> >> [ 0.537604] mutex_lock_nested+0x34/0x48
> >> [ 0.537605] split_kernel_leaf_mapping+0x74/0x1a0
> >> [ 0.537607] update_range_prot+0x40/0x150
> >> [ 0.537608] __change_memory_common+0x30/0x148
> >> [ 0.537609] __kernel_map_pages+0x70/0x88
> >> [ 0.537610] __free_frozen_pages+0x6e4/0x7b8
> >> [ 0.537613] free_frozen_pages+0x1c/0x30
> >> [ 0.537615] __free_slab+0xf0/0x168
> >> [ 0.537617] free_slab+0x2c/0xf8
> >> [ 0.537619] free_to_partial_list+0x4e0/0x620
> >> [ 0.537621] __slab_free+0x228/0x250
> >> [ 0.537623] kfree+0x3c4/0x4c0
> >> [ 0.537625] destroy_sched_domain+0xf8/0x140
> >> [ 0.537627] cpu_attach_domain+0x17c/0x610
> >> [ 0.537628] build_sched_domains+0x15a4/0x1718
> >> [ 0.537630] sched_init_domains+0xbc/0xf8
> >> [ 0.537631] sched_init_smp+0x30/0x98
> >> [ 0.537632] kernel_init_freeable+0x148/0x230
> >> [ 0.537633] kernel_init+0x28/0x148
> >> [ 0.537635] ret_from_fork+0x10/0x20
> >>
> >> ---
> >> bisect:
> >>
> >> # bad: [3a8660878839faadb4f1a6dd72c3179c1df56787] Linux 6.18-rc1
> >> # good: [e5f0a698b34ed76002dc5cff3804a61c80233a7a] Linux 6.17
> >> git bisect start 'v6.18-rc1' 'v6.17'
> >> # bad: [58809f614e0e3f4e12b489bddf680bfeb31c0a20] Merge tag 'drm-next-2025-10-01' of https://gitlab.freedesktop.org/drm/kernel
> >> git bisect bad 58809f614e0e3f4e12b489bddf680bfeb31c0a20
> >> # bad: [a8253f807760e9c80eada9e5354e1240ccf325f9] Merge tag 'soc-newsoc-6.18' of git://git.kernel.org/pub/scm/linux/kernel/git/soc/soc
> >> git bisect bad a8253f807760e9c80eada9e5354e1240ccf325f9
> >> # bad: [4b81e2eb9e4db8f6094c077d0c8b27c264901c1b] Merge tag 'timers-vdso-2025-09-29' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
> >> git bisect bad 4b81e2eb9e4db8f6094c077d0c8b27c264901c1b
> >> # bad: [f1004b2f19d7e9add9d707f64d9fcbc50f67921b] Merge tag 'm68k-for-v6.18-tag1' of git://git.kernel.org/pub/scm/linux/kernel/git/geert/linux-m68k
> >> git bisect bad f1004b2f19d7e9add9d707f64d9fcbc50f67921b
> >> # good: [a9401710a5f5681abd2a6f21f9e76bc9f2e81891] Merge tag 'v6.18-rc-part1-smb3-common' of git://git.samba.org/ksmbd
> >> git bisect good a9401710a5f5681abd2a6f21f9e76bc9f2e81891
> >> # good: [fe68bb2861808ed5c48d399bd7e670ab76829d55] Merge tag 'microblaze-v6.18' of git://git.monstr.eu/linux-2.6-microblaze
> >> git bisect good fe68bb2861808ed5c48d399bd7e670ab76829d55
> >> # bad: [f2d64a22faeeecff385b4c91fab5fe036ab00162] Merge branch 'for-next/perf' into for-next/core
> >> git bisect bad f2d64a22faeeecff385b4c91fab5fe036ab00162
> >> # good: [30f9386820cddbba59b48ae0670c3a1646dd440e] Merge branch 'for-next/misc' into for-next/core
> >> git bisect good 30f9386820cddbba59b48ae0670c3a1646dd440e
> >> # good: [43de0ac332b815cf56dbdce63687de9acfd35d49] drivers/perf: hisi: Relax the event ID check in the framework
> >> git bisect good 43de0ac332b815cf56dbdce63687de9acfd35d49
> >> # good: [5973a62efa34c80c9a4e5eac1fca6f6209b902af] arm64: map [_text, _stext) virtual address range non-executable+read-only
> >> git bisect good 5973a62efa34c80c9a4e5eac1fca6f6209b902af
> >> # good: [b3abb08d6f628a76c36bf7da9508e1a67bf186a0] drivers/perf: hisi: Refactor the event configuration of L3C PMU
> >> git bisect good b3abb08d6f628a76c36bf7da9508e1a67bf186a0
> >> # good: [6d2f913fda5683fbd4c3580262e10386c1263dfb] Documentation: hisi-pmu: Add introduction to HiSilicon V3 PMU
> >> git bisect good 6d2f913fda5683fbd4c3580262e10386c1263dfb
> >> # good: [2084660ad288c998b6f0c885e266deb364f65fba] perf/dwc_pcie: Fix use of uninitialized variable
> >> git bisect good 2084660ad288c998b6f0c885e266deb364f65fba
> >> # bad: [77dfca70baefcb988318a72fe69eb99f6dabbbb1] Merge branch 'for-next/mm' into for-next/core
> >> git bisect bad 77dfca70baefcb988318a72fe69eb99f6dabbbb1
> >> # first bad commit: [77dfca70baefcb988318a72fe69eb99f6dabbbb1] Merge branch 'for-next/mm' into for-next/core
> >>
> >> ---
> >> bisect into branch:
> >>
> >> - git checkout -b testing 77dfca70baefcb988318a72fe69eb99f6dabbbb1
> >> - git rebase 77dfca70baefcb988318a72fe69eb99f6dabbbb1~1
> >> [ fix minor conflict similar to the conflict resolution in 77dfca70baefc]
> >> - git diff 77dfca70baefcb988318a72fe69eb99f6dabbbb1
> >> [ confirmed that there are no differences ]
> >> - confirm that the problem is still seen at the tip of the rebase
> >> - git bisect start HEAD 77dfca70baefcb988318a72fe69eb99f6dabbbb1~1
> >> - run bisect
> >>
> >> Results:
> >>
> >> # bad: [47fc25df1ae3ae8412f1b812fb586c714d04a5e6] arm64: map [_text, _stext) virtual address range non-executable+read-only
> >> # good: [30f9386820cddbba59b48ae0670c3a1646dd440e] Merge branch 'for-next/misc' into for-next/core
> >> git bisect start 'HEAD' '77dfca70baefcb988318a72fe69eb99f6dabbbb1~1'
> >> # good: [805491d19fc21271b5c27f4602f8f66b625c110f] arm64/Kconfig: Remove CONFIG_RODATA_FULL_DEFAULT_ENABLED
> >> git bisect good 805491d19fc21271b5c27f4602f8f66b625c110f
> >> # bad: [13c7d7426232cc4489df7cd2e1f646a22d3f6172] arm64: mm: support large block mapping when rodata=full
> >> git bisect bad 13c7d7426232cc4489df7cd2e1f646a22d3f6172
> >> # good: [a4d9c67e503f2b73c2d89d8e8209dfd241bdc8d8] arm64: Enable permission change on arm64 kernel block mappings
> >> git bisect good a4d9c67e503f2b73c2d89d8e8209dfd241bdc8d8
> >> # first bad commit: [13c7d7426232cc4489df7cd2e1f646a22d3f6172] arm64: mm: support large block mapping when rodata=full
> >
>
On Sun, Nov 02, 2025 at 12:11:11PM +0000, Ryan Roberts wrote: ... > > Here's a proposed fix, although I can't get access to a system with BBML2 until > tomorrow at the earliest. Guenter, I wonder if you could check that this > resolves your issue? Testing. Thanks! Guenter
© 2016 - 2026 Red Hat, Inc.