mm/damon: misc fixups for documents, comments and its tracepoint
Subsystems (5)
SeongJae Park
maintainercover mm/damon: misc fixups for documents, comments and its tracepoint
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
Signature · 1 line
2.25.1
SeongJae Park
maintainerPATCH 1/11 Docs/admin-guide/mm/damon/usage: fixup missed :ref: keyword
A cross-link reference in DAMON usage document is missing ':ref:' Sphynx keyword. Fix it.
--- Documentation/admin-guide/mm/damon/usage.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Documentation/admin-guide/mm/damon/usage.rst +1 -1
@@ -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
Signature · 1 line
2.25.1
SeongJae Park
maintainerPATCH 2/11 Docs/admin-guide/mm/damon/usage: place debugfs usage at the bottom
In reply to SeongJae Parkdebugfs interface is deprecated. Put it at the bottom of the document so that readers have less chances to read it.
--- Documentation/admin-guide/mm/damon/usage.rst | 39 ++++++++++---------- 1 file changed, 19 insertions(+), 20 deletions(-)
Documentation/admin-guide/mm/damon/usage.rst +19 -20
@@ -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
Signature · 1 line
2.25.1
SeongJae Park
maintainerPATCH 3/11 Docs/admin-guide/mm/damon/usage: move debugfs intro to the bottom of the section
In reply to SeongJae ParkOn 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.
--- Documentation/admin-guide/mm/damon/usage.rst | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
Documentation/admin-guide/mm/damon/usage.rst +6 -6
@@ -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 [email protected] and - [email protected]. - *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 [email protected] and + [email protected]. .. _sysfs_interface:
Signature · 1 line
2.25.1
SeongJae Park
maintainerPATCH 4/11 Docs/mm/damon/design: explicitly introduce ``nr_accesses``
In reply to SeongJae ParkThe 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.
--- Documentation/mm/damon/design.rst | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
Documentation/mm/damon/design.rst +4 -3
@@ -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.
Signature · 1 line
2.25.1
SeongJae Park
maintainerPATCH 5/11 Docs/admin-guide/mm/damon/usage: explain the format of damon_aggregate tracepoint
In reply to SeongJae ParkThe example of the section for damon_aggregated tracepoint is not explaining how the output looks like, and how it can be interpreted. Add it.
--- Documentation/admin-guide/mm/damon/usage.rst | 14 ++++++++++++++ Documentation/mm/damon/design.rst | 4 ++++ 2 files changed, 18 insertions(+)
Documentation/admin-guide/mm/damon/usage.rst +14 -0
@@ -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:
Documentation/mm/damon/design.rst +4 -0
@@ -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 ~~~~~~~~~~~~
Signature · 1 line
2.25.1
SeongJae Park
maintainerPATCH 6/11 Docs/mm/damon/design: add a section for kdamond and DAMON context
In reply to SeongJae ParkThe 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.
--- Documentation/mm/damon/design.rst | 10 ++++++++++ 1 file changed, 10 insertions(+)
Documentation/mm/damon/design.rst +10 -0
@@ -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.
Signature · 1 line
2.25.1
SeongJae Park
maintainerPATCH 7/11 Docs/admin-guide/mm/damon/usage: link design doc for details of kdamond and context
In reply to SeongJae ParkThe 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.
--- Documentation/admin-guide/mm/damon/usage.rst | 19 +++++++++---------- Documentation/mm/damon/design.rst | 2 ++ 2 files changed, 11 insertions(+), 10 deletions(-)
Documentation/admin-guide/mm/damon/usage.rst +9 -10
@@ -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:
Documentation/mm/damon/design.rst +2 -0
@@ -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 ===================================
Signature · 1 line
2.25.1
SeongJae Park
maintainerPATCH 8/11 mm/damon/core: fix a comment about damon_set_attrs() call timings
In reply to SeongJae ParkThe 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.
--- mm/damon/core.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
mm/damon/core.c +5 -1
@@ -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.
Signature · 1 line
2.25.1
SeongJae Park
maintainerPATCH 9/11 mm/damon/core: add more comments for nr_accesses
In reply to SeongJae ParkThe 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.
--- include/linux/damon.h | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-)
include/linux/damon.h +12 -7
@@ -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;
Signature · 1 line
2.25.1
SeongJae Park
maintainerPATCH 10/11 mm/damon/core: remove duplicated comment for watermarks-based deactivation
In reply to SeongJae ParkThe comment for explaining about watermarks-based monitoring part deactivation is duplicated in two paragraphs. Remove one.
--- include/linux/damon.h | 3 --- 1 file changed, 3 deletions(-)
include/linux/damon.h +0 -3
@@ -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
Signature · 1 line
2.25.1
SeongJae Park
maintainerPATCH 11/11 mm/damon/core: remove 'struct target *' parameter from damon_aggregated tracepoint
In reply to SeongJae Parkdamon_aggregateed tracepoint is receiving 'struct target *', but doesn't use it. Remove it from the prototype.
--- include/trace/events/damon.h | 6 +++--- mm/damon/core.c | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-)
include/trace/events/damon.h +3 -3
@@ -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)
mm/damon/core.c +1 -1
@@ -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 ; }
Signature · 1 line
2.25.1