Linux Kernel Selftest development
 help / color / mirror / Atom feed
* [PATCH v2 00/27] mm/damon: let users report their data attribute findings
@ 2026-11-24 15:36 SJ Park
  2026-11-24 15:36 ` [PATCH v2 24/27] selftests/damon/sysfs.sh: add basic tests for admin/reports/ SJ Park
  2026-11-25 22:10 ` [PATCH v2 00/27] mm/damon: let users report their data attribute findings Ravi Jonnalagadda
  0 siblings, 2 replies; 5+ messages in thread
From: SJ Park @ 2026-11-24 15:36 UTC (permalink / raw)
  To: Andrew Morton
  Cc: SJ Park, Jonathan Corbet, Randy Dunlap, Shuah Khan, Shuah Khan,
	damon, linux-doc, linux-kselftest, linux-mm

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/20260525225208.1179-1-sj@kernel.org/

Tests
=====

Confirmed the user report is working like below.

Submit report for [5 GiB, 6 GiB) address range for every 5 milliseconds.

    # cd /sys/kernel/mm/damon/admin/reports/producers/
    # echo 1 > nr_producers
    # echo $((5*1024*1024)) > 0/addr_start
    # echo $((6*1024*1024)) > 0/addr_end
    # echo on > 0/producer_state
    # while true; do echo submit > producer_state ; sleep 0.005; done

On another terminal session, start DAMON in the attribute only
monitoring mode, with user_report report_made probe filter type, using
DAMON user-space tool, damo [1].

    $ sudo ./damo start --probe \
            --probe_filter allow report_made user_report \
            --probe_weight 1

Show the user report for the [5 GiB, 6 GiB) address range is detected:

    $ sudo ./damo report attrs --sort_regions_by address
    heatmap:
    00000000000000000000000000000000000000000000000000069999999995111111100000000000
    # min/max temperatures: -790,000,000, 80,001,900, column size: 99.800
    MiB
    probe allow report_made user_report (weight: 1)
    intervals: sample 5 ms aggr 100 ms (max probe hits 20)
    #   size         address       age           probe_hits
    0   4.678 GiB    4.000 KiB     7.900 s       0
    1   329.582 MiB  4.678 GiB     7.400 s       0
    2   1024.000 MiB  5.000 GiB     800 ms        19
    3   792.809 MiB  6.000 GiB     6.900 s       0
    4   1.023 GiB    6.774 GiB     7.900 s       0
    memory bw estimate: 0 B per second
    total size: 7.797 GiB
    record DAMON intervals: sample 5 ms, aggr 100 ms

the region of index 2 is the region for the [5 GiB, 6 GiB) address
range.  DAMON received the user report for nearly all sampling
intervals, and therefore shows its probe_hits as 19.

Stop user report submissions using Ctrl-C on the report submit terminal
session. Show DAMON monitoring results showing no more reports are
submitted.

    $ sudo ./damo report attrs --sort_regions_by address
    heatmap:
    00000000000000000000000000000000000000000000000366666668999999822222221000000000
    # min/max temperatures: -1,740,000,000, -740,000,000, column size:
    99.800 MiB
    probe allow report_made user_report (weight: 1)
    intervals: sample 5 ms aggr 100 ms (max probe hits 20)
    #   size         address       age           probe_hits
    0   1.551 GiB    4.000 KiB     17.400 s      0
    1   1.536 GiB    1.551 GiB     17.300 s      0
    2   788.715 MiB  3.087 GiB     17.200 s      0
    3   797.793 MiB  3.857 GiB     16.800 s      0
    4   764.137 MiB  4.636 GiB     10.300 s      0
    5   768.867 MiB  5.382 GiB     7.400 s       0
    6   774.043 MiB  6.133 GiB     14.500 s      0
    7   797.250 MiB  6.889 GiB     17 s          0
    8   132.488 MiB  7.667 GiB     17.400 s      0
    memory bw estimate: 0 B per second
    total size: 7.797 GiB
    record DAMON intervals: sample 5 ms, aggr 100 ms

