* [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 3/3] mm/damon/tests/core-kunit: test PSI goal values with explicit samples 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 3/3] mm/damon/tests/core-kunit: test PSI goal values with explicit samples
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: Karl Mehltretter, Brendan Higgins, David Gow, Kunwu Chan,
Lian Wang, SJ Park, damon, kunit-dev, linux-kernel,
linux-kselftest, linux-mm
From: Karl Mehltretter <kmehltretter@gmail.com>
Test the PSI current-value helper with explicit totals so the result does
not depend on the test system's memory pressure. Cover an unmeasured
consist goal, unmeasured temporal goals with zero and nonzero effective
quotas, and measured rounds for both tuners. Check last_psi_total after
each call.
Cc: Lian Wang <lianux.mm@gmail.com>
Cc: Kunwu Chan <kunwu.chan@gmail.com>
Assisted-by: LLM
Signed-off-by: Karl Mehltretter <kmehltretter@gmail.com>
Reviewed-by: SJ Park <sj@kernel.org>
Signed-off-by: SJ Park <sj@kernel.org>
---
Changes from v2
- v2: https://lore.kernel.org/20260921020013.33105-1-kmehltretter@gmail.com
- Collect R-b: from SJ.
- Split out from the series.
- Rebase to the latest mm-new.
- Delete mention of old behavior, as it is irrelevant for commit message.
Changes from v1
- v1: https://lore.kernel.org/20260915060937.3423-1-kmehltretter@gmail.com/
- Use the previous effective quota for the temporal decision, including
when it is zero. Keep resetting last_psi_total for new and updated
goals.
- Move the current-value calculation and last_psi_total update into a
helper. Test both tuners with explicit samples and check
last_psi_total after each call.
mm/damon/tests/core-kunit.h | 43 +++++++++++++++++++++++++++++++++++++
1 file changed, 43 insertions(+)
diff --git a/mm/damon/tests/core-kunit.h b/mm/damon/tests/core-kunit.h
index df84d9cc7d20..ef4b8b85d67b 100644
--- a/mm/damon/tests/core-kunit.h
+++ b/mm/damon/tests/core-kunit.h
@@ -910,6 +910,48 @@ static void damos_test_commit_quota_goal(struct kunit *test)
});
}
+static void damos_test_set_psi_current_val(struct kunit *test)
+{
+ struct damos s = {
+ .quota.goal_tuner = DAMOS_QUOTA_GOAL_TUNER_CONSIST,
+ };
+ struct damos_quota_goal goal = {
+ .metric = DAMOS_QUOTA_SOME_MEM_PSI_US,
+ .target_value = 100,
+ .last_psi_total = U64_MAX,
+ };
+
+ /* uninitialized last_psi_total keeps the consist tuner quota */
+ damos_set_psi_current_val(1000, &goal, &s);
+ KUNIT_EXPECT_EQ(test, goal.current_value, 100ul);
+ KUNIT_EXPECT_EQ(test, goal.last_psi_total, 1000ull);
+
+ /* initialized last_psi_total gives the delta */
+ damos_set_psi_current_val(1030, &goal, &s);
+ KUNIT_EXPECT_EQ(test, goal.current_value, 30ul);
+ KUNIT_EXPECT_EQ(test, goal.last_psi_total, 1030ull);
+
+ /* temporal tuner keeps a zero quota */
+ s.quota.goal_tuner = DAMOS_QUOTA_GOAL_TUNER_TEMPORAL;
+ s.quota.esz = 0;
+ goal.last_psi_total = U64_MAX;
+ damos_set_psi_current_val(2000, &goal, &s);
+ KUNIT_EXPECT_EQ(test, goal.current_value, 100ul);
+ KUNIT_EXPECT_EQ(test, goal.last_psi_total, 2000ull);
+
+ /* temporal tuner keeps a non-zero quota */
+ s.quota.esz = SZ_64K;
+ goal.last_psi_total = U64_MAX;
+ damos_set_psi_current_val(3000, &goal, &s);
+ KUNIT_EXPECT_EQ(test, goal.current_value, 0ul);
+ KUNIT_EXPECT_EQ(test, goal.last_psi_total, 3000ull);
+
+ /* temporal tuner uses the measured PSI delta */
+ damos_set_psi_current_val(3250, &goal, &s);
+ KUNIT_EXPECT_EQ(test, goal.current_value, 250ul);
+ KUNIT_EXPECT_EQ(test, goal.last_psi_total, 3250ull);
+}
+
static void damos_test_commit_quota_goals_for(struct kunit *test,
struct damos_quota_goal *dst_goals, int nr_dst_goals,
struct damos_quota_goal *src_goals, int nr_src_goals)
@@ -2260,6 +2302,7 @@ static struct kunit_case damon_test_cases[] = {
KUNIT_CASE(damon_test_nr_accesses_mvsum),
KUNIT_CASE(damos_test_new_filter),
KUNIT_CASE(damos_test_commit_quota_goal),
+ KUNIT_CASE(damos_test_set_psi_current_val),
KUNIT_CASE(damos_test_commit_quota_goals),
KUNIT_CASE(damos_test_commit_quota),
KUNIT_CASE(damos_test_commit_dests),
--
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 3/3] mm/damon/tests/core-kunit: test PSI goal values with explicit samples SJ Park
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox