mm/damon: misc updates for 6.8
Subsystems (4)
SeongJae Park
maintainercover mm/damon: misc updates for 6.8
Update comments, tests, and documents for DAMON aiming to be merged in the next merge window for Linux v6.8.
SeongJae Park (6):
mm/damon: update email of SeongJae
mm/damon/core-test: test max_nr_accesses overflow caused
divide-by-zero
Docs/mm/damon/design: place execution model and data structures at the
beginning
Docs/admin-guide/mm/damon/usage: update context directory section
label
Docs/admin-guide/mm/damon/usage: add links to sysfs files hierarchy Docs/admin-guide/mm/damon/usage: use a list for 'state' sysfs file
input commands
Documentation/admin-guide/mm/damon/usage.rst | 123 +++++++++++-------- Documentation/mm/damon/design.rst | 24 ++-- include/linux/damon.h | 2 +- mm/damon/core-test.h | 13 +- mm/damon/core.c | 2 +- mm/damon/dbgfs-test.h | 2 +- mm/damon/dbgfs.c | 2 +- mm/damon/modules-common.c | 2 +- mm/damon/vaddr-test.h | 2 +- mm/damon/vaddr.c | 2 +- 10 files changed, 106 insertions(+), 68 deletions(-)
base-commit: def619f2545d0286e6f4ed6c09fac8f863a70da1
Signature · 1 line
2.34.1
SeongJae Park
maintainerPATCH 1/6 mm/damon: update email of SeongJae
SeongJae is using his kernel.org account for DAMON development. Update the old email addresses on the comments of DAMON source files.
--- include/linux/damon.h | 2 +- mm/damon/core-test.h | 2 +- mm/damon/core.c | 2 +- mm/damon/dbgfs-test.h | 2 +- mm/damon/dbgfs.c | 2 +- mm/damon/modules-common.c | 2 +- mm/damon/vaddr-test.h | 2 +- mm/damon/vaddr.c | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-)
include/linux/damon.h +1 -1
@@ -2,7 +2,7 @@/* * DAMON api * -* Author: SeongJae Park <[email protected]> +* Author: SeongJae Park <[email protected]> */ #ifndef _DAMON_H_
mm/damon/core-test.h +1 -1
@@ -4,7 +4,7 @@* * Copyright 2019 Amazon.com, Inc. or its affiliates. All rights reserved. * -* Author: SeongJae Park <[email protected]> +* Author: SeongJae Park <[email protected]> */ #ifdef CONFIG_DAMON_KUNIT_TEST
mm/damon/core.c +1 -1
@@ -2,7 +2,7 @@/* * Data Access Monitor * -* Author: SeongJae Park <[email protected]> +* Author: SeongJae Park <[email protected]> */ #define pr_fmt (fmt) "damon: " fmt
mm/damon/dbgfs-test.h +1 -1
@@ -2,7 +2,7 @@/* * DAMON Debugfs Interface Unit Tests * -* Author: SeongJae Park <[email protected]> +* Author: SeongJae Park <[email protected]> */ #ifdef CONFIG_DAMON_DBGFS_KUNIT_TEST
mm/damon/dbgfs.c +1 -1
@@ -2,7 +2,7 @@/* * DAMON Debugfs Interface * -* Author: SeongJae Park <[email protected]> +* Author: SeongJae Park <[email protected]> */ #define pr_fmt (fmt) "damon-dbgfs: " fmt
mm/damon/modules-common.c +1 -1
@@ -2,7 +2,7 @@/* * Common Primitives for DAMON Modules * -* Author: SeongJae Park <[email protected]> +* Author: SeongJae Park <[email protected]> */ #include <linux/damon.h>
mm/damon/vaddr-test.h +1 -1
@@ -4,7 +4,7 @@* * Copyright 2019 Amazon.com, Inc. or its affiliates. All rights reserved. * -* Author: SeongJae Park <[email protected]> +* Author: SeongJae Park <[email protected]> */ #ifdef CONFIG_DAMON_VADDR_KUNIT_TEST
mm/damon/vaddr.c +1 -1
@@ -2,7 +2,7 @@/* * DAMON Primitives for Virtual Address Spaces * -* Author: SeongJae Park <[email protected]> +* Author: SeongJae Park <[email protected]> */ #define pr_fmt (fmt) "damon-va: " fmt
Signature · 1 line
2.34.1
SeongJae Park
maintainerPATCH 2/6 mm/damon/core-test: test max_nr_accesses overflow caused divide-by-zero
In reply to SeongJae ParkCommit 35f5d94187a6 ("mm/damon: implement a function for max nr_accesses safe calculation") has fixed an overflow bug that could cause divide-by-zero. Add a kunit test for the bug to ensure similar bugs are not introduced again.
--- mm/damon/core-test.h | 11 +++++++++++ 1 file changed, 11 insertions(+)
mm/damon/core-test.h +11 -0
@@ -302,6 +302,16 @@ static void damon_test_set_regions(struct kunit *test)damon_destroy_target (t); } +static void damon_test_nr_accesses_to_accesses_bp (struct kunit *test) +{ +struct damon_attrs attrs = { + .sample_interval =10 , + .aggr_interval = ((unsigned long )UINT_MAX +1 ) *10 + }; + +KUNIT_EXPECT_EQ (test,damon_nr_accesses_to_accesses_bp (123 , &attrs),0 ); +} +static void damon_test_update_monitoring_result (struct kunit *test) {struct damon_attrs old_attrs = {
@@ -487,6 +497,7 @@ static struct kunit_case damon_test_cases[] = {KUNIT_CASE (damon_test_split_regions_of),KUNIT_CASE (damon_test_ops_registration),KUNIT_CASE (damon_test_set_regions), +KUNIT_CASE (damon_test_nr_accesses_to_accesses_bp),KUNIT_CASE (damon_test_update_monitoring_result),KUNIT_CASE (damon_test_set_attrs), KUNIT_CASE(damon_test_moving_sum),
Signature · 1 line
2.34.1
SeongJae Park
maintainerPATCH 3/6 Docs/mm/damon/design: place execution model and data structures at the beginning
In reply to SeongJae ParkThe execution model and data structures section at the end of the design document is briefly explaining how DAMON works overall. Knowing that first may help better drawing the overall picture. It may also help better understanding following detailed sections. Move it to the beginning of the document.
--- Documentation/mm/damon/design.rst | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-)
Documentation/mm/damon/design.rst +12 -12
@@ -5,6 +5,18 @@ Design ====== +.. _damon_design_execution_model_and_data_structures: + +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. + + Overall Architecture ====================
@@ -490,15 +502,3 @@ 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`). - - -.. _damon_design_execution_model_and_data_structures: - -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.34.1
SeongJae Park
maintainerPATCH 4/6 Docs/admin-guide/mm/damon/usage: update context directory section label
In reply to SeongJae ParkThe label for context DAMON sysfs directory section is having name sysfs_contexts. The name would be better to be used for the contexts directory. Rename it to represent a single context.
--- Documentation/admin-guide/mm/damon/usage.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
Documentation/admin-guide/mm/damon/usage.rst +3 -3
@@ -164,7 +164,7 @@ number (``N``) to the file creates the number of child directories named as details). At the moment, only one context per kdamond is supported, so only ``0`` or ``1`` can be written to the file. -.. _sysfs_contexts: +.. _sysfs_context: contexts/<N>/ -------------
@@ -288,7 +288,7 @@ The ``action`` file is for setting and getting the scheme's :ref:`action from the file and their meaning are as below. Note that support of each action depends on the running DAMON operations set -:ref:`implementation <sysfs_contexts>`. +:ref:`implementation <sysfs_context>`. - ``willneed``: Call ``madvise()`` for the region with ``MADV_WILLNEED``. Supported by ``vaddr`` and ``fvaddr`` operations set.
@@ -428,7 +428,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`` :ref:`implementation <sysfs_contexts>` is being used. +``paddr`` :ref:`implementation <sysfs_context>` 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.34.1
SeongJae Park
maintainerPATCH 5/6 Docs/admin-guide/mm/damon/usage: add links to sysfs files hierarchy
In reply to SeongJae Park'Sysfs Files Hierarchy' section of DAMON usage document shows whole picture of the interface. Then sections for detailed explanation of the files follow. Due to the amount of the files, navigating between the whole picture and the section for specific files sometimes require no subtle amount of scrolling. Add links from the whole picture to the dedicated sections for making the navigation easier.
--- Documentation/admin-guide/mm/damon/usage.rst | 70 ++++++++++++++------ 1 file changed, 49 insertions(+), 21 deletions(-)
Documentation/admin-guide/mm/damon/usage.rst +49 -21
@@ -59,43 +59,47 @@ Files Hierarchy The files hierarchy of DAMON sysfs interface is shown below. In the below figure, parents-children relations are represented with indentations, each directory is having ``/`` suffix, and files in each directory are separated by -comma (","). :: - - /sys/kernel/mm/damon/admin - │ kdamonds/nr_kdamonds - │ │ 0/state,pid - │ │ │ contexts/nr_contexts - │ │ │ │ 0/avail_operations,operations - │ │ │ │ │ monitoring_attrs/ +comma (","). + +.. parsed-literal:: + + :ref:`/sys/kernel/mm/damon <sysfs_root>`/admin + │ :ref:`kdamonds <sysfs_kdamonds>`/nr_kdamonds + │ │ :ref:`0 <sysfs_kdamond>`/state,pid + │ │ │ :ref:`contexts <sysfs_contexts>`/nr_contexts + │ │ │ │ :ref:`0 <sysfs_context>`/avail_operations,operations + │ │ │ │ │ :ref:`monitoring_attrs <sysfs_monitoring_attrs>`/ │ │ │ │ │ │ intervals/sample_us,aggr_us,update_us │ │ │ │ │ │ nr_regions/min,max - │ │ │ │ │ targets/nr_targets - │ │ │ │ │ │ 0/pid_target - │ │ │ │ │ │ │ regions/nr_regions - │ │ │ │ │ │ │ │ 0/start,end + │ │ │ │ │ :ref:`targets <sysfs_targets>`/nr_targets + │ │ │ │ │ │ :ref:`0 <sysfs_target>`/pid_target + │ │ │ │ │ │ │ :ref:`regions <sysfs_regions>`/nr_regions + │ │ │ │ │ │ │ │ :ref:`0 <sysfs_region>`/start,end │ │ │ │ │ │ │ │ ... │ │ │ │ │ │ ... - │ │ │ │ │ schemes/nr_schemes - │ │ │ │ │ │ 0/action,apply_interval_us - │ │ │ │ │ │ │ access_pattern/ + │ │ │ │ │ :ref:`schemes <sysfs_schemes>`/nr_schemes + │ │ │ │ │ │ :ref:`0 <sysfs_scheme>`/action,apply_interval_us + │ │ │ │ │ │ │ :ref:`access_pattern <sysfs_access_pattern>`/ │ │ │ │ │ │ │ │ sz/min,max │ │ │ │ │ │ │ │ nr_accesses/min,max │ │ │ │ │ │ │ │ age/min,max - │ │ │ │ │ │ │ quotas/ms,bytes,reset_interval_ms + │ │ │ │ │ │ │ :ref:`quotas <sysfs_quotas>`/ms,bytes,reset_interval_ms │ │ │ │ │ │ │ │ weights/sz_permil,nr_accesses_permil,age_permil - │ │ │ │ │ │ │ │ goals/nr_goals + │ │ │ │ │ │ │ │ :ref:`goals <sysfs_schemes_quota_goals>`/nr_goals │ │ │ │ │ │ │ │ │ 0/target_value,current_value - │ │ │ │ │ │ │ watermarks/metric,interval_us,high,mid,low - │ │ │ │ │ │ │ filters/nr_filters + │ │ │ │ │ │ │ :ref:`watermarks <sysfs_watermarks>`/metric,interval_us,high,mid,low + │ │ │ │ │ │ │ :ref:`filters <sysfs_filters>`/nr_filters │ │ │ │ │ │ │ │ 0/type,matching,memcg_id - │ │ │ │ │ │ │ stats/nr_tried,sz_tried,nr_applied,sz_applied,qt_exceeds - │ │ │ │ │ │ │ tried_regions/total_bytes + │ │ │ │ │ │ │ :ref:`stats <sysfs_schemes_stats>`/nr_tried,sz_tried,nr_applied,sz_applied,qt_exceeds + │ │ │ │ │ │ │ :ref:`tried_regions <sysfs_schemes_tried_regions>`/total_bytes │ │ │ │ │ │ │ │ 0/start,end,nr_accesses,age │ │ │ │ │ │ │ │ ... │ │ │ │ │ │ ... │ │ │ │ ... │ │ ... +.. _sysfs_root: + Root ----
@@ -104,6 +108,8 @@ has one directory named ``admin``. The directory contains the files for privileged user space programs' control of DAMON. User space tools or daemons having the root permission could use this directory. +.. _sysfs_kdamonds: + kdamonds/ ---------
@@ -154,6 +160,8 @@ If the state is ``on``, reading ``pid`` shows the pid of the kdamond thread. ``contexts`` directory contains files for controlling the monitoring contexts that this kdamond will execute. +.. _sysfs_contexts: + kdamonds/<N>/contexts/ ----------------------
@@ -214,6 +222,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`). +.. _sysfs_targets: + contexts/<N>/targets/ ---------------------
@@ -221,6 +231,8 @@ In the beginning, this directory has only one file, ``nr_targets``. Writing a number (``N``) to the file creates the number of child directories named ``0`` to ``N-1``. Each directory represents each monitoring target. +.. _sysfs_target: + targets/<N>/ ------------
@@ -255,6 +267,8 @@ In the beginning, this directory has only one file, ``nr_regions``. Writing a number (``N``) to the file creates the number of child directories named ``0`` to ``N-1``. Each directory represents each initial monitoring target region. +.. _sysfs_region: + regions/<N>/ ------------
@@ -265,6 +279,8 @@ region by writing to and reading from the files, respectively. Each region should not overlap with others. ``end`` of directory ``N`` should be equal or smaller than ``start`` of directory ``N+1``. +.. _sysfs_schemes: + contexts/<N>/schemes/ ---------------------
@@ -276,6 +292,8 @@ In the beginning, this directory has only one file, ``nr_schemes``. Writing a number (``N``) to the file creates the number of child directories named ``0`` to ``N-1``. Each directory represents each DAMON-based operation scheme. +.. _sysfs_scheme: + schemes/<N>/ ------------
@@ -310,6 +328,8 @@ Note that support of each action depends on the running DAMON operations set The ``apply_interval_us`` file is for setting and getting the scheme's :ref:`apply_interval <damon_design_damos>` in microseconds. +.. _sysfs_access_pattern: + schemes/<N>/access_pattern/ ---------------------------
@@ -323,6 +343,8 @@ to and reading from the ``min`` and ``max`` files under ``sz``, ``nr_accesses``, and ``age`` directories, respectively. Note that the ``min`` and the ``max`` form a closed interval. +.. _sysfs_quotas: + schemes/<N>/quotas/ -------------------
@@ -369,6 +391,8 @@ metrics for the values. Note that users should write ``commit_schemes_quota_goals`` to the ``state`` file of the :ref:`kdamond directory <sysfs_kdamond>` to pass the feedback to DAMON. +.. _sysfs_watermarks: + schemes/<N>/watermarks/ -----------------------
@@ -388,6 +412,8 @@ as below. The ``interval`` should written in microseconds unit. +.. _sysfs_filters: + schemes/<N>/filters/ --------------------
@@ -483,6 +509,8 @@ and query-like efficient data access monitoring results retrievals. For the latter use case, in particular, users can set the ``action`` as ``stat`` and set the ``access pattern`` as their interested pattern that they want to query. +.. _sysfs_schemes_tried_region: + tried_regions/<N>/ ------------------
Signature · 1 line
2.34.1
SeongJae Park
maintainerPATCH 6/6 Docs/admin-guide/mm/damon/usage: use a list for 'state' sysfs file input commands
In reply to SeongJae ParkThere are eight command inputs for 'state' DAMON sysfs file, and those are verbosely explained in multiple paragraphs. It is not easy to find explanation of specific command, and getting whole picture of supported commands. Replace the paragraphs with a list.
--- Documentation/admin-guide/mm/damon/usage.rst | 47 ++++++++++---------- 1 file changed, 23 insertions(+), 24 deletions(-)
Documentation/admin-guide/mm/damon/usage.rst +23 -24
@@ -130,30 +130,29 @@ In each kdamond directory, two files (``state`` and ``pid``) and one directory (``contexts``) exist. Reading ``state`` returns ``on`` if the kdamond is currently running, or -``off`` if it is not running. Writing ``on`` or ``off`` makes the kdamond be -in the state. - -Writing ``commit`` to the ``state`` file makes kdamond reads the -user inputs in the sysfs files except ``state`` file again. Writing -``commit_schemes_quota_goals`` to the ``state`` file makes kdamond reads the -DAMON-based operation schemes' :ref:`quota goals <sysfs_schemes_quota_goals>` -of the kdamond. - -Writing ``update_schemes_stats`` to ``state`` file updates the -contents of stats files for each DAMON-based operation scheme of the kdamond. -For details of the stats, please refer to :ref:`stats section -<sysfs_schemes_stats>`. - -Writing ``update_schemes_tried_regions`` to ``state`` file updates the -DAMON-based operation scheme action tried regions directory for each -DAMON-based operation scheme of the kdamond. Writing -``update_schemes_tried_bytes`` to ``state`` file updates only -``.../tried_regions/total_bytes`` files. Writing -``clear_schemes_tried_regions`` to ``state`` file clears the DAMON-based -operating scheme action tried regions directory for each DAMON-based operation -scheme of the kdamond. For details of the DAMON-based operation scheme action -tried regions directory, please refer to :ref:`tried_regions section -<sysfs_schemes_tried_regions>`. +``off`` if it is not running. + +Users can write below commands for the kdamond to the ``state`` file. + +- ``on``: Start running. +- ``off``: Stop running. +- ``commit``: Read the user inputs in the sysfs files except ``state`` file + again. +- ``commit_schemes_quota_goals``: Read the DAMON-based operation schemes' + :ref:`quota goals <sysfs_schemes_quota_goals>`. +- ``update_schemes_stats``: Update the contents of stats files for each + DAMON-based operation scheme of the kdamond. For details of the stats, + please refer to :ref:`stats section <sysfs_schemes_stats>`. +- ``update_schemes_tried_regions``: Update the DAMON-based operation scheme + action tried regions directory for each DAMON-based operation scheme of the + kdamond. For details of the DAMON-based operation scheme action tried + regions directory, please refer to + :ref:`tried_regions section <sysfs_schemes_tried_regions>`. +- ``update_schemes_tried_bytes``: Update only ``.../tried_regions/total_bytes`` + files. +- ``clear_schemes_tried_regions``: Clear the DAMON-based operating scheme + action tried regions directory for each DAMON-based operation scheme of the + kdamond. If the state is ``on``, reading ``pid`` shows the pid of the kdamond thread.
Signature · 1 line
2.34.1