Re: [PATCH] mm/damon/core: reduce kernel stack usage

From: Andrew Morton

Date: Sun Jun 28 2026 - 01:34:17 EST


On Thu, 11 Jun 2026 06:56:07 -0700 SeongJae Park <sj@xxxxxxxxxx> wrote:

> On Thu, 11 Jun 2026 14:56:57 +0200 Arnd Bergmann <arnd@xxxxxxxxxx> wrote:
>
> > From: Arnd Bergmann <arnd@xxxxxxxx>
> >
> > The main thread function has recently grown to the point of
> > exceeding stack frame size warning limits in some configurations.
> > This is what I hit on s390 with clang and CONFIG_KASAN:
> >
> > mm/damon/core.c:3440:31: error: stack frame size (1352) exceeds limit (1280) in 'kdamond_fn' [-Werror,-Wframe-larger-than]
> > 3440 | static int kdamond_fn(struct damon_ctx *ctx)

Well cheers to s390 for using a nice tight stack limit.

> > The largest stack usage here is inside of the kdamond_tune_intervals(),
> > so by marking that one as noinline_for_stack, the functions individually
> > stay below the warning limit, though kdamond_fn() itself still uses
> > hundreds of kilobytes for some reason.

Wait what wut. This cannot mean that kdamond_fn() uses x00,000 bytes of
stack, so what does it mean?

> Thank you for this fix, Arnd! I will also take a look in kdamond_fn() to see
> if there are more things to reduce.
>
> >
> > Signed-off-by: Arnd Bergmann <arnd@xxxxxxxx>
>
> Reviewed-by: SeongJae Park <sj@xxxxxxxxxx>
>
> Should we add Fixes: and Cc: stable@ too? This function was introduced by
> commit f04b0fedbe71 ("mm/damon/core: implement intervals auto-tuning") which
> was merged into 6.15.

I don't think so - kernel is full of these offenders and it will be a
long and painstaking process to weed them out.