[PATCH v18 42/42] mm: percpu: increase PERCPU_DYNAMIC_SIZE_SHIFT on DEPT and large PAGE_SIZE

From: Byungchul Park

Date: Fri Dec 05 2025 - 02:21:20 EST


Yunseong reported a build failure due to the BUILD_BUG_ON() statement in
alloc_kmem_cache_cpus(). In the following test:

PERCPU_DYNAMIC_EARLY_SIZE < NR_KMALLOC_TYPES * KMALLOC_SHIFT_HIGH * sizeof(struct kmem_cache_cpu)

The following factors increase the right side of the equation:

1. PAGE_SIZE > 4KiB increases KMALLOC_SHIFT_HIGH.
2. DEPT increases the size of the local_lock_t in kmem_cache_cpu.

Increase PERCPU_DYNAMIC_SIZE_SHIFT to 11 on configs with PAGE_SIZE
larger than 4KiB and DEPT enabled.

Reported-by: Yunseong Kim <ysk@xxxxxxxxxxx>
Signed-off-by: Byungchul Park <byungchul@xxxxxx>
---
include/linux/percpu.h | 4 ++++
1 file changed, 4 insertions(+)

diff --git a/include/linux/percpu.h b/include/linux/percpu.h
index 85bf8dd9f087..dd74321d4bbd 100644
--- a/include/linux/percpu.h
+++ b/include/linux/percpu.h
@@ -43,7 +43,11 @@
# define PERCPU_DYNAMIC_SIZE_SHIFT 12
#endif /* LOCKDEP and PAGE_SIZE > 4KiB */
#else
+#if defined(CONFIG_DEPT) && !defined(CONFIG_PAGE_SIZE_4KB)
+#define PERCPU_DYNAMIC_SIZE_SHIFT 11
+#else
#define PERCPU_DYNAMIC_SIZE_SHIFT 10
+#endif /* DEPT and PAGE_SIZE > 4KiB */
#endif

/*
--
2.17.1