* [PATCH] mm: percpu: Increase PERCPU_DYNAMIC_SIZE_SHIFT on certain builds.
@ 2024-10-07 14:30 Sebastian Andrzej Siewior
2024-10-07 14:34 ` Vlastimil Babka
2024-10-13 20:47 ` David Rientjes
0 siblings, 2 replies; 3+ messages in thread
From: Sebastian Andrzej Siewior @ 2024-10-07 14:30 UTC (permalink / raw)
To: linux-mm, Andrew Morton, Vlastimil Babka
Cc: Arnd Bergmann, Christoph Lameter, David Rientjes, Dennis Zhou,
Hyeonggon Yoo, Joonsoo Kim, Pekka Enberg, Roman Gushchin,
Tejun Heo, Thomas Gleixner
Arnd reported a build failure due to the BUILD_BUG_ON() statement in
alloc_kmem_cache_cpus(). The test
PERCPU_DYNAMIC_EARLY_SIZE < NR_KMALLOC_TYPES * KMALLOC_SHIFT_HIGH * sizeof(struct kmem_cache_cpu)
The factors that increase the right side of the equation:
- PAGE_SIZE > 4KiB increases KMALLOC_SHIFT_HIGH
- For the local_lock_t in kmem_cache_cpu:
- PREEMPT_RT adds an actual lock.
- LOCKDEP increases the size of the lock.
- LOCK_STAT adds additional bytes plus padding to the lockdep
structure.
The net difference with and without PREEMPT_RT is 88 bytes for the
lock_lock_t, 96 bytes for kmem_cache_cpu due to additional padding.
This is enough to exceed the 80KiB limit with 16KiB page size - the 8KiB
page size is fine.
Increase PERCPU_DYNAMIC_SIZE_SHIFT to 13 on configs with PAGE_SIZE larger
than 4KiB and LOCKDEP enabled.
Fixes: d8fccd9ca5f9 ("arm64: Allow to enable PREEMPT_RT.")
Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202410020326.iaZIteIx-lkp@intel.com/
Reported-by: Arnd Bergmann <arnd@kernel.org>
Closes: https://lore.kernel.org/20241004095702.637528-1-arnd@kernel.org
Acked-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
include/linux/percpu.h | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/include/linux/percpu.h b/include/linux/percpu.h
index b6321fc491598..52b5ea663b9f0 100644
--- a/include/linux/percpu.h
+++ b/include/linux/percpu.h
@@ -41,7 +41,11 @@
PCPU_MIN_ALLOC_SHIFT)
#ifdef CONFIG_RANDOM_KMALLOC_CACHES
-#define PERCPU_DYNAMIC_SIZE_SHIFT 12
+# if defined(CONFIG_LOCKDEP) && !defined(CONFIG_PAGE_SIZE_4KB)
+# define PERCPU_DYNAMIC_SIZE_SHIFT 13
+# else
+# define PERCPU_DYNAMIC_SIZE_SHIFT 12
+#endif /* LOCKDEP and PAGE_SIZE > 4KiB */
#else
#define PERCPU_DYNAMIC_SIZE_SHIFT 10
#endif
--
2.45.2
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] mm: percpu: Increase PERCPU_DYNAMIC_SIZE_SHIFT on certain builds.
2024-10-07 14:30 [PATCH] mm: percpu: Increase PERCPU_DYNAMIC_SIZE_SHIFT on certain builds Sebastian Andrzej Siewior
@ 2024-10-07 14:34 ` Vlastimil Babka
2024-10-13 20:47 ` David Rientjes
1 sibling, 0 replies; 3+ messages in thread
From: Vlastimil Babka @ 2024-10-07 14:34 UTC (permalink / raw)
To: Sebastian Andrzej Siewior, linux-mm, Andrew Morton
Cc: Arnd Bergmann, Christoph Lameter, David Rientjes, Dennis Zhou,
Hyeonggon Yoo, Joonsoo Kim, Pekka Enberg, Roman Gushchin,
Tejun Heo, Thomas Gleixner
On 10/7/24 4:30 PM, Sebastian Andrzej Siewior wrote:
> Arnd reported a build failure due to the BUILD_BUG_ON() statement in
> alloc_kmem_cache_cpus(). The test
>
> PERCPU_DYNAMIC_EARLY_SIZE < NR_KMALLOC_TYPES * KMALLOC_SHIFT_HIGH * sizeof(struct kmem_cache_cpu)
>
> The factors that increase the right side of the equation:
> - PAGE_SIZE > 4KiB increases KMALLOC_SHIFT_HIGH
> - For the local_lock_t in kmem_cache_cpu:
> - PREEMPT_RT adds an actual lock.
> - LOCKDEP increases the size of the lock.
> - LOCK_STAT adds additional bytes plus padding to the lockdep
> structure.
>
> The net difference with and without PREEMPT_RT is 88 bytes for the
> lock_lock_t, 96 bytes for kmem_cache_cpu due to additional padding.
> This is enough to exceed the 80KiB limit with 16KiB page size - the 8KiB
> page size is fine.
>
> Increase PERCPU_DYNAMIC_SIZE_SHIFT to 13 on configs with PAGE_SIZE larger
> than 4KiB and LOCKDEP enabled.
>
> Fixes: d8fccd9ca5f9 ("arm64: Allow to enable PREEMPT_RT.")
> Reported-by: kernel test robot <lkp@intel.com>
> Closes: https://lore.kernel.org/oe-kbuild-all/202410020326.iaZIteIx-lkp@intel.com/
> Reported-by: Arnd Bergmann <arnd@kernel.org>
> Closes: https://lore.kernel.org/20241004095702.637528-1-arnd@kernel.org
> Acked-by: Arnd Bergmann <arnd@arndb.de>
> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
IIRC Dennis at some point mentioned this will eventually become more
robust as now it's kind of a whack-a-mole? :) But yeah, let's fix in a
way that we can.
Acked-by: Vlastimil Babka <vbabka@suse.cz>
> ---
> include/linux/percpu.h | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/include/linux/percpu.h b/include/linux/percpu.h
> index b6321fc491598..52b5ea663b9f0 100644
> --- a/include/linux/percpu.h
> +++ b/include/linux/percpu.h
> @@ -41,7 +41,11 @@
> PCPU_MIN_ALLOC_SHIFT)
>
> #ifdef CONFIG_RANDOM_KMALLOC_CACHES
> -#define PERCPU_DYNAMIC_SIZE_SHIFT 12
> +# if defined(CONFIG_LOCKDEP) && !defined(CONFIG_PAGE_SIZE_4KB)
> +# define PERCPU_DYNAMIC_SIZE_SHIFT 13
> +# else
> +# define PERCPU_DYNAMIC_SIZE_SHIFT 12
> +#endif /* LOCKDEP and PAGE_SIZE > 4KiB */
> #else
> #define PERCPU_DYNAMIC_SIZE_SHIFT 10
> #endif
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] mm: percpu: Increase PERCPU_DYNAMIC_SIZE_SHIFT on certain builds.
2024-10-07 14:30 [PATCH] mm: percpu: Increase PERCPU_DYNAMIC_SIZE_SHIFT on certain builds Sebastian Andrzej Siewior
2024-10-07 14:34 ` Vlastimil Babka
@ 2024-10-13 20:47 ` David Rientjes
1 sibling, 0 replies; 3+ messages in thread
From: David Rientjes @ 2024-10-13 20:47 UTC (permalink / raw)
To: Sebastian Andrzej Siewior
Cc: linux-mm, Andrew Morton, Vlastimil Babka, Arnd Bergmann,
Christoph Lameter, Dennis Zhou, Hyeonggon Yoo, Joonsoo Kim,
Pekka Enberg, Roman Gushchin, Tejun Heo, Thomas Gleixner
On Mon, 7 Oct 2024, Sebastian Andrzej Siewior wrote:
> Arnd reported a build failure due to the BUILD_BUG_ON() statement in
> alloc_kmem_cache_cpus(). The test
>
> PERCPU_DYNAMIC_EARLY_SIZE < NR_KMALLOC_TYPES * KMALLOC_SHIFT_HIGH * sizeof(struct kmem_cache_cpu)
>
> The factors that increase the right side of the equation:
> - PAGE_SIZE > 4KiB increases KMALLOC_SHIFT_HIGH
> - For the local_lock_t in kmem_cache_cpu:
> - PREEMPT_RT adds an actual lock.
> - LOCKDEP increases the size of the lock.
> - LOCK_STAT adds additional bytes plus padding to the lockdep
> structure.
>
> The net difference with and without PREEMPT_RT is 88 bytes for the
> lock_lock_t, 96 bytes for kmem_cache_cpu due to additional padding.
> This is enough to exceed the 80KiB limit with 16KiB page size - the 8KiB
> page size is fine.
>
> Increase PERCPU_DYNAMIC_SIZE_SHIFT to 13 on configs with PAGE_SIZE larger
> than 4KiB and LOCKDEP enabled.
>
> Fixes: d8fccd9ca5f9 ("arm64: Allow to enable PREEMPT_RT.")
> Reported-by: kernel test robot <lkp@intel.com>
> Closes: https://lore.kernel.org/oe-kbuild-all/202410020326.iaZIteIx-lkp@intel.com/
> Reported-by: Arnd Bergmann <arnd@kernel.org>
> Closes: https://lore.kernel.org/20241004095702.637528-1-arnd@kernel.org
> Acked-by: Arnd Bergmann <arnd@arndb.de>
> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Acked-by: David Rientjes <rientjes@google.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-10-13 20:47 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-10-07 14:30 [PATCH] mm: percpu: Increase PERCPU_DYNAMIC_SIZE_SHIFT on certain builds Sebastian Andrzej Siewior
2024-10-07 14:34 ` Vlastimil Babka
2024-10-13 20:47 ` David Rientjes
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox