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

From: Arnd Bergmann

Date: Thu Jun 11 2026 - 09:01:36 EST


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)

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.

Signed-off-by: Arnd Bergmann <arnd@xxxxxxxx>
---
mm/damon/core.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mm/damon/core.c b/mm/damon/core.c
index 265d51ade25b..69f38c48ac08 100644
--- a/mm/damon/core.c
+++ b/mm/damon/core.c
@@ -2002,7 +2002,7 @@ static unsigned long damon_get_intervals_adaptation_bp(struct damon_ctx *c)
return adaptation_bp;
}

-static void kdamond_tune_intervals(struct damon_ctx *c)
+static noinline_for_stack void kdamond_tune_intervals(struct damon_ctx *c)
{
unsigned long adaptation_bp;
struct damon_attrs new_attrs;
--
2.39.5