From: Matt Fleming <matt@readmodwrite.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: linux-kernel@vger.kernel.org, kernel-team@cloudflare.com,
Marco Elver <elver@google.com>,
Alexander Potapenko <glider@google.com>,
Andrey Konovalov <andreyknvl@gmail.com>,
Dmitry Vyukov <dvyukov@google.com>,
Oscar Salvador <osalvador@suse.de>,
Vlastimil Babka <vbabka@suse.cz>,
Matt Fleming <mfleming@cloudflare.com>
Subject: [PATCH] stackdepot: Make max number of pools build-time configurable
Date: Tue, 10 Jun 2025 12:15:59 +0100 [thread overview]
Message-ID: <20250610111559.1667156-1-matt@readmodwrite.com> (raw)
From: Matt Fleming <mfleming@cloudflare.com>
We're hitting the WARN in depot_init_pool() about reaching the stack
depot limit. My assumption is 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>
---
lib/Kconfig | 6 ++++++
lib/stackdepot.c | 9 ++++-----
2 files changed, 10 insertions(+), 5 deletions(-)
diff --git a/lib/Kconfig b/lib/Kconfig
index b38849af6f13..2c5af89daff9 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"
+ 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..1c24230b4a37 100644
--- a/lib/stackdepot.c
+++ b/lib/stackdepot.c
@@ -36,11 +36,7 @@
#include <linux/memblock.h>
#include <linux/kasan-enabled.h>
-#define DEPOT_POOLS_CAP 8192
-/* 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)
+#define DEPOT_MAX_POOLS CONFIG_STACKDEPOT_MAX_POOLS
static bool stack_depot_disabled;
static bool __stack_depot_early_init_requested __initdata = IS_ENABLED(CONFIG_STACKDEPOT_ALWAYS_INIT);
@@ -245,6 +241,9 @@ static bool depot_init_pool(void **prealloc)
{
lockdep_assert_held(&pool_lock);
+ /* The pool_index is offset by 1 so the first record does not have a 0 handle. */
+ BUILD_BUG_ON((1LL << (DEPOT_POOL_INDEX_BITS)) - 1 < DEPOT_MAX_POOLS);
+
if (unlikely(pools_num >= DEPOT_MAX_POOLS)) {
/* Bail out if we reached the pool limit. */
WARN_ON_ONCE(pools_num > DEPOT_MAX_POOLS); /* should never happen */
--
2.34.1
next reply other threads:[~2025-06-10 11:16 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-10 11:15 Matt Fleming [this message]
2025-06-10 11:35 ` Marco Elver
2025-06-10 16:09 ` Andrey Konovalov
2025-06-11 12:21 ` Matt Fleming
2025-07-02 13:54 ` Matt Fleming
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250610111559.1667156-1-matt@readmodwrite.com \
--to=matt@readmodwrite.com \
--cc=akpm@linux-foundation.org \
--cc=andreyknvl@gmail.com \
--cc=dvyukov@google.com \
--cc=elver@google.com \
--cc=glider@google.com \
--cc=kernel-team@cloudflare.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mfleming@cloudflare.com \
--cc=osalvador@suse.de \
--cc=vbabka@suse.cz \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®