linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 00/11] mm/damon: misc fixups for documents, comments and its tracepoint
@ 2023-09-07  2:29 SeongJae Park
  2023-09-07  2:29 ` [PATCH 01/11] Docs/admin-guide/mm/damon/usage: fixup missed :ref: keyword SeongJae Park
                   ` (10 more replies)
  0 siblings, 11 replies; 12+ messages in thread
From: SeongJae Park @ 2023-09-07  2:29 UTC (permalink / raw)
  To: Andrew Morton
  Cc: SeongJae Park, Jonathan Corbet, Steven Rostedt, damon, linux-mm,
	linux-doc, linux-trace-kernel, linux-kernel

This patchset contains miscellaneous simple fixups for documents, comments and
tracepoint of DAMON.

SeongJae Park (11):
  Docs/admin-guide/mm/damon/usage: fixup missed :ref: keyword
  Docs/admin-guide/mm/damon/usage: place debugfs usage at the bottom
  Docs/admin-guide/mm/damon/usage: move debugfs intro to the bottom of
    the section
  Docs/mm/damon/design: explicitly introduce ``nr_accesses``
  Docs/admin-guide/mm/damon/usage: explain the format of damon_aggregate
    tracepoint
  Docs/mm/damon/design: add a section for kdamond and DAMON context
  Docs/admin-guide/mm/damon/usage: link design doc for details of
    kdamond and context
  mm/damon/core: fix a comment about damon_set_attrs() call timings
  mm/damon/core: add more comments for nr_accesses
  mm/damon/core: remove duplicated comment for watermarks-based
    deactivation
  mm/damon/core: remove 'struct target *' parameter from
    damon_aggregated tracepoint

 Documentation/admin-guide/mm/damon/usage.rst | 86 +++++++++++---------
 Documentation/mm/damon/design.rst            | 23 +++++-
 include/linux/damon.h                        | 22 ++---
 include/trace/events/damon.h                 |  6 +-
 mm/damon/core.c                              |  8 +-
 5 files changed, 90 insertions(+), 55 deletions(-)


base-commit: ac8e8303c9c11b5c2e1d2e110866eb66c9fd771e
-- 
2.25.1



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

* [PATCH 01/11] Docs/admin-guide/mm/damon/usage: fixup missed :ref: keyword
  2023-09-07  2:29 [PATCH 00/11] mm/damon: misc fixups for documents, comments and its tracepoint SeongJae Park
@ 2023-09-07  2:29 ` SeongJae Park
  2023-09-07  2:29 ` [PATCH 02/11] Docs/admin-guide/mm/damon/usage: place debugfs usage at the bottom SeongJae Park
                   ` (9 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: SeongJae Park @ 2023-09-07  2:29 UTC (permalink / raw)
  To: Andrew Morton
  Cc: SeongJae Park, Jonathan Corbet, damon, linux-mm, linux-doc, linux-kernel

A cross-link reference in DAMON usage document is missing ':ref:' Sphynx
keyword.  Fix it.

Signed-off-by: SeongJae Park <sj@kernel.org>
---
 Documentation/admin-guide/mm/damon/usage.rst | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Documentation/admin-guide/mm/damon/usage.rst b/Documentation/admin-guide/mm/damon/usage.rst
index 8da1b7281827..834eefe39650 100644
--- a/Documentation/admin-guide/mm/damon/usage.rst
+++ b/Documentation/admin-guide/mm/damon/usage.rst
@@ -392,7 +392,7 @@ pages of all memory cgroups except ``/having_care_already``.::
     echo N > 1/matching
 
 Note that ``anon`` and ``memcg`` filters are currently supported only when
-``paddr`` `implementation <sysfs_contexts>` is being used.
+``paddr`` :ref:`implementation <sysfs_contexts>` is being used.
 
 Also, memory regions that are filtered out by ``addr`` or ``target`` filters
 are not counted as the scheme has tried to those, while regions that filtered
-- 
2.25.1



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

* [PATCH 02/11] Docs/admin-guide/mm/damon/usage: place debugfs usage at the bottom
  2023-09-07  2:29 [PATCH 00/11] mm/damon: misc fixups for documents, comments and its tracepoint SeongJae Park
  2023-09-07  2:29 ` [PATCH 01/11] Docs/admin-guide/mm/damon/usage: fixup missed :ref: keyword SeongJae Park
