* [RFC PATCH v3 11/37] Docs/mm/damon/design: document page fault sampling primitive
2025-12-08 6:29 [RFC PATCH v3 00/37] mm/damon: introduce per-CPUs/threads/write/read monitoring SeongJae Park
@ 2025-12-08 6:29 ` SeongJae Park
2025-12-08 6:29 ` [RFC PATCH v3 12/37] Docs/admin-guide/mm/damon/usage: document sample primitives dir SeongJae Park
` (5 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: SeongJae Park @ 2025-12-08 6:29 UTC (permalink / raw)
Cc: SeongJae Park, Liam R. Howlett, Andrew Morton, David Hildenbrand,
Jonathan Corbet, Lorenzo Stoakes, Michal Hocko, Mike Rapoport,
Suren Baghdasaryan, Vlastimil Babka, damon, linux-doc,
linux-kernel, linux-mm
Update DAMON design document for support of page fault events based
access check sampling primitives.
Signed-off-by: SeongJae Park <sj@kernel.org>
---
Documentation/mm/damon/design.rst | 33 +++++++++++++++++++++++++++++++
1 file changed, 33 insertions(+)
diff --git a/Documentation/mm/damon/design.rst b/Documentation/mm/damon/design.rst
index 7fd819b8bbf7..a21973b33bc3 100644
--- a/Documentation/mm/damon/design.rst
+++ b/Documentation/mm/damon/design.rst
@@ -117,6 +117,7 @@ to make a reasonable trade-off. Below shows this in detail::
<BIG UNMAPPED REGION 2>
<stack>
+.. _damon_design_pte_accessed_bit_access_check:
PTE Accessed-bit Based Access Check
-----------------------------------
@@ -135,6 +136,23 @@ the interference is the responsibility of sysadmins. However, it solves the
conflict with the reclaim logic using ``PG_idle`` and ``PG_young`` page flags,
as Idle page tracking does.
+.. _damon_design_page_fault_access_check:
+
+Monitoring-purpose Page Faults Based Access Check
+-------------------------------------------------
+
+The operation set implementation for the physical address space (``paddr``) can
+do the access check using monitoring-purpose page fault events in a way similar
+to NUMA balancing hinting faults. When it is being used, ``paddr`` installs
+the page protection in a way similar to that of NUMA balancing hinting faults.
+Then the page fault handler reports the faults happend by the installed page
+protection to DAMON core layer.
+
+``paddr`` uses :ref:`accessed-bit based check
+<damon_design_pte_accessed_bit_access_check>` by default, and users can change
+it to use this page faults based one, using :ref:`access sampling primitives
+selection <damon_design_sampling_primitives_selection>`.
+
.. _damon_design_addr_unit:
Address Unit
@@ -244,6 +262,21 @@ maximum number of regions after the split.
In this way, DAMON provides its best-effort quality and minimal overhead while
keeping the bounds users set for their trade-off.
+.. _damon_design_sampling_primitives_selection:
+
+Access Sampling Primitives Selection
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Some operations set implementations could utilize multiple access sampling
+primitives. For example, the operations set implementation for physical
+address space (``paddr``) support two promitives at the moment: 1) page tables'
+Accessed bits, and access monitoring-purpose page fault events. In future, it
+could be extended for more hardware features such as AMD IBS or CXL HMU, and
+support from the operations set implementation for virtual address spaces
+(``vaddr``). DAMON API callers or ABI users can select what primitives to use.
+
+At the moment, only exclusive use of the primitives is supported.
+
.. _damon_design_age_tracking:
--
2.47.3
^ permalink raw reply related [flat|nested] 8+ messages in thread* [RFC PATCH v3 12/37] Docs/admin-guide/mm/damon/usage: document sample primitives dir
2025-12-08 6:29 [RFC PATCH v3 00/37] mm/damon: introduce per-CPUs/threads/write/read monitoring SeongJae Park
2025-12-08 6:29 ` [RFC PATCH v3 11/37] Docs/mm/damon/design: document page fault sampling primitive SeongJae Park
@ 2025-12-08 6:29 ` SeongJae Park
2025-12-08 6:29 ` [RFC PATCH v3 24/37] Docs/mm/damon/design: document sample filters SeongJae Park
` (4 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: SeongJae Park @ 2025-12-08 6:29 UTC (permalink / raw)
Cc: SeongJae Park, Liam R. Howlett, Andrew Morton, David Hildenbrand,
Jonathan Corbet, Lorenzo Stoakes, Michal Hocko, Mike Rapoport,
Suren Baghdasaryan, Vlastimil Babka, damon, linux-doc,
linux-kernel, linux-mm
Update DAMON usage document for the selective access sampling primitives
activation, which is essential for using page fault events as the access
check sampling primitive.
Signed-off-by: SeongJae Park <sj@kernel.org>
---
Documentation/admin-guide/mm/damon/usage.rst | 19 ++++++++++++++++---
1 file changed, 16 insertions(+), 3 deletions(-)
diff --git a/Documentation/admin-guide/mm/damon/usage.rst b/Documentation/admin-guide/mm/damon/usage.rst
index 7da4c002cb39..897a89950351 100644
--- a/Documentation/admin-guide/mm/damon/usage.rst
+++ b/Documentation/admin-guide/mm/damon/usage.rst
@@ -65,6 +65,7 @@ comma (",").
│ │ │ │ │ :ref:`monitoring_attrs <sysfs_monitoring_attrs>`/
│ │ │ │ │ │ intervals/sample_us,aggr_us,update_us
│ │ │ │ │ │ │ intervals_goal/access_bp,aggrs,min_sample_us,max_sample_us
+ │ │ │ │ │ │ sample/primitives/page_table,page_faults
│ │ │ │ │ │ nr_regions/min,max
│ │ │ │ │ :ref:`targets <sysfs_targets>`/nr_targets
│ │ │ │ │ │ :ref:`0 <sysfs_target>`/pid_target,obsolete_target
@@ -215,9 +216,9 @@ contexts/<N>/monitoring_attrs/
------------------------------
Files for specifying attributes of the monitoring including required quality
-and efficiency of the monitoring are in ``monitoring_attrs`` directory.
-Specifically, two directories, ``intervals`` and ``nr_regions`` exist in this
-directory.
+and efficiency of the monitoring, and types of accesses to monitor are in
+``monitoring_attrs`` directory. Specifically, three directories, ``intervals``
+, ``nr_regions`` and ``sample`` exist in this directory.
Under ``intervals`` directory, three files for DAMON's sampling interval
(``sample_us``), aggregation interval (``aggr_us``), and update interval
@@ -232,6 +233,18 @@ writing to and rading from the files.
For more details about the intervals and monitoring regions range, please refer
to the Design document (:doc:`/mm/damon/design`).
+Under ``sample`` directory, a directory, ``primitives`` exists.
+
+contexts/<N>/monitoring_attrs/sample/primitives/
+------------------------------------------------
+
+This directory is for the access sampling primitives :ref:`selection
+<damon_design_sampling_primitives_selection>`. Under ``primitives`` directory,
+two files, ``page_table`` and ``page_faults`` exist. By writing ``Y`` or ``N``
+to these files, users can select whether to use the :ref:`page table accessed
+bit <damon_design_pte_accessed_bit_access_check>` and :ref:`page fault events
+<damon_design_page_fault_access_check>`, respectively.
+
.. _damon_usage_sysfs_monitoring_intervals_goal:
contexts/<N>/monitoring_attrs/intervals/intervals_goal/
--
2.47.3
^ permalink raw reply related [flat|nested] 8+ messages in thread* [RFC PATCH v3 24/37] Docs/mm/damon/design: document sample filters
2025-12-08 6:29 [RFC PATCH v3 00/37] mm/damon: introduce per-CPUs/threads/write/read monitoring SeongJae Park
2025-12-08 6:29 ` [RFC PATCH v3 11/37] Docs/mm/damon/design: document page fault sampling primitive SeongJae Park
2025-12-08 6:29 ` [RFC PATCH v3 12/37] Docs/admin-guide/mm/damon/usage: document sample primitives dir SeongJae Park
@ 2025-12-08 6:29 ` SeongJae Park
2025-12-08 6:29 ` [RFC PATCH v3 25/37] Docs/admin-guide/mm/damon/usage: document sample filters dir SeongJae Park
` (3 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: SeongJae Park @ 2025-12-08 6:29 UTC (permalink / raw)
Cc: SeongJae Park, Liam R. Howlett, Andrew Morton, David Hildenbrand,
Jonathan Corbet, Lorenzo Stoakes, Michal Hocko, Mike Rapoport,
Suren Baghdasaryan, Vlastimil Babka, damon, linux-doc,
linux-kernel, linux-mm
Update DAMON design document for the access sample results filtering.
Signed-off-by: SeongJae Park <sj@kernel.org>
---
Documentation/mm/damon/design.rst | 42 +++++++++++++++++++++++++++++--
1 file changed, 40 insertions(+), 2 deletions(-)
diff --git a/Documentation/mm/damon/design.rst b/Documentation/mm/damon/design.rst
index a21973b33bc3..9a4679de437f 100644
--- a/Documentation/mm/damon/design.rst
+++ b/Documentation/mm/damon/design.rst
@@ -146,12 +146,17 @@ do the access check using monitoring-purpose page fault events in a way similar
to NUMA balancing hinting faults. When it is being used, ``paddr`` installs
the page protection in a way similar to that of NUMA balancing hinting faults.
Then the page fault handler reports the faults happend by the installed page
-protection to DAMON core layer.
+protection to DAMON core layer. Compared to the accessed-bit based one, this
+approach gives more information to DAMON, such as the access-generated
+CPU.
``paddr`` uses :ref:`accessed-bit based check
<damon_design_pte_accessed_bit_access_check>` by default, and users can change
it to use this page faults based one, using :ref:`access sampling primitives
-selection <damon_design_sampling_primitives_selection>`.
+selection <damon_design_sampling_primitives_selection>`. Also, the addtional
+information can be used for doing monitoring of only specific type accesses,
+using :ref:`access sampling results filters
+<damon_design_sampling_results_filters>`.
.. _damon_design_addr_unit:
@@ -277,6 +282,39 @@ support from the operations set implementation for virtual address spaces
At the moment, only exclusive use of the primitives is supported.
+.. _damon_design_sampling_results_filters:
+
+Access Sampling Results Filter
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Depending on the access sampling primitives that used, the sampling results
+could inform more than whether an access is made, such as the CPU or the thread
+the sampled access was made from, and whether the sampled access was for
+writing or reading. By filtering the results based on the additional
+information, DAMON can perform for more detailed access monitoring, such as
+per-CPUs/threads or read/write-only monitoring.
+
+For such special types of monitoring, DAMON provides a feature called "sampling
+results filter". The feature allows users to set an arbitrary number of
+filters for the sampling results. Each of the filters specifies
+
+- a type of the additional information (``type``),
+- whether it is for the sampling results of the type or all except the type
+ (``matching``), and
+- whether it is to allow (include) or reject (exclude) consuming of the type of
+ sampling results.
+
+Each filter is applied in the order of the installation. Only sampling results
+that allowed by previous filters are continue to be evaluated by the next
+filters. If a sampling result is decided to be rejected by a filter, it is
+just discarded and no later filter is applied.
+
+Below ``type`` of access sampling results filter are currently supported.
+
+- cpumask
+ - Whether the sampled access was generated by a cpu that included in a
+ given cpumask.
+
.. _damon_design_age_tracking:
--
2.47.3
^ permalink raw reply related [flat|nested] 8+ messages in thread* [RFC PATCH v3 25/37] Docs/admin-guide/mm/damon/usage: document sample filters dir
2025-12-08 6:29 [RFC PATCH v3 00/37] mm/damon: introduce per-CPUs/threads/write/read monitoring SeongJae Park
` (2 preceding siblings ...)
2025-12-08 6:29 ` [RFC PATCH v3 24/37] Docs/mm/damon/design: document sample filters SeongJae Park
@ 2025-12-08 6:29 ` SeongJae Park
2025-12-08 6:29 ` [RFC PATCH v3 31/37] Docs/mm/damon/design: document threads type sample filter SeongJae Park
` (2 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: SeongJae Park @ 2025-12-08 6:29 UTC (permalink / raw)
Cc: SeongJae Park, Liam R. Howlett, Andrew Morton, David Hildenbrand,
Jonathan Corbet, Lorenzo Stoakes, Michal Hocko, Mike Rapoport,
Suren Baghdasaryan, Vlastimil Babka, damon, linux-doc,
linux-kernel, linux-mm
Update DAMON usage document for the added DAMON sysfs files for
installing and setting the access sample results filtering.
Signed-off-by: SeongJae Park <sj@kernel.org>
---
Documentation/admin-guide/mm/damon/usage.rst | 25 +++++++++++++++++++-
1 file changed, 24 insertions(+), 1 deletion(-)
diff --git a/Documentation/admin-guide/mm/damon/usage.rst b/Documentation/admin-guide/mm/damon/usage.rst
index 897a89950351..365a4548a5ba 100644
--- a/Documentation/admin-guide/mm/damon/usage.rst
+++ b/Documentation/admin-guide/mm/damon/usage.rst
@@ -66,6 +66,8 @@ comma (",").
│ │ │ │ │ │ intervals/sample_us,aggr_us,update_us
│ │ │ │ │ │ │ intervals_goal/access_bp,aggrs,min_sample_us,max_sample_us
│ │ │ │ │ │ sample/primitives/page_table,page_faults
+ │ │ │ │ │ │ sample/filters/nr_filters
+ │ │ │ │ │ │ │ 0/type,matching,allow,cpumask
│ │ │ │ │ │ nr_regions/min,max
│ │ │ │ │ :ref:`targets <sysfs_targets>`/nr_targets
│ │ │ │ │ │ :ref:`0 <sysfs_target>`/pid_target,obsolete_target
@@ -233,7 +235,8 @@ writing to and rading from the files.
For more details about the intervals and monitoring regions range, please refer
to the Design document (:doc:`/mm/damon/design`).
-Under ``sample`` directory, a directory, ``primitives`` exists.
+Under ``sample`` directory, two directories, ``primitives`` and ``filters``
+exist.
contexts/<N>/monitoring_attrs/sample/primitives/
------------------------------------------------
@@ -245,6 +248,26 @@ to these files, users can select whether to use the :ref:`page table accessed
bit <damon_design_pte_accessed_bit_access_check>` and :ref:`page fault events
<damon_design_page_fault_access_check>`, respectively.
+contexts/<N>/monitoring_attrs/sample/filters/
+---------------------------------------------
+
+This directory is for control of the :ref:`access sampling results filters
+<damon_design_sampling_results_filters>`. At the beginning, this directory has
+only one file, ``nr_filters``. Writing a positive integer ``<n>`` to the file
+generates directories of the number, named ``0`` to ``<n - 1>``. The generated
+directories represent the sampling result filters to install to the DAMON
+context, in the order of the directory names. Writing ``0`` to ``nr_filters``
+removes the directories.
+
+Under the individual filter directory, five files, ``type``, ``matching``,
+``allow``, and ``cpumask`` exist. The first three files are same to the
+properties of the filter specified on the :ref:`design doc
+<damon_design_sampling_results_filters>`.
+
+Users can specify the cpumask of the filter by writing it to ``cpumask``. The
+format for ``cpumask`` input is same to that for other cpumask inputs like that
+for cgroup cpusets.
+
.. _damon_usage_sysfs_monitoring_intervals_goal:
contexts/<N>/monitoring_attrs/intervals/intervals_goal/
--
2.47.3
^ permalink raw reply related [flat|nested] 8+ messages in thread* [RFC PATCH v3 31/37] Docs/mm/damon/design: document threads type sample filter
2025-12-08 6:29 [RFC PATCH v3 00/37] mm/damon: introduce per-CPUs/threads/write/read monitoring SeongJae Park
` (3 preceding siblings ...)
2025-12-08 6:29 ` [RFC PATCH v3 25/37] Docs/admin-guide/mm/damon/usage: document sample filters dir SeongJae Park
@ 2025-12-08 6:29 ` SeongJae Park
2025-12-08 6:29 ` [RFC PATCH v3 32/37] Docs/admin-guide/mm/damon/usage: document tids_arr file SeongJae Park
2025-12-08 6:29 ` [RFC PATCH v3 37/37] Docs/mm/damon/design: document write access sample filter type SeongJae Park
6 siblings, 0 replies; 8+ messages in thread
From: SeongJae Park @ 2025-12-08 6:29 UTC (permalink / raw)
Cc: SeongJae Park, Liam R. Howlett, Andrew Morton, David Hildenbrand,
Jonathan Corbet, Lorenzo Stoakes, Michal Hocko, Mike Rapoport,
Suren Baghdasaryan, Vlastimil Babka, damon, linux-doc,
linux-kernel, linux-mm
Update DAMON design document for threads type access sample results
filtering.
Signed-off-by: SeongJae Park <sj@kernel.org>
---
Documentation/mm/damon/design.rst | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/Documentation/mm/damon/design.rst b/Documentation/mm/damon/design.rst
index 9a4679de437f..4c6d83263a7b 100644
--- a/Documentation/mm/damon/design.rst
+++ b/Documentation/mm/damon/design.rst
@@ -148,7 +148,7 @@ the page protection in a way similar to that of NUMA balancing hinting faults.
Then the page fault handler reports the faults happend by the installed page
protection to DAMON core layer. Compared to the accessed-bit based one, this
approach gives more information to DAMON, such as the access-generated
-CPU.
+CPU/threads.
``paddr`` uses :ref:`accessed-bit based check
<damon_design_pte_accessed_bit_access_check>` by default, and users can change
@@ -314,6 +314,9 @@ Below ``type`` of access sampling results filter are currently supported.
- cpumask
- Whether the sampled access was generated by a cpu that included in a
given cpumask.
+- threads
+ - Whether the sampled access was generated by a thread that having a thread
+ (task) id that exist in a given array of ids.
.. _damon_design_age_tracking:
--
2.47.3
^ permalink raw reply related [flat|nested] 8+ messages in thread* [RFC PATCH v3 32/37] Docs/admin-guide/mm/damon/usage: document tids_arr file
2025-12-08 6:29 [RFC PATCH v3 00/37] mm/damon: introduce per-CPUs/threads/write/read monitoring SeongJae Park
` (4 preceding siblings ...)
2025-12-08 6:29 ` [RFC PATCH v3 31/37] Docs/mm/damon/design: document threads type sample filter SeongJae Park
@ 2025-12-08 6:29 ` SeongJae Park
2025-12-08 6:29 ` [RFC PATCH v3 37/37] Docs/mm/damon/design: document write access sample filter type SeongJae Park
6 siblings, 0 replies; 8+ messages in thread
From: SeongJae Park @ 2025-12-08 6:29 UTC (permalink / raw)
Cc: SeongJae Park, Liam R. Howlett, Andrew Morton, David Hildenbrand,
Jonathan Corbet, Lorenzo Stoakes, Michal Hocko, Mike Rapoport,
Suren Baghdasaryan, Vlastimil Babka, damon, linux-doc,
linux-kernel, linux-mm
Update DAMON usage document for the threads based access sampling
results filtering.
Signed-off-by: SeongJae Park <sj@kernel.org>
---
Documentation/admin-guide/mm/damon/usage.rst | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/Documentation/admin-guide/mm/damon/usage.rst b/Documentation/admin-guide/mm/damon/usage.rst
index 365a4548a5ba..d22d80710355 100644
--- a/Documentation/admin-guide/mm/damon/usage.rst
+++ b/Documentation/admin-guide/mm/damon/usage.rst
@@ -67,7 +67,7 @@ comma (",").
│ │ │ │ │ │ │ intervals_goal/access_bp,aggrs,min_sample_us,max_sample_us
│ │ │ │ │ │ sample/primitives/page_table,page_faults
│ │ │ │ │ │ sample/filters/nr_filters
- │ │ │ │ │ │ │ 0/type,matching,allow,cpumask
+ │ │ │ │ │ │ │ 0/type,matching,allow,cpumask,tid_arr
│ │ │ │ │ │ nr_regions/min,max
│ │ │ │ │ :ref:`targets <sysfs_targets>`/nr_targets
│ │ │ │ │ │ :ref:`0 <sysfs_target>`/pid_target,obsolete_target
@@ -260,13 +260,14 @@ context, in the order of the directory names. Writing ``0`` to ``nr_filters``
removes the directories.
Under the individual filter directory, five files, ``type``, ``matching``,
-``allow``, and ``cpumask`` exist. The first three files are same to the
-properties of the filter specified on the :ref:`design doc
+``allow``, ``cpumask`` and ``tid_arr`` exist. The first three files are same
+to the properties of the filter specified on the :ref:`design doc
<damon_design_sampling_results_filters>`.
-Users can specify the cpumask of the filter by writing it to ``cpumask``. The
-format for ``cpumask`` input is same to that for other cpumask inputs like that
-for cgroup cpusets.
+Users can specify the cpumask and thread id array of the filter by writing
+those to ``cpumask`` and ``tid_arr``. The format for ``cpumask`` input is same
+to that for other cpumask inputs like that for cgroup cpusets. For
+``tid_arr``, users can write array of the thread ids, separated by a comma.
.. _damon_usage_sysfs_monitoring_intervals_goal:
--
2.47.3
^ permalink raw reply related [flat|nested] 8+ messages in thread* [RFC PATCH v3 37/37] Docs/mm/damon/design: document write access sample filter type
2025-12-08 6:29 [RFC PATCH v3 00/37] mm/damon: introduce per-CPUs/threads/write/read monitoring SeongJae Park
` (5 preceding siblings ...)
2025-12-08 6:29 ` [RFC PATCH v3 32/37] Docs/admin-guide/mm/damon/usage: document tids_arr file SeongJae Park
@ 2025-12-08 6:29 ` SeongJae Park
6 siblings, 0 replies; 8+ messages in thread
From: SeongJae Park @ 2025-12-08 6:29 UTC (permalink / raw)
Cc: SeongJae Park, Liam R. Howlett, Andrew Morton, David Hildenbrand,
Jonathan Corbet, Lorenzo Stoakes, Michal Hocko, Mike Rapoport,
Suren Baghdasaryan, Vlastimil Babka, damon, linux-doc,
linux-kernel, linux-mm
Update DAMON design document for the write access sample results
filtering.
Signed-off-by: SeongJae Park <sj@kernel.org>
---
Documentation/mm/damon/design.rst | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/Documentation/mm/damon/design.rst b/Documentation/mm/damon/design.rst
index 4c6d83263a7b..b194bf4a6519 100644
--- a/Documentation/mm/damon/design.rst
+++ b/Documentation/mm/damon/design.rst
@@ -148,7 +148,7 @@ the page protection in a way similar to that of NUMA balancing hinting faults.
Then the page fault handler reports the faults happend by the installed page
protection to DAMON core layer. Compared to the accessed-bit based one, this
approach gives more information to DAMON, such as the access-generated
-CPU/threads.
+CPU/threads and whether it was for writing or reading.
``paddr`` uses :ref:`accessed-bit based check
<damon_design_pte_accessed_bit_access_check>` by default, and users can change
@@ -317,6 +317,8 @@ Below ``type`` of access sampling results filter are currently supported.
- threads
- Whether the sampled access was generated by a thread that having a thread
(task) id that exist in a given array of ids.
+- write
+ - Whether the sampled access was for writing.
.. _damon_design_age_tracking:
--
2.47.3
^ permalink raw reply related [flat|nested] 8+ messages in thread