mm/damon: introduce probe_hits_wsum DAMOS core filter
Subsystems (4)
SJ Park
maintainercover mm/damon: introduce probe_hits_wsum DAMOS core filter
DAMON can do flexible data attributes monitoring. The classical data access monitoring can also be done using the attributes monitoring. The access event is just one of the data attributes that DAMON supports. Users do monitoring to make some actions based on it. DAMOS is a feature for automating that. However, DAMOS cannot utilize the data attributes monitoring results. It is still Data "Access" Monitoring-based Operation Schemes. It requires users to set the target "access" pattern.
DAMOS core filter is effectively the same as the target access pattern. It is just a more generalized and flexible way of describing the operation action target region. Introduce a new DAMOS core filter type, probe_hits_wsum. It specifies the filter target based on a range of the probe hits weighted sum. Using this, users can apply DAMOS actions to regions of specific data attributes pattern.
Note that the classic target access pattern still works. Hence the target nr_accesses range should still be properly configured. The new filter would be used in only data attributes-only mode. In the mode, classic access monitoring is just turned off, and therefore nr_accesses of regions are always zero. Users could simply set the target nr_accesses range to include the zero nr_Accesses regions.
Patches Sequence
================
Patch 1 updates the DAMON kernel API for the new filter type. Patch 2 implements the filter type in the core layer. Patch 3 refactor DAMON sysfs interface internal data structure for efficient reuse of data structure for the probe hits weighted sum range user inputs. Patch 4 updates DAMON sysfs interface to support the new filter type. Patches 5 and 6 update design and usage documents for the new filter type, respectively.
SJ Park (6):
mm/damon/api: introduce DAMOS_FILTER_TYPE_PROBE_HITS_WSUM mm/damon/core: support probe_hits_wsum damos core filter mm/damon/sysfs-schemes: rename sysfs_filter->sz_range to
range_{min,max} mm/damon/sysfs-schemes: setup range_{min,max} for probe_hits_wsum
filter
Docs/mm/damon/design: update for probe_hits_wsum DAMOS core filter Docs/admin-guide/mm/damon/usage: update for probe_hits_wsum DAMOS
filter
Documentation/admin-guide/mm/damon/usage.rst | 4 +++ Documentation/mm/damon/design.rst | 3 ++ include/linux/damon.h | 8 ++++++ mm/damon/core.c | 12 +++++++- mm/damon/sysfs-schemes.c | 30 ++++++++++++++------ 5 files changed, 48 insertions(+), 9 deletions(-)
base-commit: 787c63ba44ce65021966f55673e27d778c8d9c68
Signature · 1 line
2.47.3
SJ Park
maintainerRFC PATCH 1/6 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 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.
--- include/linux/damon.h | 8 ++++++++ 1 file changed, 8 insertions(+)
include/linux/damon.h +8 -0
@@ -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. */
Signature · 1 line
2.47.3
[email protected]
AI reviewRe: [RFC PATCH 1/6] mm/damon/api: introduce DAMOS_FILTER_TYPE_PROBE_HITS_WSUM
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. --
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 <[email protected]>
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.
Quoted 4 lines
include/linux/damon.h +0
-0
[ ... ]
include/linux/damon.h enum damos_filter_type { · line 440
Quoted 6 lines
include/linux/damon.h +2
-0@@ -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?
Quoted 14 lines
include/linux/damon.h +4
-0* * 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. */
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
SJ Park
maintainerRe: [RFC PATCH 1/6] mm/damon/api: introduce DAMOS_FILTER_TYPE_PROBE_HITS_WSUM
Quoted 18 lines · On Sun, 06 Sep 2026 21:13:01 +0000 [email protected] 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 forrange_max. --commit
7d0758e3c3054c52a080a43553753f124a5933b1
Author: SJ Park <[email protected]>
mm/damon/api: introduceDAMOS_FILTER_TYPE_PROBE_HITS_WSUMUpdate DAMON kernel API to introduce new DAMOS core filter type,
PROBE_HITS_WSUM. It adds two type-dependent union fields todamos_filterfor describing the filtering target weighted sum range.Quoted 4 lines
include/linux/damon.h +0
-0[ ... ]
Quoted 11 lines
include/linux/damon.h enum damos_filter_type { · line 440
Quoted 6 lines
include/linux/damon.h +2
-0@@ -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.
Quoted 18 lines
Quoted 15 lines
include/linux/damon.h +4
-0* * 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. */ Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Thanks,
SJ
SJ Park
maintainerRFC PATCH 2/6 mm/damon/core: support probe_hits_wsum damos core filter
In reply to SJ ParkImplement 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.
--- mm/damon/core.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
mm/damon/core.c +11 -1
@@ -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; }
Signature · 1 line
2.47.3
[email protected]
AI reviewRe: [RFC PATCH 2/6] mm/damon/core: support probe_hits_wsum damos core filter
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…
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 <[email protected]>
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.
Quoted 4 lines
mm/damon/core.c +0
-0
[ ... ]
mm/damon/core.c static bool damos_filter_match(struct damon_ctx *ctx, struct damon_target *t, · line 2549
Quoted 8 lines
mm/damon/core.c +4
-0@@ -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?
Quoted 4 lines
mm/damon/core.c +1
-0+break ;default :return false; }
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
SJ Park
maintainerRe: [RFC PATCH 2/6] mm/damon/core: support probe_hits_wsum damos core filter
Quoted 33 lines · On Sun, 06 Sep 2026 21:17:53 +0000 [email protected] wrote:
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium]DAMOS_FILTER_TYPE_PROBE_HITS_WSUMuses raw, unscaled probe hits instead of a moving sum, leading to inaccurate filter evaluation whenapply_intervalis smaller thanaggr_interval. --commit
75c1f2781e8de8f015329fce3e8a8d40e521f7de
Author: SJ Park <[email protected]>
mm/damon/core: supportprobe_hits_wsumdamos core filterThis commit implements the
probe_hits_wsumDAMOS core filter support. It updatesdamos_filter_for_ops, handles the range parameters during filter commits, and calculates the weighted sum of probe hits for filter matching.Quoted 4 lines
mm/damon/core.c +0
-0[ ... ]
mm/damon/core.c static bool damos_filter_match(struct damon_ctx *ctx, struct damon_target *t, · line 2549
Quoted 8 lines
mm/damon/core.c +4
-0@@ -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'sapply_interval_usis smaller than itsaggr_interval_us, does this evaluate incomplete probe hits?
Quoted 8 lines
Because the
probe_hitsarray 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, usingdamon_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.
Quoted 9 lines
Quoted 5 lines
mm/damon/core.c +1
-0+break ;default :return false; }Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
Thanks,
SJ
SJ Park
maintainerRFC PATCH 3/6 mm/damon/sysfs-schemes: rename sysfs_filter->sz_range to range_{min,max}
In reply to SJ ParkDAMON 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.
--- mm/damon/sysfs-schemes.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-)
mm/damon/sysfs-schemes.c +11 -8
@@ -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);
Signature · 1 line
2.47.3
[email protected]
AI reviewRe: [RFC PATCH 3/6] mm/damon/sysfs-schemes: rename sysfs_filter->sz_range to range_{min,max}
Sashiko has reviewed this patch and found no issues. It looks great!
Quoted 6 lines
DAMON sysfs interface provides 'min' and 'max' files under the DAMOS filter directory. The purpose is setting the general range arguments for
hugepage_sizelike filters that require range arguments. So far,hugepage_sizewas the only filter using it. Hencesz_rangefield ofdamon_sysfs_scheme_filterstruct was connected to the files.
Quoted 7 lines
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_hitsweighted sum. In this case, simply reusing thesz_rangefield would make it a little confusing. Renamesz_rangeto range_{min,max} to avoid such confusion.Signed-off-by SJ Park <[email protected]>
Sashiko has reviewed this patch and found no issues. It looks great!
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=3
SJ Park
maintainerRFC PATCH 4/6 mm/damon/sysfs-schemes: setup range_{min,max} for probe_hits_wsum filter
In reply to SJ ParkExtend 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.
--- mm/damon/sysfs-schemes.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-)
mm/damon/sysfs-schemes.c +12 -1
@@ -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);
Signature · 1 line
2.47.3
[email protected]
AI reviewRe: [RFC PATCH 4/6] mm/damon/sysfs-schemes: setup range_{min,max} for probe_hits_wsum filter
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…
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 <[email protected]>
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.
Quoted 4 lines
mm/damon/sysfs-schemes.c +0
-0
[ ... ]
mm/damon/sysfs-schemes.c static int damon_sysfs_add_scheme_filters(struct damos *scheme, · line 2857
Quoted 12 lines
mm/damon/sysfs-schemes.c +8
-0@@ -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.
Quoted 3 lines
mm/damon/sysfs-schemes.c +0
-0}damos_add_filter (scheme, filter);
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=4
SJ Park
maintainerRe: [RFC PATCH 4/6] mm/damon/sysfs-schemes: setup range_{min,max} for probe_hits_wsum filter
Quoted 43 lines · On Sun, 06 Sep 2026 21:16:17 +0000 [email protected] wrote:
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] Incorrect union member assignment forPROBE_HITS_WSUMfilter type risks silent corruption if struct layout changes. --commit
67e5bf0750883cfdf7b8857b78d72c17c2de406e
Author: SJ Park <[email protected]>
mm/damon/sysfs-schemes: setup range_{min,max} forprobe_hits_wsumfilterThis commit extends the DAMON sysfs interface to support
probe_hits_wsuminput. It updates the sysfs input based scheme build logic to set up the min/max probe hits weighted sum range provided by the user.Quoted 4 lines
mm/damon/sysfs-schemes.c +0
-0[ ... ]
mm/damon/sysfs-schemes.c static int damon_sysfs_add_scheme_filters(struct damos *scheme, · line 2857
Quoted 12 lines
mm/damon/sysfs-schemes.c +8
-0@@ -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 isDAMOS_FILTER_TYPE_PROBE_HITS_WSUM, should this be assigning directly tofilter->range_minandfilter->range_maxinstead offilter->sz_range?While struct
damon_size_rangeand the anonymous { unsigned longrange_min; unsigned longrange_max; } struct currently share the exact same memory layout in the structdamos_filterunion, usingsz_rangehere appears to be a copy-paste error from theDAMOS_FILTER_TYPE_HUGEPAGE_SIZEblock.
Quoted 5 lines
This seems to bypass the earlier refactoring that explicitly introduced the anonymous struct to avoid reusing
sz_rangefor non-size fields. If structdamon_size_rangeis modified in the future, assigning viasz_rangewhile the core logic consumesrange_mincould lead to silent data corruption when building aPROBE_HITS_WSUMscheme filter.
Good catch. I will fix this in the next revision
Quoted 8 lines
Quoted 4 lines
mm/damon/sysfs-schemes.c +0
-0}damos_add_filter (scheme, filter);Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=4
Thanks,
SJ
SJ Park
maintainerRFC PATCH 5/6 Docs/mm/damon/design: update for probe_hits_wsum DAMOS core filter
In reply to SJ ParkUpdate DAMON design document for the newly added probe hits weighted sum based DAMOS core filter type.
--- Documentation/mm/damon/design.rst | 3 +++ 1 file changed, 3 insertions(+)
Documentation/mm/damon/design.rst +3 -0
@@ -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.
Signature · 1 line
2.47.3
[email protected]
AI reviewRe: [RFC PATCH 5/6] Docs/mm/damon/design: update for probe_hits_wsum DAMOS core filter
Sashiko has reviewed this patch and found no issues. It looks great!
Quoted 4 lines
Update DAMON design document for the newly added probe hits weighted sum based DAMOS core filter type.
Signed-off-by SJ Park <[email protected]>
Sashiko has reviewed this patch and found no issues. It looks great!
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=5
SJ Park
maintainerRFC PATCH 6/6 Docs/admin-guide/mm/damon/usage: update for probe_hits_wsum DAMOS filter
In reply to SJ ParkUpdate DAMON usage document for the newly added probe hits weighted sum based DAMOS core filter type.
--- Documentation/admin-guide/mm/damon/usage.rst | 4 ++++ 1 file changed, 4 insertions(+)
Documentation/admin-guide/mm/damon/usage.rst +4 -0
@@ -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
Signature · 1 line
2.47.3
[email protected]
AI reviewRe: [RFC PATCH 6/6] Docs/admin-guide/mm/damon/usage: update for probe_hits_wsum DAMOS filter
Sashiko has reviewed this patch and found no issues. It looks great!
Quoted 4 lines
Update DAMON usage document for the newly added probe hits weighted sum based DAMOS core filter type.
Signed-off-by SJ Park <[email protected]>
Sashiko has reviewed this patch and found no issues. It looks great!
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=6