Re: [PATCH] damon: reduce stack usage further
From: SJ Park
Date: Fri Sep 25 2026 - 15:02:15 EST
On Fri, 25 Sep 2026 15:02:46 +0200 Arnd Bergmann <arnd@xxxxxxxxxx> wrote:
> From: Arnd Bergmann <arnd@xxxxxxxx>
>
> In a previous patch, I had annotated kdamond_tune_intervals() as
> noinline_for_stack in order to not exceed the stack frame warning
> limit. Unfortunately, my current linux-next randconfig builds show
> a similar problem again with clang-21:
>
> mm/damon/core.c:3953:12: error: stack frame size (1288) exceeds limit (1280) in 'kdamond_fn' [-Werror,-Wframe-larger-than]
> 3953 | static int kdamond_fn(void *data)
>
> Do the same thing with kdamond_apply_schemes(), kdamond_merge_regions(),
> and kdamond_split_regions(), which also have individually large stacks.
> This should work to keep the deepest total stack depth down much more
> as well as avoid the warning.
>
> I also tried to reduce the complexity of kdamond_fn() itself by splitting
> out the while() loop into a separate function. While this arguably led
> to slightly more readable code, it had no effect on the total stack
> usage and just made the new function the largest stack user and had
> a nonzero risk of me getting the conversion wrong.
Looks good to me. Thank you Arnd!
>
> Fixes: 5a00cae64de1 ("mm/damon/core: reduce kernel stack usage")
> Signed-off-by: Arnd Bergmann <arnd@xxxxxxxx>
Reviewed-by: SJ Park <sj@xxxxxxxxxx>
This patch is applied to damon/next [1] tree. If this patch is not added to
mm.git in short term (~1 week?), I will ask mm.git maintainer (Andrew Morton)
to pick this. So, no action from your side is needed for now. If it seems I
also forgot doing that or you cannot wait for my action, please feel free to
ping me or Andrew.
[1] https://origin.kernel.org/doc/html/latest/mm/damon/maintainer-profile.html#scm-trees
Thanks,
SJ
[...]