[RFC PATCH v1.2 0/4] mm/damon: fix misc bugs in kunit, quota goals and sysfs refresh_ms

2 views
Skip to first unread message

SJ Park

unread,
Aug 27, 2026, 9:47:09 PM (14 days ago) Aug 27
to SJ Park, sta...@vger.kernel.org, Andrew Morton, Brendan Higgins, David Gow, Quanmin Yan, Ravi Jonnalagadda, da...@lists.linux.dev, kuni...@googlegroups.com, linux-...@vger.kernel.org, linux-k...@vger.kernel.org, linu...@kvack.org
DAMOS quota goals commit unit test is mistakenly not testing a test case
that was designed to test. DAMOS quota goals and DAMON sysfs refresh_ms
file have bugs that can produce non critical but still unexpected
behaviors. Fix the bugs.

Patch 1 fixes the DAMOS quota goals commit unit test to cover a
mistakenly uncovered case. Patches 2 and 3 fix the bugs in DAMOS PSI
goal initialization and eligible_mem_bp online commit, respectively.
Patch 4 fixes the bug in DAMON sysfs refresh_ms file handling.

Changes from RFC v1.1
- RFC v1.1: https://lore.kernel.org/2026082713442...@kernel.org
- Fix quota goals commit unit test that was mistakenly missing a test case.
- Initialize last_psi_total as uninitialized at the beginning.
- Correct kunit test for changed last_psi_total initialization behavior.
Changes from RFC
- RFC: https://lore.kernel.org/202608270429...@kernel.org
(Mistakenly missed RFC tag)
- Fix build error.
- Add eligible_mem_bp nid commit fix.

SJ Park (4):
mm/damon/tests/core-kunit: test committing psi goal to psi goal
mm/damon/core: handle uninitialized damos_quota_goal->last_psi_total
mm/damon/core: copy nid for eligible_mem_bp damos quota goal commit
mm/damon/sysfs: set next refresh jiffies per sysfs context

mm/damon/core.c | 13 ++++++++++++-
mm/damon/sysfs.c | 11 +++++------
mm/damon/tests/core-kunit.h | 16 ++++++++++------
3 files changed, 27 insertions(+), 13 deletions(-)


base-commit: 90e1725f175e19e191adc6e1b0f0317feeddd268
--
2.47.3

SJ Park

unread,
Aug 28, 2026, 2:37:00 PM (13 days ago) Aug 28
to SJ Park, sta...@vger.kernel.org, Andrew Morton, Brendan Higgins, David Gow, Quanmin Yan, Ravi Jonnalagadda, da...@lists.linux.dev, kuni...@googlegroups.com, linux-...@vger.kernel.org, linux-k...@vger.kernel.org, linu...@kvack.org
DAMOS quota goals commit unit test is mistakenly not testing a test case
that was designed to test. DAMOS quota goals and DAMON sysfs refresh_ms
file have bugs that can produce non critical but still unexpected
behaviors. Fix the bugs.

Patch 1 fixes the DAMOS quota goals commit unit test to cover a
mistakenly uncovered case. Patches 2 and 3 fix the bugs in DAMOS PSI
goal initialization and eligible_mem_bp online commit, respectively.
Patch 4 fixes the bug in DAMON sysfs refresh_ms file handling.

Changes from RFC v1.2
- RFC v1.2: https://lore.kernel.org/2026082801465...@kernel.org
- Fix last_psi_total underflow.
Changes from RFC v1.1
- RFC v1.1: https://lore.kernel.org/2026082713442...@kernel.org
- Fix quota goals commit unit test that was mistakenly missing a test case.
- Initialize last_psi_total as uninitialized at the beginning.
- Correct kunit test for changed last_psi_total initialization behavior.
Changes from RFC
- RFC: https://lore.kernel.org/202608270429...@kernel.org
(Mistakenly missed RFC tag)
- Fix build error.
- Add eligible_mem_bp nid commit fix.

SJ Park (4):
mm/damon/tests/core-kunit: test committing psi goal to psi goal
mm/damon/core: handle uninitialized damos_quota_goal->last_psi_total
mm/damon/core: copy nid for eligible_mem_bp damos quota goal commit
mm/damon/sysfs: set next refresh jiffies per sysfs context

mm/damon/core.c | 16 ++++++++++++++--
mm/damon/sysfs.c | 11 +++++------
mm/damon/tests/core-kunit.h | 16 ++++++++++------
3 files changed, 29 insertions(+), 14 deletions(-)


base-commit: f508ed0a3bc67ac2a17ba4eaa7f219a95f6b3954
--
2.47.3

SJ Park

unread,
Aug 28, 2026, 2:37:01 PM (13 days ago) Aug 28
to SJ Park, sta...@vger.kernel.org, Andrew Morton, Brendan Higgins, David Gow, da...@lists.linux.dev, kuni...@googlegroups.com, linux-...@vger.kernel.org, linux-k...@vger.kernel.org, linu...@kvack.org
damon_test_commit_quota_goal_for() is set to test committing a new psi
goal on an existing psi goal. However, damon_test_commit_quota_goal()
is mistakenly not covering the test case. Add the test case.

Fixes: 99f89debafc5 ("mm/damon/tests/core-kunit: add damos_commit_quota_goal() test")
Cc: <sta...@vger.kernel.org> # 6.19.x
Signed-off-by: SJ Park <s...@kernel.org>
---
mm/damon/tests/core-kunit.h | 7 +++++++
1 file changed, 7 insertions(+)

diff --git a/mm/damon/tests/core-kunit.h b/mm/damon/tests/core-kunit.h
index 4a536d41cdb2d..b643f9a83f14a 100644
--- a/mm/damon/tests/core-kunit.h
+++ b/mm/damon/tests/core-kunit.h
@@ -787,6 +787,13 @@ static void damos_test_commit_quota_goal(struct kunit *test)
.last_psi_total = 456,
};