No more probe_hits for [5 GiB, 6 GiB) address range is shown, since the
user report is stopped..

[1] https://github.com/damonitor/damo

Changes from v1
- v1: https://lore.kernel.org/20261121210013.130397-1-sj@kernel.org
- Convert probing address from phys_addr_t to unsigned long, using
  addr_unit.
- Collect R-b: from Aveline and Lian.
- Rebase to the latest mm-new.
Changes from RFC v2
- RFC v2: https://lore.kernel.org/20261118022225.100659-1-sj@kernel.org
- Add test results to the cover letter.
- Rebase to the latest mm-new.
- Drop RFC tag.
Changes from RFC
- RFC: https://lore.kernel.org/20261115202849.99134-1-sj@kernel.org
- 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/20261017195747.89961-1-sj@kernel.org
- 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: 8a564d37d55547b5884c310776de062e6add5ef3
-- 
2.47.3

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH v2 24/27] selftests/damon/sysfs.sh: add basic tests for admin/reports/
  2026-11-24 15:36 [PATCH v2 00/27] mm/damon: let users report their data attribute findings SJ Park
@ 2026-11-24 15:36 ` SJ Park
  2026-11-25 22:10 ` [PATCH v2 00/27] mm/damon: let users report their data attribute findings Ravi Jonnalagadda
  1 sibling, 0 replies; 5+ messages in thread
From: SJ Park @ 2026-11-24 15:36 UTC (permalink / raw)
  To: Andrew Morton
  Cc: SJ Park, Shuah Khan, damon, linux-kselftest, linux-mm,
	Aveline Noir, Lian Wang

Update sysfs.sh DAMON selftest to cover basic file operations for the
sysfs files under the admin/reports/ directory.

Reviewed-by: Aveline Noir <jm5905938@gmail.com>
Reviewed-by: Lian Wang <lianux.mm@gmail.com>
Signed-off-by: SJ Park <sj@kernel.org>
---
 tools/testing/selftests/damon/sysfs.sh | 52 ++++++++++++++++++++++++++
 1 file changed, 52 insertions(+)

