Skip to content

RFC mm/damon: let users report their data attribute findings

SJ Park damon linux-doc linux-kselftest linux-mm lkml 2 versions – New

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 RFC Latest27 patches 0 repliesNew
  2. v1 RFC27 patches 11 repliesSuperseded

Changes from RFC v0 from the cover letter

- 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.

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/27mm/damon/api: introduce struct damon_reportinclude/linux/damon.h+21 -00 replies
2/27mm/damon/core: implement data attribute report queuemm/damon/core.c+30 -10 replies
3/27mm/damon/core: introduce damon_submit_report()include/linux/damon.h mm/damon/core.c+32 -00 replies
4/27mm/damon/sysfs: add admin/reports/ directorymm/damon/sysfs.c+59 -40 replies
5/27mm/damon/sysfs: add reports/producers/ directorymm/damon/sysfs.c+47 -10 replies
6/27mm/damon/sysfs: add producers/nr_producers filemm/damon/sysfs.c+51 -00 replies
7/27mm/damon/sysfs: implement report producer directorymm/damon/sysfs.c+70 -10 replies
8/27mm/damon/sysfs: implement report producer type and state filesmm/damon/sysfs.c+80 -00 replies
9/27Docs/mm/damon/design: update for report systemDocumentation/mm/damon/design.rst+26 -00 replies
10/27Docs/admin-guide/mm/damon/usage: update for report producer sysfsDocumentation/admin-guide/mm/damon/usage.rst+35 -00 replies
11/27Docs/ABI/damon: update for report producer sysfs filesDocumentation/ABI/testing/sysfs-kernel-mm-damon+20 -00 replies
12/27mm/damon/core: introduce DAMON_FILTER_TYPE_REPORT_MADEinclude/linux/damon.h mm/damon/core.c+11 -00 replies
13/27mm/damon/core: introduce damon_report_exist()include/linux/damon.h mm/damon/core.c+49 -00 replies
14/27mm/damon/paddr: support REPORT_MADE type probe filtermm/damon/paddr.c+13 -40 replies
15/27mm/damon/sysfs: add filter_report_type file under probe filter directorymm/damon/sysfs.c+52 -90 replies
16/27mm/damon/sysfs: support REPORT_MADE type probe filter setupmm/damon/sysfs.c+6 -00 replies
17/27Docs/mm/damon/design: update for report_made probe filter typeDocumentation/mm/damon/design.rst+6 -00 replies
18/27Docs/admin-guide/mm/damon/usage: update for REPORT_MADE probe filterDocumentation/admin-guide/mm/damon/usage.rst+5 -10 replies
19/27Docs/ABI/damon: update for REPORT_MADE probe filterDocumentation/ABI/testing/sysfs-kernel-mm-damon+7 -00 replies
20/27mm/damon/api: introduce user_report report typeinclude/linux/damon.h+3 -10 replies
21/27mm/damon/sysfs: add user_report support for report type inputmm/damon/sysfs.c+4 -00 replies
22/27mm/damon/sysfs: implement report producer addr_{start,end} filesmm/damon/sysfs.c+45 -00 replies
23/27mm/damon/sysfs: implement submit command for report producermm/damon/sysfs.c+16 -30 replies
24/27selftests/damon/sysfs.sh: add basic tests for admin/reports/tools/testing/selftests/damon/sysfs.sh+52 -00 replies
25/27Docs/mm/damon/design: update for user report supportDocumentation/mm/damon/design.rst+14 -10 replies
26/27Docs/admin-guide/mm/damon/usage: update for user_report report supportDocumentation/admin-guide/mm/damon/usage.rst+10 -10 replies
27/27Docs/ABI/damon: update for user_report report supportDocumentation/ABI/testing/sysfs-kernel-mm-damon+16 -00 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v2 yet.

Read the v2 thread

Cover letter [RFC PATCH v2 00/27] 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 [1] 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.

References
==========

[1] Beyond page table accessed bits DAMON extension roadmap:

    https://lore.kernel.org/[email protected]/

Changes from RFC
- RFC: https://lore.kernel.org/[email protected]
- Add parent project roadmap link in the cover letter.
- Fixup kernel-doc comments.
- Mark damon_report_queue as static.
- Destroy damon_region_cache for queue setup failure.
- Fix out-of-bound writing in damon_submit_report().
- Setup damon_filter->report_type in damon_commit_filters() path, too.
- Fix wrong index referencing in damon_report_exist().
- Rebase to the latest mm-new.
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                               | 113 ++++-
 mm/damon/paddr.c                              |  17 +-
 mm/damon/sysfs.c                              | 420 +++++++++++++++++-
 tools/testing/selftests/damon/sysfs.sh        |  52 +++
 8 files changed, 763 insertions(+), 10 deletions(-)

base-commit: 595ae33ab080415771ec5707280ac89f40eeb75d

Signature · 1 line
2.47.3