+ damos_test_commit_quota_goal_for(test, &dst,
+ &(struct damos_quota_goal) {
+ .metric = DAMOS_QUOTA_SOME_MEM_PSI_US,
+ .target_value = 234,
+ .current_value = 345,
+ .last_psi_total = 567,
+ });
damos_test_commit_quota_goal_for(test, &dst,
&(struct damos_quota_goal){
.metric = DAMOS_QUOTA_USER_INPUT,
--
2.47.3

SJ Park

unread,
Sep 1, 2026, 8:27:35 PM (9 days ago) Sep 1
to Andrew Morton, SJ Park, sta...@vger.kernel.org, Brendan Higgins, David Gow, da...@lists.linux.dev, kuni...@googlegroups.com, linux-...@vger.kernel.org, linux-k...@vger.kernel.org, linu...@kvack.org
damon_test_commit_quota_goal_for() is set to test committing a new psi
goal on an existing psi goal. However, damon_test_commit_quota_goal()
is mistakenly not covering the test case. Add the test case.

Fixes: 99f89debafc5 ("mm/damon/tests/core-kunit: add damos_commit_quota_goal() test")
Cc: <sta...@vger.kernel.org> # 6.19.x
Signed-off-by: SJ Park <s...@kernel.org>
---
mm/damon/tests/core-kunit.h | 7 +++++++
1 file changed, 7 insertions(+)

diff --git a/mm/damon/tests/core-kunit.h b/mm/damon/tests/core-kunit.h
index 7071ec277b007..f1e11548c771b 100644
--- a/mm/damon/tests/core-kunit.h
+++ b/mm/damon/tests/core-kunit.h
@@ -793,6 +793,13 @@ static void damos_test_commit_quota_goal(struct kunit *test)

SJ Park

unread,
Sep 1, 2026, 8:27:36 PM (9 days ago) Sep 1
to Andrew Morton, SJ Park, sta...@vger.kernel.org, Brendan Higgins, David Gow, Quanmin Yan, Ravi Jonnalagadda, da...@lists.linux.dev, kuni...@googlegroups.com, linux-...@vger.kernel.org, linux-k...@vger.kernel.org, linu...@kvack.org
DAMOS quota goals commit unit test is mistakenly not testing a test case
that was designed to test. DAMOS quota goals and DAMON sysfs refresh_ms
file have bugs that can produce non critical but still unexpected
behaviors. Fix the bugs.

Patch 1 fixes the DAMOS quota goals commit unit test to cover a
mistakenly uncovered case. Patches 2 and 3 fix the bugs in DAMOS PSI
goal initialization and eligible_mem_bp online commit, respectively.
Patch 4 fixes the bug in DAMON sysfs refresh_ms file handling.

Changes from RFC v1.3
- RFC v1.3: https://lore.kernel.org/202608281836...@kernel.org
- Drop RFC tag.
- Rebase to latest mm-new.
Changes from RFC v1.2
- RFC v1.2: https://lore.kernel.org/2026082801465...@kernel.org
- Fix last_psi_total underflow.
Changes from RFC v1.1
- RFC v1.1: https://lore.kernel.org/2026082713442...@kernel.org
- Fix quota goals commit unit test that was mistakenly missing a test case.
- Initialize last_psi_total as uninitialized at the beginning.
- Correct kunit test for changed last_psi_total initialization behavior.
Changes from RFC
- RFC: https://lore.kernel.org/202608270429...@kernel.org
(Mistakenly missed RFC tag)
- Fix build error.
- Add eligible_mem_bp nid commit fix.

SJ Park (4):
mm/damon/tests/core-kunit: test committing psi goal to psi goal
mm/damon/core: handle uninitialized damos_quota_goal->last_psi_total
mm/damon/core: copy nid for eligible_mem_bp damos quota goal commit
mm/damon/sysfs: set next refresh jiffies per sysfs context

mm/damon/core.c | 16 ++++++++++++++--
mm/damon/sysfs.c | 11 +++++------
mm/damon/tests/core-kunit.h | 16 ++++++++++------
3 files changed, 29 insertions(+), 14 deletions(-)


base-commit: ee125db0b1f24a2f6b04e3143ffe1a14324176fe
--
2.47.3

SJ Park

unread,
Sep 1, 2026, 9:16:35 PM (9 days ago) Sep 1
to SJ Park, Andrew Morton, sta...@vger.kernel.org, Brendan Higgins, David Gow, Quanmin Yan, Ravi Jonnalagadda, da...@lists.linux.dev, kuni...@googlegroups.com, linux-...@vger.kernel.org, linux-k...@vger.kernel.org, linu...@kvack.org
On Tue, 1 Sep 2026 17:27:19 -0700 SJ Park <s...@kernel.org> wrote:

> DAMOS quota goals commit unit test is mistakenly not testing a test case
> that was designed to test. DAMOS quota goals and DAMON sysfs refresh_ms
> file have bugs that can produce non critical but still unexpected
> behaviors. Fix the bugs.

Sashiko found no blocker for this series. Sashiko sent findings to damon@
mailing list [1], and I replied to all the comments. Please read those for
details.

Sashiko found a typo in the commit message of patch 3, though. It should
's/QUITA/QUOTA/'. I asked Andrew if he could fix it from his side.

[1] https://lore.kernel.org/damon/


Thanks,
SJ

Lian Wang

unread,
Sep 2, 2026, 11:14:06 PM (8 days ago) Sep 2
to SJ Park, Andrew Morton, sta...@vger.kernel.org, Brendan Higgins, David Gow, Quanmin Yan, Ravi Jonnalagadda, da...@lists.linux.dev, kuni...@googlegroups.com, linux-...@vger.kernel.org, linux-k...@vger.kernel.org, linu...@kvack.org
Hi SJ,

> Patch 1 fixes the DAMOS quota goals commit unit test to cover a
> mistakenly uncovered case. Patches 2 and 3 fix the bugs in DAMOS PSI
> goal initialization and eligible_mem_bp online commit, respectively.
> Patch 4 fixes the bug in DAMON sysfs refresh_ms file handling.

I reviewed and tested the integrated four-patch series in mm-new:

a20e38846efb..72dc8fdaae62

The integrated commits had stable patch-ids matching the posted patches.
DAMON KUnit passed 42/42 tests. I also ran test-only eligible_mem_bp nid and
two-kdamond refresh-isolation regression cases; they passed 42/42 and 43/43
tests, respectively. Both test-only changes were then removed and the
worktree returned clean at the unchanged series tip.

These were functional UML KUnit tests. The fixes look good to me.

For the series:

Reviewed-by: Lian Wang <lian...@gmail.com>
Tested-by: Lian Wang <lian...@gmail.com>

Thanks,
Lian

Kunwu Chan

unread,
Sep 3, 2026, 4:33:32 AM (8 days ago) Sep 3
to SJ Park, Kunwu Chan, Andrew Morton, sta...@vger.kernel.org, Brendan Higgins, David Gow, da...@lists.linux.dev, kuni...@googlegroups.com, linux-...@vger.kernel.org, linux-k...@vger.kernel.org, linu...@kvack.org, Kunwu Chan
Thanks SJ. The added case correctly exercises the PSI -> PSI commit
path before the existing tests change the destination metric.

Reviewed-by: Kunwu Chan <kunwu...@gmail.com>

Thanks,
Kunwu


Sent using hkml (https://github.com/sjp38/hackermail)

SJ Park

unread,
Sep 3, 2026, 9:51:34 AM (7 days ago) Sep 3
to Lian Wang, SJ Park, Andrew Morton, sta...@vger.kernel.org, Brendan Higgins, David Gow, Quanmin Yan, Ravi Jonnalagadda, da...@lists.linux.dev, kuni...@googlegroups.com, linux-...@vger.kernel.org, linux-k...@vger.kernel.org, linu...@kvack.org
Thank you for your review and test, Lian!


Thanks,
SJ

[...]
Reply all
Reply to author
Forward
0 new messages