diff --git a/tools/testing/selftests/damon/sysfs.sh b/tools/testing/selftests/damon/sysfs.sh
index 1cc7ab2d7e22f..577953ee4e631 100755
--- a/tools/testing/selftests/damon/sysfs.sh
+++ b/tools/testing/selftests/damon/sysfs.sh
@@ -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
-- 
2.47.3

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH v2 00/27] mm/damon: let users report their data attribute findings
  2026-11-24 15:36 [PATCH v2 00/27] mm/damon: let users report their data attribute findings SJ Park
  2026-11-24 15:36 ` [PATCH v2 24/27] selftests/damon/sysfs.sh: add basic tests for admin/reports/ SJ Park
@ 2026-11-25 22:10 ` Ravi Jonnalagadda
  2026-11-26  2:04   ` SJ Park
  1 sibling, 1 reply; 5+ messages in thread
From: Ravi Jonnalagadda @ 2026-11-25 22:10 UTC (permalink / raw)
  To: SJ Park
  Cc: Andrew Morton, Jonathan Corbet, Randy Dunlap, Shuah Khan,
	Shuah Khan, damon, linux-doc, linux-kselftest, linux-mm

Hi SJ,

I tested v2 as it is in mm-new, and wanted to share what I saw.

How I tested:

The guest is x86_64 with 8 CPUs and 4 GiB of RAM in two NUMA nodes.
A paddr context watches 1 GiB of node 1, the physical range
[4 GiB, 5 GiB).  Every 5 ms DAMON samples an address in each region,
and the context's probes decide whether that sample counts as a hit.
User reports are submitted through the sysfs producer files.

The context has three probes:

- one with a REPORT_MADE filter for user_report, matching=Y, allow=Y:
  it counts the samples that find a report;
- one with the same filter but matching=N: it counts the samples that
  find no report;
- one with no filter: it counts all samples.

For each test I compared the hits of the first two with the number
they should be, as a share of all samples.

I tried four cases:

1. A report that starts exactly at the sampled address, with
   addr_unit 1 and 4096.
2. A report over the whole watched range, kept fresh by one to
   sixteen writers re-submitting it, slowly and then as fast as they
   can.  Every sample should find it.
3. Reports with an empty or inverted range, next to one valid report.
4. A REPORT_MADE filter on a vaddr context instead of paddr.

The DAMON KUnit suites pass.

What I saw

Case 1 works now: with the addr_unit fix in v2, those reports match.
Thanks.

Cases 2 to 4 do not behave as I expected:

2. As the submit rate goes up, two things go wrong:
   - with matching=Y, the probe misses the report more and more
     often, although it is always there;
   - with matching=N, the probe matches more and more often, although
     it should never match.
3. Empty and inverted reports are accepted.  They never match, but
   they take queue slots, and enough of them push the valid report
   out.
4. On a vaddr context the filter is accepted but has no effect.

Where it comes from

Case 2: a busy report queue (13/27, 14/27)

When a lookup finds the report queue locked, for example by a submit,
it answers "not found" rather than "don't know".  For matching=Y that
is a miss; for matching=N it is a match.  The more writers, the busier
the queue, and the more samples go wrong.

The right answer here is 100 % of samples for matching=Y and 0 % for
matching=N.  What I measured (the last column is the share of submits
refused as busy):

  writers               matching=Y   matching=N   refused submits
  1, one submit per ms     99.5 %        0.5 %          0.1 %
  1, back to back          45.5 %       55.3 %          0.2 %
  4, back to back          49.0 %       51.3 %         60.2 %
  16, back to back         15.6 %       84.9 %         79.9 %

The numbers vary somewhat between boots; the trend does not.

Could a lookup that finds the queue busy skip that sample instead of
counting it as a miss?

Cases 3 and 4: input checks

Two smaller things, both about inputs that are accepted but cannot
work:

- Submit accepts a report whose start equals its end, or is above it
  (22/27, 23/27).  It never matches but takes a queue slot: with 1000
  of them after a valid report, the valid one is found in only 4 % of
  samples.  Return -EINVAL for these?
- A vaddr context accepts a REPORT_MADE filter (16/27), but the vaddr
  operations never evaluate it.  Refuse it for non-paddr contexts for
  now?

A minor nit in the cover letter: the loop
"echo submit > producer_state" runs in producers/, so it fails with
"Permission denied".  It should be "echo submit > 0/producer_state".

Thanks,
Ravi

---
The case 2 setup, for reference (paddr, node 1 = [4 GiB, 5 GiB)):

  A=/sys/kernel/mm/damon/admin
  C=$A/kdamonds/0/contexts/0
  echo 1 > $A/kdamonds/nr_kdamonds
  echo 1 > $A/kdamonds/0/contexts/nr_contexts
  echo paddr > $C/operations
  echo 1 > $C/addr_unit
  echo 5000 > $C/monitoring_attrs/intervals/sample_us
  echo 100000 > $C/monitoring_attrs/intervals/aggr_us
  echo 100 > $C/monitoring_attrs/nr_regions/min
  echo 100 > $C/monitoring_attrs/nr_regions/max
  echo 1 > $C/targets/nr_targets
  echo 1 > $C/targets/0/regions/nr_regions
  echo $((4 << 30)) > $C/targets/0/regions/0/start
  echo $((5 << 30)) > $C/targets/0/regions/0/end

  # probe 0: matching=Y, probe 1: matching=N, probe 2: no filter
  echo 3 > $C/monitoring_attrs/probes/nr_probes
  for i in 0 1; do
      F=$C/monitoring_attrs/probes/$i/filters
      echo 1 > $F/nr_filters
      echo report_made > $F/0/type
      echo user_report > $F/0/filter_report_type
      echo Y > $F/0/allow
  done
  echo Y > $C/monitoring_attrs/probes/0/filters/0/matching
  echo N > $C/monitoring_attrs/probes/1/filters/0/matching

  # one producer covering the whole watched range
  P=$A/reports/producers
  echo 1 > $P/nr_producers
  echo user_report > $P/0/report_type
  echo $((4 << 30)) > $P/0/addr_start
  echo $((5 << 30)) > $P/0/addr_end
  echo on > $P/0/producer_state
  echo on > $A/kdamonds/0/state

The writers are 1 to 16 copies of a small loop that writes "submit"
to $P/0/producer_state for 10 s, with a 1 ms sleep (the first row) or
none.  Hits are read from the damon_region_aggregated tracepoint's
probe_hits.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2 00/27] mm/damon: let users report their data attribute findings
  2026-11-25 22:10 ` [PATCH v2 00/27] mm/damon: let users report their data attribute findings Ravi Jonnalagadda
