* [PATCH 0/3] mm/damon/core: cleanup code, reduce stack usage, and add kunit
@ 2026-09-28 8:39 SJ Park
2026-09-28 8:39 ` [PATCH 2/3] mm/damon/core: reduce stack usage further SJ Park
0 siblings, 1 reply; 2+ messages in thread
From: SJ Park @ 2026-09-28 8:39 UTC (permalink / raw)
To: Andrew Morton
Cc: SJ Park, Arnd Bergmann, Bill Wendling, Brendan Higgins, David Gow,
Justin Stitt, Kunwu Chan, Lian Wang, Nathan Chancellor,
Nick Desaulniers, Ravi Jonnalagadda, damon, kunit-dev,
linux-kernel, linux-kselftest, linux-mm, llvm
Three various improvements. Patch 1 from Zenghui Yu (Huawei) cleans up
unused enums. Patch 2 from Arnd Bergmann reduces kdamond's stack usage.
Patch 3 from Karl Mehltretter adds a kunit test for uninitialized PSI
quota goal stage logic.
Arnd Bergmann (1):
mm/damon/core: reduce stack usage further
Karl Mehltretter (1):
mm/damon/tests/core-kunit: test PSI goal values with explicit samples
Zenghui Yu (Huawei) (1):
mm/damon/api: remove unused NR_DAMOS_* enumerators
include/linux/damon.h | 8 -------
mm/damon/core.c | 9 ++++----
mm/damon/tests/core-kunit.h | 43 +++++++++++++++++++++++++++++++++++++
3 files changed, 48 insertions(+), 12 deletions(-)
base-commit: 9a7b617f9c0b3cc653987c9e6d0434cf1079130f
--
2.47.3
^ permalink raw reply [flat|nested] 2+ messages in thread
* [PATCH 2/3] mm/damon/core: reduce stack usage further
2026-09-28 8:39 [PATCH 0/3] mm/damon/core: cleanup code, reduce stack usage, and add kunit SJ Park
@ 2026-09-28 8:39 ` SJ Park
0 siblings, 0 replies; 2+ messages in thread
From: SJ Park @ 2026-09-28 8:39 UTC (permalink / raw)
To: Andrew Morton
Cc: Arnd Bergmann, Bill Wendling, Justin Stitt, Nathan Chancellor,
Nick Desaulniers, Ravi Jonnalagadda, SJ Park, damon, linux-kernel,
linux-mm, llvm
From: Arnd Bergmann <arnd@arndb.de>
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.
Fixes: 5a00cae64de1 ("mm/damon/core: reduce kernel stack usage")
Cc: Nick Desaulniers <ndesaulniers@google.com>
Cc: Bill Wendling <morbo@google.com>
Cc: Justin Stitt <justinstitt@google.com>
Cc: Ravi Jonnalagadda <ravis.opensrc@gmail.com>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Reviewed-by: SJ Park <sj@kernel.org>
Signed-off-by: SJ Park <sj@kernel.org>
---
Changes from v1
- v1: https://lore.kernel.org/20260925130254.4022227-1-arnd@kernel.org
- Collect R-b: from SJ.
- Rebase to the latest mm-new.
- Update subject prefix.
mm/damon/core.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/mm/damon/core.c b/mm/damon/core.c
index 733025b36745..0e375f4445fd 100644
--- a/mm/damon/core.c
+++ b/mm/damon/core.c
@@ -3433,7 +3433,7 @@ static void damos_trace_stat(struct damon_ctx *c, struct damos *s)
trace_call__damos_stat_after_apply_interval(cidx, sidx, &s->stat);
}
-static void kdamond_apply_schemes(struct damon_ctx *c)
+static noinline_for_stack void kdamond_apply_schemes(struct damon_ctx *c)
{
struct damon_target *t;
struct damos *s;
@@ -3589,8 +3589,9 @@ static void damon_merge_regions_of(struct damon_target *t, unsigned int thres,
* while DAMON is running. For such a case, repeat merging until the limit is
* met while increasing @threshold up to possible maximum level.
*/
-static void kdamond_merge_regions(struct damon_ctx *c, unsigned int threshold,
- unsigned long sz_limit)
+static noinline_for_stack void kdamond_merge_regions(struct damon_ctx *c,
+ unsigned int threshold,
+ unsigned long sz_limit)
{
struct damon_target *t;
unsigned int nr_regions;
@@ -3734,7 +3735,7 @@ static void damon_split_some_regions(struct damon_ctx *ctx,
* split was unnecessarily made, later 'kdamond_merge_regions()' will revert
* it.
*/
-static void kdamond_split_regions(struct damon_ctx *ctx)
+static noinline_for_stack void kdamond_split_regions(struct damon_ctx *ctx)
{
struct damon_target *t;
unsigned long nr_regions = 0;
--
2.47.3
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-09-28 8:40 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-28 8:39 [PATCH 0/3] mm/damon/core: cleanup code, reduce stack usage, and add kunit SJ Park
2026-09-28 8:39 ` [PATCH 2/3] mm/damon/core: reduce stack usage further SJ Park
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox