[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CA+fCnZdR3qC-mDKSb9wWnA3-2qQxMvgArCPd3Cd_h=psjBx+vA@mail.gmail.com>
Date: Tue, 10 Jun 2025 18:09:43 +0200
From: Andrey Konovalov <andreyknvl@...il.com>
To: Matt Fleming <matt@...dmodwrite.com>
Cc: Andrew Morton <akpm@...ux-foundation.org>, linux-kernel@...r.kernel.org,
kernel-team@...udflare.com, Marco Elver <elver@...gle.com>,
Alexander Potapenko <glider@...gle.com>, Dmitry Vyukov <dvyukov@...gle.com>,
Oscar Salvador <osalvador@...e.de>, Vlastimil Babka <vbabka@...e.cz>,
Matt Fleming <mfleming@...udflare.com>
Subject: Re: [PATCH] stackdepot: Make max number of pools build-time configurable
On Tue, Jun 10, 2025 at 1:16 PM Matt Fleming <matt@...dmodwrite.com> wrote:
>
> From: Matt Fleming <mfleming@...udflare.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.
Note that this might happen if filter_irq_stacks() somehow fails in your setup.
See e.g. this:
https://lore.kernel.org/all/CA+fCnZdWgAD1pu4yyjON0ph9ae1B6iaWas0CbET+MXLNNXt5Hg@mail.gmail.com/
https://lore.kernel.org/all/44140c34-e2bd-4f6e-892c-51469edc8dfb@redhat.com/
>
> 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@...udflare.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
>
Powered by blists - more mailing lists