linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] stackdepot: Make max number of pools build-time configurable
@ 2025-07-04 12:06 Matt Fleming
  2025-07-04 20:35 ` Andrew Morton
  2025-07-05  6:00 ` kernel test robot
  0 siblings, 2 replies; 7+ messages in thread
From: Matt Fleming @ 2025-07-04 12:06 UTC (permalink / raw)
  To: Andrew Morton
  Cc: linux-kernel, kernel-team, Marco Elver, Alexander Potapenko,
	Andrey Konovalov, Dmitry Vyukov, Oscar Salvador, Vlastimil Babka,
	Matt Fleming

From: Matt Fleming <mfleming@cloudflare.com>

We're hitting the WARN in depot_init_pool() about reaching the stack
depot limit because we have long stacks that don't dedup very well.

Introduce a new config to allow users to set the number of maximum stack
depot pools at build time. Also, turn the silent capping into a
build-time assert to provide more obvious feedback when users set this
value too high.

Signed-off-by: Matt Fleming <mfleming@cloudflare.com>
---

Changes in v2:
 - Replace BUILD_BUG_ON with static_assert()
 - Hide STACKDEPOT_MAX_POOLS behind EXPERT

 lib/Kconfig      | 6 ++++++
 lib/stackdepot.c | 8 ++++----
 2 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/lib/Kconfig b/lib/Kconfig
index b38849af6f13..092a2b69310b 100644
--- a/lib/Kconfig
+++ b/lib/Kconfig
@@ -720,6 +720,12 @@ config STACKDEPOT_MAX_FRAMES
 	default 64
 	depends on STACKDEPOT
 
+config STACKDEPOT_MAX_POOLS
+	int "Maximum number of stack depot pools to store stack traces" if EXPERT
+	range 1024 131071
+	default 8192
+	depends on STACKDEPOT
+
 config REF_TRACKER
 	bool
 	depends on STACKTRACE_SUPPORT
diff --git a/lib/stackdepot.c b/lib/stackdepot.c
index 245d5b416699..1c25c40f31f9 100644
--- a/lib/stackdepot.c
+++ b/lib/stackdepot.c
@@ -36,11 +36,11 @@
 #include <linux/memblock.h>
 #include <linux/kasan-enabled.h>
 
-#define DEPOT_POOLS_CAP 8192
+#define DEPOT_MAX_POOLS CONFIG_STACKDEPOT_MAX_POOLS
+
 /* The pool_index is offset by 1 so the first record does not have a 0 handle. */
-#define DEPOT_MAX_POOLS \
-	(((1LL << (DEPOT_POOL_INDEX_BITS)) - 1 < DEPOT_POOLS_CAP) ? \
-	 (1LL << (DEPOT_POOL_INDEX_BITS)) - 1 : DEPOT_POOLS_CAP)
+static_assert(DEPOT_MAX_POOLS <= (1LL << (DEPOT_POOL_INDEX_BITS)) - 1);
+
 
 static bool stack_depot_disabled;
 static bool __stack_depot_early_init_requested __initdata = IS_ENABLED(CONFIG_STACKDEPOT_ALWAYS_INIT);
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2025-07-07 12:06 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-04 12:06 [PATCH v2] stackdepot: Make max number of pools build-time configurable Matt Fleming
2025-07-04 20:35 ` Andrew Morton
2025-07-07  8:12   ` Marco Elver
2025-07-07 12:06     ` Matt Fleming
2025-07-05  6:00 ` kernel test robot
2025-07-07  6:39   ` Marco Elver
2025-07-07 12:05     ` Matt Fleming

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).