Skip to contentSkip to conversation

Docs/mm/damon/design: document data attributes report infra design (beyond page table accessed-bit milestone 2)

RFC PATCH In review SJ Park 4 participants 16 messages Oct 17 – Nov 12

Subsystems (4)
lore
Share & tools
lore

SJ Park

author maintainer
#0 lore raw

RFC PATCH 1/1 Docs/mm/damon/design: document data attributes report infra design (beyond page table accessed-bit milestone 2)

The "beyond page table accessed-bit DAMON extension" project [1] milestone 2 is for building the basic infrastructure for continued extension. After starting it, I studied perf event little and found a few demons in details. I therefore spent time on high level design. As it started looks like making sense to me, I'd like to share the humble design first and get feedback from more eyeballs.

Add a blueprint of the milestone 2 as a high level design document. Describe the API and ABI of data attribute report infrastructure, and an example use case of it for per-CPUs write-only monitoring. The API and ABI will later be extended for more data attributes reporters utilizing AMD IBS, Intel PEBS, Arm SPEs like h/w features and any possible DAMON-external reporter kernel components.

Request for comments
====================

This is an RFC for high level design discussion, so no implementation is provided. Comments I want to receive include but not limited to below.

Does the idea for perf CPU cycle sampling based access monitoring makes sense?

Does the design provides clear idea about how it can be extended for the future extensions that already scoped for milestone 3 (AMD IBS, Intel PEBS, Arm SPE)?

For the foreseeable extensions (AMD IBS, Intel PEBS, Arm SPE), would the required change minimum and maintainable?

Next steps
==========

I will start implementing the infrastructure and perf CPU cycle sampling based access monitoring as described in this patch. It will go through the normal development process. Delivery of it will be the completion of the milestone 2. As set on the initial roadmap [1], ETA of the delivery is LSFMMBPF'27. No delay is expected so far.

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

---
 Documentation/mm/damon/design.rst | 44 +++++++++++++++++++++++++++++++
 1 file changed, 44 insertions(+)
Documentation/mm/damon/design.rst +44 -0
index a465e34bb1d9c..1e699e3f8a496 100644
@@ -433,6 +433,50 @@ monitoring.
 Refer to the :ref:`admin guide <damon_usage_sysfs_probes>` to know how users
 can use the mode.
 
+Data Attributes Reporting
+~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Infrastructure for receiving attribute information from DAMON-external kernel
+components.
+
+Because DAMON is not hooked in every place but runs in its own worker thread,
+it cannot retrieve some types of data attribute information by itself.  Many of
+those are available to DAMON-external kernel components such as perf event
+callbacks and page fault handler.  For such cases, DAMON provides attributes
+reporting infrastructure.  Using its API, any kernel components can report
+their finding to DAMON.
+
+The API for doing the report is a function, damon_report_attrs().  The function
+receives the attribute information and saves it in DAMON's internal buffer.
+The function is safe to be called in any context including NMI.  The internal
+buffer has a fixed size and keeps only latest reports of the size.  Because one
+buffer size doesn't fit all, multiple report buffers of different size and
+rules can be generated and shared by multiple reporters.  DAMON provides API
+for such management of report buffers.  damon_report_attrs() can specify into
+which buffer the report should be saved.  DAMON user interface (ABI) for doing
+the buffer setup, and enable/disable reports of supported types is also
+supported.
+
+The data attribute probe supports the reports.  The probes can be configured to
+hit for a given memory region depending on the existence of specific types of
+reports that associated with the memory region in given report buffers.
+
+For example, per-CPUs write-only monitoring can be configured using this
+infrastructure like below.
+
+The user sets a report buffer and enable CPU instruction sampling report for
+the buffer.  DAMON will enable perf event counter for CPU cycles sampling.  The
+sampling callback will save the sampling time CPU instruction and the id of the
+CPU that was executing it, into the DAMON report buffer, using
+damon_report_attrs().  DAMON can automatically adjust the perf event sampling
+frequency to minimize old report drops due to the buffer size limit.
+
+The user further sets a DAMON probe.  The probe hits for a given DAMON region
+if a store instruction for a memory in the region that was executed from a
+given CPUs group exists in the report buffer.  As a result, the probe hit
+counts represent relative frequency of writes from a given CPUs group to a
+given memory region.
+
 Dynamic Target Space Updates Handling
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 

base-commit: 366c6418699768dba5826d412700a29d562ca039

Signature · 1 line
2.47.3
#1 lore raw
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Medium] Docs/mm/damon: CPU cycle instruction sampling lacks target memory address --

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] Docs/mm/damon: CPU cycle instruction sampling lacks target memory address --

commit a164f9ff38c8cd1963db3e0c7ea062dbc93135a3
Author: SJ Park <[email protected]>

Docs/mm/damon/design: document data attributes report infra design (beyond page table accessed-bit milestone 2)

This patch documents the high-level design for DAMON's data attributes reporting infrastructure, including the damon_report_attrs() API and an example use case for per-CPU write-only monitoring using perf CPU cycles sampling.

Quoted 10 lines
Documentation/mm/damon/design.rst +2 -0
index a465e34bb1d9c..1e699e3f8a496 100644
@@ -433,6 +433,50 @@ monitoring.
 Refer to the :ref:`admin guide <damon_usage_sysfs_probes>` to know how users
 can use the mode.
 
+Data Attributes Reporting
+~~~~~~~~~~~~~~~~~~~~~~~~~

[ ... ]

Quoted 5 lines
Documentation/mm/damon/design.rst +5 -0
+For example, per-CPUs write-only monitoring can be configured using this
+infrastructure like below.
+
+The user sets a report buffer and enable CPU instruction sampling report for
+the buffer.  DAMON will enable perf event counter for CPU cycles sampling.  The

Documentation/mm/damon/design.rst monitoring. · line 478

Quoted 10 lines
Documentation/mm/damon/design.rst +10 -0
+sampling callback will save the sampling time CPU instruction and the id of the
+CPU that was executing it, into the DAMON report buffer, using
+damon_report_attrs().  DAMON can automatically adjust the perf event sampling
+frequency to minimize old report drops due to the buffer size limit.
+
+The user further sets a DAMON probe.  The probe hits for a given DAMON region
+if a store instruction for a memory in the region that was executed from a
+given CPUs group exists in the report buffer.  As a result, the probe hit
+counts represent relative frequency of writes from a given CPUs group to a
+given memory region.

[Severity: Medium]
In the Data Attributes Reporting section of Documentation/mm/damon/design.rst, how can the DAMON probe determine whether a sampled store instruction targeted a given DAMON memory region if the callback only saves the CPU instruction and CPU ID from a generic CPU cycles counter?

A sampled instruction (or instruction pointer) only encodes the opcode and register operands, not the effective virtual or physical data address being written. Saving only the instruction and executing CPU ID via damon_report_attrs() does not appear to provide the target memory address needed to match against a DAMON region when the probe inspects the buffer.