@ 2023-09-07  2:29 ` SeongJae Park
  2023-09-07  2:29 ` [PATCH 03/11] Docs/admin-guide/mm/damon/usage: move debugfs intro to the bottom of the section SeongJae Park
                   ` (8 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: SeongJae Park @ 2023-09-07  2:29 UTC (permalink / raw)
  To: Andrew Morton
  Cc: SeongJae Park, Jonathan Corbet, damon, linux-mm, linux-doc, linux-kernel

debugfs interface is deprecated.  Put it at the bottom of the document
so that readers have less chances to read it.

Signed-off-by: SeongJae Park <sj@kernel.org>
---
 Documentation/admin-guide/mm/damon/usage.rst | 39 ++++++++++----------
 1 file changed, 19 insertions(+), 20 deletions(-)

diff --git a/Documentation/admin-guide/mm/damon/usage.rst b/Documentation/admin-guide/mm/damon/usage.rst
index 834eefe39650..bffe9dd9b0d6 100644
--- a/Documentation/admin-guide/mm/damon/usage.rst
+++ b/Documentation/admin-guide/mm/damon/usage.rst
@@ -495,6 +495,25 @@ Please note that it's highly recommended to use user space tools like `damo
 <https://github.com/awslabs/damo>`_ rather than manually reading and writing
 the files as above.  Above is only for an example.
 
+.. _tracepoint:
+
+Tracepoint for Monitoring Results
+=================================
+
+Users can get the monitoring results via the :ref:`tried_regions
+<sysfs_schemes_tried_regions>` or a tracepoint, ``damon:damon_aggregated``.
+While the tried regions directory is useful for getting a snapshot, the
+tracepoint is useful for getting a full record of the results.  While the
+monitoring is turned on, you could record the tracepoint events and show
+results using tracepoint supporting tools like ``perf``.  For example::
+
+    # echo on > monitor_on
+    # perf record -e damon:damon_aggregated &
+    # sleep 5
+    # kill 9 $(pidof perf)
+    # echo off > monitor_on
+    # perf script
+
 .. _debugfs_interface:
 
 debugfs Interface (DEPRECATED!)
@@ -790,23 +809,3 @@ directory by putting the name of the context to the ``rm_contexts`` file. ::
 
 Note that ``mk_contexts``, ``rm_contexts``, and ``monitor_on`` files are in the
 root directory only.
-
-
-.. _tracepoint:
-
-Tracepoint for Monitoring Results
-=================================
-
-Users can get the monitoring results via the :ref:`tried_regions
-<sysfs_schemes_tried_regions>` or a tracepoint, ``damon:damon_aggregated``.
-While the tried regions directory is useful for getting a snapshot, the
-tracepoint is useful for getting a full record of the results.  While the
-monitoring is turned on, you could record the tracepoint events and show
-results using tracepoint supporting tools like ``perf``.  For example::
-
-    # echo on > monitor_on
-    # perf record -e damon:damon_aggregated &
-    # sleep 5
-    # kill 9 $(pidof perf)
-    # echo off > monitor_on
-    # perf script
-- 
2.25.1



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

* [PATCH 03/11] Docs/admin-guide/mm/damon/usage: move debugfs intro to the bottom of the section
  2023-09-07  2:29 [PATCH 00/11] mm/damon: misc fixups for documents, comments and its tracepoint SeongJae Park
  2023-09-07  2:29 ` [PATCH 01/11] Docs/admin-guide/mm/damon/usage: fixup missed :ref: keyword SeongJae Park
  2023-09-07  2:29 ` [PATCH 02/11] Docs/admin-guide/mm/damon/usage: place debugfs usage at the bottom SeongJae Park
