* [RFC PATCH 1/6] mm/damon/api: introduce DAMOS_FILTER_TYPE_PROBE_HITS_WSUM
2026-09-06 21:05 [RFC PATCH 0/6] mm/damon: introduce probe_hits_wsum DAMOS core filter SJ Park
@ 2026-09-06 21:05 ` SJ Park
2026-09-06 21:13 ` sashiko-bot
2026-09-06 21:05 ` [RFC PATCH 2/6] mm/damon/core: support probe_hits_wsum damos core filter SJ Park
` (4 subsequent siblings)
5 siblings, 1 reply; 16+ messages in thread
From: SJ Park @ 2026-09-06 21:05 UTC (permalink / raw)
Cc: SJ Park, damon, linux-kernel, linux-mm
Update DAMON kernel API to introduce new DAMOS core filter type,
PROBE_HITS_WSUM. It will allow API callers to describe the DAMOS action
target regions based on their probe_hits weighted sum. For describing
the filtering target weighted sum range, add two type-dependent union
fields to damos_filter.
Signed-off-by: SJ Park <sj@kernel.org>
---
include/linux/damon.h | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/include/linux/damon.h b/include/linux/damon.h
index 871d26adf6ae5..59d57131d8327 100644
--- a/include/linux/damon.h
+++ b/include/linux/damon.h
@@ -399,6 +399,7 @@ struct damos_stat {
* @DAMOS_FILTER_TYPE_UNMAPPED: Unmapped pages.
* @DAMOS_FILTER_TYPE_ADDR: Address range.
* @DAMOS_FILTER_TYPE_TARGET: Data Access Monitoring target.
+ * @DAMOS_FILTER_TYPE_PROBE_HITS_WSUM: probe_hits weighted sum range.
* @NR_DAMOS_FILTER_TYPES: Number of filter types.
*
* All types except &DAMOS_FILTER_TYPE_ADDR and &DAMOS_FILTER_TYPE_TARGET
@@ -420,6 +421,7 @@ enum damos_filter_type {
DAMOS_FILTER_TYPE_UNMAPPED,
DAMOS_FILTER_TYPE_ADDR,
DAMOS_FILTER_TYPE_TARGET,
+ DAMOS_FILTER_TYPE_PROBE_HITS_WSUM,
NR_DAMOS_FILTER_TYPES,
};
@@ -434,6 +436,8 @@ enum damos_filter_type {
* &damon_ctx->adaptive_targets if @type is
* DAMOS_FILTER_TYPE_TARGET.
* @sz_range: Size range if @type is DAMOS_FILTER_TYPE_HUGEPAGE_SIZE.
+ * @range_min: Minimum value of range arguments.
+ * @range_mx: Maximum value of range arguments.
*
* Before applying the &damos->action to a memory region, DAMOS checks if each
* byte of the region matches to this given condition and avoid applying the
@@ -450,6 +454,10 @@ struct damos_filter {
struct damon_addr_range addr_range;
int target_idx;
struct damon_size_range sz_range;
+ struct {
+ unsigned long range_min;
+ unsigned long range_max;
+ };
};
/* private: */
/* List head for siblings. */
--
2.47.3
^ permalink raw reply related [flat|nested] 16+ messages in thread* Re: [RFC PATCH 1/6] mm/damon/api: introduce DAMOS_FILTER_TYPE_PROBE_HITS_WSUM
2026-09-06 21:05 ` [RFC PATCH 1/6] mm/damon/api: introduce DAMOS_FILTER_TYPE_PROBE_HITS_WSUM SJ Park
@ 2026-09-06 21:13 ` sashiko-bot
2026-09-06 21:15 ` SJ Park
0 siblings, 1 reply; 16+ messages in thread
From: sashiko-bot @ 2026-09-06 21:13 UTC (permalink / raw)
To: SJ Park; +Cc: damon
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] Mismatch between kernel-doc comment and the actual struct field name for range_max.
--
commit 7d0758e3c3054c52a080a43553753f124a5933b1
Author: SJ Park <sj@kernel.org>
mm/damon/api: introduce DAMOS_FILTER_TYPE_PROBE_HITS_WSUM
Update DAMON kernel API to introduce new DAMOS core filter type,
PROBE_HITS_WSUM. It adds two type-dependent union fields to damos_filter
for describing the filtering target weighted sum range.
> diff --git a/include/linux/damon.h b/include/linux/damon.h
> index 871d26adf6ae5..59d57131d8327 100644
> --- a/include/linux/damon.h
> +++ b/include/linux/damon.h
[ ... ]
> @@ -434,6 +436,8 @@ enum damos_filter_type {
> * &damon_ctx->adaptive_targets if @type is
> * DAMOS_FILTER_TYPE_TARGET.
> * @sz_range: Size range if @type is DAMOS_FILTER_TYPE_HUGEPAGE_SIZE.
> + * @range_min: Minimum value of range arguments.
> + * @range_mx: Maximum value of range arguments.
[Severity: Low]
This isn't a bug, but there appears to be a typo in the kernel-doc comment
compared to the actual struct field. Should this be @range_max instead of
@range_mx to match the struct field defined below?
> *
> * Before applying the &damos->action to a memory region, DAMOS checks if each
> * byte of the region matches to this given condition and avoid applying the
> @@ -450,6 +454,10 @@ struct damos_filter {
> struct damon_addr_range addr_range;
> int target_idx;
> struct damon_size_range sz_range;
> + struct {
> + unsigned long range_min;
> + unsigned long range_max;
> + };
> };
> /* private: */
> /* List head for siblings. */
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260906210513.106895-1-sj@kernel.org?part=1
^ permalink raw reply [flat|nested] 16+ messages in thread* Re: [RFC PATCH 1/6] mm/damon/api: introduce DAMOS_FILTER_TYPE_PROBE_HITS_WSUM
2026-09-06 21:13 ` sashiko-bot
@ 2026-09-06 21:15 ` SJ Park
0 siblings, 0 replies; 16+ messages in thread
From: SJ Park @ 2026-09-06 21:15 UTC (permalink / raw)
To: sashiko-bot; +Cc: SJ Park, damon
On Sun, 06 Sep 2026 21:13:01 +0000 sashiko-bot@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
> - [Low] Mismatch between kernel-doc comment and the actual struct field name for range_max.
> --
>
> commit 7d0758e3c3054c52a080a43553753f124a5933b1
> Author: SJ Park <sj@kernel.org>
>
> mm/damon/api: introduce DAMOS_FILTER_TYPE_PROBE_HITS_WSUM
>
> Update DAMON kernel API to introduce new DAMOS core filter type,
> PROBE_HITS_WSUM. It adds two type-dependent union fields to damos_filter
> for describing the filtering target weighted sum range.
>
> > diff --git a/include/linux/damon.h b/include/linux/damon.h
> > index 871d26adf6ae5..59d57131d8327 100644
> > --- a/include/linux/damon.h
> > +++ b/include/linux/damon.h
> [ ... ]
> > @@ -434,6 +436,8 @@ enum damos_filter_type {
> > * &damon_ctx->adaptive_targets if @type is
> > * DAMOS_FILTER_TYPE_TARGET.
> > * @sz_range: Size range if @type is DAMOS_FILTER_TYPE_HUGEPAGE_SIZE.
> > + * @range_min: Minimum value of range arguments.
> > + * @range_mx: Maximum value of range arguments.
>
> [Severity: Low]
> This isn't a bug, but there appears to be a typo in the kernel-doc comment
> compared to the actual struct field. Should this be @range_max instead of
> @range_mx to match the struct field defined below?
Good catch. I will fix this in the next revision.
>
> > *
> > * Before applying the &damos->action to a memory region, DAMOS checks if each
> > * byte of the region matches to this given condition and avoid applying the
> > @@ -450,6 +454,10 @@ struct damos_filter {
> > struct damon_addr_range addr_range;
> > int target_idx;
> > struct damon_size_range sz_range;
> > + struct {
> > + unsigned long range_min;
> > + unsigned long range_max;
> > + };
> > };
> > /* private: */
> > /* List head for siblings. */
>
> --
> Sashiko AI review · https://sashiko.dev/#/patchset/20260906210513.106895-1-sj@kernel.org?part=1
Thanks,
SJ
^ permalink raw reply [flat|nested] 16+ messages in thread
* [RFC PATCH 2/6] mm/damon/core: support probe_hits_wsum damos core filter
2026-09-06 21:05 [RFC PATCH 0/6] mm/damon: introduce probe_hits_wsum DAMOS core filter SJ Park
2026-09-06 21:05 ` [RFC PATCH 1/6] mm/damon/api: introduce DAMOS_FILTER_TYPE_PROBE_HITS_WSUM SJ Park
@ 2026-09-06 21:05 ` SJ Park
2026-09-06 21:17 ` sashiko-bot
2026-09-06 21:05 ` [RFC PATCH 3/6] mm/damon/sysfs-schemes: rename sysfs_filter->sz_range to range_{min,max} SJ Park
` (3 subsequent siblings)
5 siblings, 1 reply; 16+ messages in thread
From: SJ Park @ 2026-09-06 21:05 UTC (permalink / raw)
Cc: SJ Park, Andrew Morton, damon, linux-kernel, linux-mm
Implement probe_hits_wsum DAMOS core filter support in the core layer.
Make three small changes for the support. First, update
damos_filter_for_ops() to treat probe_hits_wsum filter as core filter.
Second, Update destination damos_filter->range_{min,max} for
probe_hits_wsum type damos filter commits. Third, extend
damos_filter_match() to handle probe_hits_wsum type filter. Calculate
the weighted sum of the given region and compare it with the given
filter's target weighted sum range.
Signed-off-by: SJ Park <sj@kernel.org>
---
mm/damon/core.c | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/mm/damon/core.c b/mm/damon/core.c
index 1752afede01e2..5b976162c5eed 100644
--- a/mm/damon/core.c
+++ b/mm/damon/core.c
@@ -654,6 +654,7 @@ bool damos_filter_for_ops(enum damos_filter_type type)
switch (type) {
case DAMOS_FILTER_TYPE_ADDR:
case DAMOS_FILTER_TYPE_TARGET:
+ case DAMOS_FILTER_TYPE_PROBE_HITS_WSUM:
return false;
default:
break;
@@ -1328,6 +1329,10 @@ static void damos_commit_filter_arg(
case DAMOS_FILTER_TYPE_HUGEPAGE_SIZE:
dst->sz_range = src->sz_range;
break;
+ case DAMOS_FILTER_TYPE_PROBE_HITS_WSUM:
+ dst->range_min = src->range_min;
+ dst->range_max = src->range_max;
+ break;
default:
break;
}
@@ -2506,7 +2511,7 @@ static bool damos_filter_match(struct damon_ctx *ctx, struct damon_target *t,
bool matched = false;
struct damon_target *ti;
int target_idx = 0;
- unsigned long start, end;
+ unsigned long start, end, wsum;
switch (filter->type) {
case DAMOS_FILTER_TYPE_TARGET:
@@ -2541,6 +2546,11 @@ static bool damos_filter_match(struct damon_ctx *ctx, struct damon_target *t,
damon_split_region_at(t, r, end - r->ar.start);
matched = true;
break;
+ case DAMOS_FILTER_TYPE_PROBE_HITS_WSUM:
+ wsum = damon_probe_hits_wsum(r, false, ctx);
+ matched = filter->range_min <= wsum &&
+ wsum <= filter->range_max;
+ break;
default:
return false;
}
--
2.47.3
^ permalink raw reply related [flat|nested] 16+ messages in thread* Re: [RFC PATCH 2/6] mm/damon/core: support probe_hits_wsum damos core filter
2026-09-06 21:05 ` [RFC PATCH 2/6] mm/damon/core: support probe_hits_wsum damos core filter SJ Park
@ 2026-09-06 21:17 ` sashiko-bot
2026-09-06 21:29 ` SJ Park
0 siblings, 1 reply; 16+ messages in thread
From: sashiko-bot @ 2026-09-06 21:17 UTC (permalink / raw)
To: SJ Park; +Cc: damon
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] DAMOS_FILTER_TYPE_PROBE_HITS_WSUM uses raw, unscaled probe hits instead of a moving sum, leading to inaccurate filter evaluation when apply_interval is smaller than aggr_interval.
--
commit 75c1f2781e8de8f015329fce3e8a8d40e521f7de
Author: SJ Park <sj@kernel.org>
mm/damon/core: support probe_hits_wsum damos core filter
This commit implements the probe_hits_wsum DAMOS core filter support. It
updates damos_filter_for_ops, handles the range parameters during filter
commits, and calculates the weighted sum of probe hits for filter matching.
> diff --git a/mm/damon/core.c b/mm/damon/core.c
> index ce8c6f99106ed..ec1a1666aa9cc 100644
> --- a/mm/damon/core.c
> +++ b/mm/damon/core.c
[ ... ]
> @@ -2538,6 +2543,11 @@ static bool damos_filter_match(struct damon_ctx *ctx, struct damon_target *t,
> damon_split_region_at(t, r, end - r->ar.start);
> matched = true;
> break;
> + case DAMOS_FILTER_TYPE_PROBE_HITS_WSUM:
> + wsum = damon_probe_hits_wsum(r, false, ctx);
> + matched = filter->range_min <= wsum &&
> + wsum <= filter->range_max;
[Severity: Medium]
When a scheme's apply_interval_us is smaller than its aggr_interval_us, does
this evaluate incomplete probe hits?
Because the probe_hits array accumulates from zero over the aggregation
interval, evaluating the raw probe hits mid-interval yields artificially low
values. This differs from access pattern evaluations, which scale the count
based on the elapsed fraction of the aggregation interval (for example, using
damon_nr_accesses_mvsum()).
Could this cause regions to incorrectly fail or falsely match the filter
depending on when the scheme is evaluated within the aggregation interval?
> + break;
> default:
> return false;
> }
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260906210513.106895-1-sj@kernel.org?part=2
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [RFC PATCH 2/6] mm/damon/core: support probe_hits_wsum damos core filter
2026-09-06 21:17 ` sashiko-bot
@ 2026-09-06 21:29 ` SJ Park
0 siblings, 0 replies; 16+ messages in thread
From: SJ Park @ 2026-09-06 21:29 UTC (permalink / raw)
To: sashiko-bot; +Cc: SJ Park, damon
On Sun, 06 Sep 2026 21:17:53 +0000 sashiko-bot@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
> - [Medium] DAMOS_FILTER_TYPE_PROBE_HITS_WSUM uses raw, unscaled probe hits instead of a moving sum, leading to inaccurate filter evaluation when apply_interval is smaller than aggr_interval.
> --
>
> commit 75c1f2781e8de8f015329fce3e8a8d40e521f7de
> Author: SJ Park <sj@kernel.org>
>
> mm/damon/core: support probe_hits_wsum damos core filter
>
> This commit implements the probe_hits_wsum DAMOS core filter support. It
> updates damos_filter_for_ops, handles the range parameters during filter
> commits, and calculates the weighted sum of probe hits for filter matching.
>
> > diff --git a/mm/damon/core.c b/mm/damon/core.c
> > index ce8c6f99106ed..ec1a1666aa9cc 100644
> > --- a/mm/damon/core.c
> > +++ b/mm/damon/core.c
>
> [ ... ]
>
> > @@ -2538,6 +2543,11 @@ static bool damos_filter_match(struct damon_ctx *ctx, struct damon_target *t,
> > damon_split_region_at(t, r, end - r->ar.start);
> > matched = true;
> > break;
> > + case DAMOS_FILTER_TYPE_PROBE_HITS_WSUM:
> > + wsum = damon_probe_hits_wsum(r, false, ctx);
> > + matched = filter->range_min <= wsum &&
> > + wsum <= filter->range_max;
>
> [Severity: Medium]
> When a scheme's apply_interval_us is smaller than its aggr_interval_us, does
> this evaluate incomplete probe hits?
>
> Because the probe_hits array accumulates from zero over the aggregation
> interval, evaluating the raw probe hits mid-interval yields artificially low
> values. This differs from access pattern evaluations, which scale the count
> based on the elapsed fraction of the aggregation interval (for example, using
> damon_nr_accesses_mvsum()).
>
> Could this cause regions to incorrectly fail or falsely match the filter
> depending on when the scheme is evaluated within the aggregation interval?
Good catch. I will extend damon_probe_hits_wsum() to provide moving sum based
weighted sum, and use it in the next revision.
>
> > + break;
> > default:
> > return false;
> > }
>
> --
> Sashiko AI review · https://sashiko.dev/#/patchset/20260906210513.106895-1-sj@kernel.org?part=2
>
Thanks,
SJ
^ permalink raw reply [flat|nested] 16+ messages in thread
* [RFC PATCH 3/6] mm/damon/sysfs-schemes: rename sysfs_filter->sz_range to range_{min,max}
2026-09-06 21:05 [RFC PATCH 0/6] mm/damon: introduce probe_hits_wsum DAMOS core filter SJ Park
2026-09-06 21:05 ` [RFC PATCH 1/6] mm/damon/api: introduce DAMOS_FILTER_TYPE_PROBE_HITS_WSUM SJ Park
2026-09-06 21:05 ` [RFC PATCH 2/6] mm/damon/core: support probe_hits_wsum damos core filter SJ Park
@ 2026-09-06 21:05 ` SJ Park
2026-09-06 21:11 ` sashiko-bot
2026-09-06 21:05 ` [RFC PATCH 4/6] mm/damon/sysfs-schemes: setup range_{min,max} for probe_hits_wsum filter SJ Park
` (2 subsequent siblings)
5 siblings, 1 reply; 16+ messages in thread
From: SJ Park @ 2026-09-06 21:05 UTC (permalink / raw)
Cc: SJ Park, Andrew Morton, damon, linux-kernel, linux-mm
DAMON sysfs interface provides 'min' and 'max' files under the DAMOS
filter directory. The purpose is setting the general range arguments
for hugepage_size like filters that require range arguments. So far,
hugepage_size was the only filter using it. Hence sz_range field of
damon_sysfs_scheme_filter struct was connected to the files.
In future, we could add a new filter that can reuse the 'min' and 'max'
files. And the filter might use a range of a type that is not size. For
example, probe_hits weighted sum. In this case, simply reusing the
sz_range field would make it a little confusing. Rename sz_range to
range_{min,max} to avoid such confusion.
Signed-off-by: SJ Park <sj@kernel.org>
---
mm/damon/sysfs-schemes.c | 19 +++++++++++--------
1 file changed, 11 insertions(+), 8 deletions(-)
diff --git a/mm/damon/sysfs-schemes.c b/mm/damon/sysfs-schemes.c
index d9b81d7b5910e..4d9147d2a269e 100644
--- a/mm/damon/sysfs-schemes.c
+++ b/mm/damon/sysfs-schemes.c
@@ -534,7 +534,8 @@ struct damon_sysfs_scheme_filter {
bool allow;
char *memcg_path;
struct damon_addr_range addr_range;
- struct damon_size_range sz_range;
+ unsigned long range_min;
+ unsigned long range_max;
int target_idx;
};
@@ -588,6 +589,7 @@ damos_sysfs_filter_type_names[] = {
.type = DAMOS_FILTER_TYPE_TARGET,
.name = "target",
},
+
};
static ssize_t type_show(struct kobject *kobj,
@@ -778,7 +780,7 @@ static ssize_t min_show(struct kobject *kobj,
struct damon_sysfs_scheme_filter *filter = container_of(kobj,
struct damon_sysfs_scheme_filter, kobj);
- return sysfs_emit(buf, "%lu\n", filter->sz_range.min);
+ return sysfs_emit(buf, "%lu\n", filter->range_min);
}
static ssize_t min_store(struct kobject *kobj,
@@ -786,7 +788,7 @@ static ssize_t min_store(struct kobject *kobj,
{
struct damon_sysfs_scheme_filter *filter = container_of(kobj,
struct damon_sysfs_scheme_filter, kobj);
- int err = kstrtoul(buf, 0, &filter->sz_range.min);
+ int err = kstrtoul(buf, 0, &filter->range_min);
return err ? err : count;
}
@@ -797,7 +799,7 @@ static ssize_t max_show(struct kobject *kobj,
struct damon_sysfs_scheme_filter *filter = container_of(kobj,
struct damon_sysfs_scheme_filter, kobj);
- return sysfs_emit(buf, "%lu\n", filter->sz_range.max);
+ return sysfs_emit(buf, "%lu\n", filter->range_max);
}
static ssize_t max_store(struct kobject *kobj,
@@ -805,7 +807,7 @@ static ssize_t max_store(struct kobject *kobj,
{
struct damon_sysfs_scheme_filter *filter = container_of(kobj,
struct damon_sysfs_scheme_filter, kobj);
- int err = kstrtoul(buf, 0, &filter->sz_range.max);
+ int err = kstrtoul(buf, 0, &filter->range_max);
return err ? err : count;
}
@@ -2835,12 +2837,13 @@ static int damon_sysfs_add_scheme_filters(struct damos *scheme,
} else if (filter->type == DAMOS_FILTER_TYPE_TARGET) {
filter->target_idx = sysfs_filter->target_idx;
} else if (filter->type == DAMOS_FILTER_TYPE_HUGEPAGE_SIZE) {
- if (sysfs_filter->sz_range.min >
- sysfs_filter->sz_range.max) {
+ if (sysfs_filter->range_min >
+ sysfs_filter->range_max) {
damos_destroy_filter(filter);
return -EINVAL;
}
- filter->sz_range = sysfs_filter->sz_range;
+ filter->sz_range.min = sysfs_filter->range_min;
+ filter->sz_range.max = sysfs_filter->range_max;
}
damos_add_filter(scheme, filter);
--
2.47.3
^ permalink raw reply related [flat|nested] 16+ messages in thread* [RFC PATCH 4/6] mm/damon/sysfs-schemes: setup range_{min,max} for probe_hits_wsum filter
2026-09-06 21:05 [RFC PATCH 0/6] mm/damon: introduce probe_hits_wsum DAMOS core filter SJ Park
` (2 preceding siblings ...)
2026-09-06 21:05 ` [RFC PATCH 3/6] mm/damon/sysfs-schemes: rename sysfs_filter->sz_range to range_{min,max} SJ Park
@ 2026-09-06 21:05 ` SJ Park
2026-09-06 21:16 ` sashiko-bot
2026-09-06 21:05 ` [RFC PATCH 5/6] Docs/mm/damon/design: update for probe_hits_wsum DAMOS core filter SJ Park
2026-09-06 21:05 ` [RFC PATCH 6/6] Docs/admin-guide/mm/damon/usage: update for probe_hits_wsum DAMOS filter SJ Park
5 siblings, 1 reply; 16+ messages in thread
From: SJ Park @ 2026-09-06 21:05 UTC (permalink / raw)
Cc: SJ Park, Andrew Morton, damon, linux-kernel, linux-mm
Extend DAMON sysfs interface to support probe_hits_wsum input. Also
update sysfs input based scheme build logic to setup the min/max probe
hits weighted sum range as user provided.
Signed-off-by: SJ Park <sj@kernel.org>
---
mm/damon/sysfs-schemes.c | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/mm/damon/sysfs-schemes.c b/mm/damon/sysfs-schemes.c
index 4d9147d2a269e..e297a20c0af03 100644
--- a/mm/damon/sysfs-schemes.c
+++ b/mm/damon/sysfs-schemes.c
@@ -589,7 +589,10 @@ damos_sysfs_filter_type_names[] = {
.type = DAMOS_FILTER_TYPE_TARGET,
.name = "target",
},
-
+ {
+ .type = DAMOS_FILTER_TYPE_PROBE_HITS_WSUM,
+ .name = "probe_hits_wsum",
+ },
};
static ssize_t type_show(struct kobject *kobj,
@@ -2844,6 +2847,14 @@ static int damon_sysfs_add_scheme_filters(struct damos *scheme,
}
filter->sz_range.min = sysfs_filter->range_min;
filter->sz_range.max = sysfs_filter->range_max;
+ } else if (filter->type == DAMOS_FILTER_TYPE_PROBE_HITS_WSUM) {
+ if (sysfs_filter->range_min >
+ sysfs_filter->range_max) {
+ damos_destroy_filter(filter);
+ return -EINVAL;
+ }
+ filter->sz_range.min = sysfs_filter->range_min;
+ filter->sz_range.max = sysfs_filter->range_max;
}
damos_add_filter(scheme, filter);
--
2.47.3
^ permalink raw reply related [flat|nested] 16+ messages in thread* Re: [RFC PATCH 4/6] mm/damon/sysfs-schemes: setup range_{min,max} for probe_hits_wsum filter
2026-09-06 21:05 ` [RFC PATCH 4/6] mm/damon/sysfs-schemes: setup range_{min,max} for probe_hits_wsum filter SJ Park
@ 2026-09-06 21:16 ` sashiko-bot
2026-09-06 21:30 ` SJ Park
0 siblings, 1 reply; 16+ messages in thread
From: sashiko-bot @ 2026-09-06 21:16 UTC (permalink / raw)
To: SJ Park; +Cc: damon
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] Incorrect union member assignment for PROBE_HITS_WSUM filter type risks silent corruption if struct layout changes.
--
commit 67e5bf0750883cfdf7b8857b78d72c17c2de406e
Author: SJ Park <sj@kernel.org>
mm/damon/sysfs-schemes: setup range_{min,max} for probe_hits_wsum filter
This commit extends the DAMON sysfs interface to support probe_hits_wsum
input. It updates the sysfs input based scheme build logic to set up the
min/max probe hits weighted sum range provided by the user.
> diff --git a/mm/damon/sysfs-schemes.c b/mm/damon/sysfs-schemes.c
> index 4d9147d2a269e..e297a20c0af03 100644
> --- a/mm/damon/sysfs-schemes.c
> +++ b/mm/damon/sysfs-schemes.c
[ ... ]
> @@ -2844,6 +2847,14 @@ static int damon_sysfs_add_scheme_filters(struct damos *scheme,
> }
> filter->sz_range.min = sysfs_filter->range_min;
> filter->sz_range.max = sysfs_filter->range_max;
> + } else if (filter->type == DAMOS_FILTER_TYPE_PROBE_HITS_WSUM) {
> + if (sysfs_filter->range_min >
> + sysfs_filter->range_max) {
> + damos_destroy_filter(filter);
> + return -EINVAL;
> + }
> + filter->sz_range.min = sysfs_filter->range_min;
> + filter->sz_range.max = sysfs_filter->range_max;
[Severity: Low]
Is this assigning to the wrong union member? Since the filter type is
DAMOS_FILTER_TYPE_PROBE_HITS_WSUM, should this be assigning directly to
filter->range_min and filter->range_max instead of filter->sz_range?
While struct damon_size_range and the anonymous { unsigned long range_min;
unsigned long range_max; } struct currently share the exact same memory layout
in the struct damos_filter union, using sz_range here appears to be a
copy-paste error from the DAMOS_FILTER_TYPE_HUGEPAGE_SIZE block.
This seems to bypass the earlier refactoring that explicitly introduced
the anonymous struct to avoid reusing sz_range for non-size fields. If
struct damon_size_range is modified in the future, assigning via sz_range
while the core logic consumes range_min could lead to silent data corruption
when building a PROBE_HITS_WSUM scheme filter.
> }
>
> damos_add_filter(scheme, filter);
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260906210513.106895-1-sj@kernel.org?part=4
^ permalink raw reply [flat|nested] 16+ messages in thread* Re: [RFC PATCH 4/6] mm/damon/sysfs-schemes: setup range_{min,max} for probe_hits_wsum filter
2026-09-06 21:16 ` sashiko-bot
@ 2026-09-06 21:30 ` SJ Park
0 siblings, 0 replies; 16+ messages in thread
From: SJ Park @ 2026-09-06 21:30 UTC (permalink / raw)
To: sashiko-bot; +Cc: SJ Park, damon
On Sun, 06 Sep 2026 21:16:17 +0000 sashiko-bot@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
> - [Low] Incorrect union member assignment for PROBE_HITS_WSUM filter type risks silent corruption if struct layout changes.
> --
>
> commit 67e5bf0750883cfdf7b8857b78d72c17c2de406e
> Author: SJ Park <sj@kernel.org>
>
> mm/damon/sysfs-schemes: setup range_{min,max} for probe_hits_wsum filter
>
> This commit extends the DAMON sysfs interface to support probe_hits_wsum
> input. It updates the sysfs input based scheme build logic to set up the
> min/max probe hits weighted sum range provided by the user.
>
> > diff --git a/mm/damon/sysfs-schemes.c b/mm/damon/sysfs-schemes.c
> > index 4d9147d2a269e..e297a20c0af03 100644
> > --- a/mm/damon/sysfs-schemes.c
> > +++ b/mm/damon/sysfs-schemes.c
>
> [ ... ]
>
> > @@ -2844,6 +2847,14 @@ static int damon_sysfs_add_scheme_filters(struct damos *scheme,
> > }
> > filter->sz_range.min = sysfs_filter->range_min;
> > filter->sz_range.max = sysfs_filter->range_max;
> > + } else if (filter->type = DAMOS_FILTER_TYPE_PROBE_HITS_WSUM) {
> > + if (sysfs_filter->range_min >
> > + sysfs_filter->range_max) {
> > + damos_destroy_filter(filter);
> > + return -EINVAL;
> > + }
> > + filter->sz_range.min = sysfs_filter->range_min;
> > + filter->sz_range.max = sysfs_filter->range_max;
>
> [Severity: Low]
> Is this assigning to the wrong union member? Since the filter type is
> DAMOS_FILTER_TYPE_PROBE_HITS_WSUM, should this be assigning directly to
> filter->range_min and filter->range_max instead of filter->sz_range?
>
> While struct damon_size_range and the anonymous { unsigned long range_min;
> unsigned long range_max; } struct currently share the exact same memory layout
> in the struct damos_filter union, using sz_range here appears to be a
> copy-paste error from the DAMOS_FILTER_TYPE_HUGEPAGE_SIZE block.
>
> This seems to bypass the earlier refactoring that explicitly introduced
> the anonymous struct to avoid reusing sz_range for non-size fields. If
> struct damon_size_range is modified in the future, assigning via sz_range
> while the core logic consumes range_min could lead to silent data corruption
> when building a PROBE_HITS_WSUM scheme filter.
Good catch. I will fix this in the next revision
>
> > }
> >
> > damos_add_filter(scheme, filter);
>
> --
> Sashiko AI review · https://sashiko.dev/#/patchset/20260906210513.106895-1-sj@kernel.org?part=4
>
Thanks,
SJ
^ permalink raw reply [flat|nested] 16+ messages in thread
* [RFC PATCH 5/6] Docs/mm/damon/design: update for probe_hits_wsum DAMOS core filter
2026-09-06 21:05 [RFC PATCH 0/6] mm/damon: introduce probe_hits_wsum DAMOS core filter SJ Park
` (3 preceding siblings ...)
2026-09-06 21:05 ` [RFC PATCH 4/6] mm/damon/sysfs-schemes: setup range_{min,max} for probe_hits_wsum filter SJ Park
@ 2026-09-06 21:05 ` SJ Park
2026-09-06 21:07 ` sashiko-bot
2026-09-06 21:05 ` [RFC PATCH 6/6] Docs/admin-guide/mm/damon/usage: update for probe_hits_wsum DAMOS filter SJ Park
5 siblings, 1 reply; 16+ messages in thread
From: SJ Park @ 2026-09-06 21:05 UTC (permalink / raw)
Cc: SJ Park, Liam R. Howlett, Andrew Morton, David Hildenbrand,
Jonathan Corbet, Lorenzo Stoakes, Michal Hocko, Mike Rapoport,
Randy Dunlap, Shuah Khan, Suren Baghdasaryan, Vlastimil Babka,
damon, linux-doc, linux-kernel, linux-mm
Update DAMON design document for the newly added probe hits weighted sum
based DAMOS core filter type.
Signed-off-by: SJ Park <sj@kernel.org>
---
Documentation/mm/damon/design.rst | 3 +++
1 file changed, 3 insertions(+)
diff --git a/Documentation/mm/damon/design.rst b/Documentation/mm/damon/design.rst
index aac84de261aa8..8e980dde362de 100644
--- a/Documentation/mm/damon/design.rst
+++ b/Documentation/mm/damon/design.rst
@@ -822,6 +822,9 @@ Below ``type`` of filters are currently supported.
- Applied to pages that belonging to a given address range.
- target
- Applied to pages that belonging to a given DAMON monitoring target.
+ - probe_hits_wsum
+ - Matches to monitoring regions having a given range of :ref:`probe
+ hits weighted sum <damon_design_attrs_only_monitoring>` value.
- Operations layer handled, supported by only ``paddr`` operations set.
- anon
- Applied to pages that containing data that not stored in files.
--
2.47.3
^ permalink raw reply related [flat|nested] 16+ messages in thread* [RFC PATCH 6/6] Docs/admin-guide/mm/damon/usage: update for probe_hits_wsum DAMOS filter
2026-09-06 21:05 [RFC PATCH 0/6] mm/damon: introduce probe_hits_wsum DAMOS core filter SJ Park
` (4 preceding siblings ...)
2026-09-06 21:05 ` [RFC PATCH 5/6] Docs/mm/damon/design: update for probe_hits_wsum DAMOS core filter SJ Park
@ 2026-09-06 21:05 ` SJ Park
2026-09-06 21:11 ` sashiko-bot
5 siblings, 1 reply; 16+ messages in thread
From: SJ Park @ 2026-09-06 21:05 UTC (permalink / raw)
Cc: SJ Park, Liam R. Howlett, Andrew Morton, David Hildenbrand,
Jonathan Corbet, Lorenzo Stoakes, Michal Hocko, Mike Rapoport,
Randy Dunlap, Shuah Khan, Suren Baghdasaryan, Vlastimil Babka,
damon, linux-doc, linux-kernel, linux-mm
Update DAMON usage document for the newly added probe hits weighted sum
based DAMOS core filter type.
Signed-off-by: SJ Park <sj@kernel.org>
---
Documentation/admin-guide/mm/damon/usage.rst | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/Documentation/admin-guide/mm/damon/usage.rst b/Documentation/admin-guide/mm/damon/usage.rst
index 023c6334024f8..d3e37400367bd 100644
--- a/Documentation/admin-guide/mm/damon/usage.rst
+++ b/Documentation/admin-guide/mm/damon/usage.rst
@@ -551,6 +551,10 @@ and ``damon_target_idx``. To ``type`` file, you can write the type of the
filter. Refer to :ref:`the design doc <damon_design_damos_filters>` for
available type names, their meaning and on what layer those are handled.
+For ``probe_hits_wsum`` type, you can specify the minimum and maximum probe
+hits weighted sum value for the filter to ``min`` and ``max`` files,
+respectively.
+
For ``memcg`` type, you can specify the memory cgroup of the interest by
writing the path of the memory cgroup from the cgroups mount point to
``memcg_path`` file. For ``addr`` type, you can specify the start and end
--
2.47.3
^ permalink raw reply related [flat|nested] 16+ messages in thread