Even if the perf overflow callback attempted to resolve the target data address at NMI time, generic CPU cycle counter interrupts (PERF_COUNT_HW_CPU_CYCLES) are non-precise on out-of-order CPUs and suffer from skid. At NMI time, regs->ip typically points to a subsequent instruction rather than the instruction that caused the overflow, and the register values in struct pt_regs may already have been modified.

Furthermore, without hardware data-address sampling features (such as Intel PEBS, AMD IBS, or Arm SPE populating perf_sample_data->addr or phys_addr, which are scoped for Milestone 3), resolving the effective address from a raw instruction would require fetching instruction bytes in NMI context, running an architecture-specific instruction decoder and address-calculation emulator, and translating virtual addresses to physical addresses for paddr monitoring.

How is the target memory address intended to be obtained and matched to DAMON regions in Milestone 2 with generic CPU cycle sampling?

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
author maintainer
#2 lore raw
Quoted 69 lines · On Sun, 18 Oct 2026 19:58:01 +0000 [email protected] wrote:

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] Docs/mm/damon: CPU cycle instruction sampling lacks target memory address --

commit a164f9ff38c8cd1963db3e0c7ea062dbc93135a3
Author: SJ Park <[email protected]>

Docs/mm/damon/design: document data attributes report infra design (beyond page table accessed-bit milestone 2)

This patch documents the high-level design for DAMON's data attributes reporting infrastructure, including the damon_report_attrs() API and an example use case for per-CPU write-only monitoring using perf CPU cycles sampling.

Quoted 10 lines
Documentation/mm/damon/design.rst +2 -0
index a465e34bb1d9c..1e699e3f8a496 100644
@@ -433,6 +433,50 @@ monitoring.
 Refer to the :ref:`admin guide <damon_usage_sysfs_probes>` to know how users
 can use the mode.
 
+Data Attributes Reporting
+~~~~~~~~~~~~~~~~~~~~~~~~~

[ ... ]

Quoted 5 lines
Documentation/mm/damon/design.rst +5 -0
+For example, per-CPUs write-only monitoring can be configured using this
+infrastructure like below.
+
+The user sets a report buffer and enable CPU instruction sampling report for
+the buffer.  DAMON will enable perf event counter for CPU cycles sampling.  The

Documentation/mm/damon/design.rst monitoring. · line 478

Quoted 10 lines
Documentation/mm/damon/design.rst +10 -0
+sampling callback will save the sampling time CPU instruction and the id of the
+CPU that was executing it, into the DAMON report buffer, using
+damon_report_attrs().  DAMON can automatically adjust the perf event sampling
+frequency to minimize old report drops due to the buffer size limit.
+
+The user further sets a DAMON probe.  The probe hits for a given DAMON region
+if a store instruction for a memory in the region that was executed from a
+given CPUs group exists in the report buffer.  As a result, the probe hit
+counts represent relative frequency of writes from a given CPUs group to a
+given memory region.

[Severity: Medium]
In the Data Attributes Reporting section of Documentation/mm/damon/design.rst, how can the DAMON probe determine whether a sampled store instruction targeted a given DAMON memory region if the callback only saves the CPU instruction and CPU ID from a generic CPU cycles counter?

A sampled instruction (or instruction pointer) only encodes the opcode and register operands, not the effective virtual or physical data address being written. Saving only the instruction and executing CPU ID via damon_report_attrs() does not appear to provide the target memory address needed to match against a DAMON region when the probe inspects the buffer.

Even if the perf overflow callback attempted to resolve the target data address at NMI time, generic CPU cycle counter interrupts (PERF_COUNT_HW_CPU_CYCLES) are non-precise on out-of-order CPUs and suffer from skid. At NMI time, regs->ip typically points to a subsequent instruction rather than the instruction that caused the overflow, and the register values in struct pt_regs may already have been modified.

Furthermore, without hardware data-address sampling features (such as Intel PEBS, AMD IBS, or Arm SPE populating perf_sample_data->addr or phys_addr, which are scoped for Milestone 3), resolving the effective address from a raw instruction would require fetching instruction bytes in NMI context, running an architecture-specific instruction decoder and address-calculation emulator, and translating virtual addresses to physical addresses for paddr monitoring.

Quoted 2 lines

How is the target memory address intended to be obtained and matched to DAMON regions in Milestone 2 with generic CPU cycle sampling?

Good question. damon_report_attr() will save the register contents and pid into report, too. And the probe in kdamond context will decode the instruction and get the memory address. For physical address, it will also do the page table walk of the process of the pid.

Quoted 3 lines
Signature · 2 lines
-- 
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1

Thanks,
SJ

#3 lore raw

Hi SJ,

Quoted 4 lines · On Sun, 18 Oct 2026 13:08:07 -0700 SJ Park <[email protected]> wrote:

Good question. damon_report_attr() will save the register contents and pid into report, too. And the probe in kdamond context will decode the instruction and get the memory address. For physical address, it will also do the page table walk of the process of the pid.

I measured what the samples carry, to see how far decode would go.

On AMD, cpu-cycles:p is IBS Op, and its memory-op samples carry a hardware data address. On Intel (Granite Rapids), cycles samples carry no data address at all; the PEBS memory events (MEM_INST_RETIRED.ALL_LOADS/ALL_STORES) do.

Share of samples with an address inside the 2 GiB test buffer (random loads and stores; perf record -d; one run per event):

  Xeon 6960P   cycles:p / cycles:pp / :ppp     0 %
  Xeon 6960P   mem_inst_retired.*:pp          100 %
  EPYC 9555P   cycles:p, cycles:pp, ibs_op//  ~21 % of all samples

(the memory-op ones)

How often the saved AX holds the target address when AX is the base register (perf record -d --intr-regs=AX; store to (%rax) vs pointer-chase load mov (%rax), %rax):

  Xeon 6960P   store loop 100 %    pointer-chase loop 0 %
  EPYC 9555P   store loop   0 %    pointer-chase loop 0 %

PEBS saves registers just after the instruction retires, so a load that overwrites its base register defeats decode. IBS saves no general registers (perf reports the registers at the NMI), so decode is not reliable on AMD. Decode in kdamond must also survive exec, munmap, exit and pid reuse. These are synthetic loops chosen to separate the cases; how often real code hits the failing case is not measured.

For the physical address, taking it at sample time, while the task is current, avoids walking a page table that may have changed by the time kdamond runs. IBS supplies it when valid; on Intel the producer can call perf_prepare_sample() in the overflow NMI to do the walk.

So the suggestion is for the first report type to use the PMU-captured address and load/store flag (AMD cpu-cycles:p; on Intel, the PEBS memory events, which moves them into milestone 2). Your call, of course.

Thanks,
Ravi

author maintainer
#4 lore raw
Quoted 38 lines · On Wed, 21 Oct 2026 21:17:08 -0700 Ravi Jonnalagadda <[email protected]>…