@ 2023-09-07  2:29 ` SeongJae Park
  2023-09-07  2:29 ` [PATCH 04/11] Docs/mm/damon/design: explicitly introduce ``nr_accesses`` SeongJae Park
                   ` (7 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: SeongJae Park @ 2023-09-07  2:29 UTC (permalink / raw)
  To: Andrew Morton
  Cc: SeongJae Park, Jonathan Corbet, damon, linux-mm, linux-doc, linux-kernel

On the DAMON usage introduction section, the introduction of DAMON
debugfs interface, which is deprecated, is above kernel API, which is
actively supported.  Move the DAMON debugfs intro to bottom, so that
readers have less chances to read it.

Signed-off-by: SeongJae Park <sj@kernel.org>
---
 Documentation/admin-guide/mm/damon/usage.rst | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/Documentation/admin-guide/mm/damon/usage.rst b/Documentation/admin-guide/mm/damon/usage.rst
index bffe9dd9b0d6..e48101c777e1 100644
--- a/Documentation/admin-guide/mm/damon/usage.rst
+++ b/Documentation/admin-guide/mm/damon/usage.rst
@@ -20,18 +20,18 @@ DAMON provides below interfaces for different users.
   you can write and use your personalized DAMON sysfs wrapper programs that
   reads/writes the sysfs files instead of you.  The `DAMON user space tool
   <https://github.com/awslabs/damo>`_ is one example of such programs.
-- *debugfs interface. (DEPRECATED!)*
-  :ref:`This <debugfs_interface>` is almost identical to :ref:`sysfs interface
-  <sysfs_interface>`.  This is deprecated, so users should move to the
-  :ref:`sysfs interface <sysfs_interface>`.  If you depend on this and cannot
-  move, please report your usecase to damon@lists.linux.dev and
-  linux-mm@kvack.org.
 - *Kernel Space Programming Interface.*
   :doc:`This </mm/damon/api>` is for kernel space programmers.  Using this,
   users can utilize every feature of DAMON most flexibly and efficiently by
   writing kernel space DAMON application programs for you.  You can even extend
   DAMON for various address spaces.  For detail, please refer to the interface
   :doc:`document </mm/damon/api>`.
+- *debugfs interface. (DEPRECATED!)*
+  :ref:`This <debugfs_interface>` is almost identical to :ref:`sysfs interface
+  <sysfs_interface>`.  This is deprecated, so users should move to the
+  :ref:`sysfs interface <sysfs_interface>`.  If you depend on this and cannot
+  move, please report your usecase to damon@lists.linux.dev and
+  linux-mm@kvack.org.
 
 .. _sysfs_interface:
 
-- 
2.25.1



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

* [PATCH 04/11] Docs/mm/damon/design: explicitly introduce ``nr_accesses``
  2023-09-07  2:29 [PATCH 00/11] mm/damon: misc fixups for documents, comments and its tracepoint SeongJae Park
                   ` (2 preceding siblings ...)
  2023-09-07  2:29 ` [PATCH 03/11] Docs/admin-guide/mm/damon/usage: move debugfs intro to the bottom of the section SeongJae Park
