Skip to contentSkip to conversation

FAILED: patch "[PATCH] mm/damon/core: don't skip damos_adjust_quota() while esz is" failed to apply to 6.6-stable tree

PATCH Applied [email protected] 4 participants 5 messages Oct 3 – Oct 4

Subsystems (3)
lore
Share & tools
lore

[email protected]

author maintainer
#0 lore raw

The patch below does not apply to the 6.6-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.

To reproduce the conflict and resubmit, you may use the following commands:

git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.6.y
git checkout FETCH_HEAD
git cherry-pick -x 52ae167ce16609c7e6fffef588b3c2c26de2db19
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2026100318-preteen-hazelnut-d38b@gregkh' --subject-prefix 'PATCH 6.6.y' 'HEAD^..'

Possible dependencies:

thanks,

greg k-h

------------------ original commit in Linus's tree ------------------

From 52ae167ce16609c7e6fffef588b3c2c26de2db19 Mon Sep 17 00:00:00 2001
From: SJ Park <[email protected]>
Date: Wed, 16 Sep 2026 06:50:19 -0700
Subject: [PATCH] mm/damon/core: don't skip damos_adjust_quota() while esz is
not zero

DAMOS could unexpectedly stop working when a user disables quota using the online parameters commit feature. Fix it by correcting a wrong quota unset check in damos_adjust_quota().

DAMON users could disable all quotas by unsetting time and size quotas, and removing all quota goals. The intention of disabling quotas would be making DAMOS run at full speed. When such quota disabled setup is detected, damos_adjust_quota() skips all its work. The skipped works include effective size quota (damos_quota->esz) updates and charged quota amount (damos_quota->charged_sz) resets. The intention is to avoid doing unnecessary work when quotas are disabled.

However, users could do the setup while effective size quota is non-zero, by doing the disabling with the online DAMON parameters commit feature. In this case, because the effective size quota exists, DAMOS will keep working with the quota until it is fully charged. After the effective quota is fully charged, the charged quota amount (damos_quota->charged_sz) cannot be reset because damos_adjust_quota() skips it. Then, DAMOS stops working until the quota is newly set or DAMON is entirely restarted.

The problem happens because damos_adjust_quota() assumes the user setup for disabling quota immediately disabled it. In reality, the quota is still working until the effective size quota is also updated to zero. Other logic for catching that uses damos_quota_is_set(), which understands the fact and therefore checks the effective size quota in addition to the user setup. Fix the issue by using damos_quota_is_set() in damos_adjust_quota() to determine if its works should be skipped.

The user impact is a non-deterministic and unexpected DAMOS stop behavior. That is, users would disable quotas using the online parameters commit feature, expecting DAMOS will run at full speed. However, depending on the timing, the setup can be updated while the effective size quota is non-zero. Due to the above mentioned internal mechanism, DAMOS stops working instead of running at full speed. It is unexpected behavior. It is also non-deterministic because sometimes the setup is done when the effective size quota is zero, depending on the timing. It doesn't cause critical issues like crashes or leaks. Users can simply set a reasonable quota again, or restart DAMON. But definitely it is an unexpected and non-deterministic behavior that makes it difficult to reliably use. Also investigating the root cause of the behavior would be quite difficult.

Fixes da87878010e5 ("mm/damon/sysfs: support online inputs update")
Cc <[email protected]> # 5.19.x
mm/damon/core.c +1 -1
index 1764620903f2..ab3c4d754964 100644
@@ -3147,7 +3147,7 @@ static void damos_adjust_quota(struct damon_ctx *c, struct damos *s)
 	unsigned long cumulated_sz, cached_esz;
 	unsigned int score, max_score = 0;
 
-	if (!quota->ms && !quota->sz && list_empty(&quota->goals))
+	if (!damos_quota_is_set(quota))
 		return;
 
 	/* First charge window */
maintainer
#1 lore raw

PATCH 1/1 mm/damon/core: don't skip damos_adjust_quota() while esz is not zero

