Skip to contentSkip to conversation

mm/damon/reclaim: use parameter context correctly

PATCH In review SJ Park 2 participants 3 messages Nov 17

Subsystems (3)
lore
Share & tools
lore

SJ Park

author maintainer
#0 lore raw

PATCH 1/1 mm/damon/reclaim: use parameter context correctly

From: SeongJae Park <[email protected]>

damon_reclaim_apply_parameters() allocates a new DAMON context, stages user-specified DAMON parameters on it, and commits to running DAMON context at once, using damon_commit_ctx(). The code is mistakenly over-writing the monitoring attributes and the reclaim scheme on the running context. It is not causing a real problem for monitoring attributes, but the scheme overwriting can remove scheme's internal status such as charged quota. Fix the wrong use of the parameter context.

Fixes 11ddcfc257a3 ("mm/damon/reclaim: use damon_commit_ctx()")
(cherry picked from commit fed48693bdfeca666f7536ba88a05e9a4e5523b6)

---
Mark Polyakov found [1] this patch is missed in 6.12.y and causing an issue.

[1] https://lore.kernel.org/CAA5JH2yO-gw1gn_172hv0YWFfQpkXz915a=uoVH+e49P_D8-+Q@mail.gmail.com

 mm/damon/reclaim.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
mm/damon/reclaim.c +2 -2
index 9df096218beb7..254d84166131f 100644
@@ -190,7 +190,7 @@ static int damon_reclaim_apply_parameters(void)
 		goto out;
 	}
 
-	err = damon_set_attrs(ctx, &damon_reclaim_mon_attrs);
+	err = damon_set_attrs(param_ctx, &damon_reclaim_mon_attrs);
 	if (err)
 		goto out;
 
@@ -198,7 +198,7 @@ static int damon_reclaim_apply_parameters(void)
 	scheme = damon_reclaim_new_scheme();
 	if (!scheme)
 		goto out;
-	damon_set_schemes(ctx, &scheme, 1);
+	damon_set_schemes(param_ctx, &scheme, 1);
 
 	if (quota_mem_pressure_us) {
 		goal = damos_new_quota_goal(DAMOS_QUOTA_SOME_MEM_PSI_US,

base-commit: 8ea1fd6d2beedbc49a917cdccea09a0354b64d5f

Signature · 1 line
2.47.3
#1 lore raw
Sashiko has reviewed this patch and found no issues.
Quoted 10 lines

From: SeongJae Park <[email protected]>

damon_reclaim_apply_parameters() allocates a new DAMON context, stages user-specified DAMON parameters on it, and commits to running DAMON context at once, using damon_commit_ctx(). The code is mistakenly over-writing the monitoring attributes and the reclaim scheme on the running context. It is not causing a real problem for monitoring attributes, but the scheme overwriting can remove scheme's internal status such as charged quota. Fix the wrong use of the parameter context.

Quoted 6 lines
Fixes 11ddcfc257a3 ("mm/damon/reclaim: use damon_commit_ctx()")
(cherry picked from commit fed48693bdfeca666f7536ba88a05e9a4e5523b6)

Sashiko has reviewed this patch and found no issues.

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
author maintainer
#2 lore raw
In reply to SJ Park
Quoted 16 lines · On Mon, 16 Nov 2026 18:51:42 -0800 SJ Park <[email protected]> wrote:

From: SeongJae Park <[email protected]>

damon_reclaim_apply_parameters() allocates a new DAMON context, stages user-specified DAMON parameters on it, and commits to running DAMON context at once, using damon_commit_ctx(). The code is mistakenly over-writing the monitoring attributes and the reclaim scheme on the running context. It is not causing a real problem for monitoring attributes, but the scheme overwriting can remove scheme's internal status such as charged quota. Fix the wrong use of the parameter context.

Fixes 11ddcfc257a3 ("mm/damon/reclaim: use damon_commit_ctx()")
(cherry picked from commit fed48693bdfeca666f7536ba88a05e9a4e5523b6)
Quoted 3 lines

---
Mark Polyakov found [1] this patch is missed in 6.12.y and causing an issue.

By the way, it was not picked for 6.12.y because I underestimated the bug and therefore didn't Cc: stable@. Sorry about that, Mark and stable@ maintainers. Also appreciate again for the issue report, Mark!

Quoted 2 lines

[1] https://lore.kernel.org/CAA5JH2yO-gw1gn_172hv0YWFfQpkXz915a=uoVH+e49P_D8-+Q@mail.gmail.com

Thanks,
SJ

[...]