Hi SJ,

Quoted 4 lines · On Sun, 18 Oct 2026 13:08:07 -0700 SJ Park <[email protected]> wrote:

Good question. damon_report_attr() will save the register contents and pid into report, too. And the probe in kdamond context will decode the instruction and get the memory address. For physical address, it will also do the page table walk of the process of the pid.

I measured what the samples carry, to see how far decode would go.

On AMD, cpu-cycles:p is IBS Op, and its memory-op samples carry a hardware data address. On Intel (Granite Rapids), cycles samples carry no data address at all; the PEBS memory events (MEM_INST_RETIRED.ALL_LOADS/ALL_STORES) do.

Share of samples with an address inside the 2 GiB test buffer (random loads and stores; perf record -d; one run per event):

  Xeon 6960P   cycles:p / cycles:pp / :ppp     0 %
  Xeon 6960P   mem_inst_retired.*:pp          100 %
  EPYC 9555P   cycles:p, cycles:pp, ibs_op//  ~21 % of all samples

(the memory-op ones)

How often the saved AX holds the target address when AX is the base register (perf record -d --intr-regs=AX; store to (%rax) vs pointer-chase load mov (%rax), %rax):

  Xeon 6960P   store loop 100 %    pointer-chase loop 0 %
  EPYC 9555P   store loop   0 %    pointer-chase loop 0 %

PEBS saves registers just after the instruction retires, so a load that overwrites its base register defeats decode. IBS saves no general registers (perf reports the registers at the NMI), so decode is not reliable on AMD. Decode in kdamond must also survive exec, munmap, exit and pid reuse. These are synthetic loops chosen to separate the cases; how often real code hits the failing case is not measured.

Quoted 4 lines

For the physical address, taking it at sample time, while the task is current, avoids walking a page table that may have changed by the time kdamond runs. IBS supplies it when valid; on Intel the producer can call perf_prepare_sample() in the overflow NMI to do the walk.

Thank you for these testing, Ravi. Unfortunately I'm still learning perf event and therefore not yet fully understanding these tests. I will revisit after gaining more understanding.

Quoted 5 lines

So the suggestion is for the first report type to use the PMU-captured address and load/store flag (AMD cpu-cycles:p; on Intel, the PEBS memory events, which moves them into milestone 2). Your call, of course.

Meanwhile, I will start with the current plan (capture register contents in NMI and decode in kdamond) if you don't have strong concern.

Thanks,
SJ

[...]

#5 lore raw

Hi SJ,

Quoted 2 lines · On Wed, 21 Oct 2026 22:32:26 -0700 SJ Park <[email protected]> wrote:

On Wed, 21 Oct 2026 21:17:08 -0700 Ravi Jonnalagadda <[email protected]> wrote:

[...]

Quoted 6 lines
Quoted 6 lines

PEBS saves registers just after the instruction retires, so a load that overwrites its base register defeats decode. IBS saves no general registers (perf reports the registers at the NMI), so decode is not reliable on AMD. Decode in kdamond must also survive exec, munmap, exit and pid reuse. These are synthetic loops chosen to separate the cases; how often real code hits the failing case is not measured.

[...]

Quoted 5 lines

Thank you for these testing, Ravi. Unfortunately I'm still learning perf event and therefore not yet fully understanding these tests. I will revisit after gaining more understanding.

Quoted 7 lines
Quoted 4 lines

So the suggestion is for the first report type to use the PMU-captured address and load/store flag (AMD cpu-cycles:p; on Intel, the PEBS memory events, which moves them into milestone 2). Your call, of course.

Meanwhile, I will start with the current plan (capture register contents in NMI and decode in kdamond) if you don't have strong concern.

No strong concern. Starting with decode makes sense, and VMs are a good reason for it: in the KVM setups tried on Intel and AMD hosts, no guest got a data address from the PMU, whereas every guest had a software CPU clock (PERF_COUNT_SW_CPU_CLOCK) or basic hardware cycle counter (PERF_COUNT_HW_CPU_CYCLES).

As quick background on why those earlier test tables brought up PEBS and IBS: in perf_event, sampling CPU cycles has two modes, selected by attr.precise_ip (the :p suffix in perf record):

- Plain cycle or timer sampling (attr.precise_ip = 0, the default):
a counter overflows and raises a normal interrupt/NMI. The hardware does not record a data address; the handler just sees pt_regs where the CPU stopped between instructions. Even though the interrupt lands a few instructions after the overflow ("skid"), regs->ip is the next instruction about to run and pt_regs holds its untouched input registers -- so decoding regs->ip gives the address it is about to access.

- Hardware "precise" sampling (attr.precise_ip > 0, which routes to Intel PEBS or AMD IBS): the PMU hardware itself snapshots the instruction and, on supported events, the data address it touched. My earlier tables tested this mode. Because PEBS records registers after the instruction retires (when a load into its own base register has already overwritten it) and IBS does not capture general registers, software decode breaks there -- which is fine, since in that mode you use the hardware-captured address instead (your Milestone 3).

So there is no need to revisit those earlier test tables for your Milestone 2 prototype.

Two small tips for the prototype:

- use PERF_COUNT_HW_CPU_CYCLES (or PERF_COUNT_SW_CPU_CLOCK in VMs

    without a virtual PMU) with the default attr.precise_ip = 0;

- skip, and count, samples whose instruction does not access memory; in typical programs, only ~15-60% of cycle samples land on a load or store.

If you want to inspect what those samples look like from user space on a program:

  R=AX,BX,CX,DX,SI,DI,BP,SP,IP,R8,R9,R10,R11,R12,R13,R14,R15
  perf record -c 2000003 -e cycles:u --intr-regs=$R -- <program>
  perf script -F ip,iregs,insn

(In a guest without hardware cycle counters, use -e cpu-clock:u instead.) Each sample shows the IP, the registers and the instruction bytes to decode.

Thanks,
Ravi

author maintainer
#6 lore raw
Quoted 70 lines · On Fri, 23 Oct 2026 12:48:48 -0700 Ravi Jonnalagadda <[email protected]>…

Hi SJ,

Quoted 2 lines · On Wed, 21 Oct 2026 22:32:26 -0700 SJ Park <[email protected]> wrote:

On Wed, 21 Oct 2026 21:17:08 -0700 Ravi Jonnalagadda <[email protected]> wrote:

[...]

Quoted 6 lines
Quoted 6 lines

PEBS saves registers just after the instruction retires, so a load that overwrites its base register defeats decode. IBS saves no general registers (perf reports the registers at the NMI), so decode is not reliable on AMD. Decode in kdamond must also survive exec, munmap, exit and pid reuse. These are synthetic loops chosen to separate the cases; how often real code hits the failing case is not measured.

[...]

Quoted 5 lines

Thank you for these testing, Ravi. Unfortunately I'm still learning perf event and therefore not yet fully understanding these tests. I will revisit after gaining more understanding.