@ 2026-11-26  2:04   ` SJ Park
  2026-11-26  7:03     ` Ravi Jonnalagadda
  0 siblings, 1 reply; 5+ messages in thread
From: SJ Park @ 2026-11-26  2:04 UTC (permalink / raw)
  To: Ravi Jonnalagadda
  Cc: SJ Park, Andrew Morton, Jonathan Corbet, Randy Dunlap, Shuah Khan,
	Shuah Khan, damon, linux-doc, linux-kselftest, linux-mm

Hi Ravi,

On Wed, 25 Nov 2026 14:10:15 -0800 Ravi Jonnalagadda <ravis.opensrc@gmail.com> wrote:

> Hi SJ,
> 
> I tested v2 as it is in mm-new, and wanted to share what I saw.

Thank you for sharing!

[...]
> 2. As the submit rate goes up, two things go wrong:
>    - with matching=Y, the probe misses the report more and more
>      often, although it is always there;
>    - with matching=N, the probe matches more and more often, although
>      it should never match.
> 3. Empty and inverted reports are accepted.  They never match, but
>    they take queue slots, and enough of them push the valid report
>    out.
> 4. On a vaddr context the filter is accepted but has no effect.
> 
> Where it comes from
> 
> Case 2: a busy report queue (13/27, 14/27)
> 
> When a lookup finds the report queue locked, for example by a submit,
> it answers "not found" rather than "don't know".  For matching=Y that
> is a miss; for matching=N it is a match.  The more writers, the busier
> the queue, and the more samples go wrong.

This is the expected result.  The implementation is more strict for type
matching.  If it is unclear, it says the type is not matched.

For example, if filter type is PGIDLE_SET and we cannot confirm it, it is
treated as not PGIDLE_SET.  For example, DAMON could fail at confirming that if
it was unable to get the folio for the probing memory due to some races.

> 
> The right answer here is 100 % of samples for matching=Y and 0 % for
> matching=N.  What I measured (the last column is the share of submits
> refused as busy):
> 
>   writers               matching=Y   matching=N   refused submits
>   1, one submit per ms     99.5 %        0.5 %          0.1 %
>   1, back to back          45.5 %       55.3 %          0.2 %
>   4, back to back          49.0 %       51.3 %         60.2 %
>   16, back to back         15.6 %       84.9 %         79.9 %
> 
> The numbers vary somewhat between boots; the trend does not.
> 
> Could a lookup that finds the queue busy skip that sample instead of
> counting it as a miss?

I agree that could reduce the error rate.  But I concern if it could make the
behavior inconsistent.

In my humble opinion, , the user could work around this issue by not submitting
the report too frequently.

But the more important question is, if the user really need to do this kind of
frequent report submissions.  I have no clue at the moment.  If it turns out
so, we could improve kernel side.

One straightforward way would be introducing a complenting type.  For example,
we introduced PGIDLE_UNSET to complement PGILDE_SET.  We could add something
similar for REPORT_MADE, say, REPORT_UNMADE.

Yet more possible kernel side improvement would be making the report queue
synchronization be more robust to contentions.

