Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

mm/damon/core: allow quota goals set zero effective size quota

User-explicit quotas (size and time quotas) having zero value means the
quotas are unset. And, effective size quota is set as the minimum value
of the explicit quotas. When quota goals are set, the goal-based quota
tuner can make it lower. But the existing only single tuner never sets
the effective size quota zero. Because of the fact, DAMON core assumes
zero effective quota means the user has set no quota.

Multiple tuners are now allowed, though. In the future, some tuners might
want to set a zero effective size quota. There is no reason to restrict
that. Meanwhile, because of the current implementation, it will only
deactivate all quotas and make the scheme work at its full speed.

Introduce a dedicated function for checking if no quota is set. The
function checks the fact by showing if the user-set explicit quotas are
zero and no goal is installed. It is decoupled from zero effective quota,
and hence allows future tuners set zero effective quota for intentionally
deactivating the scheme by a purpose.

Link: https://lkml.kernel.org/r/20260310010529.91162-3-sj@kernel.org
Signed-off-by: SeongJae Park <sj@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

SeongJae Park and committed by
Andrew Morton
54419bbd 8719c59c

+26 -5
+26 -5
mm/damon/core.c
··· 387 387 damos_free_quota_goal(g); 388 388 } 389 389 390 + static bool damos_quota_goals_empty(struct damos_quota *q) 391 + { 392 + return list_empty(&q->goals); 393 + } 394 + 390 395 /* initialize fields of @quota that normally API users wouldn't set */ 391 396 static struct damos_quota *damos_quota_init(struct damos_quota *quota) 392 397 { ··· 1796 1791 r->age <= s->pattern.max_age_region; 1797 1792 } 1798 1793 1794 + /* 1795 + * damos_quota_is_set() - Return if the given quota is actually set. 1796 + * @quota: The quota to check. 1797 + * 1798 + * Returns true if the quota is set, false otherwise. 1799 + */ 1800 + static bool damos_quota_is_set(struct damos_quota *quota) 1801 + { 1802 + return quota->esz || quota->sz || quota->ms || 1803 + !damos_quota_goals_empty(quota); 1804 + } 1805 + 1799 1806 static bool damos_valid_target(struct damon_ctx *c, struct damon_region *r, 1800 1807 struct damos *s) 1801 1808 { 1802 1809 bool ret = __damos_valid_target(r, s); 1803 1810 1804 - if (!ret || !s->quota.esz || !c->ops.get_scheme_score) 1811 + if (!ret || !damos_quota_is_set(&s->quota) || !c->ops.get_scheme_score) 1805 1812 return ret; 1806 1813 1807 1814 return c->ops.get_scheme_score(c, r, s) >= s->quota.min_score; ··· 2083 2066 } 2084 2067 2085 2068 if (c->ops.apply_scheme) { 2086 - if (quota->esz && quota->charged_sz + sz > quota->esz) { 2069 + if (damos_quota_is_set(quota) && 2070 + quota->charged_sz + sz > quota->esz) { 2087 2071 sz = ALIGN_DOWN(quota->esz - quota->charged_sz, 2088 2072 c->min_region_sz); 2089 2073 if (!sz) ··· 2103 2085 quota->total_charged_ns += timespec64_to_ns(&end) - 2104 2086 timespec64_to_ns(&begin); 2105 2087 quota->charged_sz += sz; 2106 - if (quota->esz && quota->charged_sz >= quota->esz) { 2088 + if (damos_quota_is_set(quota) && 2089 + quota->charged_sz >= quota->esz) { 2107 2090 quota->charge_target_from = t; 2108 2091 quota->charge_addr_from = r->ar.end + 1; 2109 2092 } ··· 2132 2113 continue; 2133 2114 2134 2115 /* Check the quota */ 2135 - if (quota->esz && quota->charged_sz >= quota->esz) 2116 + if (damos_quota_is_set(quota) && 2117 + quota->charged_sz >= quota->esz) 2136 2118 continue; 2137 2119 2138 2120 if (damos_skip_charged_region(t, r, s, c->min_region_sz)) ··· 2418 2398 /* New charge window starts */ 2419 2399 if (time_after_eq(jiffies, quota->charged_from + 2420 2400 msecs_to_jiffies(quota->reset_interval))) { 2421 - if (quota->esz && quota->charged_sz >= quota->esz) 2401 + if (damos_quota_is_set(quota) && 2402 + quota->charged_sz >= quota->esz) 2422 2403 s->stat.qt_exceeds++; 2423 2404 quota->total_charged_sz += quota->charged_sz; 2424 2405 quota->charged_from = jiffies;