Quoted 7 lines
Quoted 4 lines

So the suggestion is for the first report type to use the PMU-captured address and load/store flag (AMD cpu-cycles:p; on Intel, the PEBS memory events, which moves them into milestone 2). Your call, of course.

Meanwhile, I will start with the current plan (capture register contents in NMI and decode in kdamond) if you don't have strong concern.

No strong concern. Starting with decode makes sense, and VMs are a good reason for it: in the KVM setups tried on Intel and AMD hosts, no guest got a data address from the PMU, whereas every guest had a software CPU clock (PERF_COUNT_SW_CPU_CLOCK) or basic hardware cycle counter (PERF_COUNT_HW_CPU_CYCLES).

As quick background on why those earlier test tables brought up PEBS and IBS: in perf_event, sampling CPU cycles has two modes, selected by attr.precise_ip (the :p suffix in perf record):

- Plain cycle or timer sampling (attr.precise_ip = 0, the default):
a counter overflows and raises a normal interrupt/NMI. The hardware does not record a data address; the handler just sees pt_regs where the CPU stopped between instructions. Even though the interrupt lands a few instructions after the overflow ("skid"), regs->ip is the next instruction about to run and pt_regs holds its untouched input registers -- so decoding regs->ip gives the address it is about to access.

- Hardware "precise" sampling (attr.precise_ip > 0, which routes to Intel PEBS or AMD IBS): the PMU hardware itself snapshots the instruction and, on supported events, the data address it touched. My earlier tables tested this mode. Because PEBS records registers after the instruction retires (when a load into its own base register has already overwritten it) and IBS does not capture general registers, software decode breaks there -- which is fine, since in that mode you use the hardware-captured address instead (your Milestone 3).

So there is no need to revisit those earlier test tables for your Milestone 2 prototype.

Two small tips for the prototype:

- use PERF_COUNT_HW_CPU_CYCLES (or PERF_COUNT_SW_CPU_CLOCK in VMs

    without a virtual PMU) with the default attr.precise_ip = 0;

- skip, and count, samples whose instruction does not access memory; in typical programs, only ~15-60% of cycle samples land on a load or store.

If you want to inspect what those samples look like from user space on a program:

Quoted 7 lines
  R=AX,BX,CX,DX,SI,DI,BP,SP,IP,R8,R9,R10,R11,R12,R13,R14,R15
  perf record -c 2000003 -e cycles:u --intr-regs=$R -- <program>
  perf script -F ip,iregs,insn

(In a guest without hardware cycle counters, use -e cpu-clock:u instead.) Each sample shows the IP, the registers and the instruction bytes to decode.

Thank you for these useful information an tips!

Thanks,
SJ

#7 lore raw
In reply to SJ Park

Hi SJ,

Thank you for sharing the design early. Short version: the design makes sense to me, with one main suggestion. The first report type should use the data address the PMU captures at sample time, rather than decode the instruction later in kdamond. The measurements behind it are in my reply to your answer to sashiko.

Quoted 2 lines · On Sat, 17 Oct 2026 12:57:45 -0700 SJ Park <[email protected]> wrote:

Does the idea for perf CPU cycle sampling based access monitoring makes sense?

On AMD, yes, with precise_ip (cpu-cycles:p routes to IBS Op): its memory-op samples carry a data address and load/store type. On Intel, even precise cycles samples (cycles:pp) carry no data address; PEBS memory events do. Decode from saved registers worked for one of two test loops on Intel and for neither on AMD (details in the other reply), hence the suggestion above.

Quoted 3 lines

Does the design provides clear idea about how it can be extended for the future extensions that already scoped for milestone 3 (AMD IBS, Intel PEBS, Arm SPE)?

Yes, if the report has an address field with a validity bit and carries the producing report-type (attr) id. Then IBS, PEBS, Arm SPE (through an adapter, since SPE uses the perf AUX buffer) and device-side monitors all produce the same report, into the same queues and probes.

Quoted 2 lines

For the foreseeable extensions (AMD IBS, Intel PEBS, Arm SPE), would the required change minimum and maintainable?

Yes, if staged. The sample-filter matcher and its sysfs already exist per context; attaching them per probe is the main change. For example:

M2.1 in-kernel only: damon_report_attrs(), the queue, region
lookup, the perf producer; kunit, no new sysfs
M2.2 your per-CPU write-only example, set up from user space:
attr_reports files, per-filter report_queue, write/cpumask/threads probe filters
M2.3 counters, a silence check (tracepoint/debugfs first), tuning
M3 more producers: Arm SPE, device monitors

Implementation notes:

1. One sampler per CPU per attr, owned by attr_reports (as in your damon/next usage doc) and shared by all contexts. IBS has one unit per CPU, so perf time-slices multiple events: on EPYC 9555P one ibs_op event got 67,140 samples; two on the same CPU got 33,547 + 33,535. On Intel the event also needs wakeup_events = 1, or an in-kernel handler sees only the last record of each large-PEBS batch.

2. A lockless queue, as your NOTE in damon_report_access() anticipates. Today's buffer is documented "May sleep" and uses mutex_trylock(), which interrupt context cannot use; its inclusive jiffy staleness check can also count one report in up to three intervals (HZ=250, 5 ms interval). A simple design: a per-CPU circular array with a write counter and a per-slot seqcount_t (using raw_write_seqcount_begin/end() for NMI safety), overwriting the oldest slot. Readers never consume; each context keeps its last-seen write counter per CPU. A nested writer (e.g. an NMI over a task-context write) drops its report and counts it.

3. Report fields: paddr, vaddr, size, time, cpu, tid, tgid, the producer's attr id, and flags (is_write, plus a validity bit per address, since 0 is a valid paddr). Store global ids; translate namespaces at the filter.

4. Binary search over a sorted region snapshot (your todo in kdamond_apply_access_report()) beats a linear walk from about 2 reports per interval for 1,000 regions (a model, to be measured).

5. Samplers can stop silently: in a report on the v4 thread [1], IBS Op samples stopped after about 10 minutes on a Ryzen 5 5600H, but not with the NMI watchdog enabled. So count dropped reports and check for silence against an independent reference. For tuning, step sample_period rather than use frequency mode, and do not raise perf_event_max_sample_rate: on an early DAMON PEBS prototype (Xeon 6960P), perf cut it from 100000 to 10000 in about 20 seconds.

Three decisions would unblock M2.1:

- The first report type: the PMU-captured address (suggested), or decode from saved registers in kdamond (your current plan).
- Whether the report carries the producer's attr id (suggested: yes).
- The queue: the per-CPU seqcount design in note 2 (suggested), or ftrace's ring buffer with one iterator per reader.

One question on the ABI: the usage document in your damon/next tree adds a report_queue file under each probe filter. Is it meant as "this filter tests reports in queue N"?

Happy to write, review or test any piece: the queue with kunit, the AMD/Intel perf producer, a decode-accuracy study on real workloads, or runs on Xeon 6960P and EPYC 9555P. Several exist in RFC v4 [2].

Thanks,
Ravi

[1] https://lore.kernel.org/r/[email protected]
[2] https://lore.kernel.org/r/20261005-damon-perf-rfc-v3-send-2026-10-03-v4-0-b03452e137f3@gmail.com

author maintainer
#8 lore raw

Hi Ravi,

Quoted 7 lines · On Wed, 21 Oct 2026 21:17:24 -0700 Ravi Jonnalagadda <[email protected]>…

Hi SJ,

Thank you for sharing the design early. Short version: the design makes sense to me, with one main suggestion. The first report type should use the data address the PMU captures at sample time, rather than decode the instruction later in kdamond. The measurements behind it are in my reply to your answer to sashiko.

Thank you for your detailed review and testing of the first design! I'd still like to try decoding idea first, mainly for quick prototyping.

Quoted 6 lines · On Sat, 17 Oct 2026 12:57:45 -0700 SJ Park <[email protected]> wrote:
Quoted 3 lines

Does the idea for perf CPU cycle sampling based access monitoring makes sense?

Quoted 6 lines

On AMD, yes, with precise_ip (cpu-cycles:p routes to IBS Op): its memory-op samples carry a data address and load/store type. On Intel, even precise cycles samples (cycles:pp) carry no data address; PEBS memory events do. Decode from saved registers worked for one of two test loops on Intel and for neither on AMD (details in the other reply), hence the suggestion above.

My current understanding of perf event is not good enough to deeply understand those. I will start with full registers capture-decode option and revisit this.

Quoted 9 lines
Quoted 4 lines

Does the design provides clear idea about how it can be extended for the future extensions that already scoped for milestone 3 (AMD IBS, Intel PEBS, Arm SPE)?

Yes, if the report has an address field with a validity bit and carries the producing report-type (attr) id. Then IBS, PEBS, Arm SPE (through an adapter, since SPE uses the perf AUX buffer) and device-side monitors all produce the same report, into the same queues and probes.

Thank you for confirming. And yes, I think we can add more (union) fields to the report structure.

However, could you further clarify what are the validity bit and attr id, and why those are needed? I'm still newbie to perf event, please bear in mind with me.

Quoted 15 lines
Quoted 3 lines

For the foreseeable extensions (AMD IBS, Intel PEBS, Arm SPE), would the required change minimum and maintainable?

Yes, if staged. The sample-filter matcher and its sysfs already exist per context; attaching them per probe is the main change. For example:

M2.1 in-kernel only: damon_report_attrs(), the queue, region
lookup, the perf producer; kunit, no new sysfs
M2.2 your per-CPU write-only example, set up from user space:
attr_reports files, per-filter report_queue, write/cpumask/threads probe filters
M2.3 counters, a silence check (tracepoint/debugfs first), tuning
M3 more producers: Arm SPE, device monitors

Quoted 4 lines

Implementation notes:

1. One sampler per CPU per attr, owned by attr_reports (as in your damon/next usage doc)

The things in damon/next are just my sketches that are not yet ready for review. It will nearly all be re-written. I'd recommend to ignore those for now.

Quoted 7 lines

and shared by all contexts. IBS has one unit
per CPU, so perf time-slices multiple events: on EPYC 9555P one ibs_op event got 67,140 samples; two on the same CPU got 33,547 + 33,535. On Intel the event also needs wakeup_events = 1, or an in-kernel handler sees only the last record of each large-PEBS batch.

Quoted 10 lines

2. A lockless queue, as your NOTE in damon_report_access() anticipates. Today's buffer is documented "May sleep" and uses mutex_trylock(), which interrupt context cannot use; its inclusive jiffy staleness check can also count one report in up to three intervals (HZ=250, 5 ms interval). A simple design: a per-CPU circular array with a write counter and a per-slot seqcount_t (using raw_write_seqcount_begin/end() for NMI safety), overwriting the oldest slot. Readers never consume; each context keeps its last-seen write counter per CPU. A nested writer (e.g. an NMI over a task-context write) drops its report and counts it.

I agree the queue shouldn't sleep. You can ignore those in damon/next. Nonetheless, I'd like to start from global queue rather than per-CPU queue. If the performance is concern, we can later consider optimization. Let me know if I'm missing something.

Quoted 5 lines

3. Report fields: paddr, vaddr, size, time, cpu, tid, tgid, the producer's attr id, and flags (is_write, plus a validity bit per address, since 0 is a valid paddr). Store global ids; translate namespaces at the filter.

Yes, this kind of information will be added. Some of those could be union. And we could extend the fields as needed.

Quoted 4 lines

4. Binary search over a sorted region snapshot (your todo in kdamond_apply_access_report()) beats a linear walk from about 2 reports per interval for 1,000 regions (a model, to be measured).

Yes, this efficient region-report matching would be important. We could also consider starting with linear walk and later optimize, though.

Quoted 8 lines

5. Samplers can stop silently: in a report on the v4 thread [1], IBS Op samples stopped after about 10 minutes on a Ryzen 5 5600H, but not with the NMI watchdog enabled. So count dropped reports and check for silence against an independent reference. For tuning, step sample_period rather than use frequency mode, and do not raise perf_event_max_sample_rate: on an early DAMON PEBS prototype (Xeon 6960P), perf cut it from 100000 to 10000 in about 20 seconds.

Unfortunately my understanding of perf event is not yet good enough to understand this in depth. I will revisit this after starting implementation.

Quoted 5 lines

Three decisions would unblock M2.1:

- The first report type: the PMU-captured address (suggested), or decode from saved registers in kdamond (your current plan).

I'd like to start from decoding option. It will be easier to test on my setup and therefore I will be able to share first prototype earlier. Also, there are users who cannot use address-capturing PMUs. For example, some users need to run DAMON inside virtual machines that might not support virtual PMUs.

Quoted 1 line

- Whether the report carries the producer's attr id (suggested: yes).

We can add any field if needed. I'm not very sure what attr id is and why needed, though, as I asked above.

Quoted 2 lines

- The queue: the per-CPU seqcount design in note 2 (suggested), or ftrace's ring buffer with one iterator per reader.

My current plan is to use DAMON's original simple lockless and global queue per report queue. Let me know if the report queue design is not clearly explaining what it would look like, or there is a clear problem.

Quoted 4 lines

One question on the ABI: the usage document in your damon/next tree adds a report_queue file under each probe filter. Is it meant as "this filter tests reports in queue N"?

Please simply ignore those in damon/next for now. Those are not meant to be reviewed. I am still redesigning the interface. The high level design in the initial mail of this thread is still unchanged, though. Feel free to ask questions if any of the design is unclear or concerning.

Quoted 4 lines