> 
> Cases 3 and 4: input checks
> 
> Two smaller things, both about inputs that are accepted but cannot
> work:
> 
> - Submit accepts a report whose start equals its end, or is above it
>   (22/27, 23/27).  It never matches but takes a queue slot: with 1000
>   of them after a valid report, the valid one is found in only 4 % of
>   samples.  Return -EINVAL for these?
> - A vaddr context accepts a REPORT_MADE filter (16/27), but the vaddr
>   operations never evaluate it.  Refuse it for non-paddr contexts for
>   now?

I agree this could be confusing.  In a sense, that said, those are working as
documented.  There is no documentation saying addr_start should be less than
addr_end.  DAMOS filter design documentation mentions "support of the filter
types depends on the DAMON operations set".  And the probe filter design
documentation says "The filters work the same as DAMOS filters".

I personally tend to prefer keeping code simple over making good user
experience, as long as it is not causing critical issues like crashes and/or
leaks.

If it turns out to really confuse users to be real problematic, we could add
documents or make code changes.

> 
> A minor nit in the cover letter: the loop
> "echo submit > producer_state" runs in producers/, so it fails with
> "Permission denied".  It should be "echo submit > 0/producer_state".

Good finding, thank you.  Maybe we could ask Andrew to fix this up, but this
might be too minor thing that readers could easily find out themselves...?

Thank you again for your review and testing, Ravi!


Thanks,
SJ

[...]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2 00/27] mm/damon: let users report their data attribute findings
  2026-11-26  2:04   ` SJ Park
@ 2026-11-26  7:03     ` Ravi Jonnalagadda
  0 siblings, 0 replies; 5+ messages in thread
From: Ravi Jonnalagadda @ 2026-11-26  7:03 UTC (permalink / raw)
  To: SJ Park
  Cc: Andrew Morton, Jonathan Corbet, Randy Dunlap, Shuah Khan,
	Shuah Khan, damon, linux-doc, linux-kselftest, linux-mm

Hi SJ,

On Wed, 25 Nov 2026 18:04:15 -0800 SJ Park <sj@kernel.org> wrote:

[...]
> This is the expected result.  The implementation is more strict for type
> matching.  If it is unclear, it says the type is not matched.
>
> For example, if filter type is PGIDLE_SET and we cannot confirm it, it is
> treated as not PGIDLE_SET.  For example, DAMON could fail at confirming that if
> it was unable to get the folio for the probing memory due to some races.

That makes sense, thank you for explaining.

[...]
> In my humble opinion, , the user could work around this issue by not submitting
> the report too frequently.
>
> But the more important question is, if the user really need to do this kind of
> frequent report submissions.  I have no clue at the moment.  If it turns out
> so, we could improve kernel side.

Agreed, user reports through sysfs are unlikely to be submitted this
often.  The main reason I tested at high submit rates was future
hardware samplers, which would produce reports much faster than a
user would.  I was checking how the queue holds up under that kind of
load.  I am happy to discuss this further once this series is in and
you share more on the next milestones.

[...]
> I agree this could be confusing.  In a sense, that said, those are working as
> documented.  There is no documentation saying addr_start should be less than
> addr_end.  DAMOS filter design documentation mentions "support of the filter
> types depends on the DAMON operations set".  And the probe filter design
> documentation says "The filters work the same as DAMOS filters".

Agreed.

[...]
> Good finding, thank you.  Maybe we could ask Andrew to fix this up, but this
> might be too minor thing that readers could easily find out themselves...?

Agreed, it is a minor nit; can be ignored.

Thanks,
Ravi

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-11-26  7:03 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-24 15:36 [PATCH v2 00/27] mm/damon: let users report their data attribute findings SJ Park
2026-11-24 15:36 ` [PATCH v2 24/27] selftests/damon/sysfs.sh: add basic tests for admin/reports/ SJ Park
2026-11-25 22:10 ` [PATCH v2 00/27] mm/damon: let users report their data attribute findings Ravi Jonnalagadda
2026-11-26  2:04   ` SJ Park
2026-11-26  7:03     ` Ravi Jonnalagadda

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox