mm/damon: introduce perf event based access check
Subsystems (3)
cover mm/damon: introduce perf event based access check
DAMON currently only provides PTE accessed-bit based access check, this patch series adds a new perf event based access check.
Since perf event-based access checks do not require modifying the PTE accessed-bit for pages representing each damon region, this patch series also includes a feature that allows you to set upper and lower limits on the damon region size to enable access checks with finer granularity.
Using these features also requires modifications to damo, but these are not included in this patch series and are currently under development in the following branch:
https://github.com/mita/damo/tree/damo-perf-for-v3.1.0
Any feedback or advice on the patch set would be greatly appreciated.
Akinobu Mita (4):
mm/damon/core: add common code for perf event based access check mm/damon/vaddr: support perf event based access check mm/damon/paddr: support perf event based access check mm/damon: allow user to set min and max size of region
.../ABI/testing/sysfs-kernel-mm-damon | 11 + include/linux/damon.h | 42 +- mm/damon/core.c | 202 ++++- mm/damon/ops-common.h | 39 + mm/damon/paddr.c | 106 ++- mm/damon/sysfs.c | 402 +++++++++- mm/damon/tests/core-kunit.h | 2 +- mm/damon/tests/sysfs-kunit.h | 2 + mm/damon/tests/vaddr-kunit.h | 7 +- mm/damon/vaddr.c | 690 ++++++++++++++++-- 10 files changed, 1425 insertions(+), 78 deletions(-)
Signature · 1 line
2.43.0
RFC PATCH 1/4 mm/damon/core: add common code for perf event based access check
This patch creates the necessary infrastructure (structure definitions, functions, sysfs interfaces) to support perf event based access checks for both physical and virtual address space monitoring.
Perf events can be added through the following sysfs interface:
What: /sys/kernel/mm/damon/admin/kdamonds/<K>/contexts/<C>/perf_events/nr_perf_events
Description: Writing a number 'N' to this file creates the number of directories for controlling each perf event named '0' to 'N-1' under the perf_events/ directory.
What: /sys/kernel/mm/damon/admin/kdamonds/<K>/contexts/<C>/perf_events/<P>/type
Description: Writing to and reading from this file sets and gets the "type" field of struct perf_event_attr for perf event based access check.
What: /sys/kernel/mm/damon/admin/kdamonds/<K>/contexts/<C>/perf_events/<P>/config
Description: Same as above.
What: /sys/kernel/mm/damon/admin/kdamonds/<K>/contexts/<C>/perf_events/<P>/config1
Description: Same as above.
What: /sys/kernel/mm/damon/admin/kdamonds/<K>/contexts/<C>/perf_events/<P>/config2
Description: Same as above.
What: /sys/kernel/mm/damon/admin/kdamonds/<K>/contexts/<C>/perf_events/<P>/sample_freq
Description: Same as above.
What: /sys/kernel/mm/damon/admin/kdamonds/<K>/contexts/<C>/perf_events/<P>/sample_phys_addr
Description: Writing to and reading from this file sets and gets the PERF_SAMPLE_PHYS_ADDR bitfield in the "sample_type" field of struct perf_event_attr for perf event based access check.
The perf event that can be specified for the perf event based access check must be able to obtain the data source address corresponding to the sample.
If at least one perf event is specified, the perf event based access check will be enabled instead of the existing PTE accessed-bit based access check.
In other words, if no perf event is specified, the existing PTE accessed-bit based access check will be used.
Add the following common functions required for both physical and virtual address space monitoring:
damon_ops_init()
This is the function to call in the damon_operations->init callback.
Each perf event specified by the sysfs interface is initialized with perf_event_create_kernel_counter().
damon_ops_cleanup()
This is the function to call in the damon_operations->cleanup callback. Release each initialized perf event with perf_event_release_kernel().
damon_perf_prepare_access_checks()
This is the function used to implement the damon_operations->prepare_access_checks callback. Enable each initialized perf event with perf_event_enable().
--- .../ABI/testing/sysfs-kernel-mm-damon | 8 + include/linux/damon.h | 34 ++ mm/damon/core.c | 52 +++ mm/damon/ops-common.h | 21 + mm/damon/paddr.c | 4 +- mm/damon/sysfs.c | 373 +++++++++++++++++- mm/damon/vaddr.c | 216 +++++++++- 7 files changed, 700 insertions(+), 8 deletions(-)
Documentation/ABI/testing/sysfs-kernel-mm-damon +8 -0
@@ -570,3 +570,11 @@ Contact: SeongJae Park <[email protected]> Description: Reading this file returns the size of the memory in the region that passed DAMON operations layer-handled filters of the scheme in bytes. + +What: /sys/kernel/mm/damon/admin/kdamonds/<K>/contexts/<C>/perf_events/nr_perf_events +What: /sys/kernel/mm/damon/admin/kdamonds/<K>/contexts/<C>/perf_events/<P>/type +What: /sys/kernel/mm/damon/admin/kdamonds/<K>/contexts/<C>/perf_events/<P>/config +What: /sys/kernel/mm/damon/admin/kdamonds/<K>/contexts/<C>/perf_events/<P>/config1 +What: /sys/kernel/mm/damon/admin/kdamonds/<K>/contexts/<C>/perf_events/<P>/config2 +What: /sys/kernel/mm/damon/admin/kdamonds/<K>/contexts/<C>/perf_events/<P>/sample_phys_addr +What: /sys/kernel/mm/damon/admin/kdamonds/<K>/contexts/<C>/perf_events/<P>/sample_freq
include/linux/damon.h +34 -0
@@ -54,6 +54,7 @@ struct damon_size_range {* each sampling interval. * @list: List head for siblings. * @age: Age of this region. +* @accessed: Whether the region has accessed during last sampling interval. * * @nr_accesses is reset to zero for every &damon_attrs->aggr_interval and be * increased for every &damon_attrs->sample_interval if an access to the region
@@ -83,6 +84,7 @@ struct damon_region {unsigned int age;/* private: Internal value for age calculation. */ unsigned int last_nr_accesses; +bool accessed; };/**
@@ -753,6 +755,36 @@ struct damon_attrs {unsigned long aggr_samples; }; +/** +* struct damon_perf_event_attr - raw PMU event attr for access check +* +* @type: raw PMU event type for access check +* @config: raw PMU event config for access check +* @config1: raw PMU event config1 for access check +* @config2: raw PMU event config2 for access check +* @sample_phys_addr: raw PMU event PERF_SAMPLE_PHYS_ADDR in sample_type for access check +* @sample_freq: raw PMU event sample_freq for access check +*/ +struct damon_perf_event_attr { +u32 type; +u64 config; +u64 config1; +u64 config2; +bool sample_phys_addr; +u64 sample_freq; +}; + +/** +* struct damon_perf_event - perf event for access check +* +* @priv: Monitoring operations-specific data +*/ +struct damon_perf_event { +struct damon_perf_event_attr attr; +void *priv; +struct list_head list; +}; +/** * struct damon_ctx - Represents a context for each monitoring. This is the * main interface that allows users to set the attributes and get the results
@@ -777,6 +809,7 @@ struct damon_attrs {* @ops: Set of monitoring operations for given use cases. * @addr_unit: Scale factor for core to ops address conversion. * @min_sz_region: Minimum region size. +* @perf_events: Head of perf events (&damon_perf_event) list. * @adaptive_targets: Head of monitoring targets (&damon_target) list. * @schemes: Head of schemes (&damos) list. */
@@ -823,6 +856,7 @@ struct damon_ctx {unsigned long addr_unit;unsigned long min_sz_region; +struct list_head perf_events;struct list_head adaptive_targets;struct list_head schemes; };
mm/damon/core.c +52 -0
76 lines not on this page · raw message
mm/damon/ops-common.h +21 -0
@@ -23,3 +23,24 @@ bool damos_folio_filter_match(struct damos_filter *filter, struct folio *folio);unsigned long damon_migrate_pages (struct list_head *folio_list,int target_nid);bool damos_ops_has_filter (struct damos *s); + +#ifdef CONFIG_PERF_EVENTS + +void damon_perf_prepare_access_checks (struct damon_ctx *ctx,struct damon_perf_event *event); + +struct damon_perf { +struct perf_event *__percpu *event; +struct damon_perf_buffer __percpu *buffer; +}; + +#else /* CONFIG_PERF_EVENTS */ + +static inline void damon_perf_prepare_access_checks (struct damon_ctx *ctx, +struct damon_perf_event *event) +{ +} + +#endif /* CONFIG_PERF_EVENTS */ + +void damon_ops_init (struct damon_ctx *ctx); +void damon_ops_cleanup (struct damon_ctx *ctx);
mm/damon/paddr.c +2 -2
@@ -368,12 +368,12 @@ static int __init damon_pa_initcall(void) {struct damon_operations ops = { .id =DAMON_OPS_PADDR , - .init =NULL , + .init = damon_ops_init, .update =NULL , .prepare_access_checks = damon_pa_prepare_access_checks, .check_accesses = damon_pa_check_accesses, .target_valid =NULL , - .cleanup =NULL , + .cleanup = damon_ops_cleanup, .apply_scheme = damon_pa_apply_scheme, .get_scheme_score = damon_pa_scheme_score, };
mm/damon/sysfs.c +370 -3
424 lines not on this page · raw message
mm/damon/vaddr.c +213 -3
246 lines not on this page · raw message
Signature · 1 line
2.43.0
RFC PATCH 2/4 mm/damon/vaddr: support perf event based access check
In reply to Akinobu MitaThis patch adds perf event based access check for virtual address space monitoring.
The perf event that can be specified for perf event-based access check must be able to obtain the data source address corresponding to the sample.
In other words, PERF_SAMPLE_DATA_SRC must be able to be specified in perf_event_attr.sample_type
The perf event based access check is performed as follows:
1. During the sampling interval, samples of the perf event are stored in a sampling buffer.
2. After the sampling interval ends, during the access check, a histogram showing the number of accesses to each memory address is generated based on each sample contained in the sampling buffer.
If the sampling buffer is full during a sampling interval,
the sampling buffer is expanded to prepare for the next sampling interval.
If you configure the memory addresses corresponding to the perf event samples to be obtained as virtual addresses, the histogram is implemented as a two-dimensional xarray indexed by pid and virtual memory address.
If you configure perf event samples to have their corresponding memory addresses retrieved by physical addresses, the histogram is implemented using an xarray indexed by physical addresses.
3. For each monitoring target region, the number of accesses is updated based on the histogram.
--- mm/damon/ops-common.h | 18 ++ mm/damon/vaddr.c | 406 +++++++++++++++++++++++++++++++++++++++++- 2 files changed, 418 insertions(+), 6 deletions(-)
mm/damon/ops-common.h +18 -0
@@ -28,11 +28,29 @@ bool damos_ops_has_filter(struct damos *s);void damon_perf_prepare_access_checks (struct damon_ctx *ctx,struct damon_perf_event *event); +struct damon_vaddr_histogram { +struct xarray targets; +}; + +struct damon_paddr_histogram { +struct xarray accesses; +}; +struct damon_perf {struct perf_event *__percpu *event;struct damon_perf_buffer __percpu *buffer; +union { +struct damon_vaddr_histogram vaddr_histogram; +struct damon_paddr_histogram paddr_histogram; + }; }; +void damon_paddr_histogram_init (struct damon_paddr_histogram *histogram); +unsigned long damon_paddr_histogram_count (struct damon_paddr_histogram *histogram,u64 paddr); +void damon_paddr_histogram_destroy (struct damon_paddr_histogram *histogram); + +void damon_perf_populate_paddr_histogram (struct damon_ctx *ctx,struct damon_perf_event *event); +#else /* CONFIG_PERF_EVENTS */ static inline void damon_perf_prepare_access_checks(struct damon_ctx *ctx,
mm/damon/vaddr.c +400 -6
466 lines not on this page · raw message
Signature · 1 line
2.43.0
RFC PATCH 3/4 mm/damon/paddr: support perf event based access check
In reply to Akinobu MitaThis patch adds perf event based access checks for physical address spaces monitoring.
The implementation is very similar to that described in perf event based access check for virtual address space monitoring.
However, for perf events that can be specified with physical address spaces monitoring, the data source address corresponding to the sample must be obtainable as a physical address. In other words, PERF_SAMPLE_DATA_SRC and PERF_SAMPLE_PHYS_ADDR must be specifiable in perf_event_attr.sample_type.
--- mm/damon/paddr.c | 102 ++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 96 insertions(+), 6 deletions(-)
mm/damon/paddr.c +96 -6
@@ -48,7 +48,7 @@ static void damon_pa_mkold(phys_addr_t paddr)folio_put (folio); } -static void __damon_pa_prepare_access_check (struct damon_region *r, +static void __damon_pa_basic_prepare_access_check (struct damon_region *r,unsigned long addr_unit) { r->sampling_addr =damon_rand (r->ar.start, r->ar.end);
@@ -56,14 +56,14 @@ static void __damon_pa_prepare_access_check(struct damon_region *r,damon_pa_mkold (damon_pa_phys_addr (r->sampling_addr, addr_unit)); } -static void damon_pa_prepare_access_checks (struct damon_ctx *ctx) +static void damon_pa_basic_prepare_access_checks (struct damon_ctx *ctx) {struct damon_target *t;struct damon_region *r;damon_for_each_target (t, ctx) {damon_for_each_region (r, t) -__damon_pa_prepare_access_check (r, ctx->addr_unit); +__damon_pa_basic_prepare_access_check (r, ctx->addr_unit); } }
@@ -81,7 +81,7 @@ static bool damon_pa_young(phys_addr_t paddr, unsigned long *folio_sz)return accessed; } -static void __damon_pa_check_access (struct damon_region *r, +static void __damon_pa_basic_check_access (struct damon_region *r,struct damon_attrs *attrs,unsigned long addr_unit) {static phys_addr_t last_addr;
@@ -103,7 +103,7 @@ static void __damon_pa_check_access(struct damon_region *r, last_addr = sampling_addr; } -static unsigned int damon_pa_check_accesses (struct damon_ctx *ctx) +static unsigned int damon_pa_basic_check_accesses (struct damon_ctx *ctx) {struct damon_target *t;struct damon_region *r;
@@ -111,7 +111,7 @@ static unsigned int damon_pa_check_accesses(struct damon_ctx *ctx)damon_for_each_target (t, ctx) {damon_for_each_region (r, t) { -__damon_pa_check_access ( +__damon_pa_basic_check_access ( r, &ctx->attrs, ctx->addr_unit); max_nr_accesses =max (r->nr_accesses, max_nr_accesses); }
@@ -364,6 +364,96 @@ static int damon_pa_scheme_score(struct damon_ctx *context,return DAMOS_MAX_SCORE ; } +#ifdef CONFIG_PERF_EVENTS + +static void damon_pa_perf_check_accesses (struct damon_ctx *ctx,struct damon_perf_event *event) +{ +struct damon_perf *perf = event->priv; +struct damon_target *t; +unsigned int tidx =0 ; + +if (!perf) +return ; + +damon_paddr_histogram_init (&perf->paddr_histogram); + +damon_perf_populate_paddr_histogram (ctx, event); + +damon_for_each_target (t, ctx) { +struct damon_region *r; +unsigned int nr_accessed =0 ; + +damon_for_each_region (r, t) { +unsigned long addr; + +if (r->accessed) +continue ; + +for (addr = r->ar.start; addr < r->ar.end; addr +=PAGE_SIZE ) { +if (damon_paddr_histogram_count (&perf->paddr_histogram, + addr &PAGE_MASK )) { + r->accessed = true; + nr_accessed++; +break ; + } + } + } + tidx++; + } + +damon_paddr_histogram_destroy (&perf->paddr_histogram); +} + +#else /* CONFIG_PERF_EVENTS */ + +static void damon_pa_perf_check_accesses (struct damon_ctx *ctx,struct damon_perf_event *event) +{ +} + +#endif /* CONFIG_PERF_EVENTS */ + +static void damon_pa_prepare_access_checks (struct damon_ctx *ctx) +{ +struct damon_perf_event *event; + +if (list_empty (&ctx->perf_events)) +return damon_pa_basic_prepare_access_checks (ctx); + +list_for_each_entry (event, &ctx->perf_events, list) +damon_perf_prepare_access_checks (ctx, event); +} + +static unsigned int damon_pa_check_accesses (struct damon_ctx *ctx) +{ +struct damon_target *t; +struct damon_perf_event *event; +unsigned int max_nr_accesses =0 ; + +if (list_empty (&ctx->perf_events)) +return damon_pa_basic_check_accesses (ctx); + +damon_for_each_target (t, ctx) { +struct damon_region *r; + +damon_for_each_region (r, t) + r->accessed = false; + } + +list_for_each_entry (event, &ctx->perf_events, list) +damon_pa_perf_check_accesses (ctx, event); + +damon_for_each_target (t, ctx) { +struct damon_region *r; + +damon_for_each_region (r, t) { +damon_update_region_access_rate (r, r->accessed, &ctx->attrs); + max_nr_accesses =max (r->nr_accesses, max_nr_accesses); + } + } + +return max_nr_accesses; +} +static int __init damon_pa_initcall (void ) {struct damon_operations ops = {
Signature · 1 line
2.43.0
RFC PATCH 4/4 mm/damon: allow user to set min and max size of region
In reply to Akinobu MitaCurrently, the region size is limited to a page size or more, but this patch makes it possible to set the upper and lower limits using the following sysfs interfaces:
What: /sys/kernel/mm/damon/admin/kdamonds/<K>/contexts/<C>/targets/<T>/region_sz/min
Description: Writing a value to this file sets the minimum size of monitoring regions of the DAMON target as the value. Reading this file returns the value.
What: /sys/kernel/mm/damon/admin/kdamonds/<K>/contexts/<C>/targets/<T>/region_sz/max
Description: Writing a value to this file sets the maximum size of monitoring regions of the DAMON target as the value. Reading this file returns the value.
By setting the minimum and maximum sizes of regions to the same value, the region size can be kept constant (no region merging or splitting).
This patch allows you to set the minimum and maximum size of a region, so it may not be possible to simultaneously satisfy the existing minimum and maximum settings for the number of damon regions (min_regions, max_regions).
--- .../ABI/testing/sysfs-kernel-mm-damon | 3 + include/linux/damon.h | 8 +- mm/damon/core.c | 150 +++++++++++++++--- mm/damon/sysfs.c | 29 +++- mm/damon/tests/core-kunit.h | 2 +- mm/damon/tests/sysfs-kunit.h | 2 + mm/damon/tests/vaddr-kunit.h | 7 +- mm/damon/vaddr.c | 68 ++++---- 8 files changed, 211 insertions(+), 58 deletions(-)
Documentation/ABI/testing/sysfs-kernel-mm-damon +3 -0
@@ -571,6 +571,9 @@ Description: Reading this file returns the size of the memory in the region that passed DAMON operations layer-handled filters of the scheme in bytes. +What: /sys/kernel/mm/damon/admin/kdamonds/<K>/contexts/<C>/targets/<T>/region_sz/min +What: /sys/kernel/mm/damon/admin/kdamonds/<K>/contexts/<C>/targets/<T>/region_sz/max + What: /sys/kernel/mm/damon/admin/kdamonds/<K>/contexts/<C>/perf_events/nr_perf_events What: /sys/kernel/mm/damon/admin/kdamonds/<K>/contexts/<C>/perf_events/<P>/type What: /sys/kernel/mm/damon/admin/kdamonds/<K>/contexts/<C>/perf_events/<P>/config
include/linux/damon.h +7 -1
@@ -91,6 +91,8 @@ struct damon_region {* struct damon_target - Represents a monitoring target. * @pid: The PID of the virtual address space to monitor. * @nr_regions: Number of monitoring target regions of this target. +* @min_region_sz: The minimum size of adaptive monitoring regions. +* @max_region_sz: The maximum size of adaptive monitoring regions. * @regions_list: Head of the monitoring target regions of this target. * @list: List head for siblings. * @obsolete: Whether the commit destination target is obsolete.
@@ -107,6 +109,8 @@ struct damon_region {struct damon_target {struct pid *pid;unsigned int nr_regions; +unsigned long min_region_sz; +unsigned long max_region_sz;struct list_head regions_list;struct list_head list;bool obsolete;
@@ -944,7 +948,7 @@ static inline void damon_insert_region(struct damon_region *r,void damon_add_region (struct damon_region *r,struct damon_target *t);void damon_destroy_region (struct damon_region *r,struct damon_target *t);int damon_set_regions (struct damon_target *t,struct damon_addr_range *ranges, -unsigned int nr_ranges,unsigned long min_sz_region); +unsigned int nr_ranges,unsigned long min_sz_region,bool split);void damon_update_region_access_rate (struct damon_region *r,bool accessed,struct damon_attrs *attrs);
@@ -1013,6 +1017,8 @@ int damos_walk(struct damon_ctx *ctx, struct damos_walk_control *control);int damon_set_region_biggest_system_ram_default (struct damon_target *t,unsigned long *start,unsigned long *end,unsigned long min_sz_region); +int damon_evenly_split_region (struct damon_target *t, +struct damon_region *r,unsigned int nr_pieces,unsigned long sz_piece);#endif /* CONFIG_DAMON */
mm/damon/core.c +131 -19
310 lines not on this page · raw message
mm/damon/sysfs.c +27 -2
@@ -211,6 +211,7 @@ static const struct kobj_type damon_sysfs_regions_ktype = {struct damon_sysfs_target {struct kobject kobj;struct damon_sysfs_regions *regions; +struct damon_sysfs_ul_range *region_sz_range;int pid;bool obsolete; };
@@ -223,6 +224,7 @@ static struct damon_sysfs_target *damon_sysfs_target_alloc(void)static int damon_sysfs_target_add_dirs (struct damon_sysfs_target *target) {struct damon_sysfs_regions *regions =damon_sysfs_regions_alloc (); +struct damon_sysfs_ul_range *region_sz_range;int err;if (!regions)
@@ -231,14 +233,35 @@ static int damon_sysfs_target_add_dirs(struct damon_sysfs_target *target) err =kobject_init_and_add (®ions->kobj, &damon_sysfs_regions_ktype, &target->kobj,"regions" );if (err) -kobject_put (®ions->kobj); + goto put_regions_out;else target->regions = regions; + + region_sz_range =damon_sysfs_ul_range_alloc (0 ,0 ); +if (!region_sz_range) { + err = -ENOMEM ; + goto put_regions_out; + } + + err =kobject_init_and_add (®ion_sz_range->kobj, + &damon_sysfs_ul_range_ktype, &target->kobj,"region_sz" ); +if (err) + goto put_region_sz_out; + target->region_sz_range = region_sz_range; +return 0 ; + +put_region_sz_out: +kobject_put (®ion_sz_range->kobj); + target->region_sz_range =NULL ; +put_regions_out: +kobject_put (®ions->kobj); + target->regions =NULL ;return err; }static void damon_sysfs_target_rm_dirs (struct damon_sysfs_target *target) { +kobject_put (&target->region_sz_range->kobj);damon_sysfs_regions_rm_dirs (target->regions);kobject_put (&target->regions->kobj); }
@@ -1717,7 +1740,7 @@ static int damon_sysfs_set_regions(struct damon_target *t,if (ranges[i -1 ].end > ranges[i].start) goto out; } - err =damon_set_regions (t, ranges, sysfs_regions->nr, min_sz_region); + err =damon_set_regions (t, ranges, sysfs_regions->nr, min_sz_region, true); out:kfree (ranges);return err;
@@ -1739,6 +1762,8 @@ static int damon_sysfs_add_target(struct damon_sysfs_target *sys_target,return -EINVAL ; } t->obsolete = sys_target->obsolete; + t->min_region_sz = sys_target->region_sz_range->min; + t->max_region_sz = sys_target->region_sz_range->max;return damon_sysfs_set_regions (t, sys_target->regions, ctx->min_sz_region); }
mm/damon/tests/core-kunit.h +1 -1
@@ -399,7 +399,7 @@ static void damon_test_set_regions(struct kunit *test)damon_add_region (r1, t);damon_add_region (r2, t); -damon_set_regions (t, &range,1 ,1 ); +damon_set_regions (t, &range,1 ,1 , false);KUNIT_EXPECT_EQ (test,damon_nr_regions (t),3 );damon_for_each_region (r, t) {
mm/damon/tests/sysfs-kunit.h +2 -0
@@ -70,6 +70,7 @@ static void damon_sysfs_test_add_targets(struct kunit *test)kunit_skip (test,"sysfs_regions alloc fail" ); } + sysfs_target->region_sz_range =damon_sysfs_ul_range_alloc (0 ,0 ); sysfs_targets->targets_arr[0 ] = sysfs_target; ctx =damon_new_ctx ();
@@ -93,6 +94,7 @@ static void damon_sysfs_test_add_targets(struct kunit *test)kfree (sysfs_targets->targets_arr);kfree (sysfs_targets);kfree (sysfs_target->regions); +kfree (sysfs_target->region_sz_range);kfree (sysfs_target); }
mm/damon/tests/vaddr-kunit.h +5 -2
@@ -65,6 +65,7 @@ static int __link_vmas(struct maple_tree *mt, struct vm_area_struct *vmas,*/ static void damon_test_three_regions_in_vmas (struct kunit *test) { +struct damon_target *t =damon_new_target ();static struct mm_struct mm;struct damon_addr_range regions[3 ] = {0 };/* 10-20-25, 200-210-220, 300-305, 307-330 */
@@ -81,7 +82,7 @@ static void damon_test_three_regions_in_vmas(struct kunit *test)if (__link_vmas (&mm.mm_mt, vmas,ARRAY_SIZE (vmas)))kunit_skip (test,"Failed to create VMA tree" ); -__damon_va_three_regions (&mm, regions); +__damon_va_three_regions (t, &mm, regions);KUNIT_EXPECT_EQ (test,10ul , regions[0 ].start);KUNIT_EXPECT_EQ (test,25ul , regions[0 ].end);
@@ -89,6 +90,8 @@ static void damon_test_three_regions_in_vmas(struct kunit *test)KUNIT_EXPECT_EQ (test,220ul , regions[1 ].end);KUNIT_EXPECT_EQ (test,300ul , regions[2 ].start);KUNIT_EXPECT_EQ (test,330ul , regions[2 ].end); + +damon_free_target (t); }static struct damon_region *__nth_region_of (struct damon_target *t,int idx)
@@ -147,7 +150,7 @@ static void damon_do_test_apply_three_regions(struct kunit *test,damon_add_region (r, t); } -damon_set_regions (t, three_regions,3 ,DAMON_MIN_REGION ); +damon_set_regions (t, three_regions,3 ,DAMON_MIN_REGION , false);for (i =0 ; i < nr_expected /2 ; i++) { r =__nth_region_of (t, i);
mm/damon/vaddr.c +35 -33
132 lines not on this page · raw message
Signature · 1 line
2.43.0
SeongJae Park
maintainerQuoted 2 lines · On Fri, 23 Jan 2026 11:10:10 +0900 Akinobu Mita <[email protected]> wrote:
DAMON currently only provides PTE accessed-bit based access check, this patch series adds a new perf event based access check.
Very interesting patch series. Thank you for sharing this Akinobu!
I only took a glance on the patches, but my understanding is that this series modifies DAMON to be able to enable perf events of PERF_SAMPLE_ADDR type, and utilize the sampled perf events in the perf events buffer as the source of DAMON's access checks. In more detail, I understand enabling PERF_SAMPLE_ADDR type perf events makes the perf events buffer filled with memory access event information with the access destination address. The event will be sampled based on time (e.g., one access event per X milliseconds). And probably that sample data could include more information includign the CPU and the process that executing the sampled access? Please correct me if I'm wrong and add more details I'm missing, as my understanding of perf event is very poor.
And one quick question. Can this work on virtual machines? I'm asking this question the for following reason. I'm actuaally working on a similar project that extends DAMON for page fault based access events sampling [1]. The project aims to use page fault event rather than other h/w features such as AMD IBS or Intel PEBS, because my understanding is that such h/w features are not available on virtual machines.
Quoted 5 lines
Since perf event-based access checks do not require modifying the PTE accessed-bit for pages representing each damon region, this patch series also includes a feature that allows you to set upper and lower limits on the damon region size to enable access checks with finer granularity.
I was also thinking about extending DAMON with AMD IBS or Intel PEBS like h/w features for this kind of sub-page granularity access monitoring. So this makes sense to me, and sounds useful!
Quoted 5 lines
Using these features also requires modifications to damo, but these are not included in this patch series and are currently under development in the following branch:
Quoted 8 lines
https://github.com/mita/damo/tree/damo-perf-for-v3.1.0
Any feedback or advice on the patch set would be greatly appreciated.
Akinobu Mita (4):
mm/damon/core: add common code for perf event based access checkmm/damon/vaddr: support perf event based access checkmm/damon/paddr: support perf event based access check
I find your patches are introducing new infra code for this extension. It seems bit specialized for perf event only, though. I'm concerned if future extension for another access check primitives cannot reuse the infra.
My DAMON extension project [1] is for page fault based access monitoring, but it also introduces a framework for general multiple access sampling primitives. I'm wondering if perf event based extension can be implemented using the general acces ssampling primitives infra code, and if you already considered that but found it is not feasible.
Quoted 1 line
mm/damon: allow user to set min and max size of region
The min size setup makes sense. I understand the max size is for disabling the regions adjustment (merge/split) mechanism. IOW, for fixed granularity monitoring. Users can do that by setting min_nr_regions and max_nr_regions same [2], though. So, max size setting seems not really needed.
Again, great RFC patch series, thank you for sharing! I'm looking forward to your answers to above high level questions and comments.
Quoted 15 lines
.../ABI/testing/sysfs-kernel-mm-damon | 11 + include/linux/damon.h | 42 +- mm/damon/core.c | 202 ++++- mm/damon/ops-common.h | 39 + mm/damon/paddr.c | 106 ++- mm/damon/sysfs.c | 402 +++++++++- mm/damon/tests/core-kunit.h | 2 +- mm/damon/tests/sysfs-kunit.h | 2 + mm/damon/tests/vaddr-kunit.h | 7 +- mm/damon/vaddr.c | 690 ++++++++++++++++-- 10 files changed, 1425 insertions(+), 78 deletions(-)Signature · 1 line
2.43.0
[1] https://lore.kernel.org/damon/[email protected]/
[2] https://origin.kernel.org/doc/html/latest/mm/damon/faq.html#can-i-simply-monitor-page-granularity
Thanks,
SJ
SeongJae Park
maintainerCc-ing linux-perf-users@ for any comment from perf people, about the use of perf event from DAMON.
Thanks,
SJ
Quoted 92 lines · On Fri, 23 Jan 2026 18:39:20 SeongJae Park <[email protected]> wrote:
Quoted 2 lines · On Fri, 23 Jan 2026 11:10:10 +0900 Akinobu Mita <[email protected]> wrote:
DAMON currently only provides PTE accessed-bit based access check, this patch series adds a new perf event based access check.
Very interesting patch series. Thank you for sharing this Akinobu!
I only took a glance on the patches, but my understanding is that this series modifies DAMON to be able to enable perf events of
PERF_SAMPLE_ADDRtype, and utilize the sampled perf events in the perf events buffer as the source of DAMON's access checks. In more detail, I understand enablingPERF_SAMPLE_ADDRtype perf events makes the perf events buffer filled with memory access event information with the access destination address. The event will be sampled based on time (e.g., one access event per X milliseconds). And probably that sample data could include more information includign the CPU and the process that executing the sampled access? Please correct me if I'm wrong and add more details I'm missing, as my understanding of perf event is very poor.And one quick question. Can this work on virtual machines? I'm asking this question the for following reason. I'm actuaally working on a similar project that extends DAMON for page fault based access events sampling [1]. The project aims to use page fault event rather than other h/w features such as AMD IBS or Intel PEBS, because my understanding is that such h/w features are not available on virtual machines.
Quoted 5 lines
Since perf event-based access checks do not require modifying the PTE accessed-bit for pages representing each damon region, this patch series also includes a feature that allows you to set upper and lower limits on the damon region size to enable access checks with finer granularity.
I was also thinking about extending DAMON with AMD IBS or Intel PEBS like h/w features for this kind of sub-page granularity access monitoring. So this makes sense to me, and sounds useful!
Quoted 5 lines
Using these features also requires modifications to damo, but these are not included in this patch series and are currently under development in the following branch:
Quoted 8 lines
https://github.com/mita/damo/tree/damo-perf-for-v3.1.0
Any feedback or advice on the patch set would be greatly appreciated.
Akinobu Mita (4):
mm/damon/core: add common code for perf event based access checkmm/damon/vaddr: support perf event based access checkmm/damon/paddr: support perf event based access checkI find your patches are introducing new infra code for this extension. It seems bit specialized for perf event only, though. I'm concerned if future extension for another access check primitives cannot reuse the infra.
My DAMON extension project [1] is for page fault based access monitoring, but it also introduces a framework for general multiple access sampling primitives. I'm wondering if perf event based extension can be implemented using the general acces ssampling primitives infra code, and if you already considered that but found it is not feasible.
Quoted 1 line
mm/damon: allow user to set min and max size of region
The min size setup makes sense. I understand the max size is for disabling the regions adjustment (merge/split) mechanism. IOW, for fixed granularity monitoring. Users can do that by setting
min_nr_regionsandmax_nr_regionssame [2], though. So, max size setting seems not really needed.Again, great RFC patch series, thank you for sharing! I'm looking forward to your answers to above high level questions and comments.
Quoted 15 lines
.../ABI/testing/sysfs-kernel-mm-damon | 11 + include/linux/damon.h | 42 +- mm/damon/core.c | 202 ++++- mm/damon/ops-common.h | 39 + mm/damon/paddr.c | 106 ++- mm/damon/sysfs.c | 402 +++++++++- mm/damon/tests/core-kunit.h | 2 +- mm/damon/tests/sysfs-kunit.h | 2 + mm/damon/tests/vaddr-kunit.h | 7 +- mm/damon/vaddr.c | 690 ++++++++++++++++-- 10 files changed, 1425 insertions(+), 78 deletions(-)Signature · 1 line
2.43.0[1] https://lore.kernel.org/damon/[email protected]/
[2] https://origin.kernel.org/doc/html/latest/mm/damon/faq.html#can-i-simply-monitor-page-granularityThanks,
SJ
Hello,
Quoted 2 lines · SeongJae Park
Cc-ing linux-perf-users@ for any comment from perf people, about the use of perf event from DAMON.
Sorry for the long delay.
Quoted 10 lines · On Fri, 23 Jan 2026 18:39:20 SeongJae Park <[email protected]> wrote:
Quoted 8 lines · On Fri, 23 Jan 2026 11:10:10 +0900 Akinobu Mita <[email protected]> wrote:
Quoted 3 lines
DAMON currently only provides PTE accessed-bit based access check, this patch series adds a new perf event based access check.
Very interesting patch series. Thank you for sharing this Akinobu!
Quoted 10 lines
Quoted 10 lines
I only took a glance on the patches, but my understanding is that this series modifies DAMON to be able to enable perf events of
PERF_SAMPLE_ADDRtype, and utilize the sampled perf events in the perf events buffer as the source of DAMON's access checks. In more detail, I understand enablingPERF_SAMPLE_ADDRtype perf events makes the perf events buffer filled with memory access event information with the access destination address. The event will be sampled based on time (e.g., one access event per X milliseconds). And probably that sample data could include more information includign the CPU and the process that executing the sampled access? Please correct me if I'm wrong and add more details I'm missing, as my understanding of perf event is very poor.
I'm afraid you need to deal with PMU hardware details. For example PERF_SAMPLE_ADDR may not be available depends on events or sometimes it may not have valid values in some samples like on AMD IBS. Also hybrid CPUs may not have same events on both CPUs.
Maybe it's better to fix which event you want to use on each CPU architecture.
Quoted 7 lines
Quoted 7 lines
And one quick question. Can this work on virtual machines? I'm asking this question the for following reason. I'm actuaally working on a similar project that extends DAMON for page fault based access events sampling [1]. The project aims to use page fault event rather than other h/w features such as AMD IBS or Intel PEBS, because my understanding is that such h/w features are not available on virtual machines.
KVM supports PMU virtualization. But the existing vPMU support has a lot of overhead. Recently mediated vPMU patchset was added so you can try that instead. You'll need to pass appropriate options to qemu.
https://lore.kernel.org/lkml/[email protected]/
Thanks,
Namhyung
Quoted 68 lines
Quoted 68 lines
Quoted 6 lines
Since perf event-based access checks do not require modifying the PTE accessed-bit for pages representing each damon region, this patch series also includes a feature that allows you to set upper and lower limits on the damon region size to enable access checks with finer granularity.
I was also thinking about extending DAMON with AMD IBS or Intel PEBS like h/w features for this kind of sub-page granularity access monitoring. So this makes sense to me, and sounds useful!
Quoted 5 lines
Using these features also requires modifications to damo, but these are not included in this patch series and are currently under development in the following branch:
Quoted 8 lines
https://github.com/mita/damo/tree/damo-perf-for-v3.1.0
Any feedback or advice on the patch set would be greatly appreciated.
Akinobu Mita (4):
mm/damon/core: add common code for perf event based access checkmm/damon/vaddr: support perf event based access checkmm/damon/paddr: support perf event based access checkI find your patches are introducing new infra code for this extension. It seems bit specialized for perf event only, though. I'm concerned if future extension for another access check primitives cannot reuse the infra.
My DAMON extension project [1] is for page fault based access monitoring, but it also introduces a framework for general multiple access sampling primitives. I'm wondering if perf event based extension can be implemented using the general acces ssampling primitives infra code, and if you already considered that but found it is not feasible.
Quoted 1 line
mm/damon: allow user to set min and max size of region
The min size setup makes sense. I understand the max size is for disabling the regions adjustment (merge/split) mechanism. IOW, for fixed granularity monitoring. Users can do that by setting
min_nr_regionsandmax_nr_regionssame [2], though. So, max size setting seems not really needed.Again, great RFC patch series, thank you for sharing! I'm looking forward to your answers to above high level questions and comments.
Quoted 15 lines
.../ABI/testing/sysfs-kernel-mm-damon | 11 + include/linux/damon.h | 42 +- mm/damon/core.c | 202 ++++- mm/damon/ops-common.h | 39 + mm/damon/paddr.c | 106 ++- mm/damon/sysfs.c | 402 +++++++++- mm/damon/tests/core-kunit.h | 2 +- mm/damon/tests/sysfs-kunit.h | 2 + mm/damon/tests/vaddr-kunit.h | 7 +- mm/damon/vaddr.c | 690 ++++++++++++++++-- 10 files changed, 1425 insertions(+), 78 deletions(-)Signature · 1 line
2.43.0[1] https://lore.kernel.org/damon/[email protected]/
[2] https://origin.kernel.org/doc/html/latest/mm/damon/faq.html#can-i-simply-monitor-page-granularityThanks,
SJ
2026年2月23日(月) 17:08 Namhyung Kim <[email protected]>:
Quoted 30 lines
Hello,
Quoted 2 lines · SeongJae Park
Cc-ing linux-perf-users@ for any comment from perf people, about the use of perf event from DAMON.
Sorry for the long delay.
Quoted 10 lines · On Fri, 23 Jan 2026 18:39:20 SeongJae Park <[email protected]> wrote:
Quoted 8 lines · On Fri, 23 Jan 2026 11:10:10 +0900 Akinobu Mita <[email protected]> wrote:
Quoted 3 lines
DAMON currently only provides PTE accessed-bit based access check, this patch series adds a new perf event based access check.
Very interesting patch series. Thank you for sharing this Akinobu!
Quoted 10 lines
Quoted 10 lines
I only took a glance on the patches, but my understanding is that this series modifies DAMON to be able to enable perf events of
PERF_SAMPLE_ADDRtype, and utilize the sampled perf events in the perf events buffer as the source of DAMON's access checks. In more detail, I understand enablingPERF_SAMPLE_ADDRtype perf events makes the perf events buffer filled with memory access event information with the access destination address. The event will be sampled based on time (e.g., one access event per X milliseconds). And probably that sample data could include more information includign the CPU and the process that executing the sampled access? Please correct me if I'm wrong and add more details I'm missing, as my understanding of perf event is very poor.
Quoted 7 lines
I'm afraid you need to deal with PMU hardware details. For example
PERF_SAMPLE_ADDRmay not be available depends on events or sometimes it may not have valid values in some samples like on AMD IBS. Also hybrid CPUs may not have same events on both CPUs.Maybe it's better to fix which event you want to use on each CPU architecture.
Thank you for your advice.
Is it possible to get a list of PMUs that have the ability to get addresses (PERF_SAMPLE_ADDR or PERF_SAMPLE_PHYS_ADDR) from the kernel at runtime?
Or is it possible to detect that a perf_event initialized with a certain perf_event_attr does not have the ability to obtain the address?
Quoted 7 lines
Quoted 6 lines
Quoted 6 lines
And one quick question. Can this work on virtual machines? I'm asking this question the for following reason. I'm actuaally working on a similar project that extends DAMON for page fault based access events sampling [1]. The project aims to use page fault event rather than other h/w features such as AMD IBS or Intel PEBS, because my understanding is that such h/w features are not available on virtual machines.
Quoted 5 lines
KVM supports PMU virtualization. But the existing vPMU support has a lot of overhead. Recently mediated vPMU patchset was added so you can try that instead. You'll need to pass appropriate options to qemu.
Thank you for the important information.
Quoted 36 lines · Akinobu Mita
2026年2月23日(月) 17:08 Namhyung Kim <[email protected]>:
Quoted 35 lines
Hello,
Quoted 2 lines · SeongJae Park
Cc-ing linux-perf-users@ for any comment from perf people, about the use of perf event from DAMON.
Sorry for the long delay.
Quoted 10 lines · On Fri, 23 Jan 2026 18:39:20 SeongJae Park <[email protected]> wrote:
Quoted 8 lines · On Fri, 23 Jan 2026 11:10:10 +0900 Akinobu Mita <[email protected]> wrote:
Quoted 3 lines
DAMON currently only provides PTE accessed-bit based access check, this patch series adds a new perf event based access check.
Very interesting patch series. Thank you for sharing this Akinobu!
Quoted 10 lines
Quoted 10 lines
I only took a glance on the patches, but my understanding is that this series modifies DAMON to be able to enable perf events of
PERF_SAMPLE_ADDRtype, and utilize the sampled perf events in the perf events buffer as the source of DAMON's access checks. In more detail, I understand enablingPERF_SAMPLE_ADDRtype perf events makes the perf events buffer filled with memory access event information with the access destination address. The event will be sampled based on time (e.g., one access event per X milliseconds). And probably that sample data could include more information includign the CPU and the process that executing the sampled access? Please correct me if I'm wrong and add more details I'm missing, as my understanding of perf event is very poor.I'm afraid you need to deal with PMU hardware details. For example
PERF_SAMPLE_ADDRmay not be available depends on events or sometimes it may not have valid values in some samples like on AMD IBS. Also hybrid CPUs may not have same events on both CPUs.
Quoted 7 lines
Quoted 2 lines
Maybe it's better to fix which event you want to use on each CPU architecture.
Thank you for your advice.
Is it possible to get a list of PMUs that have the ability to get addresses (
PERF_SAMPLE_ADDRorPERF_SAMPLE_PHYS_ADDR) from the kernel at runtime?
You can lookup 'mem-loads' events on Intel CPUs. It should be 'cpu', 'cpu_core' and/or 'cpu_atom'. On AMD, you can use 'ibs_op'.
$ grep -l . /sys/bus/event_source/devices/*/events/mem-loads /sys/bus/event_source/devices/cpu/events/mem-loads
Quoted 3 lines
Or is it possible to detect that a
perf_eventinitialized with a certainperf_event_attrdoes not have the ability to obtain the address?
I don't think so. IIRC it will just have address of 0 if not supported.
Quoted 8 lines
Quoted 8 lines
Quoted 7 lines
Quoted 7 lines
And one quick question. Can this work on virtual machines? I'm asking this question the for following reason. I'm actuaally working on a similar project that extends DAMON for page fault based access events sampling [1]. The project aims to use page fault event rather than other h/w features such as AMD IBS or Intel PEBS, because my understanding is that such h/w features are not available on virtual machines.
Quoted 7 lines
Quoted 5 lines
KVM supports PMU virtualization. But the existing vPMU support has a lot of overhead. Recently mediated vPMU patchset was added so you can try that instead. You'll need to pass appropriate options to qemu.
Thank you for the important information.
No problem! You may go with the existing vPMU if you just plan to use a couple of events only.
Thanks,
Namhyung
2026年1月24日(土) 11:39 SeongJae Park <[email protected]>:
Quoted 8 lines · On Fri, 23 Jan 2026 11:10:10 +0900 Akinobu Mita <[email protected]> wrote:
Quoted 3 lines
DAMON currently only provides PTE accessed-bit based access check, this patch series adds a new perf event based access check.
Very interesting patch series. Thank you for sharing this Akinobu!
Quoted 10 lines
I only took a glance on the patches, but my understanding is that this series modifies DAMON to be able to enable perf events of
PERF_SAMPLE_ADDRtype, and utilize the sampled perf events in the perf events buffer as the source of DAMON's access checks. In more detail, I understand enablingPERF_SAMPLE_ADDRtype perf events makes the perf events buffer filled with memory access event information with the access destination address. The event will be sampled based on time (e.g., one access event per X milliseconds). And probably that sample data could include more information includign the CPU and the process that executing the sampled access? Please correct me if I'm wrong and add more details I'm missing, as my understanding of perf event is very poor.
Your understanding is correct.
One thing to note is that you need to specify a PMU event that can obtain the data address at the time of sampling.
In other words, it must be a PMU that can be used with "perf mem record".
Quoted 6 lines
And one quick question. Can this work on virtual machines? I'm asking this question the for following reason. I'm actuaally working on a similar project that extends DAMON for page fault based access events sampling [1]. The project aims to use page fault event rather than other h/w features such as AMD IBS or Intel PEBS, because my understanding is that such h/w features are not available on virtual machines.
I haven't tried it on a virtual machine yet.
As mentioned above, if "perf mem record" works on a virtual machine, you can specify its PMU, but it may not be supported at all.
Quoted 27 lines
Quoted 4 lines
Since perf event-based access checks do not require modifying the PTE accessed-bit for pages representing each damon region, this patch series also includes a feature that allows you to set upper and lower limits on the damon region size to enable access checks with finer granularity.
I was also thinking about extending DAMON with AMD IBS or Intel PEBS like h/w features for this kind of sub-page granularity access monitoring. So this makes sense to me, and sounds useful!
Quoted 5 lines
Using these features also requires modifications to damo, but these are not included in this patch series and are currently under development in the following branch:
Quoted 8 lines
https://github.com/mita/damo/tree/damo-perf-for-v3.1.0
Any feedback or advice on the patch set would be greatly appreciated.
Akinobu Mita (4):
mm/damon/core: add common code for perf event based access checkmm/damon/vaddr: support perf event based access checkmm/damon/paddr: support perf event based access checkI find your patches are introducing new infra code for this extension. It seems bit specialized for perf event only, though. I'm concerned if future extension for another access check primitives cannot reuse the infra.
Quoted 5 lines
My DAMON extension project [1] is for page fault based access monitoring, but it also introduces a framework for general multiple access sampling primitives. I'm wondering if perf event based extension can be implemented using the general acces ssampling primitives infra code, and if you already considered that but found it is not feasible.
If such infrastructure code exists, I would like to use it, so I will consider it.
Quoted 6 lines
Quoted 1 line
mm/damon: allow user to set min and max size of region
The min size setup makes sense. I understand the max size is for disabling the regions adjustment (merge/split) mechanism. IOW, for fixed granularity monitoring. Users can do that by setting
min_nr_regionsandmax_nr_regionssame [2], though. So, max size setting seems not really needed.
Yes, if fixed granularity monitoring is possible then that is sufficient.
I have tried setting min_nr_regions and max_nr_regions to be the same. I understand that the region split progresses over time and results in fixed-granularity monitoring at the minimum region size, but since my configuration has a relatively long sampling interval, it takes time to reach that state.
So in the patch, when adding a new region with damon_set_regions(), it will be split by the maximum region size.
Quoted 2 lines
Again, great RFC patch series, thank you for sharing! I'm looking forward to your answers to above high level questions and comments.
Thank you so much for checking out the patch.
SeongJae Park
maintainerQuoted 20 lines · On Tue, 27 Jan 2026 10:29:53 +0900 Akinobu Mita <[email protected]> wrote:
2026年1月24日(土) 11:39 SeongJae Park <[email protected]>:
Quoted 8 lines · On Fri, 23 Jan 2026 11:10:10 +0900 Akinobu Mita <[email protected]> wrote:
Quoted 3 lines
DAMON currently only provides PTE accessed-bit based access check, this patch series adds a new perf event based access check.
Very interesting patch series. Thank you for sharing this Akinobu!
Quoted 10 lines
I only took a glance on the patches, but my understanding is that this series modifies DAMON to be able to enable perf events of
PERF_SAMPLE_ADDRtype, and utilize the sampled perf events in the perf events buffer as the source of DAMON's access checks. In more detail, I understand enablingPERF_SAMPLE_ADDRtype perf events makes the perf events buffer filled with memory access event information with the access destination address. The event will be sampled based on time (e.g., one access event per X milliseconds). And probably that sample data could include more information includign the CPU and the process that executing the sampled access? Please correct me if I'm wrong and add more details I'm missing, as my understanding of perf event is very poor.
Quoted 6 lines
Your understanding is correct.
One thing to note is that you need to specify a PMU event that can obtain the data address at the time of sampling.
In other words, it must be a PMU that can be used with "perf mem record".
Thank you for confirming and adding the detail.
Quoted 11 lines
Quoted 7 lines
And one quick question. Can this work on virtual machines? I'm asking this question the for following reason. I'm actuaally working on a similar project that extends DAMON for page fault based access events sampling [1]. The project aims to use page fault event rather than other h/w features such as AMD IBS or Intel PEBS, because my understanding is that such h/w features are not available on virtual machines.
I haven't tried it on a virtual machine yet.
As mentioned above, if "perf mem record" works on a virtual machine, you can specify its PMU, but it may not be supported at all.
Seems that's the case at least for my setup. :'( On my QEMU-based machine, 'perf mem record' fails like below.
$ sudo perf mem record
failed: no PMU supports the memory eventsNevertheless, I think there should be users who want to run this on different setups.
Quoted 28 lines
Quoted 28 lines
Quoted 5 lines
Since perf event-based access checks do not require modifying the PTE accessed-bit for pages representing each damon region, this patch series also includes a feature that allows you to set upper and lower limits on the damon region size to enable access checks with finer granularity.
I was also thinking about extending DAMON with AMD IBS or Intel PEBS like h/w features for this kind of sub-page granularity access monitoring. So this makes sense to me, and sounds useful!
Quoted 5 lines
Using these features also requires modifications to damo, but these are not included in this patch series and are currently under development in the following branch:
Quoted 8 lines
https://github.com/mita/damo/tree/damo-perf-for-v3.1.0
Any feedback or advice on the patch set would be greatly appreciated.
Akinobu Mita (4):
mm/damon/core: add common code for perf event based access checkmm/damon/vaddr: support perf event based access checkmm/damon/paddr: support perf event based access checkI find your patches are introducing new infra code for this extension. It seems bit specialized for perf event only, though. I'm concerned if future extension for another access check primitives cannot reuse the infra.
Quoted 8 lines
Quoted 5 lines
My DAMON extension project [1] is for page fault based access monitoring, but it also introduces a framework for general multiple access sampling primitives. I'm wondering if perf event based extension can be implemented using the general acces ssampling primitives infra code, and if you already considered that but found it is not feasible.
If such infrastructure code exists, I would like to use it, so I will consider it.
Great. Please take a look and let me know if you have any questions about that. The current implementation of the infra is only for proof of the concept, so it may lack documentations and quite suboptimal.
Quoted 8 lines
Quoted 7 lines
Quoted 2 lines
mm/damon: allow user to set min and max size of region
The min size setup makes sense. I understand the max size is for disabling the regions adjustment (merge/split) mechanism. IOW, for fixed granularity monitoring. Users can do that by setting
min_nr_regionsandmax_nr_regionssame [2], though. So, max size setting seems not really needed.
Quoted 7 lines
Yes, if fixed granularity monitoring is possible then that is sufficient.
I have tried setting
min_nr_regionsandmax_nr_regionsto be the same. I understand that the region split progresses over time and results in fixed-granularity monitoring at the minimum region size, but since my configuration has a relatively long sampling interval, it takes time to reach that state.
Ok, that makes sense. Thank you for explaining the issue.
Quoted 3 lines
So in the patch, when adding a new region with
damon_set_regions(), it will be split by the maximum region size.
Actually DAMON is internally setting such maximum region size based on the min_nr_regions parameter, via damon_region_sz_limit(). Nonetheless, the limit is applied only in regions merge time. That's why it requires the regions split to happen sufficiently until the real fixed granularity monitoring is started.
And I think this behavior is just a bug, or suboptimum implementation at least. That is, users set the minimum number of regions but it may not really be kept. That's definitely confusing behavior. Actually there was a similar case that number of regions can be larger than the max_nr_regions. We fixed it, with commit 310d6c15e910 ("mm/damon/core: merge regions aggressively when max_nr_regions is unmet"). I think we discussed about similar case for min_nr_regions, but I cannot find the discussion for now.
So, I think it is better to fix this rather than introducing a new parameter. Maybe we can split regions based on the min_nr_regions based size limit, before starting the main loop of kdamond_fn(). Similar to the max_nr_regions violation, there could be yet another corner case on online parameters commit situation, so it would better to check the case, too. You could implement such fix on your own, or let me do that. In the latter case, if you don't mind, I will add your Reported-by: tag to the fix. Please let me know your preferrence.
Quoted 5 lines
Quoted 3 lines
Again, great RFC patch series, thank you for sharing! I'm looking forward to your answers to above high level questions and comments.
Thank you so much for checking out the patch.
The pleasure is mine, and hope this patch series to get more forward progress!
Thanks,
SJ
2026年1月27日(火) 15:43 SeongJae Park <[email protected]>:
Quoted 14 lines
Actually DAMON is internally setting such maximum region size based on the
min_nr_regionsparameter, viadamon_region_sz_limit(). Nonetheless, the limit is applied only in regions merge time. That's why it requires the regions split to happen sufficiently until the real fixed granularity monitoring is started.And I think this behavior is just a bug, or suboptimum implementation at least. That is, users set the minimum number of regions but it may not really be kept. That's definitely confusing behavior. Actually there was a similar case that number of regions can be larger than the
max_nr_regions. We fixed it, with commit310d6c15e910("mm/damon/core: merge regions aggressively whenmax_nr_regionsis unmet"). I think we discussed about similar case formin_nr_regions, but I cannot find the discussion for now.
Quoted 1 line
So, I think it is better to fix this rather than introducing a new parameter.
I agree with that.
Quoted 7 lines
Maybe we can split regions based on the
min_nr_regionsbased size limit, before starting the main loop ofkdamond_fn(). Similar to themax_nr_regionsviolation, there could be yet another corner case on online parameters commit situation, so it would better to check the case, too. You could implement such fix on your own, or let me do that. In the latter case, if you don't mind, I will add your Reported-by: tag to the fix. Please let me know your preferrence.
You'll be better able to fix it, so please fix it at your convenience. Adding Reported-by: tag is fine.
SeongJae Park
maintainerQuoted 27 lines · On Tue, 27 Jan 2026 21:56:43 +0900 Akinobu Mita <[email protected]> wrote:
2026年1月27日(火) 15:43 SeongJae Park <[email protected]>:
Quoted 14 lines
Actually DAMON is internally setting such maximum region size based on the
min_nr_regionsparameter, viadamon_region_sz_limit(). Nonetheless, the limit is applied only in regions merge time. That's why it requires the regions split to happen sufficiently until the real fixed granularity monitoring is started.And I think this behavior is just a bug, or suboptimum implementation at least. That is, users set the minimum number of regions but it may not really be kept. That's definitely confusing behavior. Actually there was a similar case that number of regions can be larger than the
max_nr_regions. We fixed it, with commit310d6c15e910("mm/damon/core: merge regions aggressively whenmax_nr_regionsis unmet"). I think we discussed about similar case formin_nr_regions, but I cannot find the discussion for now.Quoted 1 line
So, I think it is better to fix this rather than introducing a new parameter.
I agree with that.
Quoted 7 lines
Maybe we can split regions based on the
min_nr_regionsbased size limit, before starting the main loop ofkdamond_fn(). Similar to themax_nr_regionsviolation, there could be yet another corner case on online parameters commit situation, so it would better to check the case, too. You could implement such fix on your own, or let me do that. In the latter case, if you don't mind, I will add your Reported-by: tag to the fix. Please let me know your preferrence.
Quoted 2 lines
You'll be better able to fix it, so please fix it at your convenience. Adding Reported-by: tag is fine.
Sounds good, I will do so!
Thanks,
SJ
[...]
SeongJae Park
maintainerQuoted 29 lines · On Tue, 27 Jan 2026 17:12:23 -0800 SeongJae Park <[email protected]> wrote:
Quoted 27 lines · On Tue, 27 Jan 2026 21:56:43 +0900 Akinobu Mita <[email protected]> wrote:
2026年1月27日(火) 15:43 SeongJae Park <[email protected]>:
Quoted 14 lines
Actually DAMON is internally setting such maximum region size based on the
min_nr_regionsparameter, viadamon_region_sz_limit(). Nonetheless, the limit is applied only in regions merge time. That's why it requires the regions split to happen sufficiently until the real fixed granularity monitoring is started.And I think this behavior is just a bug, or suboptimum implementation at least. That is, users set the minimum number of regions but it may not really be kept. That's definitely confusing behavior. Actually there was a similar case that number of regions can be larger than the
max_nr_regions. We fixed it, with commit310d6c15e910("mm/damon/core: merge regions aggressively whenmax_nr_regionsis unmet"). I think we discussed about similar case formin_nr_regions, but I cannot find the discussion for now.Quoted 1 line
So, I think it is better to fix this rather than introducing a new parameter.
I agree with that.
Quoted 7 lines
Maybe we can split regions based on the
min_nr_regionsbased size limit, before starting the main loop ofkdamond_fn(). Similar to themax_nr_regionsviolation, there could be yet another corner case on online parameters commit situation, so it would better to check the case, too. You could implement such fix on your own, or let me do that. In the latter case, if you don't mind, I will add your Reported-by: tag to the fix. Please let me know your preferrence.
Quoted 4 lines
Quoted 2 lines
You'll be better able to fix it, so please fix it at your convenience. Adding Reported-by: tag is fine.
Sounds good, I will do so!
I just posted an RFC patch series [1] for this. I will drop RFC tag after the current merge window is finished. Please let me know if you find something wrong there!
[1] https://lore.kernel.org/[email protected]
Thanks,
SJ
[...]
2026年2月17日(火) 9:13 SeongJae Park <[email protected]>:
Quoted 35 lines · On Tue, 27 Jan 2026 17:12:23 -0800 SeongJae Park <[email protected]> wrote:
Quoted 33 lines · On Tue, 27 Jan 2026 21:56:43 +0900 Akinobu Mita <[email protected]> wrote:
Quoted 30 lines
2026年1月27日(火) 15:43 SeongJae Park <[email protected]>:
Quoted 14 lines
Actually DAMON is internally setting such maximum region size based on the
min_nr_regionsparameter, viadamon_region_sz_limit(). Nonetheless, the limit is applied only in regions merge time. That's why it requires the regions split to happen sufficiently until the real fixed granularity monitoring is started.And I think this behavior is just a bug, or suboptimum implementation at least. That is, users set the minimum number of regions but it may not really be kept. That's definitely confusing behavior. Actually there was a similar case that number of regions can be larger than the
max_nr_regions. We fixed it, with commit310d6c15e910("mm/damon/core: merge regions aggressively whenmax_nr_regionsis unmet"). I think we discussed about similar case formin_nr_regions, but I cannot find the discussion for now.Quoted 1 line
So, I think it is better to fix this rather than introducing a new parameter.
I agree with that.
Quoted 7 lines
Maybe we can split regions based on the
min_nr_regionsbased size limit, before starting the main loop ofkdamond_fn(). Similar to themax_nr_regionsviolation, there could be yet another corner case on online parameters commit situation, so it would better to check the case, too. You could implement such fix on your own, or let me do that. In the latter case, if you don't mind, I will add your Reported-by: tag to the fix. Please let me know your preferrence.You'll be better able to fix it, so please fix it at your convenience. Adding Reported-by: tag is fine.
Quoted 7 lines
Quoted 1 line
Sounds good, I will do so!
I just posted an RFC patch series [1] for this. I will drop RFC tag after the current merge window is finished. Please let me know if you find something wrong there!
Thank you for posting the patch series.
I tried it and found that patch 2/3 made things worse than before in terms of monitoring at page size granularity. This is because, in my evaluation, new target processes are added without stopping kdamond, so processes added later are not initially monitored at page size granularity.
Would performing a split operation like damon_apply_min_nr_regions() within damon_set_regions() solve the problem?
SeongJae Park
maintainerQuoted 42 lines · On Tue, 17 Feb 2026 22:32:43 +0900 Akinobu Mita <[email protected]> wrote:
2026年2月17日(火) 9:13 SeongJae Park <[email protected]>:
Quoted 41 lines · On Tue, 27 Jan 2026 17:12:23 -0800 SeongJae Park <[email protected]> wrote:
Quoted 30 lines · On Tue, 27 Jan 2026 21:56:43 +0900 Akinobu Mita <[email protected]> wrote:
Quoted 28 lines
2026年1月27日(火) 15:43 SeongJae Park <[email protected]>:
Quoted 14 lines
Actually DAMON is internally setting such maximum region size based on the
min_nr_regionsparameter, viadamon_region_sz_limit(). Nonetheless, the limit is applied only in regions merge time. That's why it requires the regions split to happen sufficiently until the real fixed granularity monitoring is started.And I think this behavior is just a bug, or suboptimum implementation at least. That is, users set the minimum number of regions but it may not really be kept. That's definitely confusing behavior. Actually there was a similar case that number of regions can be larger than the
max_nr_regions. We fixed it, with commit310d6c15e910("mm/damon/core: merge regions aggressively whenmax_nr_regionsis unmet"). I think we discussed about similar case formin_nr_regions, but I cannot find the discussion for now.Quoted 1 line
So, I think it is better to fix this rather than introducing a new parameter.
I agree with that.
Quoted 7 lines
Maybe we can split regions based on the
min_nr_regionsbased size limit, before starting the main loop ofkdamond_fn(). Similar to themax_nr_regionsviolation, there could be yet another corner case on online parameters commit situation, so it would better to check the case, too. You could implement such fix on your own, or let me do that. In the latter case, if you don't mind, I will add your Reported-by: tag to the fix. Please let me know your preferrence.Quoted 4 lines
Quoted 2 lines
You'll be better able to fix it, so please fix it at your convenience. Adding Reported-by: tag is fine.
Sounds good, I will do so!
I just posted an RFC patch series [1] for this. I will drop RFC tag after the current merge window is finished. Please let me know if you find something wrong there!
Quoted 6 lines
Quoted 1 line
Thank you for posting the patch series.
I tried it and found that patch 2/3 made things worse than before in terms of monitoring at page size granularity.
Thank you for sharing the test results!
Quoted 3 lines
This is because, in my evaluation, new
target processes are added without stopping kdamond, so processes added later are not initially monitored at page size granularity.
Nice catch. But, the min_nr_regions based region split of vaddr was triggered by damon_va_init(), which is called before the kdamond_fn()'s main loop. How the regions were split before the patch? Probably I'm missing something. Could you please clarify?
Quoted 3 lines
Would performing a split operation like
damon_apply_min_nr_regions()withindamon_set_regions()solve the problem?
Yes, that's the plan. The split operation should be done for online updates of total size of monitoring regions and min_nr_regions. I'm preparing a followup patch series for that. While working on it, however, I found it requires some refactoring and cleanup that taking time longer than I expected. Meanwhile I was thinking your issue is only at the beginning of kdamond, and I didn't want to make you wait too long. Hence posted the series first.
Thanks,
SJ
2026年2月18日(水) 0:15 SeongJae Park <[email protected]>:
Quoted 54 lines · On Tue, 17 Feb 2026 22:32:43 +0900 Akinobu Mita <[email protected]> wrote:
Quoted 43 lines
2026年2月17日(火) 9:13 SeongJae Park <[email protected]>:
Quoted 41 lines · On Tue, 27 Jan 2026 17:12:23 -0800 SeongJae Park <[email protected]> wrote:
Quoted 30 lines · On Tue, 27 Jan 2026 21:56:43 +0900 Akinobu Mita <[email protected]> wrote:
Quoted 28 lines
2026年1月27日(火) 15:43 SeongJae Park <[email protected]>:
Quoted 14 lines
Actually DAMON is internally setting such maximum region size based on the
min_nr_regionsparameter, viadamon_region_sz_limit(). Nonetheless, the limit is applied only in regions merge time. That's why it requires the regions split to happen sufficiently until the real fixed granularity monitoring is started.And I think this behavior is just a bug, or suboptimum implementation at least. That is, users set the minimum number of regions but it may not really be kept. That's definitely confusing behavior. Actually there was a similar case that number of regions can be larger than the
max_nr_regions. We fixed it, with commit310d6c15e910("mm/damon/core: merge regions aggressively whenmax_nr_regionsis unmet"). I think we discussed about similar case formin_nr_regions, but I cannot find the discussion for now.Quoted 1 line
So, I think it is better to fix this rather than introducing a new parameter.
I agree with that.
Quoted 7 lines
Maybe we can split regions based on the
min_nr_regionsbased size limit, before starting the main loop ofkdamond_fn(). Similar to themax_nr_regionsviolation, there could be yet another corner case on online parameters commit situation, so it would better to check the case, too. You could implement such fix on your own, or let me do that. In the latter case, if you don't mind, I will add your Reported-by: tag to the fix. Please let me know your preferrence.Quoted 4 lines
Quoted 2 lines
You'll be better able to fix it, so please fix it at your convenience. Adding Reported-by: tag is fine.
Sounds good, I will do so!
I just posted an RFC patch series [1] for this. I will drop RFC tag after the current merge window is finished. Please let me know if you find something wrong there!
Quoted 6 lines
Quoted 1 line
Thank you for posting the patch series.
I tried it and found that patch 2/3 made things worse than before in terms of monitoring at page size granularity.
Thank you for sharing the test results!
Quoted 8 lines
Quoted 3 lines
This is because, in my evaluation, new
target processes are added without stopping kdamond, so processes added later are not initially monitored at page size granularity.Nice catch. But, the
min_nr_regionsbased region split of vaddr was triggered bydamon_va_init(), which is called before the kdamond_fn()'s main loop. How the regions were split before the patch? Probably I'm missing something. Could you please clarify?
Before applying PATCH 2/3 ("mm/damon/vaddr: do not split regions for min_nr_regions"), the damon regions of processes newly added to the monitoring targets after kdamond started were split by damon_va_evenly_split_region(). After applying PATCH 2/3, the call to damon_va_evenly_split_region() is omitted, so those new processes are monitored by larger damon regions.
Quoted 9 lines
Quoted 2 lines
Would performing a split operation like
damon_apply_min_nr_regions()withindamon_set_regions()solve the problem?Yes, that's the plan. The split operation should be done for online updates of total size of monitoring regions and
min_nr_regions. I'm preparing a followup patch series for that. While working on it, however, I found it requires some refactoring and cleanup that taking time longer than I expected. Meanwhile I was thinking your issue is only at the beginning of kdamond, and I didn't want to make you wait too long. Hence posted the series first.
I see, thank you for the work.
In another evaluation using paddr, no new damon regions are added after kdamond is started, so applying the current patch series enabled monitoring at page size granularity.
SeongJae Park
maintainerQuoted 5 lines · On Wed, 18 Feb 2026 17:20:04 +0900 Akinobu Mita <[email protected]> wrote:
2026年2月18日(水) 0:15 SeongJae Park <[email protected]>:
Quoted 4 lines · On Tue, 17 Feb 2026 22:32:43 +0900 Akinobu Mita <[email protected]> wrote:
Quoted 2 lines
2026年2月17日(火) 9:13 SeongJae Park <[email protected]>:
[...]
Quoted 17 lines
Quoted 17 lines
Quoted 10 lines
Quoted 5 lines
I just posted an RFC patch series [1] for this. I will drop RFC tag after the current merge window is finished. Please let me know if you find something wrong there!
Thank you for posting the patch series.
I tried it and found that patch 2/3 made things worse than before in terms of monitoring at page size granularity.
Thank you for sharing the test results!
Quoted 3 lines
This is because, in my evaluation, new
target processes are added without stopping kdamond, so processes added later are not initially monitored at page size granularity.
Quoted 8 lines
Quoted 4 lines
Nice catch. But, the
min_nr_regionsbased region split of vaddr was triggered bydamon_va_init(), which is called before the kdamond_fn()'s main loop. How the regions were split before the patch? Probably I'm missing something. Could you please clarify?Before applying PATCH 2/3 ("
mm/damon/vaddr: do not split regions formin_nr_regions"), the damon regions of processes newly added to the monitoring targets after kdamond started were split bydamon_va_evenly_split_region().
Thank you for adding this explanation. But, damon_va_evenly_split_region() is called by only __damon_va_init_regions(), which is again called by only damon_va_init(). And damon_va_init() is called from kdamond_fn(), only at the beginning, before starting the main loop. If you add new monitoring targets after kdamond started and therefore the damon_va_init() is called, damon_va_init() cannot be called again. So damon_va_evenly_split_region() is also not called. I confirmed this using damo like below:
$ sudo damo start --target_pid $$ --monitoring_intervals 1s 5s 10s
$ sudo damo tune --target_pid $$ --target_pid $other_process_pid \
--monitoring_intervals 1s 5s 10s \
--monitoring_nr_regions_range 20 1000While running the command, I monitor the number of regions of targets using damon:damon_aggregated trace event, and confirmed the initial region is evenly split, but the new monitoring target regions that added by the second command is not evenly split from the beginning.
Am I missing something?
Quoted 2 lines
After applying PATCH 2/3, the call to
damon_va_evenly_split_region()is omitted, so those new processes are monitored by larger damon regions.
So I'm still not understanding why you saying this.
Quoted 11 lines
Quoted 10 lines
Quoted 3 lines
Would performing a split operation like
damon_apply_min_nr_regions()withindamon_set_regions()solve the problem?Yes, that's the plan. The split operation should be done for online updates of total size of monitoring regions and
min_nr_regions. I'm preparing a followup patch series for that. While working on it, however, I found it requires some refactoring and cleanup that taking time longer than I expected. Meanwhile I was thinking your issue is only at the beginning of kdamond, and I didn't want to make you wait too long. Hence posted the series first.
Quoted 5 lines
I see, thank you for the work.
In another evaluation using paddr, no new damon regions are added after kdamond is started, so applying the current patch series enabled monitoring at page size granularity.
Glad to hear that it helps the case!
Thanks,
SJ
2026年2月19日(木) 0:40 SeongJae Park <[email protected]>:
Quoted 48 lines · On Wed, 18 Feb 2026 17:20:04 +0900 Akinobu Mita <[email protected]> wrote:
Quoted 6 lines
2026年2月18日(水) 0:15 SeongJae Park <[email protected]>:
Quoted 4 lines · On Tue, 17 Feb 2026 22:32:43 +0900 Akinobu Mita <[email protected]> wrote:
Quoted 2 lines
2026年2月17日(火) 9:13 SeongJae Park <[email protected]>:
[...]
Quoted 17 lines
Quoted 17 lines
Quoted 10 lines
Quoted 5 lines
I just posted an RFC patch series [1] for this. I will drop RFC tag after the current merge window is finished. Please let me know if you find something wrong there!
Thank you for posting the patch series.
I tried it and found that patch 2/3 made things worse than before in terms of monitoring at page size granularity.
Thank you for sharing the test results!
Quoted 3 lines
This is because, in my evaluation, new
target processes are added without stopping kdamond, so processes added later are not initially monitored at page size granularity.Quoted 8 lines
Quoted 4 lines
Nice catch. But, the
min_nr_regionsbased region split of vaddr was triggered bydamon_va_init(), which is called before the kdamond_fn()'s main loop. How the regions were split before the patch? Probably I'm missing something. Could you please clarify?Before applying PATCH 2/3 ("
mm/damon/vaddr: do not split regions formin_nr_regions"), the damon regions of processes newly added to the monitoring targets after kdamond started were split bydamon_va_evenly_split_region().Thank you for adding this explanation. But,
damon_va_evenly_split_region()is called by only__damon_va_init_regions(), which is again called by onlydamon_va_init(). Anddamon_va_init()is called fromkdamond_fn(), only at the beginning, before starting the main loop. If you add new monitoring targets after kdamond started and therefore thedamon_va_init()is called,damon_va_init()cannot be called again. Sodamon_va_evenly_split_region()is also not called. I confirmed this using damo like below:$ sudo damo start --target_pid $$ --monitoring_intervals 1s 5s 10s $ sudo damo tune --target_pid $$ --target_pid $other_process_pid \ --monitoring_intervals 1s 5s 10s \ --monitoring_nr_regions_range 20 1000
Quoted 6 lines
While running the command, I monitor the number of regions of targets using damon:damon_aggregated trace event, and confirmed the initial region is evenly split, but the new monitoring target regions that added by the second command is not evenly split from the beginning.
Am I missing something?
Your explanation is correct.
It was only my own internal changes that were affecting it (calling ops.init() from damon_commit_ctx()).
https://lore.kernel.org/damon/[email protected]/
So the current patch series hasn't made things worse. Sorry for the mistake.
SeongJae Park
maintainerQuoted 54 lines · On Thu, 19 Feb 2026 15:28:24 +0900 Akinobu Mita <[email protected]> wrote:
2026年2月19日(木) 0:40 SeongJae Park <[email protected]>:
Quoted 53 lines · On Wed, 18 Feb 2026 17:20:04 +0900 Akinobu Mita <[email protected]> wrote:
Quoted 6 lines
2026年2月18日(水) 0:15 SeongJae Park <[email protected]>:
Quoted 4 lines · On Tue, 17 Feb 2026 22:32:43 +0900 Akinobu Mita <[email protected]> wrote:
Quoted 2 lines
2026年2月17日(火) 9:13 SeongJae Park <[email protected]>:
[...]
Quoted 17 lines
Quoted 17 lines
Quoted 10 lines
Quoted 5 lines
I just posted an RFC patch series [1] for this. I will drop RFC tag after the current merge window is finished. Please let me know if you find something wrong there!
Thank you for posting the patch series.
I tried it and found that patch 2/3 made things worse than before in terms of monitoring at page size granularity.
Thank you for sharing the test results!
Quoted 3 lines
This is because, in my evaluation, new
target processes are added without stopping kdamond, so processes added later are not initially monitored at page size granularity.Quoted 8 lines
Quoted 4 lines
Nice catch. But, the
min_nr_regionsbased region split of vaddr was triggered bydamon_va_init(), which is called before the kdamond_fn()'s main loop. How the regions were split before the patch? Probably I'm missing something. Could you please clarify?Before applying PATCH 2/3 ("
mm/damon/vaddr: do not split regions formin_nr_regions"), the damon regions of processes newly added to the monitoring targets after kdamond started were split bydamon_va_evenly_split_region().Thank you for adding this explanation. But,
damon_va_evenly_split_region()is called by only__damon_va_init_regions(), which is again called by onlydamon_va_init(). Anddamon_va_init()is called fromkdamond_fn(), only at the beginning, before starting the main loop. If you add new monitoring targets after kdamond started and therefore thedamon_va_init()is called,damon_va_init()cannot be called again. Sodamon_va_evenly_split_region()is also not called. I confirmed this using damo like below:$ sudo damo start --target_pid $$ --monitoring_intervals 1s 5s 10s $ sudo damo tune --target_pid $$ --target_pid $other_process_pid \ --monitoring_intervals 1s 5s 10s \ --monitoring_nr_regions_range 20 1000While running the command, I monitor the number of regions of targets using damon:damon_aggregated trace event, and confirmed the initial region is evenly split, but the new monitoring target regions that added by the second command is not evenly split from the beginning.
Quoted 7 lines
Quoted 1 line
Am I missing something?
Your explanation is correct.
It was only my own internal changes that were affecting it (callingops.init()fromdamon_commit_ctx()).
Makes sense, thank you for clarifying this!
Quoted 2 lines
So the current patch series hasn't made things worse. Sorry for the mistake.
Glad to hear that. I will post the series without RFC after the current merge window. I will also try to make the planned followup for respecting the min_nr_regions for the online-added targets and updated min_nr_regions before the next merge window.
Thanks,
SJ
[...]
SeongJae Park
maintainerQuoted 67 lines · On Wed, 18 Feb 2026 22:49:48 -0800 SeongJae Park <[email protected]> wrote:
Quoted 54 lines · On Thu, 19 Feb 2026 15:28:24 +0900 Akinobu Mita <[email protected]> wrote:
2026年2月19日(木) 0:40 SeongJae Park <[email protected]>:
Quoted 53 lines · On Wed, 18 Feb 2026 17:20:04 +0900 Akinobu Mita <[email protected]> wrote:
Quoted 6 lines
2026年2月18日(水) 0:15 SeongJae Park <[email protected]>:
Quoted 4 lines · On Tue, 17 Feb 2026 22:32:43 +0900 Akinobu Mita <[email protected]> wrote:
Quoted 2 lines
2026年2月17日(火) 9:13 SeongJae Park <[email protected]>:
[...]
Quoted 17 lines
Quoted 17 lines
Quoted 10 lines
Quoted 5 lines
I just posted an RFC patch series [1] for this. I will drop RFC tag after the current merge window is finished. Please let me know if you find something wrong there!
Thank you for posting the patch series.
I tried it and found that patch 2/3 made things worse than before in terms of monitoring at page size granularity.
Thank you for sharing the test results!
Quoted 3 lines
This is because, in my evaluation, new
target processes are added without stopping kdamond, so processes added later are not initially monitored at page size granularity.Quoted 8 lines
Quoted 4 lines
Nice catch. But, the
min_nr_regionsbased region split of vaddr was triggered bydamon_va_init(), which is called before the kdamond_fn()'s main loop. How the regions were split before the patch? Probably I'm missing something. Could you please clarify?Before applying PATCH 2/3 ("
mm/damon/vaddr: do not split regions formin_nr_regions"), the damon regions of processes newly added to the monitoring targets after kdamond started were split bydamon_va_evenly_split_region().Thank you for adding this explanation. But,
damon_va_evenly_split_region()is called by only__damon_va_init_regions(), which is again called by onlydamon_va_init(). Anddamon_va_init()is called fromkdamond_fn(), only at the beginning, before starting the main loop. If you add new monitoring targets after kdamond started and therefore thedamon_va_init()is called,damon_va_init()cannot be called again. Sodamon_va_evenly_split_region()is also not called. I confirmed this using damo like below:$ sudo damo start --target_pid $$ --monitoring_intervals 1s 5s 10s $ sudo damo tune --target_pid $$ --target_pid $other_process_pid \ --monitoring_intervals 1s 5s 10s \ --monitoring_nr_regions_range 20 1000While running the command, I monitor the number of regions of targets using damon:damon_aggregated trace event, and confirmed the initial region is evenly split, but the new monitoring target regions that added by the second command is not evenly split from the beginning.
Quoted 7 lines
Quoted 1 line
Am I missing something?
Your explanation is correct.
It was only my own internal changes that were affecting it (callingops.init()fromdamon_commit_ctx()).Makes sense, thank you for clarifying this!
Quoted 1 line
Quoted 6 lines
Quoted 1 line
So the current patch series hasn't made things worse. Sorry for the mistake.
Glad to hear that. I will post the series without RFC after the current merge window. I will also try to make the planned followup for respecting the
min_nr_regionsfor the online-added targets and updatedmin_nr_regionsbefore the next merge window.
The non-RFC series is posted [1]. The version also do the min_nr_regions respect for online updates together.
[1] https://lore.kernel.org/[email protected]
Thanks,
SJ
[...]