Happy to write, review or test any piece: the queue with kunit, the AMD/Intel perf producer, a decode-accuracy study on real workloads, or runs on Xeon 6960P and EPYC 9555P. Several exist in RFC v4 [2].

As soon as this design discussion is completed, I will start prototype implementation and share it as the next RFC version, as soon as possible. Your review and test of the version will be super helpful. I may also ask you some questions for perf event and your prototypes. Thanks in advance for your help.

There are competing works, though. It would take time. I expect about one month at minimum. It might take longer; Thanksgiving holidays could be helpful to give me a time to concentrate. Please bear in mind. But once the initial prototype is implemented, I believe we could quickly iterate and meet the ETA (LSFMMBPF'27).

Quoted 6 lines

Thanks,
Ravi

[1] https://lore.kernel.org/r/[email protected]
[2] https://lore.kernel.org/r/20261005-damon-perf-rfc-v3-send-2026-10-03-v4-0-b03452e137f3@gmail.com

Thanks,
SJ

#9 lore raw

Hi SJ,

Quoted 4 lines · On Wed, 21 Oct 2026 22:29:12 -0700 SJ Park <[email protected]> wrote:

Hi Ravi,

On Wed, 21 Oct 2026 21:17:24 -0700 Ravi Jonnalagadda <[email protected]> wrote:

[...]

Quoted 3 lines

Thank you for your detailed review and testing of the first design! I'd still like to try decoding idea first, mainly for quick prototyping.

Sounds good. Starting with decode makes sense, especially for VMs where hardware address-sampling PMUs are often unavailable; some tips for the prototype are in the other reply [1].

[...]

Quoted 11 lines
Quoted 4 lines

Yes, if the report has an address field with a validity bit and carries the producing report-type (attr) id. Then IBS, PEBS, Arm SPE (through an adapter, since SPE uses the perf AUX buffer) and device-side monitors all produce the same report, into the same queues and probes.

Thank you for confirming. And yes, I think we can add more (union) fields to the report structure.

However, could you further clarify what are the validity bit and attr id, and why those are needed? I'm still newbie to perf event, please bear in mind with me.

Neither is perf-specific:

- Validity bit (or union tag): a way to tell whether a report carries a virtual address, a physical address, or both. For example, a decoded sample has no physical address if the page is not mapped. If you use a union with a type field, that already covers it.

- Attr id: an id of the producer (report type) that made the report. If several producers later feed one queue (e.g. perf sampling and a device-side monitor), a probe can filter on, or weigh, reports by their source. If each queue only ever has one producer, the queue already identifies it, and the field is not needed.

[...]

Quoted 6 lines
Quoted 3 lines

4. Binary search over a sorted region snapshot (your todo in kdamond_apply_access_report()) beats a linear walk from about 2 reports per interval for 1,000 regions (a model, to be measured).

Yes, this efficient region-report matching would be important. We could also consider starting with linear walk and later optimize, though.

Agreed; starting with a linear walk for the prototype is fine, and once it is out, happy to measure where binary search starts to matter.

[...]

Quoted 1 line
Quoted 1 line

5. Samplers can stop silently: in a report on the v4 thread [1], IBS

[...]

Quoted 2 lines

Unfortunately my understanding of perf event is not yet good enough to understand this in depth. I will revisit this after starting implementation.

Sure. The one part worth keeping in mind from the start: a sampler can stop without any error, so a counter of reports received and dropped helps tell "no accesses" from "no samples".

[...]

Quoted 6 lines
Quoted 2 lines

- The queue: the per-CPU seqcount design in note 2 (suggested), or ftrace's ring buffer with one iterator per reader.

My current plan is to use DAMON's original simple lockless and global queue per report queue. Let me know if the report queue design is not clearly explaining what it would look like, or there is a clear problem.

A global queue is fine to start with, and the design is clear. One thing to keep in mind: perf writers run in interrupt or NMI context on all CPUs at once, and an NMI can arrive in the middle of another write. So reserving a slot needs to be lock-free, and a reader should not see a half-written report. If the design already covers that, there is nothing to add.

[...]

Quoted 10 lines

As soon as this design discussion is completed, I will start prototype implementation and share it as the next RFC version, as soon as possible. Your review and test of the version will be super helpful. I may also ask you some questions for perf event and your prototypes. Thanks in advance for your help.

There are competing works, though. It would take time. I expect about one month at minimum. It might take longer; Thanksgiving holidays could be helpful to give me a time to concentrate. Please bear in mind. But once the initial prototype is implemented, I believe we could quickly iterate and meet the ETA (LSFMMBPF'27).

No rush on the timeline; that plan sounds good. Please feel free to ask any time, and I will be happy to share the test programs and review and test the prototype when it is out.

Thanks,
Ravi

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

author maintainer
#10 lore raw
Quoted 8 lines · On Fri, 23 Oct 2026 12:51:22 -0700 Ravi Jonnalagadda <[email protected]>…

Hi SJ,

Quoted 4 lines · On Wed, 21 Oct 2026 22:29:12 -0700 SJ Park <[email protected]> wrote:

Hi Ravi,

On Wed, 21 Oct 2026 21:17:24 -0700 Ravi Jonnalagadda <[email protected]> wrote:

Quoted 8 lines

[...]

Quoted 3 lines

Thank you for your detailed review and testing of the first design! I'd still like to try decoding idea first, mainly for quick prototyping.

Sounds good. Starting with decode makes sense, especially for VMs where hardware address-sampling PMUs are often unavailable; some tips for the prototype are in the other reply [1].

Thank you for confirming and the tips!

Quoted 14 lines

[...]

Quoted 11 lines
Quoted 4 lines

Yes, if the report has an address field with a validity bit and carries the producing report-type (attr) id. Then IBS, PEBS, Arm SPE (through an adapter, since SPE uses the perf AUX buffer) and device-side monitors all produce the same report, into the same queues and probes.

Thank you for confirming. And yes, I think we can add more (union) fields to the report structure.

However, could you further clarify what are the validity bit and attr id, and why those are needed? I'm still newbie to perf event, please bear in mind with me.

Quoted 6 lines

Neither is perf-specific:

- Validity bit (or union tag): a way to tell whether a report carries a virtual address, a physical address, or both. For example, a decoded sample has no physical address if the page is not mapped. If you use a union with a type field, that already covers it.

Thank you for clarifying. Yes, it may have a union with a type field.

Quoted 6 lines

- Attr id: an id of the producer (report type) that made the report. If several producers later feed one queue (e.g. perf sampling and a device-side monitor), a probe can filter on, or weigh, reports by their source. If each queue only ever has one producer, the queue already identifies it, and the field is not needed.

Thank you for clarifying. I agree this kind of information will be needed, and I will make sure it is in the report struct.

Quoted 11 lines

[...]

Quoted 6 lines
Quoted 3 lines

4. Binary search over a sorted region snapshot (your todo in kdamond_apply_access_report()) beats a linear walk from about 2 reports per interval for 1,000 regions (a model, to be measured).

Yes, this efficient region-report matching would be important. We could also consider starting with linear walk and later optimize, though.

Agreed; starting with a linear walk for the prototype is fine, and once it is out, happy to measure where binary search starts to matter.

Cool!

Quoted 10 lines

[...]

Quoted 1 line
Quoted 1 line

5. Samplers can stop silently: in a report on the v4 thread [1], IBS

[...]

Quoted 2 lines

Unfortunately my understanding of perf event is not yet good enough to understand this in depth. I will revisit this after starting implementation.

Sure. The one part worth keeping in mind from the start: a sampler can stop without any error, so a counter of reports received and dropped helps tell "no accesses" from "no samples".

Good point. I will try to make it at least easy to debug.

Quoted 9 lines

[...]

Quoted 6 lines
Quoted 2 lines

- The queue: the per-CPU seqcount design in note 2 (suggested), or ftrace's ring buffer with one iterator per reader.

My current plan is to use DAMON's original simple lockless and global queue per report queue. Let me know if the report queue design is not clearly explaining what it would look like, or there is a clear problem.

Quoted 6 lines

A global queue is fine to start with, and the design is clear. One thing to keep in mind: perf writers run in interrupt or NMI context on all CPUs at once, and an NMI can arrive in the middle of another write. So reserving a slot needs to be lock-free, and a reader should not see a half-written report. If the design already covers that, there is nothing to add.

Design is still in progress, but definitely this should be covered. Thank you for calling out!

Quoted 13 lines

[...]

Quoted 10 lines

As soon as this design discussion is completed, I will start prototype implementation and share it as the next RFC version, as soon as possible. Your review and test of the version will be super helpful. I may also ask you some questions for perf event and your prototypes. Thanks in advance for your help.

There are competing works, though. It would take time. I expect about one month at minimum. It might take longer; Thanksgiving holidays could be helpful to give me a time to concentrate. Please bear in mind. But once the initial prototype is implemented, I believe we could quickly iterate and meet the ETA (LSFMMBPF'27).

Quoted 3 lines

No rush on the timeline; that plan sounds good. Please feel free to ask any time, and I will be happy to share the test programs and review and test the prototype when it is out.

Appreciate your continued support, that will be super helpful!

Quoted 5 lines

Thanks,
Ravi

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

Thanks,
SJ

author maintainer
#11 lore raw
In reply to SJ Park
Quoted 67 lines · On Sat, 17 Oct 2026 12:57:45 -0700 SJ Park <[email protected]> wrote:

The "beyond page table accessed-bit DAMON extension" project [1] milestone 2 is for building the basic infrastructure for continued extension. After starting it, I studied perf event little and found a few demons in details. I therefore spent time on high level design. As it started looks like making sense to me, I'd like to share the humble design first and get feedback from more eyeballs.

Add a blueprint of the milestone 2 as a high level design document. Describe the API and ABI of data attribute report infrastructure, and an example use case of it for per-CPUs write-only monitoring. The API and ABI will later be extended for more data attributes reporters utilizing AMD IBS, Intel PEBS, Arm SPEs like h/w features and any possible DAMON-external reporter kernel components.

Request for comments
====================

This is an RFC for high level design discussion, so no implementation is provided. Comments I want to receive include but not limited to below.

Does the idea for perf CPU cycle sampling based access monitoring makes sense?

Does the design provides clear idea about how it can be extended for the future extensions that already scoped for milestone 3 (AMD IBS, Intel PEBS, Arm SPE)?

For the foreseeable extensions (AMD IBS, Intel PEBS, Arm SPE), would the required change minimum and maintainable?

Next steps
==========

I will start implementing the infrastructure and perf CPU cycle sampling based access monitoring as described in this patch. It will go through the normal development process. Delivery of it will be the completion of the milestone 2. As set on the initial roadmap [1], ETA of the delivery is LSFMMBPF'27. No delay is expected so far.

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

---
 Documentation/mm/damon/design.rst | 44 +++++++++++++++++++++++++++++++
 1 file changed, 44 insertions(+)
Documentation/mm/damon/design.rst +13 -0
index a465e34bb1d9c..1e699e3f8a496 100644
@@ -433,6 +433,50 @@ monitoring.
 Refer to the :ref:`admin guide <damon_usage_sysfs_probes>` to know how users
 can use the mode.
 
+Data Attributes Reporting
+~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Infrastructure for receiving attribute information from DAMON-external kernel
+components.
+
+Because DAMON is not hooked in every place but runs in its own worker thread,
+it cannot retrieve some types of data attribute information by itself.  Many of
+those are available to DAMON-external kernel components such as perf event
+callbacks and page fault handler.  For such cases, DAMON provides attributes
+reporting infrastructure.  Using its API, any kernel components can report
+their finding to DAMON.
+

Documentation/mm/damon/design.rst monitoring. · line 458

Quoted 10 lines
Documentation/mm/damon/design.rst +10 -0
+The API for doing the report is a function, damon_report_attrs().  The function
+receives the attribute information and saves it in DAMON's internal buffer.
+The function is safe to be called in any context including NMI.  The internal
+buffer has a fixed size and keeps only latest reports of the size.  Because one
+buffer size doesn't fit all, multiple report buffers of different size and
+rules can be generated and shared by multiple reporters.  DAMON provides API
+for such management of report buffers.  damon_report_attrs() can specify into
+which buffer the report should be saved.  DAMON user interface (ABI) for doing
+the buffer setup, and enable/disable reports of supported types is also
+supported.

I allowed callers/users to manage the buffers because I didn't have a confidence at maanging the buffers in a good way. But I now think it was not a good design choice.

First of all, it is offloading decision to users. I also feel like this design exposes too much internal implementation details to users. It would be better to let DAMON just manage it. If it turns out to be too suboptimal, we can later consider optimizing it and even let users control it if really needed.

Letting M:N reports:queue routing makes it quite complicated, too.

So, unless others object, I will change the design to hide the report buffers management from users.

Quoted 10 lines
Documentation/mm/damon/design.rst +10 -0
+
+The data attribute probe supports the reports.  The probes can be configured to
+hit for a given memory region depending on the existence of specific types of
+reports that associated with the memory region in given report buffers.
+
+For example, per-CPUs write-only monitoring can be configured using this
+infrastructure like below.
+
+The user sets a report buffer and enable CPU instruction sampling report for
+the buffer.  DAMON will enable perf event counter for CPU cycles sampling.  The

Documentation/mm/damon/design.rst monitoring. · line 478

Quoted 10 lines
Documentation/mm/damon/design.rst +10 -0
+sampling callback will save the sampling time CPU instruction and the id of the
+CPU that was executing it, into the DAMON report buffer, using
+damon_report_attrs().  DAMON can automatically adjust the perf event sampling
+frequency to minimize old report drops due to the buffer size limit.
+
+The user further sets a DAMON probe.  The probe hits for a given DAMON region
+if a store instruction for a memory in the region that was executed from a
+given CPUs group exists in the report buffer.  As a result, the probe hit
+counts represent relative frequency of writes from a given CPUs group to a
+given memory region.

My initial plan was to implement the above per-CPU write monitoring with the milestone 2 patch series. That's mainly because we don't want to have an API without its callers. But implementing perf cycle sampling would be no small amount of code that require extensive tests. It may take time and make the patch series quite big. I'm now trying to make it small and quick.

I find this report infrastructure could also be used for direct user reports. That is, users might know which memory they are accessing, and want to ensure DAMON knows that, by reporting their information using the report infra. I will expose an ABI for such direct user report, and connect it with the reporting infra. That would look similar to that of DAMOS quota goal user_input metric. I will continue implementing perf cpu cycle based report producer implementation on top of it. But maybe we could also just call the user report as milestone 2, as there will be no more blockers for other works like AMD IBS support.

Unless I get concerns on above plan, I will update this design patch and write user ABI documents. I will share those as RFC v0.1, and keep iterating the documentation-only patches for continued design discussion until I get a confidence in the interface design.

FYI, damon/next [1] tree may have hacky changes that could significantly be changed in future. Please don't rely on those. Don't spend time on reviewing those. I sometimes regret I should named it 'damon/hack'. Anyway, I will share things that ready to be reviewed on this mailing list.

[1] https://origin.kernel.org/doc/html/latest/mm/damon/maintainer-profile.html#scm-trees

Thanks,
SJ

[...]

#12 lore raw
In reply to SJ Park

Hi SJ,

Documentation/mm/damon/design.rst monitoring. · line 462

Quoted 3 lines · On Sat, 17 Oct 2026 12:57:45 -0700 SJ Park wrote:
Documentation/mm/damon/design.rst +3 -0
+The data attribute probe supports the reports.  The probes can be configured to
+hit for a given memory region depending on the existence of specific types of
+reports that associated with the memory region in given report buffers.

I'm wondering how this would interact with the region size. If each page of a region is reported with probability q, a region of s pages would hit with probability 1 - (1 - q)^s, so a large region may hit more often than a small region of the same access density. The page table accessed-bit check samples one page per region, so its hit rate doesn't depend on the region size in the same way.

A quick replay of the crediting rule of Ravi's RFC v4 [1] on synthetic traces showed a similar trend. The adaptive regions adjustment would mitigate this to some extent, but large cold-only regions still kept high hit rates after split and merge in the replay. I'm not sure how much it matters on real workloads, though.

Would crediting the hits relative to the region size, e.g., reported bytes / region bytes, make sense to you? It would need probe_hits wider than u8, so it is not free. If you think it is worth exploring, I may run more experiments and share the results.

[1] https://lore.kernel.org/all/20261005-damon-perf-rfc-v3-send-2026-10-03-v4-0-b03452e137f3@gmail.com/

Thanks,
Aveline Noir

author maintainer
#13 lore raw

Hi Aveline,

Quoted 4 lines · On Wed, 11 Nov 2026 18:35:52 +1100 Aveline Noir <[email protected]> wrote:

Hi SJ,

On Sat, 17 Oct 2026 12:57:45 -0700 SJ Park wrote:

Quoted 8 lines

Documentation/mm/damon/design.rst monitoring. · line 462

Quoted 3 lines
Documentation/mm/damon/design.rst +3 -0
+The data attribute probe supports the reports.  The probes can be configured to
+hit for a given memory region depending on the existence of specific types of
+reports that associated with the memory region in given report buffers.

I'm wondering how this would interact with the region size. If each page of a region is reported with probability q, a region of s pages would hit with probability 1 - (1 - q)^s, so a large region may hit more often than a small region of the same access density.

Thank you for sharing this finding. Seems this theory assumes the probe will hit for report of any byte of the region exists in the report buffers. Under the assumption, that makes sense.

But I'd say the assumed implementation is not realistic. That's because DAMON design does probing for only single sampling byte of the region, not the entire bytes of the region. In a real implementation that is aligned with the design, the probe will hit if a report associated with the sampling byte exists.

Quoted 3 lines

The page
table accessed-bit check samples one page per region, so its hit rate doesn't depend on the region size in the same way.

I'd say it is not because it uses accessed-bit, but it respects the address sampling design.

Quoted 11 lines

A quick replay of the crediting rule of Ravi's RFC v4 [1] on synthetic traces showed a similar trend. The adaptive regions adjustment would mitigate this to some extent, but large cold-only regions still kept high hit rates after split and merge in the replay. I'm not sure how much it matters on real workloads, though.

Would crediting the hits relative to the region size, e.g., reported bytes / region bytes, make sense to you? It would need probe_hits wider than u8, so it is not free. If you think it is worth exploring, I may run more experiments and share the results.

As long as the real implementation respects the address sampling design, I think this will not be needed.

Thank you again for raising this question, and please let me know if I missed something.

Thanks,
SJ

[...]

author maintainer
#14 lore raw
Quoted 17 lines · On Wed, 11 Nov 2026 10:54:11 -0800 SJ Park <[email protected]> wrote:

Hi Aveline,

Quoted 4 lines · On Wed, 11 Nov 2026 18:35:52 +1100 Aveline Noir <[email protected]> wrote:

Hi SJ,

On Sat, 17 Oct 2026 12:57:45 -0700 SJ Park wrote:

Quoted 8 lines

Documentation/mm/damon/design.rst monitoring. · line 462

Quoted 3 lines
Documentation/mm/damon/design.rst +3 -0
+The data attribute probe supports the reports.  The probes can be configured to
+hit for a given memory region depending on the existence of specific types of
+reports that associated with the memory region in given report buffers.

I'm wondering how this would interact with the region size. If each page of a region is reported with probability q, a region of s pages would hit with probability 1 - (1 - q)^s, so a large region may hit more often than a small region of the same access density.

Quoted 8 lines

Thank you for sharing this finding. Seems this theory assumes the probe will hit for report of any byte of the region exists in the report buffers. Under the assumption, that makes sense.

But I'd say the assumed implementation is not realistic. That's because DAMON design does probing for only single sampling byte of the region, not the entire bytes of the region. In a real implementation that is aligned with the design, the probe will hit if a report associated with the sampling byte exists.

I will rephrase the document in the next spin to make this be more clear. E.g., The probes can be configured to hit for existence of specific types of reports that associated with the probing memory in the report buffers.

Thanks,
SJ

[...]

#15 lore raw
In reply to SJ Park

Hi SJ,

Quoted 2 lines · On Wed, 11 Nov 2026 10:54:11 -0800 SJ Park wrote:

In a real implementation that is aligned with the design, the probe will hit if a report associated with the sampling byte exists.

Ah, I missed that. Thanks for clarifying.

Thanks,
Aveline Noir