mm/damon: let users report their data attribute findings
Subsystems (5)
SJ Park
maintainercover mm/damon: let users report their data attribute findings
TL;DR
=====
Build a system for letting DAMON-external entities report their data attribute findings to DAMON. Let users report their data attribute findings to DAMON using the report system.
When DAMON Extension Becomes Challenging
========================================
DAMON's probe based data attributes monitoring system allows flexible extension of it for new types of information. Such extensions are not always easy, though. That's because DAMON is collecting the information on its own worker threads, kdamonds. If the new information to extend for is not already stored in a data structure that kdamonds can read, the extension becomes difficult.
For example, extending DAMON for hugepage size of the given memory was straightforward. kdamonds can read that from folios. Extending DAMON for accessors or writes-only accesses is challenging because there is no existing easy way to get that information from arbitrary threads like kdamonds.
Extending DAMON for information that is not already available to kdamonds requires two works. Finding DAMON-external kernel components that already have the information. And modifying it to pass the information to DAMON. Finding and modifying the components inherently need to be done for each of such extensions. Building a universal way to report the information to DAMON could make it much easier.
Modifying the component would be particularly challenging and even controversial depending on each case. Some components wouldn't want to add a hacky change only for DAMON. Having the universal report system that is well maintained will be useful at convincing the component, too.
User Information
================
Users sometimes know some data attribute information more than what the kernel can know. They could know frequently accessed data. They could know that because they have access to the source code of the workload. They could know that using non-DAMON kernel features. They could know that from some special tools and hardware.
DAMON is not only for monitoring but also operations. DAMON finds operation targets based on only its self monitoring results, though. Letting users report their data attribute information allows more flexible and effective control of the DAMON operations. Users can make DAMON to find operation targets based on both its self monitoring and user-provided reports.
DAMON is not providing such ways to let users report their information, though.
Report System and User Report Support
=====================================
DAMON lacks efficient DAMON-external information report system and user report support. Fill the gap.
Introduce a system to report information from kdamond-external entities to DAMON. Extend DAMON to monitor those reported information. Build a user interface for letting users report their findings.
Data Attribute Report System
============================
Introduce a system to report information from kdamond-external entities to DAMON. The report system let any kernel components in any context including NMI context pass their data attribute finding to DAMON as a report.
The system provides a data structure for such reports. Using the report data structure, a flexible data attribute information for a given memory can be built. The data structure also embeds a field for the type of the report. The report producer can specify what data attribute type the report is providing, using the field.
The system exposes an API function, damon_submit_report(), for submitting the report of the data type to DAMON. The submit function can be called from any context including NMI context.
DAMON Probe for Reports
=======================
Extend the DAMON probe filter to connect the report system with the existing monitoring part of DAMON. Introduce a new DAMON probe filter type, report. When the type is "report", it receives the report type argument. Filters of the type match to a given memory if a report of the given type for the memory is made in the last sampling interval. Update DAMON sysfs ABI for probe filters setup to support the new filter type and the new argument for the report type.
User Report Support
===================
Let users report their findings. Introduce a report type for the users provided report. Extend DAMON sysfs ABI to let users manually configure and submit such reports one by one. Users can specify for what memory the report is made, with an arbitrary address range.
Using the new support, users can control DAMON using their own information. They can control DAMON using their information as only a source, or an additional source to existing ones. For example, they can let DAMON do page table accessed-bit based access monitoring. In addition to that, if they know some hot data that might not be found by the page table information, they can let DAMON know the hot data using the report system.
Ongoing and Future Works
========================
This is a part of the "beyond page table accessed-bit DAMON extension" project milestone 2. This patch series provides the initial and essential part of the data attribute report system.
I will implement a cpu cycle sampling based extension based on the report system that is implemented by this series. It is for providing accessor and type-aware access monitoring. Using it, users will be able to monitor access for given CPUs, tasks and types (read and/or write) of accesses.
While doing that, the report system will also be advanced in a way that can be used for reports that are not manually produced by the user but by the kernel or hardware itself. That will be the completion of the second milestone of the parent project. After that, people will be able to build more extensions including AMD IBS-like hardware based monitoring, using the advanced report system.
Patches Sequence
================
Introduce the data attribute report system with the first eleven patches (patches 1-11). Define the data structure for each report and expose via DAMON core API, via patch 1. Implement an internal data structure for saving the reports, struct damon_report, via patch 2. Introduce another DAMON core API function for submitting each report, damon_submit_report(), via patch 3. Implement reports/producers/ sysfs directory next to the kdamonds/ directory, for controlling report producers, via patches 4-8. Update the design, the usage and the ABI documents for the report system, with patches 9-11.
Extend the DAMON probe filter for the reports, with the following eight patches (patches 12-19). Introduce a new filter type, REPORT_MADE, which matches if a report for the probing memory is made in last sampling interval, via patch 12. Implement and expose a DAMON core API function, damon_report_exist(), that returns if a report of given condition exist in the report queue, via patch 13. Add support of the new filter type in paddr operation set, via patch 14. Implement sysfs files for setting the new type of filter, via patches 15 and 16. Update the design, the usage and the ABI documents for the new filter type and its user interface, via patches 17-19.
Finally, implement user report support with the subsequent eight patches (patches 20-27). Introduce a new report type DAMON core API, USER_REPORT, via patch 20. Add a user keyword for the new report type to sysfs files, via patch 21. Implement sysfs files for manually generating and submitting user reports, via patches 22 and 23. Add a simple selftest for new sysfs files, via patch 24. Update the design, the usage and the ABI documents for the new report type and its user interface, via patches 25-27.
Changes from RFC v0
- RFC v0: https://lore.kernel.org/[email protected]
- Implement the code.
- Update the documentation to be less like Cover letter.
- Rebase to the latest mm-new.
SJ Park (27):
mm/damon/api: introduce struct damon_report
mm/damon/core: implement data attribute report queue mm/damon/core: introduce damon_submit_report() mm/damon/sysfs: add admin/reports/ directory mm/damon/sysfs: add reports/producers/ directory mm/damon/sysfs: add producers/nr_producers file mm/damon/sysfs: implement report producer directory mm/damon/sysfs: implement report producer type and state files Docs/mm/damon/design: update for report system Docs/admin-guide/mm/damon/usage: update for report producer sysfs Docs/ABI/damon: update for report producer sysfs files mm/damon/core: introduce DAMON_FILTER_TYPE_REPORT_MADE mm/damon/core: introduce damon_report_exist() mm/damon/paddr: support REPORT_MADE type probe filter mm/damon/sysfs: add filter_report_type file under probe filter
directory
mm/damon/sysfs: support REPORT_MADE type probe filter setup Docs/mm/damon/design: update for report_made probe filter type Docs/admin-guide/mm/damon/usage: update for REPORT_MADE probe filter Docs/ABI/damon: update for REPORT_MADE probe filter mm/damon/api: introduce user_report report type mm/damon/sysfs: add user_report support for report type input mm/damon/sysfs: implement report producer addr_{start,end} files mm/damon/sysfs: implement submit command for report producer selftests/damon/sysfs.sh: add basic tests for admin/reports/ Docs/mm/damon/design: update for user report support Docs/admin-guide/mm/damon/usage: update for user_report report support Docs/ABI/damon: update for user_report report support
.../ABI/testing/sysfs-kernel-mm-damon | 43 ++ Documentation/admin-guide/mm/damon/usage.rst | 50 ++- Documentation/mm/damon/design.rst | 45 ++ include/linux/damon.h | 33 ++ mm/damon/core.c | 108 ++++- mm/damon/paddr.c | 17 +- mm/damon/sysfs.c | 420 +++++++++++++++++- tools/testing/selftests/damon/sysfs.sh | 52 +++ 8 files changed, 758 insertions(+), 10 deletions(-)
base-commit: 3c8cd5232610d6035977619fbcdb7fe5aeda35ae
Signature · 1 line
2.47.3
SJ Park
maintainerRFC PATCH 1/27 mm/damon/api: introduce struct damon_report
Define a struct for data attribute report. The struct provides public fields for the type and the memory address range. The type field represents the type of the report itself. The address range is for the memory of the reporting data. Data attribute producers can format their report using those fields.
It also has a private field representing when the report is submitted.
--- include/linux/damon.h | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+)
include/linux/damon.h +23 -0
@@ -751,6 +751,29 @@ struct damon_intervals_goal {unsigned long max_sample_us; }; +/** +* enum damon_report_type - Type of &struct damon_report. +*/ +enum damon_report_type { +NR_DAMON_REPORT_TYPES , +}; + +/** +* struct damon_report - Data attribute report information. +* +* @type: Type of the report. +* @addr_range: The address range of the memory to report for. +* +* Note that the @start_addr and @end_adr represents an end-open range. +*/ +struct damon_report { +enum damon_report_type type; +struct damon_addr_range addr_range; +/* private: */ +/* when this report is generated */ +unsigned long jiffies; +}; +/** * enum damon_prep_action - DAMON probing preparation action. *
Signature · 1 line
2.47.3
[email protected]
AI reviewRe: [RFC PATCH 01/27] mm/damon/api: introduce struct damon_report
Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [Low] mm/damon: nonexistent fields in struct damon_report kernel-doc comment --
Thank you for your contribution! Sashiko AI review found 1 potential issue to consider:
- [Low] mm/damon: nonexistent fields in struct damon_report kernel-doc comment
--
commit 919e8293a0141a206eb1e31c857deac8b6249a6d
Author: SJ Park <[email protected]>
mm/damon/api: introduce struct damon_report
This commit defines enum damon_report_type and struct damon_report to represent data attribute reports.
Quoted 16 lines
include/linux/damon.h +8
-0@@ -751,6 +751,29 @@ struct damon_intervals_goal {unsigned long max_sample_us; }; +/** +* enum damon_report_type - Type of &struct damon_report. +*/ +enum damon_report_type { +NR_DAMON_REPORT_TYPES , +}; + +/**
include/linux/damon.h struct damon_intervals_goal { · line 771
Quoted 10 lines
include/linux/damon.h +10
-0+* struct damon_report - Data attribute report information. +* +* @type: Type of the report. +* @addr_range: The address range of the memory to report for. +* +* Note that the @start_addr and @end_adr represents an end-open range. +*/ +struct damon_report { +enum damon_report_type type; +struct damon_addr_range addr_range;
[Severity: Low]
The kernel-doc comment refers to @start_addr and @end_adr (with a typo in "end_adr"), but struct damon_report embeds @addr_range (a struct damon_addr_range with @start and @end fields) rather than defining those fields directly.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
SJ Park
maintainerRe: [RFC PATCH 01/27] mm/damon/api: introduce struct damon_report
Quoted 38 lines · On Sun, 15 Nov 2026 20:34:31 +0000 [email protected] wrote:
Thank you for your contribution! Sashiko AI review found 1 potential issue to consider:
- [Low] mm/damon: nonexistent fields in structdamon_reportkernel-doc comment
--commit
919e8293a0141a206eb1e31c857deac8b6249a6d
Author: SJ Park <[email protected]>
mm/damon/api: introduce structdamon_reportThis commit defines enum
damon_report_typeand structdamon_reportto represent data attribute reports.Quoted 24 lines
include/linux/damon.h +16
-0@@ -751,6 +751,29 @@ struct damon_intervals_goal {unsigned long max_sample_us; }; +/** +* enum damon_report_type - Type of &struct damon_report. +*/ +enum damon_report_type { +NR_DAMON_REPORT_TYPES , +}; + +/** +* struct damon_report - Data attribute report information. +* +* @type: Type of the report. +* @addr_range: The address range of the memory to report for. +* +* Note that the @start_addr and @end_adr represents an end-open range. +*/ +struct damon_report {
Quoted 8 lines
include/linux/damon.h struct damon_intervals_goal { · line 771
Quoted 2 lines
include/linux/damon.h +2
-0+enum damon_report_type type; +struct damon_addr_range addr_range;[Severity: Low]
The kernel-doc comment refers to @start_addr and @end_adr (with a typo in "end_adr"), but structdamon_reportembeds @addr_range (a structdamon_addr_rangewith @start and @end fields) rather than defining those fields directly.
Good finding, thank you. I will drop the last line of the comment.
Quoted 4 lines
Signature · 2 lines
-- Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Thanks,
SJ
SJ Park
maintainerRFC PATCH 2/27 mm/damon/core: implement data attribute report queue
In reply to SJ ParkImplement DAMON core internal data structure for queuing received data attribute reports. Initialize the queue for up to 1,000 reports, inside the DAMON init routine. Also update damon_initialized() to return false for the setup failure of the queue.
--- mm/damon/core.c | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-)
mm/damon/core.c +28 -1
@@ -2334,6 +2334,25 @@ int damos_walk(struct damon_ctx *ctx, struct damos_walk_control *control)return 0 ; } +/* +* struct damon_report_queue - &struct damon_report queue. +* +* @lock: Represent if this queue is being used by someone. +* @head: Head of the queue. +* @tail: Tail of the queue. +* @size: Size of the queue. +* @reports: Array of &struct damon_report. +*/ +struct damon_report_queue { +atomic_t lock; +unsigned int tail; +unsigned int size; +unsigned int nr_reports; +struct damon_report *reports; +}; + +struct damon_report_queue damon_report_queue; +/* * Reset the aggregated monitoring results ('nr_accesses' of each region). */
@@ -4308,7 +4327,7 @@ void damon_update_region_access_rate(struct damon_region *r, bool accessed)*/ bool damon_initialized (void ) { -return damon_region_cache !=NULL ; +return damon_region_cache && damon_report_queue.reports; }static int __init damon_init (void )
@@ -4319,6 +4338,14 @@ static int __init damon_init(void)return -ENOMEM ; } + damon_report_queue.size =1000 ; + damon_report_queue.reports =kmalloc_objs (*damon_report_queue.reports, +1000 ,GFP_KERNEL ); +if (!damon_report_queue.reports) { +pr_err ("report queue alloc fail\n" ); +return -ENOMEM ; + } +return 0 ; }
Signature · 1 line
2.47.3
[email protected]
AI reviewRe: [RFC PATCH 02/27] mm/damon/core: implement data attribute report queue
Thank you for your contribution! Sashiko AI review found 3 potential issues to consider: - [Medium] mm/damon: damon_init() leaks damon_region_cache on queue alloc failure - [Low] mm/damon: missing…
Thank you for your contribution! Sashiko AI review found 3 potential issues to consider:
- [Medium] mm/damon: damon_init() leaks damon_region_cache on queue alloc failure
- [Low] mm/damon: missing static qualifier on damon_report_queue in core.c
- [Low] mm/damon: struct damon_report_queue comment documents head not nr_reports
--
commit 10a61bc9bab6e48534e4a8552380aecaccbee97a
Author: SJ Park <[email protected]>
mm/damon/core: implement data attribute report queue
This commit adds an internal damon_report_queue structure, allocates its buffer for up to 1,000 reports in damon_init(), and checks that buffer in damon_initialized().
Quoted 14 lines
mm/damon/core.c +6
-0@@ -2334,6 +2334,25 @@ int damos_walk(struct damon_ctx *ctx, struct damos_walk_control *control)return 0 ; } +/* +* struct damon_report_queue - &struct damon_report queue. +* +* @lock: Represent if this queue is being used by someone. +* @head: Head of the queue. +* @tail: Tail of the queue.
mm/damon/core.c int damos_walk(struct damon_ctx *ctx, struct damos_walk_control *control) · line 2352
Quoted 10 lines
mm/damon/core.c +10
-0+* @size: Size of the queue. +* @reports: Array of &struct damon_report. +*/ +struct damon_report_queue { +atomic_t lock; +unsigned int tail; +unsigned int size; +unsigned int nr_reports; +struct damon_report *reports; +};
[Severity: Low]
The comment above struct damon_report_queue documents @head, whereas the struct defines nr_reports instead.
mm/damon/core.c int damos_walk(struct damon_ctx *ctx, struct damos_walk_control *control) · line 2354
Quoted 2 lines
mm/damon/core.c +2
-0+ +struct damon_report_queue damon_report_queue;
[Severity: Low]
Should damon_report_queue be marked static? struct damon_report_queue is private to mm/damon/core.c, so leaving damon_report_queue non-static exports it into the global namespace and triggers sparse and W=1 missing variable declaration warnings.
Quoted 14 lines
mm/damon/core.c +2
-1+/* * Reset the aggregated monitoring results ('nr_accesses' of each region). */ @@ -4308,7 +4327,7 @@ void damon_update_region_access_rate(struct damon_region *r, bool accessed)*/ bool damon_initialized (void ) { -return damon_region_cache !=NULL ; +return damon_region_cache && damon_report_queue.reports; }static int __init damon_init (void )
mm/damon/core.c static int __init damon_init(void) · line 4347
Quoted 10 lines
mm/damon/core.c +7
-0@@ -4319,6 +4338,14 @@ static int __init damon_init(void)return -ENOMEM ; } + damon_report_queue.size =1000 ; + damon_report_queue.reports =kmalloc_objs (*damon_report_queue.reports, +1000 ,GFP_KERNEL ); +if (!damon_report_queue.reports) { +pr_err ("report queue alloc fail\n" ); +return -ENOMEM ; + }
[Severity: Medium]
Does this error path leak damon_region_cache when kmalloc_objs() fails? Destroying damon_region_cache and resetting it (along with damon_report_queue.size) before returning -ENOMEM would avoid leaking the slab cache and leaving partially initialized state.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
SJ Park
maintainerRe: [RFC PATCH 02/27] mm/damon/core: implement data attribute report queue
Quoted 39 lines · On Sun, 15 Nov 2026 20:41:23 +0000 [email protected] wrote:
Thank you for your contribution! Sashiko AI review found 3 potential issues to consider:
- [Medium] mm/damon:damon_init()leaksdamon_region_cacheon queue alloc failure
- [Low] mm/damon: missing static qualifier ondamon_report_queueincore.c
- [Low] mm/damon: structdamon_report_queuecomment documents head notnr_reports
--commit
10a61bc9bab6e48534e4a8552380aecaccbee97a
Author: SJ Park <[email protected]>
mm/damon/core: implement data attribute report queueThis commit adds an internal
damon_report_queuestructure, allocates its buffer for up to 1,000 reports indamon_init(), and checks that buffer indamon_initialized().Quoted 20 lines
mm/damon/core.c +12
-0@@ -2334,6 +2334,25 @@ int damos_walk(struct damon_ctx *ctx, struct damos_walk_control *control)return 0 ; } +/* +* struct damon_report_queue - &struct damon_report queue. +* +* @lock: Represent if this queue is being used by someone. +* @head: Head of the queue. +* @tail: Tail of the queue. +* @size: Size of the queue. +* @reports: Array of &struct damon_report. +*/ +struct damon_report_queue { +atomic_t lock; +unsigned int tail;
Quoted 8 lines
mm/damon/core.c int damos_walk(struct damon_ctx *ctx, struct damos_walk_control *control) · line 2352
Quoted 4 lines
mm/damon/core.c +4
-0+unsigned int size; +unsigned int nr_reports; +struct damon_report *reports; +};[Severity: Low]
The comment above structdamon_report_queuedocuments @head, whereas the struct definesnr_reportsinstead.
Nice catch. I will remove the comment for @head and add a comment for @nr_reports.
Quoted 9 lines
mm/damon/core.c int damos_walk(struct damon_ctx *ctx, struct damos_walk_control *control) · line 2354
Quoted 3 lines
mm/damon/core.c +2
-0+ +struct damon_report_queue damon_report_queue;[Severity: Low]
Shoulddamon_report_queuebe marked static? structdamon_report_queueis private tomm/damon/core.c, so leavingdamon_report_queuenon-static exports it into the global namespace and triggers sparse and W=1 missing variable declaration warnings.
Good suggestion, I will mark it as static.
Quoted 18 lines
Quoted 18 lines
mm/damon/core.c +2
-1+/* * Reset the aggregated monitoring results ('nr_accesses' of each region). */ @@ -4308,7 +4327,7 @@ void damon_update_region_access_rate(struct damon_region *r, bool accessed)*/ bool damon_initialized (void ) { -return damon_region_cache !=NULL ; +return damon_region_cache && damon_report_queue.reports; }static int __init damon_init (void )@@ -4319,6 +4338,14 @@ static int __init damon_init(void)return -ENOMEM ; }
Quoted 13 lines
mm/damon/core.c static int __init damon_init(void) · line 4347
Quoted 7 lines
mm/damon/core.c +7
-0+ damon_report_queue.size =1000 ; + damon_report_queue.reports =kmalloc_objs (*damon_report_queue.reports, +1000 ,GFP_KERNEL ); +if (!damon_report_queue.reports) { +pr_err ("report queue alloc fail\n" ); +return -ENOMEM ; + }[Severity: Medium]
Does this error path leakdamon_region_cachewhenkmalloc_objs()fails? Destroyingdamon_region_cacheand resetting it (along with damon_report_queue.size) before returning-ENOMEMwould avoid leaking the slab cache and leaving partially initialized state.
Good suggestion. I will do destroy damon_region_cache.
Quoted 4 lines
Signature · 2 lines
-- Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
Thanks,
SJ
SJ Park
maintainerRFC PATCH 3/27 mm/damon/core: introduce damon_submit_report()
In reply to SJ ParkImplement and expose a new DAMON API function for submitting a data attribute report. Any kernel component in any context including NMI context can use it to report their finding of data attribute information for a given memory.
The function copies the content of the report into the DAMON-internal report queue. The copy is done in a ring buffer-like manner, without being blocked for consumption. As a result, the queue keeps the latest reports up to its capacity.
Use simple CAS-based try-locking. If any parallel submission is detected, simply forgive the submission.
--- include/linux/damon.h | 2 ++ mm/damon/core.c | 30 ++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+)
include/linux/damon.h +2 -0
@@ -1189,6 +1189,8 @@ int damon_kdamond_pid(struct damon_ctx *ctx);int damon_call (struct damon_ctx *ctx,struct damon_call_control *control);int damos_walk (struct damon_ctx *ctx,struct damos_walk_control *control); +int damon_submit_report (struct damon_report *report); + int damon_set_region_system_rams_default(struct damon_target *t, unsigned long *start, unsigned long *end, unsigned long addr_unit,
mm/damon/core.c +30 -0
@@ -2353,6 +2353,36 @@ struct damon_report_queue {struct damon_report_queue damon_report_queue; +/** +* damon_submit_report() - Enqueue a given report to DAMON internal buffer. +* @report: The report to enqueue. +* +* This function can be called from any context including the NMI context. +*/ +int damon_submit_report (struct damon_report *report) +{ +struct damon_report_queue *queue; +int lock_old_val; +unsigned int tail; + + queue = &damon_report_queue; + report->jiffies = jiffies; + lock_old_val =atomic_cmpxchg (&queue->lock,0 ,1 ); +if (lock_old_val) +return -EBUSY ; + + tail = queue->tail; +if (tail == queue->size) + tail =0 ; + queue->reports[tail] = *report; + queue->tail++; +if (queue->nr_reports < queue->size) + queue->nr_reports++; +/* cmpxchg is known to be faster than xchg */ +atomic_cmpxchg (&queue->lock,1 ,0 ); +return 0 ; +} +/* * Reset the aggregated monitoring results ('nr_accesses' of each region). */
Signature · 1 line
2.47.3
[email protected]
AI reviewRe: [RFC PATCH 03/27] mm/damon/core: introduce damon_submit_report()
Thank you for your contribution! Sashiko AI review found 2 potential issues to consider: - [High] mm/damon/core: out-of-bounds write in damon_submit_report() on queue wrap - [Low] mm/damon/core…
Thank you for your contribution! Sashiko AI review found 2 potential issues to consider:
- [High] mm/damon/core: out-of-bounds write in damon_submit_report() on queue wrap
- [Low] mm/damon/core: missing Return section in damon_submit_report() kernel-doc
--
commit bcb278386fb51304d0c224892db9744bf9e27c8f
Author: SJ Park <[email protected]>
mm/damon/core: introduce damon_submit_report()
This commit adds damon_submit_report() to enqueue a data attribute report into the DAMON internal report queue using CAS-based try-locking.
Quoted 5 lines
mm/damon/core.c +0
-0
mm/damon/core.c struct damon_report_queue { · line 2362
Quoted 10 lines
mm/damon/core.c +7
-0@@ -2353,6 +2353,36 @@ struct damon_report_queue {struct damon_report_queue damon_report_queue; +/** +* damon_submit_report() - Enqueue a given report to DAMON internal buffer. +* @report: The report to enqueue. +* +* This function can be called from any context including the NMI context. +*/ +int damon_submit_report (struct damon_report *report)
[Severity: Low]
This isn't a bug, but the kernel-doc comment for damon_submit_report() is missing a Return: section describing the 0 and -EBUSY return values, which triggers a kernel-doc warning under W=2 builds.
Quoted 6 lines
mm/damon/core.c +6
-0+{ +struct damon_report_queue *queue; +int lock_old_val; +unsigned int tail; + + queue = &damon_report_queue;
mm/damon/core.c struct damon_report_queue { · line 2378
Quoted 10 lines
mm/damon/core.c +10
-0+ report->jiffies = jiffies; + lock_old_val =atomic_cmpxchg (&queue->lock,0 ,1 ); +if (lock_old_val) +return -EBUSY ; + + tail = queue->tail; +if (tail == queue->size) + tail =0 ; + queue->reports[tail] = *report; + queue->tail++;
[Severity: High]
Does this write out of bounds of queue->reports[] after the queue wraps?
When queue->tail reaches queue->size, only the local variable tail is reset to 0 while queue->tail++ increments queue->tail to queue->size + 1. Every subsequent submission then bypasses the tail == queue->size check and writes past the end of the queue->reports heap array, corrupting adjacent slab memory. Updating queue->tail = tail + 1 would wrap the index properly.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=3
SJ Park
maintainerRe: [RFC PATCH 03/27] mm/damon/core: introduce damon_submit_report()
Quoted 24 lines · On Sun, 15 Nov 2026 20:42:40 +0000 [email protected] wrote:
Thank you for your contribution! Sashiko AI review found 2 potential issues to consider:
- [High]mm/damon/core: out-of-bounds write indamon_submit_report()on queue wrap
- [Low]mm/damon/core: missing Return section indamon_submit_report()kernel-doc
--commit
bcb278386fb51304d0c224892db9744bf9e27c8f
Author: SJ Park <[email protected]>
mm/damon/core: introducedamon_submit_report()This commit adds
damon_submit_report()to enqueue a data attribute report into the DAMON internal report queue using CAS-based try-locking.Quoted 8 lines
mm/damon/core.c +0
-0@@ -2353,6 +2353,36 @@ struct damon_report_queue {struct damon_report_queue damon_report_queue;
Quoted 12 lines
mm/damon/core.c struct damon_report_queue { · line 2362
Quoted 7 lines
mm/damon/core.c +7
-0+/** +* damon_submit_report() - Enqueue a given report to DAMON internal buffer. +* @report: The report to enqueue. +* +* This function can be called from any context including the NMI context. +*/ +int damon_submit_report (struct damon_report *report)[Severity: Low]
This isn't a bug, but the kernel-doc comment fordamon_submit_report()is missing a Return: section describing the 0 and-EBUSYreturn values, which triggers a kernel-doc warning under W=2 builds.
Nice catch, I will add Return: comment.
Quoted 21 lines
Quoted 7 lines
mm/damon/core.c +6
-0+{ +struct damon_report_queue *queue; +int lock_old_val; +unsigned int tail; + + queue = &damon_report_queue;mm/damon/core.c struct damon_report_queue { · line 2378
Quoted 10 lines
mm/damon/core.c +10
-0+ report->jiffies = jiffies; + lock_old_val =atomic_cmpxchg (&queue->lock,0 ,1 ); +if (lock_old_val) +return -EBUSY ; + + tail = queue->tail; +if (tail == queue->size) + tail =0 ; + queue->reports[tail] = *report; + queue->tail++;[Severity: High]
Does this write out of bounds of queue->reports[] after the queue wraps?
Quoted 6 lines
When
queue->tailreachesqueue->size, only the local variable tail is reset to 0 while queue->tail++ incrementsqueue->tailtoqueue->size+ 1. Every subsequent submission then bypasses the tail ==queue->sizecheck and writes past the end of thequeue->reportsheap array, corrupting adjacent slab memory. Updatingqueue->tail= tail + 1 would wrap the index properly.
Good catch. I will remove tail local variable and just use queue->tail.
Quoted 4 lines
Signature · 2 lines
-- Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=3
Thanks,
SJ
SJ Park
maintainerRFC PATCH 4/27 mm/damon/sysfs: add admin/reports/ directory
In reply to SJ ParkAdd a new sysfs directory, reports/, as a place holder for sysfs files that will be used for controlling the data attribute report system. Put the directory under the admin/ directory, next to kdamonds/ directory.
--- mm/damon/sysfs.c | 63 +++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 59 insertions(+), 4 deletions(-)
mm/damon/sysfs.c +59 -4
@@ -2979,6 +2979,38 @@ static const struct kobj_type damon_sysfs_kdamonds_ktype = { .default_groups = damon_sysfs_kdamonds_groups, }; +/* reports dir */ + +struct damon_sysfs_reports { +struct kobject kobj; +}; + +static struct damon_sysfs_reports *damon_sysfs_reports_alloc (void ) +{ + return kzalloc_obj(struct damon_sysfs_reports); +} + +static int damon_sysfs_reports_add_dirs (struct damon_sysfs_reports *reports) +{ +return 0 ; +} + +static void damon_sysfs_reports_release (struct kobject *kobj) +{ +kfree (container_of(kobj ,struct damon_sysfs_reports ,kobj )); +} + +static struct attribute *damon_sysfs_reports_attrs[] = { +NULL , +}; +ATTRIBUTE_GROUPS (damon_sysfs_reports); + +static const struct kobj_type damon_sysfs_reports_ktype = { + .release = damon_sysfs_reports_release, + .sysfs_ops = &kobj_sysfs_ops, + .default_groups = damon_sysfs_reports_groups, +}; +/* * damon user interface directory */
@@ -2986,6 +3018,7 @@ static const struct kobj_type damon_sysfs_kdamonds_ktype = {struct damon_sysfs_ui_dir {struct kobject kobj;struct damon_sysfs_kdamonds *kdamonds; +struct damon_sysfs_reports *reports; };static struct damon_sysfs_ui_dir *damon_sysfs_ui_dir_alloc (void )
@@ -2996,6 +3029,7 @@ static struct damon_sysfs_ui_dir *damon_sysfs_ui_dir_alloc(void)static int damon_sysfs_ui_dir_add_dirs (struct damon_sysfs_ui_dir *ui_dir) {struct damon_sysfs_kdamonds *kdamonds; +struct damon_sysfs_reports *reports;int err; kdamonds =damon_sysfs_kdamonds_alloc ();
@@ -3005,11 +3039,32 @@ static int damon_sysfs_ui_dir_add_dirs(struct damon_sysfs_ui_dir *ui_dir) err =kobject_init_and_add (&kdamonds->kobj, &damon_sysfs_kdamonds_ktype, &ui_dir->kobj,"kdamonds" ); -if (err) { -kobject_put (&kdamonds->kobj); -return err; - } +if (err) + goto put_kdamonds_out; ui_dir->kdamonds = kdamonds; + + reports =damon_sysfs_reports_alloc (); +if (!reports) { + err = -ENOMEM ; + goto put_kdamonds_out; + } + ui_dir->reports = reports; + + err =kobject_init_and_add (&reports->kobj, &damon_sysfs_reports_ktype, + &ui_dir->kobj,"reports" ); +if (err) + goto put_reports_out; + err =damon_sysfs_reports_add_dirs (reports); +if (err) + goto put_reports_out; +return err; + +put_reports_out: +kobject_put (&reports->kobj); + ui_dir->reports =NULL ; +put_kdamonds_out: +kobject_put (&kdamonds->kobj); + ui_dir->kdamonds =NULL ;return err; }
Signature · 1 line
2.47.3
[email protected]
AI reviewRe: [RFC PATCH 04/27] mm/damon/sysfs: add admin/reports/ directory
Sashiko has reviewed this patch and found no issues.
Quoted 5 lines
Add a new sysfs directory, reports/, as a place holder for sysfs files that will be used for controlling the data attribute report system. Put the directory under the admin/ directory, next to kdamonds/ directory.
Signed-off-by SJ Park <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=4
SJ Park
maintainerRFC PATCH 5/27 mm/damon/sysfs: add reports/producers/ directory
In reply to SJ ParkAdd a new sysfs directory, producers/, under reports/ directory. It is a placeholder for files that will be used for controlling DAMON report producers.
--- mm/damon/sysfs.c | 48 +++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 47 insertions(+), 1 deletion(-)
mm/damon/sysfs.c +47 -1
@@ -2979,10 +2979,38 @@ static const struct kobj_type damon_sysfs_kdamonds_ktype = { .default_groups = damon_sysfs_kdamonds_groups, }; +/* producers dir */ + +struct damon_sysfs_producers { +struct kobject kobj; +}; + +static struct damon_sysfs_producers *damon_sysfs_producers_alloc (void ) +{ + return kzalloc_obj(struct damon_sysfs_producers); +} + +static void damon_sysfs_producers_release (struct kobject *kobj) +{ +kfree (container_of(kobj ,struct damon_sysfs_producers ,kobj )); +} + +static struct attribute *damon_sysfs_producers_attrs[] = { +NULL , +}; +ATTRIBUTE_GROUPS (damon_sysfs_producers); + +static const struct kobj_type damon_sysfs_producers_ktype = { + .release = damon_sysfs_producers_release, + .sysfs_ops = &kobj_sysfs_ops, + .default_groups = damon_sysfs_producers_groups, +}; +/* reports dir */ struct damon_sysfs_reports {struct kobject kobj; +struct damon_sysfs_producers *producers; };static struct damon_sysfs_reports *damon_sysfs_reports_alloc (void )
@@ -2992,7 +3020,25 @@ static struct damon_sysfs_reports *damon_sysfs_reports_alloc(void)static int damon_sysfs_reports_add_dirs (struct damon_sysfs_reports *reports) { -return 0 ; +struct damon_sysfs_producers *producers; +int err; + + producers =damon_sysfs_producers_alloc (); +if (!producers) +return -ENOMEM ; + reports->producers = producers; + + err =kobject_init_and_add (&producers->kobj, + &damon_sysfs_producers_ktype, &reports->kobj, +"producers" ); +if (err) + goto put_producers_out; +return err; + +put_producers_out: +kobject_put (&producers->kobj); + reports->producers =NULL ; +return err; }static void damon_sysfs_reports_release (struct kobject *kobj)
Signature · 1 line
2.47.3
[email protected]
AI reviewRe: [RFC PATCH 05/27] mm/damon/sysfs: add reports/producers/ directory
Sashiko has reviewed this patch and found no issues.
Quoted 5 lines
Add a new sysfs directory, producers/, under reports/ directory. It is a placeholder for files that will be used for controlling DAMON report producers.
Signed-off-by SJ Park <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=5
SJ Park
maintainerRFC PATCH 6/27 mm/damon/sysfs: add producers/nr_producers file
In reply to SJ ParkImplement a new sysfs file, nr_producers, under the producers/ directory. The file will be used for generating directories for each report producer, in a manner that is similar to the nr_kdamonds file.
--- mm/damon/sysfs.c | 51 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+)
mm/damon/sysfs.c +51 -0
@@ -2983,6 +2983,7 @@ static const struct kobj_type damon_sysfs_kdamonds_ktype = {struct damon_sysfs_producers {struct kobject kobj; +int nr; };static struct damon_sysfs_producers *damon_sysfs_producers_alloc (void )
@@ -2990,12 +2991,62 @@ static struct damon_sysfs_producers *damon_sysfs_producers_alloc(void) return kzalloc_obj(struct damon_sysfs_producers); } +static void damon_sysfs_producers_rm_dirs ( +struct damon_sysfs_producers *producers) +{ + producers->nr =0 ; +} + +static int damon_sysfs_producers_add_dirs ( +struct damon_sysfs_producers *producers,int nr_producers) +{ +damon_sysfs_producers_rm_dirs (producers); + producers->nr = nr_producers; +return 0 ; +} + +static ssize_t nr_producers_show (struct kobject *kobj, +struct kobj_attribute *attr,char *buf) +{ +struct damon_sysfs_producers *producers =container_of (kobj, + struct damon_sysfs_producers, kobj); + +return sysfs_emit (buf,"%d\n" , producers->nr); +} + +static ssize_t nr_producers_store (struct kobject *kobj, +struct kobj_attribute *attr,const char *buf,size_t count) +{ +struct damon_sysfs_producers *producers; +int nr, err =kstrtoint (buf,0 , &nr); + +if (err) +return err; +if (nr <0 ) +return -EINVAL ; + + producers = container_of(kobj, struct damon_sysfs_producers, kobj); + +if (!mutex_trylock (&damon_sysfs_lock)) +return -EBUSY ; + err =damon_sysfs_producers_add_dirs (producers, nr); +mutex_unlock (&damon_sysfs_lock); +if (err) +return err; + +return count; +} +static void damon_sysfs_producers_release (struct kobject *kobj) {kfree (container_of(kobj ,struct damon_sysfs_producers ,kobj )); } +static struct kobj_attribute damon_sysfs_producers_nr_attr = +__ATTR_RW_MODE (nr_producers,0600 ); +static struct attribute *damon_sysfs_producers_attrs[] = { + &damon_sysfs_producers_nr_attr.attr,NULL , };ATTRIBUTE_GROUPS (damon_sysfs_producers);
Signature · 1 line
2.47.3
[email protected]
AI reviewRe: [RFC PATCH 06/27] mm/damon/sysfs: add producers/nr_producers file
Sashiko has reviewed this patch and found no issues.
Quoted 5 lines
Implement a new sysfs file,
nr_producers, under the producers/ directory. The file will be used for generating directories for each report producer, in a manner that is similar to thenr_kdamondsfile.Signed-off-by SJ Park <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=6
SJ Park
maintainerRFC PATCH 7/27 mm/damon/sysfs: implement report producer directory
In reply to SJ ParkImplement a sysfs directory for each report producer. Create and remove the directories for reports/producers/nr_producers file writes. It is a placeholder for sysfs files that will be used for controlling each report producer.
--- mm/damon/sysfs.c | 71 +++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 70 insertions(+), 1 deletion(-)
mm/damon/sysfs.c +70 -1
@@ -2979,10 +2979,40 @@ static const struct kobj_type damon_sysfs_kdamonds_ktype = { .default_groups = damon_sysfs_kdamonds_groups, }; +/* producer dir */ + +struct damon_sysfs_producer { +struct kobject kobj; +}; + +static struct damon_sysfs_producer *damon_sysfs_producer_alloc (void ) +{ + return kzalloc_obj(struct damon_sysfs_producer); +} + +static void damon_sysfs_producer_release (struct kobject *kobj) +{ +struct damon_sysfs_producer *producer =container_of (kobj, + struct damon_sysfs_producer, kobj); +kfree (producer); +} + +static struct attribute *damon_sysfs_producer_attrs[] = { +NULL , +}; +ATTRIBUTE_GROUPS (damon_sysfs_producer); + +static const struct kobj_type damon_sysfs_producer_ktype = { + .release = damon_sysfs_producer_release, + .sysfs_ops = &kobj_sysfs_ops, + .default_groups = damon_sysfs_producer_groups, +}; +/* producers dir */ struct damon_sysfs_producers {struct kobject kobj; +struct damon_sysfs_producer **producers_arr;int nr; };
@@ -2994,14 +3024,53 @@ static struct damon_sysfs_producers *damon_sysfs_producers_alloc(void)static void damon_sysfs_producers_rm_dirs (struct damon_sysfs_producers *producers) { +struct damon_sysfs_producer **producers_arr = producers->producers_arr; +int i; + +for (i =0 ; i < producers->nr; i++) { +kobject_del (&producers_arr[i]->kobj); +kobject_put (&producers_arr[i]->kobj); + } producers->nr =0 ; +kfree (producers_arr); + producers->producers_arr =NULL ; }static int damon_sysfs_producers_add_dirs (struct damon_sysfs_producers *producers,int nr_producers) { +struct damon_sysfs_producer **producers_arr, *producer; +int err, i; +damon_sysfs_producers_rm_dirs (producers); - producers->nr = nr_producers; +if (!nr_producers) +return 0 ; + + producers_arr =kmalloc_objs (*producers_arr, nr_producers, +GFP_KERNEL | __GFP_NOWARN); +if (!producers_arr) +return -ENOMEM ; + producers->producers_arr = producers_arr; + +for (i =0 ; i < nr_producers; i++) { + producer =damon_sysfs_producer_alloc (); +if (!producer) { +damon_sysfs_producers_rm_dirs (producers); +return -ENOMEM ; + } + + err =kobject_init_and_add (&producer->kobj, + &damon_sysfs_producer_ktype, &producers->kobj, +"%d" , i); +if (err) { +kobject_put (&producer->kobj); +damon_sysfs_producers_rm_dirs (producers); +return err; + } + + producers_arr[i] = producer; + producers->nr++; + }return 0 ; }
Signature · 1 line
2.47.3
[email protected]
AI reviewRe: [RFC PATCH 07/27] mm/damon/sysfs: implement report producer directory
Sashiko has reviewed this patch and found no issues.
Quoted 6 lines
Implement a sysfs directory for each report producer. Create and remove the directories for reports/producers/nr_producers file writes. It is a placeholder for sysfs files that will be used for controlling each report producer.
Signed-off-by SJ Park <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=7
SJ Park
maintainerRFC PATCH 8/27 mm/damon/sysfs: implement report producer type and state files
In reply to SJ ParkImplement report_type and producer_state files under the report producer directory. The type file receives the type of the reports that the producer will generate and submit to DAMON. The producer_state file enables and disables the producer.
--- mm/damon/sysfs.c | 80 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+)
mm/damon/sysfs.c +80 -0
@@ -2983,6 +2983,8 @@ static const struct kobj_type damon_sysfs_kdamonds_ktype = {struct damon_sysfs_producer {struct kobject kobj; +enum damon_report_type report_type; +bool enabled; };static struct damon_sysfs_producer *damon_sysfs_producer_alloc (void )
@@ -2990,6 +2992,77 @@ static struct damon_sysfs_producer *damon_sysfs_producer_alloc(void) return kzalloc_obj(struct damon_sysfs_producer); } +struct damon_sysfs_report_type_name { +enum damon_report_type type; +char *name; +}; + +static const struct damon_sysfs_report_type_name +damon_sysfs_report_type_names[] = { +}; + +static ssize_t report_type_show (struct kobject *kobj, +struct kobj_attribute *attr,char *buf) +{ +struct damon_sysfs_producer *producer =container_of (kobj, + struct damon_sysfs_producer, kobj); +int i; + +for (i =0 ; i <ARRAY_SIZE (damon_sysfs_report_type_names); i++) { +const struct damon_sysfs_report_type_name *type_name; + + type_name = &damon_sysfs_report_type_names[i]; +if (type_name->type == producer->report_type) +return sysfs_emit (buf,"%s\n" , type_name->name); + } +return -EINVAL ; +} + +static ssize_t report_type_store (struct kobject *kobj, +struct kobj_attribute *attr,const char *buf,size_t count) +{ +struct damon_sysfs_producer *producer =container_of (kobj, + struct damon_sysfs_producer, kobj); +ssize_t ret = -EINVAL ; +int i; + +for (i =0 ; i <ARRAY_SIZE (damon_sysfs_report_type_names); i++) { +const struct damon_sysfs_report_type_name *type_name; + + type_name = &damon_sysfs_report_type_names[i]; +if (sysfs_streq (buf, type_name->name)) { + producer->report_type = type_name->type; + ret = count; +break ; + } + } +return ret; +} + +static ssize_t producer_state_show (struct kobject *kobj, +struct kobj_attribute *attr,char *buf) +{ +struct damon_sysfs_producer *producer =container_of (kobj, + struct damon_sysfs_producer, kobj); + +return sysfs_emit (buf,"%s\n" , producer->enabled ?"on" :"off" ); +} + +static ssize_t producer_state_store (struct kobject *kobj, +struct kobj_attribute *attr,const char *buf,size_t count) +{ +struct damon_sysfs_producer *producer =container_of (kobj, + struct damon_sysfs_producer, kobj); + +if (sysfs_streq (buf,"on" )) + producer->enabled = true; +else if (sysfs_streq (buf,"off" )) + producer->enabled = false; +else +return -EINVAL ; +return count; +} +static void damon_sysfs_producer_release (struct kobject *kobj) { struct damon_sysfs_producer *producer = container_of(kobj,
@@ -2997,7 +3070,14 @@ static void damon_sysfs_producer_release(struct kobject *kobj)kfree (producer); } +static struct kobj_attribute damon_sysfs_producer_report_type_attr = +__ATTR_RW_MODE (report_type,0600 ); +static struct kobj_attribute damon_sysfs_producer_producer_state_type_attr = +__ATTR_RW_MODE (producer_state,0600 ); +static struct attribute *damon_sysfs_producer_attrs[] = { + &damon_sysfs_producer_report_type_attr.attr, + &damon_sysfs_producer_producer_state_type_attr.attr,NULL , };ATTRIBUTE_GROUPS (damon_sysfs_producer);
Signature · 1 line
2.47.3
[email protected]
AI reviewRe: [RFC PATCH 08/27] mm/damon/sysfs: implement report producer type and state files
Sashiko has reviewed this patch and found no issues.
Quoted 6 lines
Implement
report_typeandproducer_statefiles under the report producer directory. The type file receives the type of the reports that the producer will generate and submit to DAMON. Theproducer_statefile enables and disables the producer.Signed-off-by SJ Park <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=8
SJ Park
maintainerRFC PATCH 9/27 Docs/mm/damon/design: update for report system
In reply to SJ ParkUpdate DAMON design for the data attribute report system.
--- Documentation/mm/damon/design.rst | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+)
Documentation/mm/damon/design.rst +26 -0
@@ -356,6 +356,32 @@ monitoring. Refer to the :ref:`admin guide <damon_usage_sysfs_probes>` to know how users can use the mode. +.. _damon_design_attr_reporting: + +Data Attributes Reporting +~~~~~~~~~~~~~~~~~~~~~~~~~ + +DAMON-external entities such as other kernel components and users may have +special data attribute information. DAMON provides a system that let them +report such information to DAMON. + +DAMON provides the kernel API for submitting a report of data attribute +information to DAMON. A report describes what type of the report is, +representing the reporting data attribute type. A report also describes the +address range of the memory that the report is made for. Depending on the +report type, the report can have additional information. The report is saved +in DAMON's internal queue. The queue is automatically managed by DAMON with +its best effort. + +DAMON provides the user :ref:`ABI <damon_usage_sysfs_reports_producers>` for +configuring report producers. Each producer is configured for a specific +report type. Users can dynamically enable and disable those. When enabled, it +can generate and submit reports of the given type. The generations and +submissions could be done automatically by the kernel or manually by the user, +depending on the type of the report. + +For now, no report type is supported. + Dynamic Target Space Updates Handling ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Signature · 1 line
2.47.3
[email protected]
AI reviewRe: [RFC PATCH 09/27] Docs/mm/damon/design: update for report system
Sashiko has reviewed this patch and found no issues.
Quoted 3 lines
Update DAMON design for the data attribute report system.
Signed-off-by SJ Park <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=9
SJ Park
maintainerRFC PATCH 10/27 Docs/admin-guide/mm/damon/usage: update for report producer sysfs
In reply to SJ ParkUpdate DAMON usage document for the newly added report producer control sysfs files.
--- Documentation/admin-guide/mm/damon/usage.rst | 35 ++++++++++++++++++++ 1 file changed, 35 insertions(+)
Documentation/admin-guide/mm/damon/usage.rst +35 -0
@@ -115,6 +115,10 @@ comma (","). │ │ │ │ │ │ ... │ │ │ │ ... │ │ ... + │ reports/ + │ │ producers/nr_producers + │ │ │ 0/report_type,producer_state + │ │ │ ... .. _sysfs_root:
@@ -729,6 +733,37 @@ Please note that it's highly recommended to use user space tools like `damo <https://github.com/damonitor/damo>`_ rather than manually reading and writing the files as above. Above is only for an example. +.. _damon_usage_sysfs_reports_producers: + +reports/producers/ +------------------ + +Under the `admin/` directory, ``reports/producers/`` directory exists. This +directory is for configuring :ref:`DAMON report producers +<damon_design_attr_reporting>`. The file below exists in the directory. + +``nr_producers`` file is for generating report producers setup files. Writing +an integer ``N`` to the file creates the number of directories named ``0`` to +``N-1``. Each number-named directory is for configuring each report producer +and called "producer directory". + +reports/producers/<N>/ +---------------------- + +Files below exist in each producer directory. + +``report_type`` file is for setting the type of the report to produce. Users +can set the type by writing the type name to the file. Reading the file shows +the last successfully written input. Refer to the :ref:`design document +<damon_design_attr_reporting>` for the list of supported report types. + +``producer_state`` file is for reading and updating the state. Reading it +shows ``on`` or ``off`` if the producer is enabled or disabled, respectively. +Users can write below keywords for the producer to the file. + +- ``on``: Enable the producer. +- ``off``: Disable the producer. + .. _tracepoint: Tracepoints for Monitoring Results
Signature · 1 line
2.47.3
[email protected]
AI reviewRe: [RFC PATCH 10/27] Docs/admin-guide/mm/damon/usage: update for report producer sysfs
Sashiko has reviewed this patch and found no issues.
Quoted 4 lines
Update DAMON usage document for the newly added report producer control sysfs files.
Signed-off-by SJ Park <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=10
SJ Park
maintainerRFC PATCH 11/27 Docs/ABI/damon: update for report producer sysfs files
In reply to SJ ParkUpdate DAMON ABI document for the newly added data attribute report producer control sysfs files.
--- .../ABI/testing/sysfs-kernel-mm-damon | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+)
Documentation/ABI/testing/sysfs-kernel-mm-damon +20 -0
@@ -695,3 +695,23 @@ Date: May 2026 Contact: SJ Park <[email protected]> Description: Reading this file returns the number of data-attribute monitoring probe-hit positive samples of the region. + +What: /sys/kernel/mm/damon/admin/reports/producers/nr_producers +Date: Nov 2026 +Contact: SJ Park <[email protected]> +Description: Writing a number 'N' to this file creates the number of + directories for controlling each DAMON report producers + named '0' to 'N-1' under the 'producers/' directory. + +What: /sys/kernel/mm/damon/admin/reports/producers/<P>/report_type +Date: Nov 2026 +Contact: SJ Park <[email protected]> +Description: Writing to and reading from this file sets and gets the type of + the reports the producer will generate and submit. + +What: /sys/kernel/mm/damon/admin/reports/producers/<P>/producer_state +Date: Nov 2026 +Contact: SJ Park <[email protected]> +Description: A file for requesting actions including enablement and + disablement of the producer. Refer to + Documentation/admin-guide/mm/damon/usage.rst for more details.
Signature · 1 line
2.47.3
[email protected]
AI reviewRe: [RFC PATCH 11/27] Docs/ABI/damon: update for report producer sysfs files
Sashiko has reviewed this patch and found no issues.
Quoted 4 lines
Update DAMON ABI document for the newly added data attribute report producer control sysfs files.
Signed-off-by SJ Park <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=11
SJ Park
maintainerRFC PATCH 12/27 mm/damon/core: introduce DAMON_FILTER_TYPE_REPORT_MADE
In reply to SJ ParkExtend DAMON probe filter for the existence of data attribute reports for the probing memory. Define a new filter type, REPORT_MADE, for the purpose. Add a union argument for specifying the type of the reports for the filter. Update the new argument for the new type when new filter parameters of the type are committed.
--- include/linux/damon.h | 3 +++ mm/damon/core.c | 3 +++ 2 files changed, 6 insertions(+)
include/linux/damon.h +3 -0
@@ -804,6 +804,7 @@ struct damon_prep {* @DAMON_FILTER_TYPE_PGIDLE_SET: Pgidle is set. * @DAMON_FILTER_TYPE_HUGEPAGE_SIZE: Page is part of a hugepage. * @DAMON_FILTER_TYPE_ACTIVE: LRU-active pages. +* @DAMON_FILTER_TYPE_REPORT_MADE: Report is submitted. */ enum damon_filter_type {DAMON_FILTER_TYPE_ANON ,
@@ -812,6 +813,7 @@ enum damon_filter_type {DAMON_FILTER_TYPE_PGIDLE_SET ,DAMON_FILTER_TYPE_HUGEPAGE_SIZE ,DAMON_FILTER_TYPE_ACTIVE , + DAMON_FILTER_TYPE_REPORT_MADE, };/**
@@ -834,6 +836,7 @@ struct damon_filter {unsigned long range_min;unsigned long range_max; }; +enum damon_report_type report_type; };/* private: */ /* Siblings list. */
mm/damon/core.c +3 -0
@@ -1834,6 +1834,9 @@ static int damon_commit_filter(struct damon_filter *dst, dst->range_min = src->range_min; dst->range_max = src->range_max;break ; +case DAMON_FILTER_TYPE_REPORT_MADE : + dst->report_type = src->report_type; +break ;default :break ; }
Signature · 1 line
2.47.3
[email protected]
AI reviewRe: [RFC PATCH 12/27] mm/damon/core: introduce DAMON_FILTER_TYPE_REPORT_MADE
Thank you for your contribution! Sashiko AI review found 2 potential issues to consider: - [Medium] mm/damon: missing report_type copy in damon_commit_filters() - [Low] mm/damon: missing kernel-doc…
Thank you for your contribution! Sashiko AI review found 2 potential issues to consider:
- [Medium] mm/damon: missing report_type copy in damon_commit_filters()
- [Low] mm/damon: missing kernel-doc for report_type in struct damon_filter
--
commit 4743cf0114c7407b0d8b853557595a3a4674cb82
Author: SJ Park <[email protected]>
mm/damon/core: introduce DAMON_FILTER_TYPE_REPORT_MADE
This commit introduces the DAMON_FILTER_TYPE_REPORT_MADE probe filter type, adds report_type to struct damon_filter, and copies it in damon_commit_filter().
Quoted 4 lines
include/linux/damon.h +0
-0
[ ... ]
include/linux/damon.h struct damon_filter { · line 840
Quoted 6 lines
include/linux/damon.h +1
-0@@ -834,6 +836,7 @@ struct damon_filter {unsigned long range_min;unsigned long range_max; }; +enum damon_report_type report_type; };
[Severity: Low]
Should @report_type be documented in the kernel-doc comment for struct damon_filter to avoid a kernel-doc warning?
mm/damon/core.c static int damon_commit_filter(struct damon_filter *dst, · line 1839
Quoted 11 lines
mm/damon/core.c +3
-0@@ -1834,6 +1834,9 @@ static int damon_commit_filter(struct damon_filter *dst, dst->range_min = src->range_min; dst->range_max = src->range_max;break ; +case DAMON_FILTER_TYPE_REPORT_MADE : + dst->report_type = src->report_type; +break ;
[Severity: Medium]
Does damon_commit_filters() also need to copy report_type when allocating a new filter?
damon_commit_filter() is only called when overwriting an existing filter in dst. When src has more filters than dst, damon_commit_filters() allocates new_filter via damon_new_filter() (which uses kmalloc_obj() without initializing the union) and runs a separate switch on src_filter->type:
mm/damon/core.c:damon_commit_filters() {
...
new_filter = damon_new_filter(
src_filter->type, src_filter->matching,
src_filter->allow);
if (!new_filter)
return -ENOMEM;
switch (src_filter->type) {
case DAMON_FILTER_TYPE_MEMCG:
new_filter->memcg_id = src_filter->memcg_id;
break;
case DAMON_FILTER_TYPE_HUGEPAGE_SIZE:
...
break;
default:
break;
}
...
}Because DAMON_FILTER_TYPE_REPORT_MADE is not handled there, committing a newly added report_made filter leaves new_filter->report_type uninitialized.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=12
SJ Park
maintainerRe: [RFC PATCH 12/27] mm/damon/core: introduce DAMON_FILTER_TYPE_REPORT_MADE
Quoted 23 lines · On Sun, 15 Nov 2026 20:36:01 +0000 [email protected] wrote:
Thank you for your contribution! Sashiko AI review found 2 potential issues to consider:
- [Medium] mm/damon: missingreport_typecopy indamon_commit_filters()
- [Low] mm/damon: missing kernel-doc forreport_typein structdamon_filter
--commit
4743cf0114c7407b0d8b853557595a3a4674cb82
Author: SJ Park <[email protected]>
mm/damon/core: introduceDAMON_FILTER_TYPE_REPORT_MADEThis commit introduces the
DAMON_FILTER_TYPE_REPORT_MADEprobe filter type, addsreport_typeto structdamon_filter, and copies it indamon_commit_filter().Quoted 4 lines
include/linux/damon.h +0
-0[ ... ]
Quoted 10 lines
include/linux/damon.h struct damon_filter { · line 840
Quoted 6 lines
include/linux/damon.h +1
-0@@ -834,6 +836,7 @@ struct damon_filter {unsigned long range_min;unsigned long range_max; }; +enum damon_report_type report_type; };[Severity: Low]
Should @report_type be documented in the kernel-doc comment for structdamon_filterto avoid a kernel-doc warning?
Nice catch. I will add the kernel-doc comment.
Quoted 43 lines
mm/damon/core.c static int damon_commit_filter(struct damon_filter *dst, · line 1839
Quoted 12 lines
mm/damon/core.c +3
-0@@ -1834,6 +1834,9 @@ static int damon_commit_filter(struct damon_filter *dst, dst->range_min = src->range_min; dst->range_max = src->range_max;break ; +case DAMON_FILTER_TYPE_REPORT_MADE : + dst->report_type = src->report_type; +break ;[Severity: Medium]
Doesdamon_commit_filters()also need to copyreport_typewhen allocating a new filter?
damon_commit_filter()is only called when overwriting an existing filter in dst. When src has more filters than dst,damon_commit_filters()allocatesnew_filterviadamon_new_filter()(which useskmalloc_obj()without initializing the union) and runs a separate switch onsrc_filter->type:mm/damon/core.c:damon_commit_filters() { ... new_filter = damon_new_filter( src_filter->type, src_filter->matching, src_filter->allow); if (!new_filter) return -ENOMEM; switch (src_filter->type) { case DAMON_FILTER_TYPE_MEMCG: new_filter->memcg_id = src_filter->memcg_id; break; case DAMON_FILTER_TYPE_HUGEPAGE_SIZE: ... break; default: break; } ... }
Quoted 3 lines
Because
DAMON_FILTER_TYPE_REPORT_MADEis not handled there, committing a newly addedreport_madefilter leavesnew_filter->report_typeuninitialized.
Good catch. I will add that.
Quoted 4 lines
Signature · 2 lines
-- Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=12
Thanks,
SJ
SJ Park
maintainerRFC PATCH 13/27 mm/damon/core: introduce damon_report_exist()
In reply to SJ ParkImplement and expose a new DAMON API function for searching data attribute reports from the report queue. The purpose is to let operation sets use it for supporting the REPORT_MADE type probe filters.
The caller can specify the type, associated memory address range, and the creation time range of reports to search.
The function uses CAS-based try-locking for the mutual-exclusive synchronization. If any parallel access to the queue is detected, it forgives searching.
--- include/linux/damon.h | 3 +++ mm/damon/core.c | 46 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+)
include/linux/damon.h +3 -0
@@ -1193,6 +1193,9 @@ int damon_call(struct damon_ctx *ctx, struct damon_call_control *control);int damos_walk (struct damon_ctx *ctx,struct damos_walk_control *control);int damon_submit_report (struct damon_report *report); +bool damon_report_exist (enum damon_report_type report_type, +struct damon_addr_range *addr_range, +unsigned long jiffies_old); int damon_set_region_system_rams_default(struct damon_target *t, unsigned long *start, unsigned long *end,
mm/damon/core.c +46 -0
52 lines not on this page · raw message
Signature · 1 line
2.47.3
[email protected]
AI reviewRe: [RFC PATCH 13/27] mm/damon/core: introduce damon_report_exist()
Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [High] mm/damon/core: out-of-bounds and uninitialized read in damon_report_exist() --
Thank you for your contribution! Sashiko AI review found 1 potential issue to consider:
- [High] mm/damon/core: out-of-bounds and uninitialized read in damon_report_exist()
--
commit be7b07b7677627ddaaa72484649217b5172610a1
Author: SJ Park <[email protected]>
mm/damon/core: introduce damon_report_exist()
This commit adds damon_report_exist() to search damon_report_queue for a report matching a given type, address range, and minimum age in jiffies.
Quoted 28 lines
mm/damon/core.c +20
-0@@ -2386,6 +2386,52 @@ int damon_submit_report(struct damon_report *report)return 0 ; } +/** +* damon_report_exist() - Find if a report of a given condition exists. +* +* @report_type: Type of the report. +* @addr_range: Address range of the report. +* @jiffies_old: Oldest jiffies to find the report for. +* +* Returns true if the report is found, false otherwise. +*/ +bool damon_report_exist (enum damon_report_type report_type, +struct damon_addr_range *addr_range,unsigned long jiffies_old) +{ +struct damon_report_queue *queue; +int lock_old_val; +unsigned int idx, nr_read; +struct damon_report *report; +bool found = false; + + queue = &damon_report_queue; + lock_old_val =atomic_cmpxchg (&queue->lock,0 ,1 );
mm/damon/core.c int damon_submit_report(struct damon_report *report) · line 2418
Quoted 10 lines
mm/damon/core.c +10
-0+ +if (lock_old_val) +return false; + idx = queue->tail; +for (nr_read =0 ; nr_read < queue->nr_reports; nr_read++) { + report = &queue->reports[idx]; +if (idx) + idx--; +else + idx = queue->size -1 ;
[Severity: High]
Can indexing queue->reports[idx] before decrementing and wrapping idx read uninitialized or out-of-bounds memory?
In damon_submit_report(), queue->tail is post-incremented after writing queue->reports[tail]:
mm/damon/core.c:damon_submit_report() {
...
tail = queue->tail;
if (tail == queue->size)
tail = 0;
queue->reports[tail] = *report;
queue->tail++;
...
}Because queue->tail points one slot past the newest report, the first iteration of damon_report_exist() reads the unwritten slot at queue->reports[queue->tail] (which is allocated with kmalloc_objs() in damon_init() without zeroing) and never visits queue->reports[0]. Once queue->size (1000) reports have been submitted, queue->tail reaches 1000 and the first iteration reads queue->reports[1000], one element past the end of the array. Also, when damon_submit_report() wraps local tail to 0, queue->tail itself is not wrapped and increments past queue->size on subsequent submissions.
Should idx be decremented (wrapping from 0 to queue->size - 1) before indexing queue->reports[idx], with damon_submit_report() updating queue->tail = tail + 1?
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=13
SJ Park
maintainerRe: [RFC PATCH 13/27] mm/damon/core: introduce damon_report_exist()
Quoted 80 lines · On Sun, 15 Nov 2026 20:37:19 +0000 [email protected] wrote:
Thank you for your contribution! Sashiko AI review found 1 potential issue to consider:
- [High]mm/damon/core: out-of-bounds and uninitialized read indamon_report_exist()
--commit
be7b07b7677627ddaaa72484649217b5172610a1
Author: SJ Park <[email protected]>
mm/damon/core: introducedamon_report_exist()This commit adds
damon_report_exist()to searchdamon_report_queuefor a report matching a given type, address range, and minimum age in jiffies.Quoted 28 lines
mm/damon/core.c +20
-0@@ -2386,6 +2386,52 @@ int damon_submit_report(struct damon_report *report)return 0 ; } +/** +* damon_report_exist() - Find if a report of a given condition exists. +* +* @report_type: Type of the report. +* @addr_range: Address range of the report. +* @jiffies_old: Oldest jiffies to find the report for. +* +* Returns true if the report is found, false otherwise. +*/ +bool damon_report_exist (enum damon_report_type report_type, +struct damon_addr_range *addr_range,unsigned long jiffies_old) +{ +struct damon_report_queue *queue; +int lock_old_val; +unsigned int idx, nr_read; +struct damon_report *report; +bool found = false; + + queue = &damon_report_queue; + lock_old_val =atomic_cmpxchg (&queue->lock,0 ,1 );mm/damon/core.c int damon_submit_report(struct damon_report *report) · line 2418
Quoted 10 lines
mm/damon/core.c +10
-0+ +if (lock_old_val) +return false; + idx = queue->tail; +for (nr_read =0 ; nr_read < queue->nr_reports; nr_read++) { + report = &queue->reports[idx]; +if (idx) + idx--; +else + idx = queue->size -1 ;[Severity: High]
Can indexing queue->reports[idx] before decrementing and wrapping idx read uninitialized or out-of-bounds memory?In
damon_submit_report(),queue->tailis post-incremented after writing queue->reports[tail]:mm/damon/core.c:damon_submit_report() { ... tail = queue->tail; if (tail == queue->size) tail = 0; queue->reports[tail] = *report; queue->tail++; ... }Because
queue->tailpoints one slot past the newest report, the first iteration ofdamon_report_exist()reads the unwritten slot at queue->reports[queue->tail] (which is allocated withkmalloc_objs()indamon_init()without zeroing) and never visits queue->reports[0]. Oncequeue->size(1000) reports have been submitted,queue->tailreaches 1000 and the first iteration reads queue->reports[1000], one element past the end of the array. Also, whendamon_submit_report()wraps local tail to 0,queue->tailitself is not wrapped and increments pastqueue->sizeon subsequent submissions.
Quoted 3 lines
Should idx be decremented (wrapping from 0 to
queue->size- 1) before indexing queue->reports[idx], withdamon_submit_report()updatingqueue->tail= tail + 1?
Good catch. I will move queue->reports[idx] after the idx decrement.
Quoted 4 lines
Signature · 2 lines
-- Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=13
Thanks,
SJ
SJ Park
maintainerRFC PATCH 14/27 mm/damon/paddr: support REPORT_MADE type probe filter
In reply to SJ ParkAdd a support of DAMON_FILTER_TYPE_REPORT_MADE type probe filter to the physical address space operation set. Use the DAMON core API function, damon_report_exist() for the core report search functionality. Set the time range as the last sampling interval. Pass damon_ctx to the filter matching function for getting the sampling interval.
--- mm/damon/paddr.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-)
mm/damon/paddr.c +13 -4
@@ -140,9 +140,10 @@ static void damon_pa_prep_probes(struct damon_ctx *ctx, bool set_samples) }static bool damon_pa_filter_match (struct damon_filter *filter, -struct folio *folio) +struct folio *folio,phys_addr_t pa,struct damon_ctx *ctx) {bool matched = false; +struct damon_addr_range addr_range;switch (filter->type) {case DAMON_FILTER_TYPE_PGIDLE_UNSET :
@@ -157,19 +158,27 @@ static bool damon_pa_filter_match(struct damon_filter *filter,else matched =damon_folio_young (folio) == false;break ; +case DAMON_FILTER_TYPE_REPORT_MADE : + addr_range.start = pa; + addr_range.end = pa +1 ; + matched =damon_report_exist (filter->report_type, &addr_range, + jiffies - +usecs_to_jiffies (ctx->attrs.sample_interval)); +break ;default :return damon_ops_filter_match (filter, folio); }return matched == filter->matching; } -static bool damon_pa_filter_pass (struct folio *folio,struct damon_probe *p) +static bool damon_pa_filter_pass (struct folio *folio,struct damon_probe *p, +phys_addr_t pa,struct damon_ctx *ctx) {struct damon_filter *f;bool pass = true;damon_for_each_filter (f, p) { -if (damon_pa_filter_match (f, folio)) { +if (damon_pa_filter_match (f, folio, pa, ctx)) { pass = f->allow;break ; }
@@ -199,7 +208,7 @@ static unsigned int damon_pa_apply_probes(struct damon_ctx *ctx, ctx->addr_unit); folio =damon_get_folio (PHYS_PFN (pa));damon_for_each_probe (p, ctx) { -if (damon_pa_filter_pass (folio, p)) +if (damon_pa_filter_pass (folio, p, pa, ctx)) r->probe_hits[i]++; i++; }
Signature · 1 line
2.47.3
[email protected]
AI reviewRe: [RFC PATCH 14/27] mm/damon/paddr: support REPORT_MADE type probe filter
Thank you for your contribution! Sashiko AI review found 3 potential issues to consider: - [High] mm/damon: out-of-bounds and uninitialized read in damon_report_exist() - [Medium] mm/damon…
Thank you for your contribution! Sashiko AI review found 3 potential issues to consider:
- [High] mm/damon: out-of-bounds and uninitialized read in damon_report_exist()
- [Medium] mm/damon: phys_addr_t truncation and unit mismatch in damon_pa_filter_match()
- [Medium] mm/damon: uninitialized filter->report_type in damon_pa_filter_match()
--
commit db7c0b8660ac4e99fdce33921b7535218eaa4dc6
Author: SJ Park <[email protected]>
mm/damon/paddr: support REPORT_MADE type probe filter
This commit adds support for the DAMON_FILTER_TYPE_REPORT_MADE probe filter in the physical address space operation set by querying damon_report_exist() over the last sampling interval.
Quoted 17 lines
mm/damon/paddr.c +2
-1@@ -140,9 +140,10 @@ static void damon_pa_prep_probes(struct damon_ctx *ctx, bool set_samples) }static bool damon_pa_filter_match (struct damon_filter *filter, -struct folio *folio) +struct folio *folio,phys_addr_t pa,struct damon_ctx *ctx) {bool matched = false; +struct damon_addr_range addr_range;switch (filter->type) {case DAMON_FILTER_TYPE_PGIDLE_UNSET :
mm/damon/paddr.c static bool damon_pa_filter_match(struct damon_filter *filter, · line 163
Quoted 6 lines
mm/damon/paddr.c +3
-0@@ -157,19 +158,27 @@ static bool damon_pa_filter_match(struct damon_filter *filter,else matched =damon_folio_young (folio) == false;break ; +case DAMON_FILTER_TYPE_REPORT_MADE : + addr_range.start = pa; + addr_range.end = pa +1 ;
[Severity: Medium]
Can assigning pa and pa + 1 into addr_range truncate 64-bit physical addresses and miss reports when ctx->addr_unit > 1?
struct damon_addr_range defines start and end as unsigned long, so on 32-bit PAE/LPAE systems where phys_addr_t is 64-bit, physical addresses at or above 4 GiB lose their upper 32 bits (and pa + 1 wraps to 0 when the low 32 bits are 0xffffffff). In addition, when ctx->addr_unit > 1, pa is aligned to ctx->addr_unit, so setting addr_range.end = pa + 1 only checks the first byte of the sampled unit instead of [pa, pa + ctx->addr_unit).
mm/damon/paddr.c static bool damon_pa_filter_match(struct damon_filter *filter, · line 167
Quoted 4 lines
mm/damon/paddr.c +4
-0+ matched =damon_report_exist (filter->report_type, &addr_range, + jiffies - +usecs_to_jiffies (ctx->attrs.sample_interval)); +break ;
[Severity: High]
Does calling damon_report_exist() read uninitialized or out-of-bounds elements from damon_report_queue.reports?
In damon_submit_report(), the report is written at queue->reports[tail] and queue->tail is then incremented, so queue->tail points to the next slot to be written and is never wrapped when it reaches queue->size:
mm/damon/core.c:damon_submit_report() {
...
tail = queue->tail;
if (tail == queue->size)
tail = 0;
queue->reports[tail] = *report;
queue->tail++;
...
}mm/damon/core.c:damon_report_exist() {
...
idx = queue->tail;
for (nr_read = 0; nr_read < queue->nr_reports; nr_read++) {
report = &queue->reports[idx];
if (idx)
idx--;
else
idx = queue->size - 1;
...
}Because damon_report_exist() indexes queue->reports[idx] at queue->tail before decrementing idx, it reads uninitialized heap memory on the first iteration while 1 <= nr_reports < queue->size (and never inspects index 0), and reads out of bounds at queue->reports[queue->size] and beyond once queue->size reports have been submitted.
[Severity: Medium]
Can filter->report_type be uninitialized here when a new DAMON_FILTER_TYPE_REPORT_MADE filter is added via damon_commit_ctx()?
damon_new_filter() allocates struct damon_filter with kmalloc_obj() without zeroing the union, and when damon_commit_filters() creates a new filter it only copies union members for DAMON_FILTER_TYPE_MEMCG and DAMON_FILTER_TYPE_HUGEPAGE_SIZE:
mm/damon/core.c:damon_commit_filters() {
...
new_filter = damon_new_filter(src_filter->type,
src_filter->matching, src_filter->allow);
if (!new_filter)
return -ENOMEM;
switch (src_filter->type) {
case DAMON_FILTER_TYPE_MEMCG:
new_filter->memcg_id = src_filter->memcg_id;
break;
case DAMON_FILTER_TYPE_HUGEPAGE_SIZE:
if (src_filter->range_max < src_filter->range_min) {
damon_destroy_filter(new_filter);
return -EINVAL;
}
new_filter->range_min = src_filter->range_min;
new_filter->range_max = src_filter->range_max;
break;
default:
break;
}
...
}As a result, new_filter->report_type retains uninitialized slab bytes when damon_pa_filter_match() passes it to damon_report_exist().
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=14
SJ Park
maintainerRe: [RFC PATCH 14/27] mm/damon/paddr: support REPORT_MADE type probe filter
Quoted 47 lines · On Sun, 15 Nov 2026 20:41:34 +0000 [email protected] wrote:
Thank you for your contribution! Sashiko AI review found 3 potential issues to consider:
- [High] mm/damon: out-of-bounds and uninitialized read indamon_report_exist()
- [Medium] mm/damon:phys_addr_ttruncation and unit mismatch indamon_pa_filter_match()
- [Medium] mm/damon: uninitializedfilter->report_typeindamon_pa_filter_match()
--commit
db7c0b8660ac4e99fdce33921b7535218eaa4dc6
Author: SJ Park <[email protected]>
mm/damon/paddr: supportREPORT_MADEtype probe filterThis commit adds support for the
DAMON_FILTER_TYPE_REPORT_MADEprobe filter in the physical address space operation set by queryingdamon_report_exist()over the last sampling interval.Quoted 17 lines
mm/damon/paddr.c +2
-1@@ -140,9 +140,10 @@ static void damon_pa_prep_probes(struct damon_ctx *ctx, bool set_samples) }static bool damon_pa_filter_match (struct damon_filter *filter, -struct folio *folio) +struct folio *folio,phys_addr_t pa,struct damon_ctx *ctx) {bool matched = false; +struct damon_addr_range addr_range;switch (filter->type) {case DAMON_FILTER_TYPE_PGIDLE_UNSET :mm/damon/paddr.c static bool damon_pa_filter_match(struct damon_filter *filter, · line 163
Quoted 6 lines
mm/damon/paddr.c +3
-0@@ -157,19 +158,27 @@ static bool damon_pa_filter_match(struct damon_filter *filter,else matched =damon_folio_young (folio) == false;break ; +case DAMON_FILTER_TYPE_REPORT_MADE : + addr_range.start = pa; + addr_range.end = pa +1 ;[Severity: Medium]
Can assigning pa and pa + 1 intoaddr_rangetruncate 64-bit physical addresses and miss reports whenctx->addr_unit> 1?
Quoted 4 lines
struct
damon_addr_rangedefines start and end as unsigned long, so on 32-bit PAE/LPAE systems wherephys_addr_tis 64-bit, physical addresses at or above 4 GiB lose their upper 32 bits (and pa + 1 wraps to 0 when the low 32 bits are0xffffffff).
Missing a report for this edge case is fine. It only degrades DAMON's monitoring results, which is anyway best effort.
Quoted 4 lines
In addition, when
ctx->addr_unit> 1,
pa is aligned toctx->addr_unit, so setting addr_range.end = pa + 1 only checks the first byte of the sampled unit instead of [pa, pa +ctx->addr_unit).
That's fine. Technically speaking, the sampling is only for the sampling byte.
Quoted 36 lines
mm/damon/paddr.c static bool damon_pa_filter_match(struct damon_filter *filter, · line 167
Quoted 5 lines
mm/damon/paddr.c +4
-0+ matched =damon_report_exist (filter->report_type, &addr_range, + jiffies - +usecs_to_jiffies (ctx->attrs.sample_interval)); +break ;[Severity: High]
Does callingdamon_report_exist()read uninitialized or out-of-bounds elements from damon_report_queue.reports?In
damon_submit_report(), the report is written at queue->reports[tail] andqueue->tailis then incremented, soqueue->tailpoints to the next slot to be written and is never wrapped when it reachesqueue->size:mm/damon/core.c:damon_submit_report() { ... tail = queue->tail; if (tail == queue->size) tail = 0; queue->reports[tail] = *report; queue->tail++; ... }mm/damon/core.c:damon_report_exist() { ... idx = queue->tail; for (nr_read = 0; nr_read < queue->nr_reports; nr_read++) { report = &queue->reports[idx]; if (idx) idx--; else idx = queue->size - 1; ... }
Quoted 5 lines
Because
damon_report_exist()indexes queue->reports[idx] atqueue->tailbefore decrementing idx, it reads uninitialized heap memory on the first iteration while 1 <=nr_reports<queue->size(and never inspects index 0), and reads out of bounds at queue->reports[queue->size] and beyond oncequeue->sizereports have been submitted.
Yes, I will fix it in the earlier patch.
Quoted 34 lines
[Severity: Medium]
Canfilter->report_typebe uninitialized here when a newDAMON_FILTER_TYPE_REPORT_MADEfilter is added viadamon_commit_ctx()?
damon_new_filter()allocates structdamon_filterwithkmalloc_obj()without zeroing the union, and whendamon_commit_filters()creates a new filter it only copies union members forDAMON_FILTER_TYPE_MEMCGandDAMON_FILTER_TYPE_HUGEPAGE_SIZE:mm/damon/core.c:damon_commit_filters() { ... new_filter = damon_new_filter(src_filter->type, src_filter->matching, src_filter->allow); if (!new_filter) return -ENOMEM; switch (src_filter->type) { case DAMON_FILTER_TYPE_MEMCG: new_filter->memcg_id = src_filter->memcg_id; break; case DAMON_FILTER_TYPE_HUGEPAGE_SIZE: if (src_filter->range_max < src_filter->range_min) { damon_destroy_filter(new_filter); return -EINVAL; } new_filter->range_min = src_filter->range_min; new_filter->range_max = src_filter->range_max; break; default: break; } ... }
Quoted 2 lines
As a result,
new_filter->report_typeretains uninitialized slab bytes whendamon_pa_filter_match()passes it todamon_report_exist().
Yes, I will fix it in the earlier patch.
Quoted 4 lines
Signature · 2 lines
-- Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=14
Thanks,
SJ
Re: [RFC PATCH 14/27] mm/damon/paddr: support REPORT_MADE type probe filter
In reply to SJ ParkHi SJ,
mm/damon/paddr.c static bool damon_pa_filter_match(struct damon_filter *filter, · line 166
Quoted 6 lines · On Sun, 15 Nov 2026 12:28:32 -0800 SJ Park wrote:
mm/damon/paddr.c +6
-0+case DAMON_FILTER_TYPE_REPORT_MADE : + addr_range.start = pa; + addr_range.end = pa +1 ; + matched =damon_report_exist (filter->report_type, &addr_range, + jiffies - +usecs_to_jiffies (ctx->attrs.sample_interval));
Since the window is counted in jiffies and rounded up, how many samples see a given report depends on HZ. With the default 5 ms sampling interval, the window is 2 jiffies at HZ=250, i.e. 8 to 12 ms, so a report is usually seen by two consecutive samples. At HZ=1000 the window is 5 jiffies, but kdamond_usleep() sleeps via schedule_timeout_idle() there, and samples end up about 6 ms apart, so a report made right after a sample can fall out of the window before the next one.
With the queue indexing fixed, user reports submitted every 50 or 250 ms and covering the whole physical address range were counted about 2.0 times each on an x86_64 guest at HZ=250, and about 0.84 times at HZ=1000.
Is this approximation intended? If each report is meant to be counted once, maybe we could keep a per-context report sequence cursor and check only the reports enqueued since the previous probe run. A quick local hack of that counted each report once on both HZ values. If reports are rather meant to stay valid for a while, like a user saying a range is hot, a validity period separate from the sampling interval might fit better.
Thanks,
Aveline Noir
SJ Park
maintainerRe: [RFC PATCH 14/27] mm/damon/paddr: support REPORT_MADE type probe filter
Hi Aveline,
Quoted 20 lines · On Mon, 16 Nov 2026 18:43:36 +1100 Aveline Noir <[email protected]> wrote:
Hi SJ,
mm/damon/paddr.c static bool damon_pa_filter_match(struct damon_filter *filter, · line 166
Quoted 6 lines · On Sun, 15 Nov 2026 12:28:32 -0800 SJ Park wrote:
mm/damon/paddr.c +6
-0+case DAMON_FILTER_TYPE_REPORT_MADE : + addr_range.start = pa; + addr_range.end = pa +1 ; + matched =damon_report_exist (filter->report_type, &addr_range, + jiffies - +usecs_to_jiffies (ctx->attrs.sample_interval));Since the window is counted in jiffies and rounded up, how many samples see a given report depends on HZ. With the default 5 ms sampling interval, the window is 2 jiffies at HZ=250, i.e. 8 to 12 ms, so a report is usually seen by two consecutive samples. At HZ=1000 the window is 5 jiffies, but
kdamond_usleep()sleeps viaschedule_timeout_idle()there, and samples end up about 6 ms apart, so a report made right after a sample can fall out of the window before the next one.
Quoted 4 lines
With the queue indexing fixed, user reports submitted every 50 or 250 ms and covering the whole physical address range were counted about 2.0 times each on an
x86_64guest at HZ=250, and about 0.84 times at HZ=1000.
Thank you for sharing your thought and test results.
Quoted 2 lines
Is this approximation intended?
Kind of intended. DAMON uses many approximations for low overhead and easy maintenance, as long as the results are practical.
For this case, I'm not that scared about such over-counting. Users ain't really care about the report counted just one more time. I'd rather expect users repeatedly submit reports to make sure DAMON shows the memory as hot.
Also I believe users could tune intervals, manually or using the auto-tuning feature.
Quoted 7 lines
If each report is meant to be counted
once, maybe we could keep a per-context report sequence cursor and check only the reports enqueued since the previous probe run. A quick local hack of that counted each report once on both HZ values. If reports are rather meant to stay valid for a while, like a user saying a range is hot, a validity period separate from the sampling interval might fit better.
If it turns out the approximation is real problem for users, we could consider this kind of improvements.
Thanks,
SJ
[...]
SJ Park
maintainerRFC PATCH 15/27 mm/damon/sysfs: add filter_report_type file under probe filter directory
In reply to SJ ParkAdd a sysfs file, filter_report_type, under probe filter directory. It receives damon_report_type from the user. Reuse damon_sysfs_report_type_name struct for user keyword matching. Move the definition instead of forward declaration, as the code change is small enough at this stage.
--- mm/damon/sysfs.c | 61 +++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 52 insertions(+), 9 deletions(-)
mm/damon/sysfs.c +52 -9
@@ -977,6 +977,7 @@ struct damon_sysfs_filter {char *path;unsigned long range_min;unsigned long range_max; +enum damon_report_type report_type; };static struct damon_sysfs_filter *damon_sysfs_filter_alloc (void )
@@ -1175,6 +1176,53 @@ static ssize_t max_store(struct kobject *kobj,return err ? err : count; } +struct damon_sysfs_report_type_name { +enum damon_report_type type; +char *name; +}; + +static const struct damon_sysfs_report_type_name +damon_sysfs_report_type_names[] = { +}; + +static ssize_t filter_report_type_show (struct kobject *kobj, +struct kobj_attribute *attr,char *buf) +{ +struct damon_sysfs_filter *filter =container_of (kobj, + struct damon_sysfs_filter, kobj); +int i; + +for (i =0 ; i <ARRAY_SIZE (damon_sysfs_report_type_names); i++) { +const struct damon_sysfs_report_type_name *type_name; + + type_name = &damon_sysfs_report_type_names[i]; +if (type_name->type == filter->report_type) +return sysfs_emit (buf,"%s\n" , type_name->name); + } +return -EINVAL ; +} + +static ssize_t filter_report_type_store (struct kobject *kobj, +struct kobj_attribute *attr,const char *buf,size_t count) +{ +struct damon_sysfs_filter *filter =container_of (kobj, + struct damon_sysfs_filter, kobj); +ssize_t ret = -EINVAL ; +int i; + +for (i =0 ; i <ARRAY_SIZE (damon_sysfs_report_type_names); i++) { +const struct damon_sysfs_report_type_name *type_name; + + type_name = &damon_sysfs_report_type_names[i]; +if (sysfs_streq (buf, type_name->name)) { + filter->report_type = type_name->type; + ret = count; +break ; + } + } +return ret; +} +static void damon_sysfs_filter_release (struct kobject *kobj) { struct damon_sysfs_filter *filter = container_of(kobj,
@@ -1202,6 +1250,9 @@ static struct kobj_attribute damon_sysfs_filter_min_attr =static struct kobj_attribute damon_sysfs_filter_max_attr =__ATTR_RW_MODE (max,0600 ); +static struct kobj_attribute damon_sysfs_filter_filter_report_type_attr = +__ATTR_RW_MODE (filter_report_type,0600 ); +static struct attribute *damon_sysfs_filter_attrs[] = { &damon_sysfs_filter_type_attr.attr, &damon_sysfs_filter_matching_attr.attr,
@@ -1209,6 +1260,7 @@ static struct attribute *damon_sysfs_filter_attrs[] = { &damon_sysfs_filter_path_attr.attr, &damon_sysfs_filter_min_attr.attr, &damon_sysfs_filter_max_attr.attr, + &damon_sysfs_filter_filter_report_type_attr.attr,NULL , };ATTRIBUTE_GROUPS (damon_sysfs_filter);
@@ -2992,15 +3044,6 @@ static struct damon_sysfs_producer *damon_sysfs_producer_alloc(void) return kzalloc_obj(struct damon_sysfs_producer); } -struct damon_sysfs_report_type_name { -enum damon_report_type type; -char *name; -}; - -static const struct damon_sysfs_report_type_name -damon_sysfs_report_type_names[] = { -}; -static ssize_t report_type_show (struct kobject *kobj,struct kobj_attribute *attr,char *buf) {
Signature · 1 line
2.47.3
[email protected]
AI reviewRe: [RFC PATCH 15/27] mm/damon/sysfs: add filter_report_type file under probe filter directory
Sashiko has reviewed this patch and found no issues.
Quoted 7 lines
Add a sysfs file,
filter_report_type, under probe filter directory. It receivesdamon_report_typefrom the user. Reusedamon_sysfs_report_type_namestruct for user keyword matching. Move the definition instead of forward declaration, as the code change is small enough at this stage.Signed-off-by SJ Park <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=15
SJ Park
maintainerRFC PATCH 16/27 mm/damon/sysfs: support REPORT_MADE type probe filter setup
In reply to SJ ParkAccept user keyword "report_made" to probe filter type file. Set the damon_filter->type as REPORT_MADE for the input. Setup damon_filter->report_type with the filter_report_type user input.
--- mm/damon/sysfs.c | 6 ++++++ 1 file changed, 6 insertions(+)
mm/damon/sysfs.c +6 -0
@@ -1016,6 +1016,10 @@ damon_sysfs_filter_type_names[] = { .type = DAMON_FILTER_TYPE_ACTIVE, .name = "active", }, + { + .type = DAMON_FILTER_TYPE_REPORT_MADE, + .name = "report_made", + }, }; static ssize_t type_show(struct kobject *kobj,
@@ -2336,6 +2340,8 @@ static int damon_sysfs_set_filters(struct damon_probe *probe, }else if (filter->type ==DAMON_FILTER_TYPE_HUGEPAGE_SIZE ) { filter->range_min = sys_filter->range_min; filter->range_max = sys_filter->range_max; + }else if (filter->type ==DAMON_FILTER_TYPE_REPORT_MADE ) { + filter->report_type = sys_filter->report_type; }damon_add_filter (probe, filter); }
Signature · 1 line
2.47.3
[email protected]
AI reviewRe: [RFC PATCH 16/27] mm/damon/sysfs: support REPORT_MADE type probe filter setup
Thank you for your contribution! Sashiko AI review found 2 potential issues to consider: - [High] mm/damon: out-of-bounds and uninitialized access in damon_report_exist() - [Medium] mm/damon…
Thank you for your contribution! Sashiko AI review found 2 potential issues to consider:
- [High] mm/damon: out-of-bounds and uninitialized access in damon_report_exist()
- [Medium] mm/damon: uninitialized report_type in damon_commit_filters() --
commit 6058e18a855d5b73c171dc4b94eb6031f06fdc63
Author: SJ Park <[email protected]>
mm/damon/sysfs: support REPORT_MADE type probe filter setup
This commit adds "report_made" to the DAMON sysfs probe filter type list and copies the filter's report_type when setting up probe filters.
Quoted 5 lines
mm/damon/sysfs.c +0
-0
mm/damon/sysfs.c damon_sysfs_filter_type_names[] = { · line 1025
Quoted 10 lines
mm/damon/sysfs.c +4
-0@@ -1016,6 +1016,10 @@ damon_sysfs_filter_type_names[] = { .type = DAMON_FILTER_TYPE_ACTIVE, .name = "active", }, + { + .type = DAMON_FILTER_TYPE_REPORT_MADE, + .name = "report_made", + }, }; static ssize_t type_show(struct kobject *kobj,
[Severity: High]
Can enabling DAMON_FILTER_TYPE_REPORT_MADE filters cause uninitialized and out-of-bounds accesses on queue->reports[]?
In damon_submit_report(), each report is stored at queue->reports[tail] and then queue->tail is incremented, so queue->tail points to the next slot to write rather than the most recent entry:
mm/damon/core.c:damon_submit_report() {
...
tail = queue->tail;
if (tail == queue->size)
tail = 0;
queue->reports[tail] = *report;
queue->tail++;
...
}When damon_pa_filter_match() calls damon_report_exist() for a report_made filter, the loop reads queue->reports[idx] starting at idx = queue->tail before decrementing idx:
mm/damon/core.c:damon_report_exist() {
...
idx = queue->tail;
for (nr_read = 0; nr_read < queue->nr_reports; nr_read++) {
report = &queue->reports[idx];
if (idx)
idx--;
else
idx = queue->size - 1;
...
}While queue->nr_reports < queue->size, the first iteration reads the unwritten slot at queue->reports[queue->tail] and the loop stops before checking queue->reports[0]. Once queue->tail reaches queue->size, damon_report_exist() reads out of bounds at queue->reports[queue->size], and the next damon_submit_report() wraps only the local tail variable before incrementing queue->tail past queue->size, causing subsequent submissions and lookups to write and read out of bounds on the heap.
mm/damon/sysfs.c static int damon_sysfs_set_filters(struct damon_probe *probe, · line 2347
Quoted 9 lines
mm/damon/sysfs.c +2
-0@@ -2336,6 +2340,8 @@ static int damon_sysfs_set_filters(struct damon_probe *probe, }else if (filter->type ==DAMON_FILTER_TYPE_HUGEPAGE_SIZE ) { filter->range_min = sys_filter->range_min; filter->range_max = sys_filter->range_max; + }else if (filter->type ==DAMON_FILTER_TYPE_REPORT_MADE ) { + filter->report_type = sys_filter->report_type; }damon_add_filter (probe, filter); }
[Severity: Medium]
Does committing a new DAMON_FILTER_TYPE_REPORT_MADE filter to a running context leave new_filter->report_type uninitialized?
When damon_sysfs_commit_input() commits the context built here via damon_commit_ctx() -> __damon_commit_ctx() -> damon_commit_probes() -> damon_commit_filters(), newly added filters are allocated with damon_new_filter(), which does not initialize the union in struct damon_filter, and the switch in damon_commit_filters() does not handle DAMON_FILTER_TYPE_REPORT_MADE:
mm/damon/core.c:damon_commit_filters() {
...
new_filter = damon_new_filter(src_filter->type,
src_filter->matching, src_filter->allow);
if (!new_filter)
return -ENOMEM;
switch (src_filter->type) {
case DAMON_FILTER_TYPE_MEMCG:
new_filter->memcg_id = src_filter->memcg_id;
break;
case DAMON_FILTER_TYPE_HUGEPAGE_SIZE:
...
default:
break;
}
...
}As a result, damon_pa_filter_match() passes uninitialized slab memory in new_filter->report_type to damon_report_exist().
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=16
SJ Park
maintainerRe: [RFC PATCH 16/27] mm/damon/sysfs: support REPORT_MADE type probe filter setup
Quoted 65 lines · On Sun, 15 Nov 2026 20:41:12 +0000 [email protected] wrote:
Thank you for your contribution! Sashiko AI review found 2 potential issues to consider:
- [High] mm/damon: out-of-bounds and uninitialized access indamon_report_exist()
- [Medium] mm/damon: uninitializedreport_typeindamon_commit_filters()--commit
6058e18a855d5b73c171dc4b94eb6031f06fdc63
Author: SJ Park <[email protected]>
mm/damon/sysfs: supportREPORT_MADEtype probe filter setupThis commit adds "
report_made" to the DAMON sysfs probe filter type list and copies the filter'sreport_typewhen setting up probe filters.Quoted 5 lines
mm/damon/sysfs.c +0
-0mm/damon/sysfs.c damon_sysfs_filter_type_names[] = { · line 1025
Quoted 10 lines
mm/damon/sysfs.c +4
-0@@ -1016,6 +1016,10 @@ damon_sysfs_filter_type_names[] = { .type = DAMON_FILTER_TYPE_ACTIVE, .name = "active", }, + { + .type = DAMON_FILTER_TYPE_REPORT_MADE, + .name = "report_made", + }, }; static ssize_t type_show(struct kobject *kobj,[Severity: High]
Can enablingDAMON_FILTER_TYPE_REPORT_MADEfilters cause uninitialized and out-of-bounds accesses on queue->reports[]?In
damon_submit_report(), each report is stored at queue->reports[tail] and thenqueue->tailis incremented, soqueue->tailpoints to the next slot to write rather than the most recent entry:mm/damon/core.c:damon_submit_report() { ... tail = queue->tail; if (tail == queue->size) tail = 0; queue->reports[tail] = *report; queue->tail++; ... }When
damon_pa_filter_match()callsdamon_report_exist()for areport_madefilter, the loop reads queue->reports[idx] starting at idx =queue->tailbefore decrementing idx:mm/damon/core.c:damon_report_exist() { ... idx = queue->tail; for (nr_read = 0; nr_read < queue->nr_reports; nr_read++) { report = &queue->reports[idx]; if (idx) idx--; else idx = queue->size - 1; ... }
Quoted 7 lines
While
queue->nr_reports<queue->size, the first iteration reads the unwritten slot at queue->reports[queue->tail] and the loop stops before checking queue->reports[0]. Oncequeue->tailreachesqueue->size,damon_report_exist()reads out of bounds at queue->reports[queue->size], and the nextdamon_submit_report()wraps only the local tail variable before incrementingqueue->tailpastqueue->size, causing subsequent submissions and lookups to write and read out of bounds on the heap.
Yes, I will fix submit_report() and report_exist() in earlier patches.
Quoted 40 lines
mm/damon/sysfs.c static int damon_sysfs_set_filters(struct damon_probe *probe, · line 2347
Quoted 10 lines
mm/damon/sysfs.c +2
-0@@ -2336,6 +2340,8 @@ static int damon_sysfs_set_filters(struct damon_probe *probe, }else if (filter->type ==DAMON_FILTER_TYPE_HUGEPAGE_SIZE ) { filter->range_min = sys_filter->range_min; filter->range_max = sys_filter->range_max; + }else if (filter->type ==DAMON_FILTER_TYPE_REPORT_MADE ) { + filter->report_type = sys_filter->report_type; }damon_add_filter (probe, filter); }[Severity: Medium]
Does committing a newDAMON_FILTER_TYPE_REPORT_MADEfilter to a running context leavenew_filter->report_typeuninitialized?When
damon_sysfs_commit_input()commits the context built here viadamon_commit_ctx()->__damon_commit_ctx()->damon_commit_probes()->damon_commit_filters(), newly added filters are allocated withdamon_new_filter(), which does not initialize the union in structdamon_filter, and the switch indamon_commit_filters()does not handleDAMON_FILTER_TYPE_REPORT_MADE:mm/damon/core.c:damon_commit_filters() { ... new_filter = damon_new_filter(src_filter->type, src_filter->matching, src_filter->allow); if (!new_filter) return -ENOMEM; switch (src_filter->type) { case DAMON_FILTER_TYPE_MEMCG: new_filter->memcg_id = src_filter->memcg_id; break; case DAMON_FILTER_TYPE_HUGEPAGE_SIZE: ... default: break; } ... }
Quoted 2 lines
As a result,
damon_pa_filter_match()passes uninitialized slab memory innew_filter->report_typetodamon_report_exist().
Yes, I will fix this in the earlier patch.
Quoted 4 lines
Signature · 2 lines
-- Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=16
Thanks,
SJ
SJ Park
maintainerRFC PATCH 17/27 Docs/mm/damon/design: update for report_made probe filter type
In reply to SJ ParkUpdate DAMON design document for the newly added data attribute report existence type probe filter.
--- Documentation/mm/damon/design.rst | 6 ++++++ 1 file changed, 6 insertions(+)
Documentation/mm/damon/design.rst +6 -0
@@ -303,6 +303,8 @@ filter types. Currently below filter types are supported. - ``hugepage_size``: Matches if the page for the memory is a part of a hugepage of a given size range. - ``active``: Same to that for DAMOS filters. +- ``report_made``: Matches if a :ref:`report <damon_design_attr_reporting>` for + the memory is made in last sampling interval. If such probes are registered, DAMON executes the probes for each region's sampling memory when it does the access :ref:`sampling
@@ -382,6 +384,10 @@ depending on the type of the report. For now, no report type is supported. +The data attribute probe supports the reports. The probes can be configured to +hit for a given memory region if a specific type of valid reports that are +associated with the probing memory exist in the reports queue. + Dynamic Target Space Updates Handling ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Signature · 1 line
2.47.3
[email protected]
AI reviewRe: [RFC PATCH 17/27] Docs/mm/damon/design: update for report_made probe filter type
Sashiko has reviewed this patch and found no issues.
Quoted 4 lines
Update DAMON design document for the newly added data attribute report existence type probe filter.
Signed-off-by SJ Park <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=17
SJ Park
maintainerRFC PATCH 18/27 Docs/admin-guide/mm/damon/usage: update for REPORT_MADE probe filter
In reply to SJ ParkUpdate DAMON usage document for the newly added REPORT_MADE type probe filter support.
--- Documentation/admin-guide/mm/damon/usage.rst | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
Documentation/admin-guide/mm/damon/usage.rst +5 -1
@@ -78,7 +78,7 @@ comma (","). │ │ │ │ │ │ │ │ │ 0/prep_action │ │ │ │ │ │ │ │ │ ... │ │ │ │ │ │ │ │ filters/nr_filters - │ │ │ │ │ │ │ │ │ 0/type,matching,allow,path,min,max + │ │ │ │ │ │ │ │ │ 0/type,matching,allow,path,min,max,filter_report_type │ │ │ │ │ │ │ │ │ ... │ │ │ │ │ │ │ ... │ │ │ │ │ :ref:`targets <sysfs_targets>`/nr_targets
@@ -317,6 +317,10 @@ filter <sysfs_filters>`. When the filter ``type`` is ``hugepage_size``, ``min`` and ``max`` files act as files of the same names for :ref:`DAMOS filter <sysfs_filters>`. +When the filter ``type`` is ``report_made``, the :ref:`report +<damon_design_attr_reporting>` type for the filtering should also be specified +by writing the type name to ``filter_report_type`` file. + .. _sysfs_targets: contexts/<N>/targets/
Signature · 1 line
2.47.3
[email protected]
AI reviewRe: [RFC PATCH 18/27] Docs/admin-guide/mm/damon/usage: update for REPORT_MADE probe filter
Sashiko has reviewed this patch and found no issues.
Quoted 4 lines
Update DAMON usage document for the newly added
REPORT_MADEtype probe filter support.Signed-off-by SJ Park <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=18
SJ Park
maintainerRFC PATCH 19/27 Docs/ABI/damon: update for REPORT_MADE probe filter
In reply to SJ ParkUpdate DAMON ABI document for the newly added REPORT_MADE type probe filter support.
--- Documentation/ABI/testing/sysfs-kernel-mm-damon | 7 +++++++ 1 file changed, 7 insertions(+)
Documentation/ABI/testing/sysfs-kernel-mm-damon +7 -0
@@ -233,6 +233,13 @@ Description: Writing 'Y' or 'N' to this file sets whether to allow or reject hitting the probe for the memory that satisfies the 'type' and the 'matching' of the directory. +What: /sys/kernel/mm/damon/admin/kdamonds/<K>/contexts/<C>/monitoring_attrs/probes/<P>/filters/<F>/filter_report_type +Date: Nov 2026 +Contact: SJ Park <[email protected]> +Description: If 'report_made' is written to the 'type' file, writing to and + reading from this file sets and gets the 'report_type' of the + reports that this filter is working for. + What: /sys/kernel/mm/damon/admin/kdamonds/<K>/contexts/<C>/targets/nr_targets Date: Mar 2022 Contact: SJ Park <[email protected]>
Signature · 1 line
2.47.3
[email protected]
AI reviewRe: [RFC PATCH 19/27] Docs/ABI/damon: update for REPORT_MADE probe filter
Sashiko has reviewed this patch and found no issues.
Quoted 4 lines
Update DAMON ABI document for the newly added
REPORT_MADEtype probe filter support.Signed-off-by SJ Park <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=19
SJ Park
maintainerRFC PATCH 20/27 mm/damon/api: introduce user_report report type
In reply to SJ ParkUsers could know some data attribute information and willing to provide that to DAMON. Introduce a new damon_report_type, DAMON_REPORT_TYPE_USER_REPORT, for such user-provided reports.
--- include/linux/damon.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
include/linux/damon.h +3 -1
@@ -753,9 +753,11 @@ struct damon_intervals_goal {/** * enum damon_report_type - Type of &struct damon_report. +* +* @DAMON_REPORT_TYPE_USER_REPORT: User-generated report. */ enum damon_report_type { -NR_DAMON_REPORT_TYPES , +DAMON_REPORT_TYPE_USER_REPORT , };/**
Signature · 1 line
2.47.3
[email protected]
AI reviewRe: [RFC PATCH 20/27] mm/damon/api: introduce user_report report type
Sashiko has reviewed this patch and found no issues.
Quoted 5 lines
Users could know some data attribute information and willing to provide that to DAMON. Introduce a new
damon_report_type,DAMON_REPORT_TYPE_USER_REPORT, for such user-provided reports.Signed-off-by SJ Park <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=20
SJ Park
maintainerRFC PATCH 21/27 mm/damon/sysfs: add user_report support for report type input
In reply to SJ ParkExtend the mapping list for data attribute report types and user keywords, for the USER_REPORT report type. Use "user_report" as the matching user keyword.
--- mm/damon/sysfs.c | 4 ++++ 1 file changed, 4 insertions(+)
mm/damon/sysfs.c +4 -0
@@ -1187,6 +1187,10 @@ struct damon_sysfs_report_type_name {static const struct damon_sysfs_report_type_name damon_sysfs_report_type_names[] = { + { + .type =DAMON_REPORT_TYPE_USER_REPORT , + .name ="user_report" , + }, }; static ssize_t filter_report_type_show(struct kobject *kobj,
Signature · 1 line
2.47.3
[email protected]
AI reviewRe: [RFC PATCH 21/27] mm/damon/sysfs: add user_report support for report type input
Sashiko has reviewed this patch and found no issues.
Quoted 5 lines
Extend the mapping list for data attribute report types and user keywords, for the
USER_REPORTreport type. Use "user_report" as the matching user keyword.Signed-off-by SJ Park <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=21
SJ Park
maintainerRFC PATCH 22/27 mm/damon/sysfs: implement report producer addr_{start,end} files
In reply to SJ ParkImplement addr_start and addr_end sysfs files under report producer directory. Those set and get the address range of the user_report type data attribute reports.
--- mm/damon/sysfs.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+)
mm/damon/sysfs.c +45 -0
@@ -3047,6 +3047,7 @@ struct damon_sysfs_producer {struct kobject kobj;enum damon_report_type report_type;bool enabled; +struct damon_addr_range addr_range; };static struct damon_sysfs_producer *damon_sysfs_producer_alloc (void )
@@ -3116,6 +3117,44 @@ static ssize_t producer_state_store(struct kobject *kobj,return count; } +static ssize_t addr_start_show (struct kobject *kobj, +struct kobj_attribute *attr,char *buf) +{ +struct damon_sysfs_producer *producer =container_of (kobj, + struct damon_sysfs_producer, kobj); + +return sysfs_emit (buf,"%lu\n" , producer->addr_range.start); +} + +static ssize_t addr_start_store (struct kobject *kobj, +struct kobj_attribute *attr,const char *buf,size_t count) +{ +struct damon_sysfs_producer *producer =container_of (kobj, + struct damon_sysfs_producer, kobj); +int err =kstrtoul (buf,0 , &producer->addr_range.start); + +return err ? err : count; +} + +static ssize_t addr_end_show (struct kobject *kobj, +struct kobj_attribute *attr,char *buf) +{ +struct damon_sysfs_producer *producer =container_of (kobj, + struct damon_sysfs_producer, kobj); + +return sysfs_emit (buf,"%lu\n" , producer->addr_range.end); +} + +static ssize_t addr_end_store (struct kobject *kobj, +struct kobj_attribute *attr,const char *buf,size_t count) +{ +struct damon_sysfs_producer *producer =container_of (kobj, + struct damon_sysfs_producer, kobj); +int err =kstrtoul (buf,0 , &producer->addr_range.end); + +return err ? err : count; +} +static void damon_sysfs_producer_release (struct kobject *kobj) { struct damon_sysfs_producer *producer = container_of(kobj,
@@ -3127,10 +3166,16 @@ static struct kobj_attribute damon_sysfs_producer_report_type_attr =__ATTR_RW_MODE (report_type,0600 );static struct kobj_attribute damon_sysfs_producer_producer_state_type_attr =__ATTR_RW_MODE (producer_state,0600 ); +static struct kobj_attribute damon_sysfs_producer_addr_start_type_attr = +__ATTR_RW_MODE (addr_start,0600 ); +static struct kobj_attribute damon_sysfs_producer_addr_end_type_attr = +__ATTR_RW_MODE (addr_end,0600 );static struct attribute *damon_sysfs_producer_attrs[] = { &damon_sysfs_producer_report_type_attr.attr, &damon_sysfs_producer_producer_state_type_attr.attr, + &damon_sysfs_producer_addr_start_type_attr.attr, + &damon_sysfs_producer_addr_end_type_attr.attr,NULL , };ATTRIBUTE_GROUPS (damon_sysfs_producer);
Signature · 1 line
2.47.3
[email protected]
AI reviewRe: [RFC PATCH 22/27] mm/damon/sysfs: implement report producer addr_{start,end} files
Sashiko has reviewed this patch and found no issues.
Quoted 5 lines
Implement
addr_startandaddr_endsysfs files under report producer directory. Those set and get the address range of theuser_reporttype data attribute reports.Signed-off-by SJ Park <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=22
SJ Park
maintainerRFC PATCH 23/27 mm/damon/sysfs: implement submit command for report producer
In reply to SJ ParkLet users manually submit a report of a data attribute for a given address range of memory. Let producer_state receive "submit" input for that. For the input, generate the report based on user inputs that are written to the appropriate sysfs files and submit to DAMON using the core API, damon_submit_report().
--- mm/damon/sysfs.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-)
mm/damon/sysfs.c +16 -3
@@ -3107,13 +3107,26 @@ static ssize_t producer_state_store(struct kobject *kobj, {struct damon_sysfs_producer *producer =container_of (kobj, struct damon_sysfs_producer, kobj); +struct damon_report report; +int err; -if (sysfs_streq (buf,"on" )) +if (sysfs_streq (buf,"on" )) { producer->enabled = true; -else if (sysfs_streq (buf,"off" )) + }else if (sysfs_streq (buf,"off" )) { producer->enabled = false; -else + }else if (sysfs_streq (buf,"submit" )) { +if (!producer->enabled) +return -EINVAL ; +if (producer->report_type !=DAMON_REPORT_TYPE_USER_REPORT ) +return -EINVAL ; + report.type =DAMON_REPORT_TYPE_USER_REPORT ; + report.addr_range = producer->addr_range; + err =damon_submit_report (&report); +if (err) +return err; + }else {return -EINVAL ; + }return count; }
Signature · 1 line
2.47.3
[email protected]
AI reviewRe: [RFC PATCH 23/27] mm/damon/sysfs: implement submit command for report producer
Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [High] mm/damon: OOB write in damon_submit_report() and read in damon_report_exist() --
Thank you for your contribution! Sashiko AI review found 1 potential issue to consider:
- [High] mm/damon: OOB write in damon_submit_report() and read in damon_report_exist()
--
commit 2f4ed587e778c0d51407454ba3a19b21c1bc10c0
Author: SJ Park <[email protected]>
mm/damon/sysfs: implement submit command for report producer
This commit adds a "submit" command to producer_state_store() so userspace can submit manual reports via damon_submit_report().
Quoted 16 lines
mm/damon/sysfs.c +4
-2@@ -3107,13 +3107,26 @@ static ssize_t producer_state_store(struct kobject *kobj, {struct damon_sysfs_producer *producer =container_of (kobj, struct damon_sysfs_producer, kobj); +struct damon_report report; +int err; -if (sysfs_streq (buf,"on" )) +if (sysfs_streq (buf,"on" )) { producer->enabled = true; -else if (sysfs_streq (buf,"off" )) + }else if (sysfs_streq (buf,"off" )) {
mm/damon/sysfs.c static ssize_t producer_state_store(struct kobject *kobj, · line 3124
Quoted 10 lines
mm/damon/sysfs.c +8
-1producer->enabled = false; - else + }else if (sysfs_streq (buf,"submit" )) { +if (!producer->enabled) +return -EINVAL ; +if (producer->report_type !=DAMON_REPORT_TYPE_USER_REPORT ) +return -EINVAL ; + report.type =DAMON_REPORT_TYPE_USER_REPORT ; + report.addr_range = producer->addr_range; + err =damon_submit_report (&report);
[Severity: High]
Can repeated "submit" writes overflow damon_report_queue.reports[] in damon_submit_report() and read out of bounds in damon_report_exist()?
mm/damon/core.c:damon_submit_report() {
...
tail = queue->tail;
if (tail == queue->size)
tail = 0;
queue->reports[tail] = *report;
queue->tail++;
...
}When queue->tail reaches queue->size (1000), damon_submit_report() wraps only the local variable tail to 0 and still increments queue->tail to 1001 instead of setting queue->tail = tail + 1. On the next submission, tail is 1001, the equality check against queue->size is false, and queue->reports[tail] writes past the end of the 1000-element heap array.
In addition, damon_report_exist() starts its backward scan at idx = queue->tail (the next free slot) and dereferences queue->reports[idx] before decrementing idx:
mm/damon/core.c:damon_report_exist() {
...
idx = queue->tail;
for (nr_read = 0; nr_read < queue->nr_reports; nr_read++) {
report = &queue->reports[idx];
if (idx)
idx--;
else
idx = queue->size - 1;
...
}Before the ring wraps, the first iteration reads uninitialized memory at queue->reports[queue->tail] while the loop stops before reaching queue->reports[0], missing a single submitted report entirely; once 1000 reports have been submitted (queue->tail == queue->size), the first iteration reads out of bounds at queue->reports[1000].
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=23
SJ Park
maintainerRe: [RFC PATCH 23/27] mm/damon/sysfs: implement submit command for report producer
Quoted 77 lines · On Sun, 15 Nov 2026 20:43:17 +0000 [email protected] wrote:
Thank you for your contribution! Sashiko AI review found 1 potential issue to consider:
- [High] mm/damon: OOB write indamon_submit_report()and read indamon_report_exist()
--commit
2f4ed587e778c0d51407454ba3a19b21c1bc10c0
Author: SJ Park <[email protected]>
mm/damon/sysfs: implement submit command for report producerThis commit adds a "submit" command to
producer_state_store()so userspace can submit manual reports viadamon_submit_report().Quoted 16 lines
mm/damon/sysfs.c +4
-2@@ -3107,13 +3107,26 @@ static ssize_t producer_state_store(struct kobject *kobj, {struct damon_sysfs_producer *producer =container_of (kobj, struct damon_sysfs_producer, kobj); +struct damon_report report; +int err; -if (sysfs_streq (buf,"on" )) +if (sysfs_streq (buf,"on" )) { producer->enabled = true; -else if (sysfs_streq (buf,"off" )) + }else if (sysfs_streq (buf,"off" )) {mm/damon/sysfs.c static ssize_t producer_state_store(struct kobject *kobj, · line 3124
Quoted 10 lines
mm/damon/sysfs.c +8
-1producer->enabled = false; - else + }else if (sysfs_streq (buf,"submit" )) { +if (!producer->enabled) +return -EINVAL ; +if (producer->report_type !=DAMON_REPORT_TYPE_USER_REPORT ) +return -EINVAL ; + report.type =DAMON_REPORT_TYPE_USER_REPORT ; + report.addr_range = producer->addr_range; + err =damon_submit_report (&report);[Severity: High]
Can repeated "submit" writes overflow damon_report_queue.reports[] indamon_submit_report()and read out of bounds indamon_report_exist()?mm/damon/core.c:damon_submit_report() { ... tail = queue->tail; if (tail == queue->size) tail = 0; queue->reports[tail] = *report; queue->tail++; ... }When
queue->tailreachesqueue->size(1000),damon_submit_report()wraps only the local variable tail to 0 and still incrementsqueue->tailto 1001 instead of settingqueue->tail= tail + 1. On the next submission, tail is 1001, the equality check againstqueue->sizeis false, and queue->reports[tail] writes past the end of the 1000-element heap array.In addition,
damon_report_exist()starts its backward scan at idx =queue->tail(the next free slot) and dereferences queue->reports[idx] before decrementing idx:mm/damon/core.c:damon_report_exist() { ... idx = queue->tail; for (nr_read = 0; nr_read < queue->nr_reports; nr_read++) { report = &queue->reports[idx]; if (idx) idx--; else idx = queue->size - 1; ... }
Quoted 5 lines
Before the ring wraps, the first iteration reads uninitialized memory at queue->reports[queue->tail] while the loop stops before reaching queue->reports[0], missing a single submitted report entirely; once 1000 reports have been submitted (
queue->tail==queue->size), the first iteration reads out of bounds at queue->reports[1000].
Yes, I will fix those in the earlier patches.
Quoted 4 lines
Signature · 2 lines
-- Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=23
Thanks,
SJ
SJ Park
maintainerRFC PATCH 24/27 selftests/damon/sysfs.sh: add basic tests for admin/reports/
In reply to SJ ParkUpdate sysfs.sh DAMON selftest to cover basic file operations for the sysfs files under the admin/reports/ directory.
--- tools/testing/selftests/damon/sysfs.sh | 52 ++++++++++++++++++++++++++ 1 file changed, 52 insertions(+)
tools/testing/selftests/damon/sysfs.sh +52 -0
@@ -510,6 +510,57 @@ test_kdamonds() ensure_dir "$kdamonds_dir/1" "not_exist" } +test_producer() +{ + producer_dir=$1 + ensure_file "$producer_dir/report_type" "exist" "600" + ensure_write_succ "$producer_dir/report_type" "user_report" \ + "valid input" + ensure_write_fail "$producer_dir/report_type" "foo" "invlid input" + + ensure_file "$producer_dir/producer_state" "exist" "600" + ensure_write_succ "$producer_dir/producer_state" "on" "valid input" + ensure_write_succ "$producer_dir/producer_state" "submit" "valid input" + ensure_write_succ "$producer_dir/producer_state" "off" "valid input" + ensure_write_fail "$producer_dir/producer_state" "foo" "invalid input" + + ensure_file "$producer_dir/addr_start" "exist" "600" + ensure_write_succ "$producer_dir/addr_start" 123 "valid input" + ensure_write_fail "$producer_dir/addr_start" foo "uinvalid input" + ensure_write_fail "$producer_dir/addr_start" "1.23" "uinvalid input" + + ensure_file "$producer_dir/addr_end" "exist" "600" + ensure_write_succ "$producer_dir/addr_end" 123 "valid input" + ensure_write_fail "$producer_dir/addr_end" foo "uinvalid input" + ensure_write_fail "$producer_dir/addr_end" "1.23" "uinvalid input" +} + +test_producers() +{ + producers_dir=$1 + ensure_dir "$producers_dir" "exist" + + ensure_file "$producers_dir/nr_producers" "exist" "600" + + ensure_write_succ "$producers_dir/nr_producers" "1" "valid input" + test_producer "$producers_dir/0" + + ensure_write_succ "$producers_dir/nr_producers" "2" "valid input" + test_producer "$producers_dir/0" + test_producer "$producers_dir/1" + + ensure_write_succ "$producers_dir/nr_producers" "0" "valid input" + ensure_dir "$producers_dir/0" "not_exist" + ensure_dir "$producers_dir/1" "not_exist" +} + +test_reports() +{ + reports_dir=$1 + ensure_dir "$reports_dir" "exist" + test_producers "$reports_dir/producers" +} + test_damon_sysfs() { damon_sysfs=$1
@@ -520,6 +571,7 @@ test_damon_sysfs() fi test_kdamonds "$damon_sysfs/kdamonds" + test_reports "$damon_sysfs/reports" } check_dependencies
Signature · 1 line
2.47.3
[email protected]
AI reviewRe: [RFC PATCH 24/27] selftests/damon/sysfs.sh: add basic tests for admin/reports/
Sashiko has reviewed this patch and found no issues.
Quoted 4 lines
Update
sysfs.shDAMON selftest to cover basic file operations for the sysfs files under the admin/reports/ directory.Signed-off-by SJ Park <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=24
SJ Park
maintainerRFC PATCH 25/27 Docs/mm/damon/design: update for user report support
In reply to SJ ParkUpdate DAMON design document for the newly aded user_report type data attribute reports.
--- Documentation/mm/damon/design.rst | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-)
Documentation/mm/damon/design.rst +14 -1
@@ -382,12 +382,25 @@ can generate and submit reports of the given type. The generations and submissions could be done automatically by the kernel or manually by the user, depending on the type of the report. -For now, no report type is supported. +Below report types are supported. + +- ``user_report``: User-provided report. To use this, the user should set the + address range of the memory to report for. This type of report is not + automatically generated and submitted to DAMON. The user should manually + generate and submit each report using the interface. The data attribute probe supports the reports. The probes can be configured to hit for a given memory region if a specific type of valid reports that are associated with the probing memory exist in the reports queue. +For example, users can run DAMON in the classical page table accessed bits +based access monitoring. In addition to that, users could find hot data that +might not be able to found by DAMON. DAMON might not able to find that due to +limitations in page table accessed bits or its overhead control mechanism. +Users may be able to find that using their access to workload source code, +experiment results or other tools. Users can complement monitoring results by +feeding the information as user reports. + Dynamic Target Space Updates Handling ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Signature · 1 line
2.47.3
[email protected]
AI reviewRe: [RFC PATCH 25/27] Docs/mm/damon/design: update for user report support
Sashiko has reviewed this patch and found no issues.
Quoted 4 lines
Update DAMON design document for the newly aded
user_reporttype data attribute reports.Signed-off-by SJ Park <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=25
SJ Park
maintainerRFC PATCH 26/27 Docs/admin-guide/mm/damon/usage: update for user_report report support
In reply to SJ ParkUpdate DAMON usage document for the newly added user_report type data attribute report support.
--- Documentation/admin-guide/mm/damon/usage.rst | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
Documentation/admin-guide/mm/damon/usage.rst +10 -1
@@ -117,7 +117,7 @@ comma (","). │ │ ... │ reports/ │ │ producers/nr_producers - │ │ │ 0/report_type,producer_state + │ │ │ 0/report_type,producer_state,addr_start,addr_end │ │ │ ... .. _sysfs_root:
@@ -767,6 +767,15 @@ Users can write below keywords for the producer to the file. - ``on``: Enable the producer. - ``off``: Disable the producer. +- ``submit``: Generate and submit a new ``user_report`` type report, if + ``report_type`` is ``user_report``, and the producer is enabled. + +``addr_start`` and ``addr_end`` files are used only for ``user_report`` report +type. Those set the address range of memory to manually report . Users can +set the start and end address of the address range by writing the addresses to +the files. Note that it is open-end range (``[addr_start,addr_end)``) and +therefore the end address is exclusive. Reading the files shows the last +successfully written input. .. _tracepoint:
Signature · 1 line
2.47.3
[email protected]
AI reviewRe: [RFC PATCH 26/27] Docs/admin-guide/mm/damon/usage: update for user_report report support
Sashiko has reviewed this patch and found no issues.
Quoted 4 lines
Update DAMON usage document for the newly added
user_reporttype data attribute report support.Signed-off-by SJ Park <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=26
SJ Park
maintainerRFC PATCH 27/27 Docs/ABI/damon: update for user_report report support
In reply to SJ ParkUpdate DAMON ABI document for the newly added user_report type data attribute report support.
--- Documentation/ABI/testing/sysfs-kernel-mm-damon | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
Documentation/ABI/testing/sysfs-kernel-mm-damon +16 -0
@@ -722,3 +722,19 @@ Contact: SJ Park <[email protected]> Description: A file for requesting actions including enablement and disablement of the producer. Refer to Documentation/admin-guide/mm/damon/usage.rst for more details. + +What: /sys/kernel/mm/damon/admin/reports/producers/<P>/addr_start +Date: Nov 2026 +Contact: SJ Park <[email protected]> +Description: Writing an integer to and reading from this file sets and gets + the start address of the report to manually generate and + submit, depending on the type of the report producer. Note + that the start address is inclusive. + +What: /sys/kernel/mm/damon/admin/reports/producers/<P>/addr_end +Date: Nov 2026 +Contact: SJ Park <[email protected]> +Description: Writing an integer to and reading from this file sets and gets + the end address of the report to manually generate and submit, + depending on the type of the report producer. Note that the + end address is exclusive.
Signature · 1 line
2.47.3
[email protected]
AI reviewRe: [RFC PATCH 27/27] Docs/ABI/damon: update for user_report report support
Sashiko has reviewed this patch and found no issues.
Quoted 4 lines
Update DAMON ABI document for the newly added
user_reporttype data attribute report support.Signed-off-by SJ Park <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=27
SJ Park
maintainerQuoted 7 lines · On Sun, 15 Nov 2026 12:28:18 -0800 SJ Park <[email protected]> wrote:
TL;DR
=====Build a system for letting DAMON-external entities report their data attribute findings to DAMON. Let users report their data attribute findings to DAMON using the report system.
[...]
Quoted 6 lines
Ongoing and Future Works
========================This is a part of the "beyond page table accessed-bit DAMON extension" project milestone 2. This patch series provides the initial and essential part of the data attribute report system.
I forgot adding a link for the project. Please refer to this thread [1] for more details, plans and status of the project.
[1] https://lore.kernel.org/[email protected]
Thanks,
SJ
[...]