DAMOS could unexpectedly stop working when a user disables quota using the online parameters commit feature. Fix it by correcting a wrong quota unset check in damos_adjust_quota().

DAMON users could disable all quotas by unsetting time and size quotas, and removing all quota goals. The intention of disabling quotas would be making DAMOS run at full speed. When such quota disabled setup is detected, damos_adjust_quota() skips all its work. The skipped works include effective size quota (damos_quota->esz) updates and charged quota amount (damos_quota->charged_sz) resets. The intention is to avoid doing unnecessary work when quotas are disabled.

However, users could do the setup while effective size quota is non-zero, by doing the disabling with the online DAMON parameters commit feature. In this case, because the effective size quota exists, DAMOS will keep working with the quota until it is fully charged. After the effective quota is fully charged, the charged quota amount (damos_quota->charged_sz) cannot be reset because damos_adjust_quota() skips it. Then, DAMOS stops working until the quota is newly set or DAMON is entirely restarted.

The problem happens because damos_adjust_quota() assumes the user setup for disabling quota immediately disabled it. In reality, the quota is still working until the effective size quota is also updated to zero. Other logic for catching that uses damos_quota_is_set(), which understands the fact and therefore checks the effective size quota in addition to the user setup. Fix the issue by using damos_quota_is_set() in damos_adjust_quota() to determine if its works should be skipped.

The user impact is a non-deterministic and unexpected DAMOS stop behavior. That is, users would disable quotas using the online parameters commit feature, expecting DAMOS will run at full speed. However, depending on the timing, the setup can be updated while the effective size quota is non-zero. Due to the above mentioned internal mechanism, DAMOS stops working instead of running at full speed. It is unexpected behavior. It is also non-deterministic because sometimes the setup is done when the effective size quota is zero, depending on the timing. It doesn't cause critical issues like crashes or leaks. Users can simply set a reasonable quota again, or restart DAMON. But definitely it is an unexpected and non-deterministic behavior that makes it difficult to reliably use. Also investigating the root cause of the behavior would be quite difficult.

Fixes da87878010e5 ("mm/damon/sysfs: support online inputs update")
Cc <[email protected]> # 5.19.x
---
 mm/damon/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mm/damon/core.c +1 -1
index fe91b296f4c6..bd46a63b611c 100644
@@ -1087,7 +1087,7 @@ static void damos_adjust_quota(struct damon_ctx *c, struct damos *s)
 	unsigned long cumulated_sz;
 	unsigned int score, max_score = 0;
 
-	if (!quota->ms && !quota->sz)
+	if (!quota->esz && !quota->ms && !quota->sz)
 		return;
 
 	/* First charge window */
Signature · 1 line
2.47.3
#2 lore raw

Re: [PATCH 6.6.y] mm/damon/core: don't skip damos_adjust_quota() while esz is not zero

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider: - [Medium] mm: commit message references nonexistent damos_quota_is_set() - [Low] mm: outdated comment for…

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Medium] mm: commit message references nonexistent damos_quota_is_set()
- [Low] mm: outdated comment for damos_set_effective_quota()
--

commit bdd4b48218af232c248d2db96f0af460e859f59e
Author: SJ Park <[email protected]>

mm/damon/core: don't skip damos_adjust_quota() while esz is not zero

DAMOS could unexpectedly stop working when a user disables quota using the online parameters commit feature. Fix it by correcting a wrong quota unset check in damos_adjust_quota().

Quoted 4 lines

Other logic for catching that uses damos_quota_is_set(), which understands the fact and therefore checks the effective size quota in addition to the user setup. Fix the issue by using damos_quota_is_set() in damos_adjust_quota() to determine if its works should be skipped.

[Severity: Medium]
The commit message states the fix uses damos_quota_is_set(). However, the code below checks the fields directly inline. Should the commit message be updated to reflect the inline check?

mm/damon/core.c static void damos_adjust_quota(struct damon_ctx *c, struct damos *s) · line 1091

Quoted 11 lines
mm/damon/core.c +1 -1
index fe91b296f4c66..bd46a63b611cf 100644
@@ -1087,7 +1087,7 @@ static void damos_adjust_quota(struct damon_ctx *c, struct damos *s)
 	unsigned long cumulated_sz;
 	unsigned int score, max_score = 0;
 
-	if (!quota->ms && !quota->sz)
+	if (!quota->esz && !quota->ms && !quota->sz)
 		return;

[Severity: Low]
With this change, damos_adjust_quota() can proceed even when quota->ms and quota->sz are zero. This allows damos_set_effective_quota() to be called later in the function during a new charge window:

	if (!time_in_range_open(...)) {
		...
		damos_set_effective_quota(quota);
	}

Does this make the comment above damos_set_effective_quota() outdated? It currently states:

/* Shouldn't be called if quota->ms and quota->sz are zero */ static void damos_set_effective_quota(struct damos_quota *quota)

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
maintainer
#3 lore raw

Re: [PATCH 6.6.y] mm/damon/core: don't skip damos_adjust_quota() while esz is not zero

Quoted 21 lines · On Sat, 03 Oct 2026 17:56:16 +0000 [email protected] wrote:

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Medium] mm: commit message references nonexistent damos_quota_is_set()
- [Low] mm: outdated comment for damos_set_effective_quota()
--

commit bdd4b48218af232c248d2db96f0af460e859f59e
Author: SJ Park <[email protected]>

mm/damon/core: don't skip damos_adjust_quota() while esz is not zero

DAMOS could unexpectedly stop working when a user disables quota using the online parameters commit feature. Fix it by correcting a wrong quota unset check in damos_adjust_quota().

Quoted 4 lines

Other logic for catching that uses damos_quota_is_set(), which understands the fact and therefore checks the effective size quota in addition to the user setup. Fix the issue by using damos_quota_is_set() in damos_adjust_quota() to determine if its works should be skipped.

Quoted 4 lines

[Severity: Medium]
The commit message states the fix uses damos_quota_is_set(). However, the code below checks the fields directly inline. Should the commit message be updated to reflect the inline check?

No, since this is a backporting of the mainline commit.

Quoted 23 lines

mm/damon/core.c static void damos_adjust_quota(struct damon_ctx *c, struct damos *s) · line 1091

Quoted 12 lines
mm/damon/core.c +1 -1
index fe91b296f4c66..bd46a63b611cf 100644
@@ -1087,7 +1087,7 @@ static void damos_adjust_quota(struct damon_ctx *c, struct damos *s)
 	unsigned long cumulated_sz;
 	unsigned int score, max_score = 0;
 
-	if (!quota->ms && !quota->sz)
+	if (!quota->esz && !quota->ms && !quota->sz)
 		return;

[Severity: Low]
With this change, damos_adjust_quota() can proceed even when quota->ms and quota->sz are zero. This allows damos_set_effective_quota() to be called later in the function during a new charge window:

	if (!time_in_range_open(...)) {
		...
		damos_set_effective_quota(quota);
	}
Quoted 5 lines

Does this make the comment above damos_set_effective_quota() outdated? It currently states:

/* Shouldn't be called if quota->ms and quota->sz are zero */ static void damos_set_effective_quota(struct damos_quota *quota)

That's out of the scope of this backport in my opinion.

Quoted 3 lines
Signature · 2 lines
-- 
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1

Thanks,
SJ

maintainer Applied
#4 lore raw

Re: [PATCH 6.6.y] mm/damon/core: don't skip damos_adjust_quota() while esz is not zero

In reply to SJ Park
Quoted 3 lines

DAMOS could unexpectedly stop working when a user disables quota using the online parameters commit feature. Fix it by correcting a wrong quota unset check in damos_adjust_quota().

Queued for 6.6, thanks.

Signature · 2 lines
Thanks,
Sasha