@ 2023-09-07  2:29 ` SeongJae Park
  2023-09-07  2:29 ` [PATCH 05/11] Docs/admin-guide/mm/damon/usage: explain the format of damon_aggregate tracepoint SeongJae Park
                   ` (6 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: SeongJae Park @ 2023-09-07  2:29 UTC (permalink / raw)
  To: Andrew Morton
  Cc: SeongJae Park, Jonathan Corbet, damon, linux-mm, linux-doc, linux-kernel

The design document is explaining about the access tracking mechanism
and the access rate counter (nr_accesses), but not directly mentions the
name.  Add a sentence for making it clear.

Signed-off-by: SeongJae Park <sj@kernel.org>
---
 Documentation/mm/damon/design.rst | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/Documentation/mm/damon/design.rst b/Documentation/mm/damon/design.rst
index a20383d01a95..5c465835a44f 100644
--- a/Documentation/mm/damon/design.rst
+++ b/Documentation/mm/damon/design.rst
@@ -163,9 +163,10 @@ assumption (pages in a region have the same access frequencies) is kept, only
 one page in the region is required to be checked.  Thus, for each ``sampling
 interval``, DAMON randomly picks one page in each region, waits for one
 ``sampling interval``, checks whether the page is accessed meanwhile, and
-increases the access frequency of the region if so.  Therefore, the monitoring
-overhead is controllable by setting the number of regions.  DAMON allows users
-to set the minimum and the maximum number of regions for the trade-off.
+increases the access frequency counter of the region if so.  The counter is
+called ``nr_regions`` of the region.  Therefore, the monitoring overhead is
+controllable by setting the number of regions.  DAMON allows users to set the
+minimum and the maximum number of regions for the trade-off.
 
 This scheme, however, cannot preserve the quality of the output if the
 assumption is not guaranteed.
-- 
2.25.1



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

* [PATCH 05/11] Docs/admin-guide/mm/damon/usage: explain the format of damon_aggregate tracepoint
  2023-09-07  2:29 [PATCH 00/11] mm/damon: misc fixups for documents, comments and its tracepoint SeongJae Park
                   ` (3 preceding siblings ...)
  2023-09-07  2:29 ` [PATCH 04/11] Docs/mm/damon/design: explicitly introduce ``nr_accesses`` SeongJae Park
@ 2023-09-07  2:29 ` SeongJae Park
  2023-09-07  2:29 ` [PATCH 06/11] Docs/mm/damon/design: add a section for kdamond and DAMON context SeongJae Park
                   ` (5 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: SeongJae Park @ 2023-09-07  2:29 UTC (permalink / raw)
  To: Andrew Morton
  Cc: SeongJae Park, Jonathan Corbet, damon, linux-mm, linux-doc, linux-kernel

The example of the section for damon_aggregated tracepoint is not
explaining how the output looks like, and how it can be interpreted.
Add it.

Signed-off-by: SeongJae Park <sj@kernel.org>
---
 Documentation/admin-guide/mm/damon/usage.rst | 14 ++++++++++++++
 Documentation/mm/damon/design.rst            |  4 ++++
 2 files changed, 18 insertions(+)

diff --git a/Documentation/admin-guide/mm/damon/usage.rst b/Documentation/admin-guide/mm/damon/usage.rst
index e48101c777e1..758575d33ab6 100644
--- a/Documentation/admin-guide/mm/damon/usage.rst
+++ b/Documentation/admin-guide/mm/damon/usage.rst
@@ -513,6 +513,20 @@ results using tracepoint supporting tools like ``perf``.  For example::
     # kill 9 $(pidof perf)
     # echo off > monitor_on
     # perf script
+    kdamond.0 46568 [027] 79357.842179: damon:damon_aggregated: target_id=0 nr_regions=11 122509119488-135708762112: 0 864
+    [...]
+
+Each line of the perf script output represents each monitoring region.  The
+first five fields are as usual other tracepoint outputs.  The sixth field
+(``target_id=X``) shows the ide of the monitoring target of the region.  The
+seventh field (``nr_regions=X``) shows the total number of monitoring regions
+for the target.  The eighth field (``X-Y:``) shows the start (``X``) and end
+(``Y``) addresses of the region in bytes.  The ninth field (``X``) shows the
+``nr_accesses`` of the region (refer to
+:ref:`design <damon_design_region_based_sampling>` for more details of the
+counter).  Finally the tenth field (``X``) shows the ``age`` of the region
+(refer to :ref:`design <damon_design_age_tracking>` for more details of the
+counter).
 
 .. _debugfs_interface:
 
diff --git a/Documentation/mm/damon/design.rst b/Documentation/mm/damon/design.rst
index 5c465835a44f..51aab9b0621a 100644
--- a/Documentation/mm/damon/design.rst
+++ b/Documentation/mm/damon/design.rst
@@ -154,6 +154,8 @@ The monitoring overhead of this mechanism will arbitrarily increase as the
 size of the target workload grows.
 
 
+.. _damon_design_region_based_sampling:
+
 Region Based Sampling
 ~~~~~~~~~~~~~~~~~~~~~
 
@@ -191,6 +193,8 @@ In this way, DAMON provides its best-effort quality and minimal overhead while
 keeping the bounds users set for their trade-off.
 
 
+.. _damon_design_age_tracking:
+
 Age Tracking
 ~~~~~~~~~~~~
 
-- 
2.25.1



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

* [PATCH 06/11] Docs/mm/damon/design: add a section for kdamond and DAMON context
  2023-09-07  2:29 [PATCH 00/11] mm/damon: misc fixups for documents, comments and its tracepoint SeongJae Park
                   ` (4 preceding siblings ...)
  2023-09-07  2:29 ` [PATCH 05/11] Docs/admin-guide/mm/damon/usage: explain the format of damon_aggregate tracepoint SeongJae Park
@ 2023-09-07  2:29 ` SeongJae Park
  2023-09-07  2:29 ` [PATCH 07/11] Docs/admin-guide/mm/damon/usage: link design doc for details of kdamond and context SeongJae Park
                   ` (4 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: SeongJae Park @ 2023-09-07  2:29 UTC (permalink / raw)
  To: Andrew Morton
  Cc: SeongJae Park, Jonathan Corbet, damon, linux-mm, linux-doc, linux-kernel

The design document is not explaining about the concept of kdamond and
the DAMON context, while usage document does.  Those concept explanation
should be in the design document, and usage document should link those.
Add a section for those.

Signed-off-by: SeongJae Park <sj@kernel.org>
---
 Documentation/mm/damon/design.rst | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/Documentation/mm/damon/design.rst b/Documentation/mm/damon/design.rst
index 51aab9b0621a..ee099d45fea8 100644
--- a/Documentation/mm/damon/design.rst
+++ b/Documentation/mm/damon/design.rst
@@ -476,3 +476,13 @@ modules for proactive reclamation and LRU lists manipulation are provided.  For
 more detail, please read the usage documents for those
 (:doc:`/admin-guide/mm/damon/reclaim` and
 :doc:`/admin-guide/mm/damon/lru_sort`).
+
+
+Execution Model and Data Structures
+===================================
+
+The monitoring-related information including the monitoring request
+specification and DAMON-based operation schemes are stored in a data structure
+called DAMON ``context``.  DAMON executes each context with a kernel thread
+called ``kdamond``.  Multiple kdamonds could run in parallel, for different
+types of monitoring.
-- 
2.25.1



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

* [PATCH 07/11] Docs/admin-guide/mm/damon/usage: link design doc for details of kdamond and context
  2023-09-07  2:29 [PATCH 00/11] mm/damon: misc fixups for documents, comments and its tracepoint SeongJae Park
                   ` (5 preceding siblings ...)
  2023-09-07  2:29 ` [PATCH 06/11] Docs/mm/damon/design: add a section for kdamond and DAMON context SeongJae Park
@ 2023-09-07  2:29 ` SeongJae Park
  2023-09-07  2:29 ` [PATCH 08/11] mm/damon/core: fix a comment about damon_set_attrs() call timings SeongJae Park
                   ` (3 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: SeongJae Park @ 2023-09-07  2:29 UTC (permalink / raw)
  To: Andrew Morton
  Cc: SeongJae Park, Jonathan Corbet, damon, linux-mm, linux-doc, linux-kernel

The explanation of kdamond and context is duplicated in the design and
the usage documents.  Replace that in the usage with links to those in
the design document.

Signed-off-by: SeongJae Park <sj@kernel.org>
---
 Documentation/admin-guide/mm/damon/usage.rst | 19 +++++++++----------
 Documentation/mm/damon/design.rst            |  2 ++
 2 files changed, 11 insertions(+), 10 deletions(-)

diff --git a/Documentation/admin-guide/mm/damon/usage.rst b/Documentation/admin-guide/mm/damon/usage.rst
index 758575d33ab6..282062b6f134 100644
--- a/Documentation/admin-guide/mm/damon/usage.rst
+++ b/Documentation/admin-guide/mm/damon/usage.rst
@@ -105,14 +105,12 @@ having the root permission could use this directory.
 kdamonds/
 ---------
 
-The monitoring-related information including request specifications and results
-are called DAMON context.  DAMON executes each context with a kernel thread
-called kdamond, and multiple kdamonds could run in parallel.
-
 Under the ``admin`` directory, one directory, ``kdamonds``, which has files for
-controlling the kdamonds exist.  In the beginning, this directory has only one
-file, ``nr_kdamonds``.  Writing a number (``N``) to the file creates the number
-of child directories named ``0`` to ``N-1``.  Each directory represents each
+controlling the kdamonds (refer to
+:ref:`design <damon_design_execution_model_and_data_structures>` for more
+details) exists.  In the beginning, this directory has only one file,
+``nr_kdamonds``.  Writing a number (``N``) to the file creates the number of
+child directories named ``0`` to ``N-1``.  Each directory represents each
 kdamond.
 
 kdamonds/<N>/
@@ -150,9 +148,10 @@ kdamonds/<N>/contexts/
 
 In the beginning, this directory has only one file, ``nr_contexts``.  Writing a
 number (``N``) to the file creates the number of child directories named as
-``0`` to ``N-1``.  Each directory represents each monitoring context.  At the
-moment, only one context per kdamond is supported, so only ``0`` or ``1`` can
-be written to the file.
+``0`` to ``N-1``.  Each directory represents each monitoring context (refer to
+:ref:`design <damon_design_execution_model_and_data_structures>` for more
+details).  At the moment, only one context per kdamond is supported, so only
+``0`` or ``1`` can be written to the file.
 
 .. _sysfs_contexts:
 
diff --git a/Documentation/mm/damon/design.rst b/Documentation/mm/damon/design.rst
index ee099d45fea8..18e9b42673f8 100644
--- a/Documentation/mm/damon/design.rst
+++ b/Documentation/mm/damon/design.rst
@@ -478,6 +478,8 @@ more detail, please read the usage documents for those
 :doc:`/admin-guide/mm/damon/lru_sort`).
 
 
+.. _damon_design_execution_model_and_data_structures:
+
 Execution Model and Data Structures
 ===================================
 
-- 
2.25.1



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

* [PATCH 08/11] mm/damon/core: fix a comment about damon_set_attrs() call timings
  2023-09-07  2:29 [PATCH 00/11] mm/damon: misc fixups for documents, comments and its tracepoint SeongJae Park
                   ` (6 preceding siblings ...)
  2023-09-07  2:29 ` [PATCH 07/11] Docs/admin-guide/mm/damon/usage: link design doc for details of kdamond and context SeongJae Park
@ 2023-09-07  2:29 ` SeongJae Park
  2023-09-07  2:29 ` [PATCH 09/11] mm/damon/core: add more comments for nr_accesses SeongJae Park
                   ` (2 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: SeongJae Park @ 2023-09-07  2:29 UTC (permalink / raw)
  To: Andrew Morton; +Cc: SeongJae Park, damon, linux-mm, linux-kernel

The comment on damon_set_attrs() says it should not be called while the
kdamond is running, but now some DAMON modules like sysfs interface and
DAMON_RECLAIM call it from after_aggregation() and/or
after_wmarks_check() callbacks for online tuning.  Update the comment.

Signed-off-by: SeongJae Park <sj@kernel.org>
---
 mm/damon/core.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/mm/damon/core.c b/mm/damon/core.c
index 28c7c49882d3..1ce483a3c2b5 100644
--- a/mm/damon/core.c
+++ b/mm/damon/core.c
@@ -570,7 +570,11 @@ static void damon_update_monitoring_results(struct damon_ctx *ctx,
  * @ctx:		monitoring context
  * @attrs:		monitoring attributes
  *
- * This function should not be called while the kdamond is running.
+ * This function should be called while the kdamond is not running, or an
+ * access check results aggregation is not ongoing (e.g., from
+ * &struct damon_callback->after_aggregation or
+ * &struct damon_callback->after_wmarks_check callbacks).
+ *
  * Every time interval is in micro-seconds.
  *
  * Return: 0 on success, negative error code otherwise.
-- 
2.25.1



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

* [PATCH 09/11] mm/damon/core: add more comments for nr_accesses
  2023-09-07  2:29 [PATCH 00/11] mm/damon: misc fixups for documents, comments and its tracepoint SeongJae Park
                   ` (7 preceding siblings ...)
  2023-09-07  2:29 ` [PATCH 08/11] mm/damon/core: fix a comment about damon_set_attrs() call timings SeongJae Park
@ 2023-09-07  2:29 ` SeongJae Park
  2023-09-07  2:29 ` [PATCH 10/11] mm/damon/core: remove duplicated comment for watermarks-based deactivation SeongJae Park
  2023-09-07  2:29 ` [PATCH 11/11] mm/damon/core: remove 'struct target *' parameter from damon_aggregated tracepoint SeongJae Park
  10 siblings, 0 replies; 12+ messages in thread
From: SeongJae Park @ 2023-09-07  2:29 UTC (permalink / raw)
  To: Andrew Morton; +Cc: SeongJae Park, damon, linux-mm, linux-kernel

The comment on struct damon_region about nr_accesses field looks not
sufficient.  Many people actually used to ask what nr_accesses mean.
There is more detailed explanation of the mechanism on the comment for
struct damon_attrs, but it is also ambiguous, as it doesn't specify the
name of the counter for aggregating the access check results.  Make
those more detailed.

Signed-off-by: SeongJae Park <sj@kernel.org>
---
 include/linux/damon.h | 19 ++++++++++++-------
 1 file changed, 12 insertions(+), 7 deletions(-)

diff --git a/include/linux/damon.h b/include/linux/damon.h
index ae2664d1d5f1..266f92b34dd2 100644
--- a/include/linux/damon.h
+++ b/include/linux/damon.h
@@ -43,6 +43,10 @@ struct damon_addr_range {
  * @list:		List head for siblings.
  * @age:		Age of this region.
  *
+ * @nr_accesses is reset to zero for every &damon_attrs->aggr_interval and be
+ * increased for every &damon_attrs->sample_interval if an access to the region
+ * during the last sampling interval is found.
+ *
  * @age is initially zero, increased for each aggregation interval, and reset
  * to zero again if the access frequency is significantly changed.  If two
  * regions are merged into a new region, both @nr_accesses and @age of the new
@@ -472,13 +476,14 @@ struct damon_callback {
  *				regions.
  *
  * For each @sample_interval, DAMON checks whether each region is accessed or
- * not.  It aggregates and keeps the access information (number of accesses to
- * each region) for @aggr_interval time.  DAMON also checks whether the target
- * memory regions need update (e.g., by ``mmap()`` calls from the application,
- * in case of virtual memory monitoring) and applies the changes for each
- * @ops_update_interval.  All time intervals are in micro-seconds.
- * Please refer to &struct damon_operations and &struct damon_callback for more
- * detail.
+ * not during the last @sample_interval.  If such access is found, DAMON
+ * aggregates the information by increasing &damon_region->nr_accesses for
+ * @aggr_interval time.  For each @aggr_interval, the count is reset.  DAMON
+ * also checks whether the target memory regions need update (e.g., by
+ * ``mmap()`` calls from the application, in case of virtual memory monitoring)
+ * and applies the changes for each @ops_update_interval.  All time intervals
+ * are in micro-seconds.  Please refer to &struct damon_operations and &struct
+ * damon_callback for more detail.
  */
 struct damon_attrs {
 	unsigned long sample_interval;
-- 
2.25.1



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

* [PATCH 10/11] mm/damon/core: remove duplicated comment for watermarks-based deactivation
  2023-09-07  2:29 [PATCH 00/11] mm/damon: misc fixups for documents, comments and its tracepoint SeongJae Park
                   ` (8 preceding siblings ...)
  2023-09-07  2:29 ` [PATCH 09/11] mm/damon/core: add more comments for nr_accesses SeongJae Park
@ 2023-09-07  2:29 ` SeongJae Park
  2023-09-07  2:29 ` [PATCH 11/11] mm/damon/core: remove 'struct target *' parameter from damon_aggregated tracepoint SeongJae Park
  10 siblings, 0 replies; 12+ messages in thread
From: SeongJae Park @ 2023-09-07  2:29 UTC (permalink / raw)
  To: Andrew Morton; +Cc: SeongJae Park, damon, linux-mm, linux-kernel

The comment for explaining about watermarks-based monitoring part
deactivation is duplicated in two paragraphs.  Remove one.

Signed-off-by: SeongJae Park <sj@kernel.org>
---
 include/linux/damon.h | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/include/linux/damon.h b/include/linux/damon.h
index 266f92b34dd2..ab3089de1478 100644
--- a/include/linux/damon.h
+++ b/include/linux/damon.h
@@ -317,9 +317,6 @@ struct damos_access_pattern {
  * monitoring context are inactive, DAMON stops monitoring either, and just
  * repeatedly checks the watermarks.
  *
- * If all schemes that registered to a &struct damon_ctx are inactive, DAMON
- * stops monitoring and just repeatedly checks the watermarks.
- *
  * Before applying the &action to a memory region, &struct damon_operations
  * implementation could check pages of the region and skip &action to respect
  * &filters
-- 
2.25.1



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

* [PATCH 11/11] mm/damon/core: remove 'struct target *' parameter from damon_aggregated tracepoint
  2023-09-07  2:29 [PATCH 00/11] mm/damon: misc fixups for documents, comments and its tracepoint SeongJae Park
                   ` (9 preceding siblings ...)
  2023-09-07  2:29 ` [PATCH 10/11] mm/damon/core: remove duplicated comment for watermarks-based deactivation SeongJae Park
@ 2023-09-07  2:29 ` SeongJae Park
  10 siblings, 0 replies; 12+ messages in thread
From: SeongJae Park @ 2023-09-07  2:29 UTC (permalink / raw)
  To: Andrew Morton
  Cc: SeongJae Park, Steven Rostedt, damon, linux-mm,
	linux-trace-kernel, linux-kernel

damon_aggregateed tracepoint is receiving 'struct target *', but doesn't
use it.  Remove it from the prototype.

Signed-off-by: SeongJae Park <sj@kernel.org>
---
 include/trace/events/damon.h | 6 +++---
 mm/damon/core.c              | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/include/trace/events/damon.h b/include/trace/events/damon.h
index c79f1d4c39af..0b8d13bde17a 100644
--- a/include/trace/events/damon.h
+++ b/include/trace/events/damon.h
@@ -11,10 +11,10 @@
 
 TRACE_EVENT(damon_aggregated,
 
-	TP_PROTO(struct damon_target *t, unsigned int target_id,
-		struct damon_region *r, unsigned int nr_regions),
+	TP_PROTO(unsigned int target_id, struct damon_region *r,
+		unsigned int nr_regions),
 
-	TP_ARGS(t, target_id, r, nr_regions),
+	TP_ARGS(target_id, r, nr_regions),
 
 	TP_STRUCT__entry(
 		__field(unsigned long, target_id)
diff --git a/mm/damon/core.c b/mm/damon/core.c
index 1ce483a3c2b5..b895f70acb2d 100644
--- a/mm/damon/core.c
+++ b/mm/damon/core.c
@@ -805,7 +805,7 @@ static void kdamond_reset_aggregated(struct damon_ctx *c)
 		struct damon_region *r;
 
 		damon_for_each_region(r, t) {
-			trace_damon_aggregated(t, ti, r, damon_nr_regions(t));
+			trace_damon_aggregated(ti, r, damon_nr_regions(t));
 			r->last_nr_accesses = r->nr_accesses;
 			r->nr_accesses = 0;
 		}
-- 
2.25.1



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

end of thread, other threads:[~2023-09-07  2:30 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-07  2:29 [PATCH 00/11] mm/damon: misc fixups for documents, comments and its tracepoint SeongJae Park
2023-09-07  2:29 ` [PATCH 01/11] Docs/admin-guide/mm/damon/usage: fixup missed :ref: keyword SeongJae Park
2023-09-07  2:29 ` [PATCH 02/11] Docs/admin-guide/mm/damon/usage: place debugfs usage at the bottom SeongJae Park
2023-09-07  2:29 ` [PATCH 03/11] Docs/admin-guide/mm/damon/usage: move debugfs intro to the bottom of the section SeongJae Park
2023-09-07  2:29 ` [PATCH 04/11] Docs/mm/damon/design: explicitly introduce ``nr_accesses`` SeongJae Park
2023-09-07  2:29 ` [PATCH 05/11] Docs/admin-guide/mm/damon/usage: explain the format of damon_aggregate tracepoint SeongJae Park
2023-09-07  2:29 ` [PATCH 06/11] Docs/mm/damon/design: add a section for kdamond and DAMON context SeongJae Park
2023-09-07  2:29 ` [PATCH 07/11] Docs/admin-guide/mm/damon/usage: link design doc for details of kdamond and context SeongJae Park
2023-09-07  2:29 ` [PATCH 08/11] mm/damon/core: fix a comment about damon_set_attrs() call timings SeongJae Park
2023-09-07  2:29 ` [PATCH 09/11] mm/damon/core: add more comments for nr_accesses SeongJae Park
2023-09-07  2:29 ` [PATCH 10/11] mm/damon/core: remove duplicated comment for watermarks-based deactivation SeongJae Park
2023-09-07  2:29 ` [PATCH 11/11] mm/damon/core: remove 'struct target *' parameter from damon_aggregated tracepoint SeongJae Park

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