* [PATCH 00/20] mm/damon: let DAMOS feeds and tame/auto-tune itself
@ 2024-02-19 19:44 SeongJae Park
2024-02-19 19:44 ` [PATCH 05/20] Docs/admin-guide/mm/damon/usage: document effective_bytes file SeongJae Park
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: SeongJae Park @ 2024-02-19 19:44 UTC (permalink / raw)
To: Andrew Morton
Cc: SeongJae Park, Jonathan Corbet, damon, linux-mm, linux-doc,
linux-kernel
The Aim-oriented Feedback-driven DAMOS Aggressiveness Auto-tuning
patchset[1] which has merged since commit 9294a037c015 ("mm/damon/core:
implement goal-oriented feedback-driven quota auto-tuning") made the
mechanism and the policy separated. That is, users can set a part of
DAMOS control policies without a deep understanding of the mechanism but
just their demands such as SLA.
However, users are still required to do some additional work of manually
collecting their target metric and feeding it to DAMOS. In the case of
end-users who use DAMON sysfs interface, the context switches between
user-space and kernel-space could also make it inefficient. The
overhead is supposed to be only trivial in common cases, though.
Meanwhile, in simple use cases, the target metric could be common system
metrics that the kernel can efficiently self-retrieve, such as memory
pressure stall time (PSI).
Extend DAMOS quota auto-tuning to support multiple types of metrics
including the DAMOS self-retrievable ones, and add support for memory
pressure stall time metric. Different types of metrics can be supported
in future. The auto-tuning capability is currently supported for only
users of DAMOS kernel API and DAMON sysfs interface. Extend the support
to DAMON_RECLAIM.
Patches Sequence
================
First five patches are for helping debugging and fine-tuning existing
quota control features. The first one (patch 1) exposes the effective
quota that is made with given user inputs to DAMOS kernel API users
and kernel-doc documents. Following four patches implement (patches 1, 2
and 3) and document (patches 4 and 5) a new DAMON sysfs file that
exposes the value.
Following six patches cleanup and simplify the existing DAMOS quota
auto-tuning code by improving layout of comments and data structures
(patches 6 and 7), supporting common use cases, namely multiple goals
(patches 8, 9 and 10), and simplifying the interface (patch 11).
Then six patches for the main purpose of this patchset follow. The
first three changes extend the core logic for various target metrics
(patch 12), implement memory pressure stall time-based target metric
support (patch 13), and update DAMON sysfs interface to support the new
target metric (patch 14). Then, documentation updates for the features
on design (patch 15), ABI (patch 16), and usage (patch 17) follow.
Last three patches add auto-tuning support on DAMON_RECLAIM. The
patches implement DAMON_RECLAIM parameters for user-feedback driven
quota auto-tuning (patch 18), memory pressure stall time-driven quota
self-tuning (patch 19), and finally update the DAMON_RECLAIM usage
document for the new parameters (patch 20).
[1] https://lore.kernel.org/all/20231130023652.50284-1-sj@kernel.org/
SeongJae Park (20):
mm/damon/core: Set damos_quota->esz as public field and document
mm/damon/sysfs-schemes: implement quota effective_bytes file
mm/damon/sysfs: implement a kdamond command for updating schemes'
effective quotas
Docs/ABI/damon: document effective_bytes sysfs file
Docs/admin-guide/mm/damon/usage: document effective_bytes file
mm/damon: move comments and fields for damos-quota-prioritization to
the end
mm/damon/core: split out quota goal related fields to a struct
mm/damon/core: add multiple goals per damos_quota and helpers for
those
mm/damon/sysfs: use only quota->goals
mm/damon/core: remove ->goal field of damos_quota
mm/damon/core: let goal specified with only target and current values
mm/damon/core: support multiple metrics for quota goal
mm/damon/core: implement PSI metric DAMOS quota goal
mm/damon/sysfs-schemes: support PSI-based quota auto-tune
Docs/mm/damon/design: document quota goal self-tuning
Docs/ABI/damon: document quota goal metric file
Docs/admin-guide/mm/damon/usage: document quota goal metric file
mm/damon/reclaim: implement user-feedback driven quota auto-tuning
mm/damon/reclaim: implement memory PSI-driven quota self-tuning
Docs/admin-guide/mm/damon/reclaim: document auto-tuning parameters
.../ABI/testing/sysfs-kernel-mm-damon | 16 ++-
.../admin-guide/mm/damon/reclaim.rst | 27 ++++
Documentation/admin-guide/mm/damon/usage.rst | 31 +++--
Documentation/mm/damon/design.rst | 20 ++-
include/linux/damon.h | 89 ++++++++++---
mm/damon/core.c | 120 +++++++++++++++--
mm/damon/reclaim.c | 53 ++++++++
mm/damon/sysfs-common.h | 6 +-
mm/damon/sysfs-schemes.c | 124 +++++++++++++++---
mm/damon/sysfs.c | 33 ++++-
10 files changed, 454 insertions(+), 65 deletions(-)
base-commit: ecd6af887705c19e7367f9d3818ae712f4674168
--
2.39.2
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 05/20] Docs/admin-guide/mm/damon/usage: document effective_bytes file
2024-02-19 19:44 [PATCH 00/20] mm/damon: let DAMOS feeds and tame/auto-tune itself SeongJae Park
@ 2024-02-19 19:44 ` SeongJae Park
2024-02-19 19:44 ` [PATCH 15/20] Docs/mm/damon/design: document quota goal self-tuning SeongJae Park
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: SeongJae Park @ 2024-02-19 19:44 UTC (permalink / raw)
To: Andrew Morton
Cc: SeongJae Park, Jonathan Corbet, damon, linux-mm, linux-doc,
linux-kernel
Update DAMON usage document for the effective quota file of the DAMON
sysfs interface.
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 db6620b5bc0a..220ebbde7324 100644
--- a/Documentation/admin-guide/mm/damon/usage.rst
+++ b/Documentation/admin-guide/mm/damon/usage.rst
@@ -83,7 +83,7 @@ comma (",").
│ │ │ │ │ │ │ │ sz/min,max
│ │ │ │ │ │ │ │ nr_accesses/min,max
│ │ │ │ │ │ │ │ age/min,max
- │ │ │ │ │ │ │ :ref:`quotas <sysfs_quotas>`/ms,bytes,reset_interval_ms
+ │ │ │ │ │ │ │ :ref:`quotas <sysfs_quotas>`/ms,bytes,reset_interval_ms,effective_bytes
│ │ │ │ │ │ │ │ weights/sz_permil,nr_accesses_permil,age_permil
│ │ │ │ │ │ │ │ :ref:`goals <sysfs_schemes_quota_goals>`/nr_goals
│ │ │ │ │ │ │ │ │ 0/target_value,current_value
@@ -153,6 +153,9 @@ Users can write below commands for the kdamond to the ``state`` file.
- ``clear_schemes_tried_regions``: Clear the DAMON-based operating scheme
action tried regions directory for each DAMON-based operation scheme of the
kdamond.
+- ``update_schemes_effective_bytes``: Update the contents of
+ ``effective_bytes`` files for each DAMON-based operation scheme of the
+ kdamond. For more details, refer to :ref:`quotas directory <sysfs_quotas>`.
If the state is ``on``, reading ``pid`` shows the pid of the kdamond thread.
@@ -320,8 +323,9 @@ schemes/<N>/quotas/
The directory for the :ref:`quotas <damon_design_damos_quotas>` of the given
DAMON-based operation scheme.
-Under ``quotas`` directory, three files (``ms``, ``bytes``,
-``reset_interval_ms``) and two directores (``weights`` and ``goals``) exist.
+Under ``quotas`` directory, four files (``ms``, ``bytes``,
+``reset_interval_ms``, ``effective_bytes``) and two directores (``weights`` and
+``goals``) exist.
You can set the ``time quota`` in milliseconds, ``size quota`` in bytes, and
``reset interval`` in milliseconds by writing the values to the three files,
@@ -332,6 +336,15 @@ apply the action to only up to ``bytes`` bytes of memory regions within the
quota limits unless at least one :ref:`goal <sysfs_schemes_quota_goals>` is
set.
+The time quota is internally transformed to a size quota. Between the
+transformed size quota and user-specified size quota, smaller one is applied.
+Based on the user-specified :ref:`goal <sysfs_schemes_quota_goals>`, the
+effective size quota is further adjusted. Reading ``effective_bytes`` returns
+the current effective size quota. The file is not updated in real time, so
+users should ask DAMON sysfs interface to update the content of the file for
+the stats by writing a special keyword, ``update_schemes_effective_bytes`` to
+the relevant ``kdamonds/<N>/state`` file.
+
Under ``weights`` directory, three files (``sz_permil``,
``nr_accesses_permil``, and ``age_permil``) exist.
You can set the :ref:`prioritization weights
--
2.39.2
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 15/20] Docs/mm/damon/design: document quota goal self-tuning
2024-02-19 19:44 [PATCH 00/20] mm/damon: let DAMOS feeds and tame/auto-tune itself SeongJae Park
2024-02-19 19:44 ` [PATCH 05/20] Docs/admin-guide/mm/damon/usage: document effective_bytes file SeongJae Park
@ 2024-02-19 19:44 ` SeongJae Park
2024-02-19 19:44 ` [PATCH 17/20] Docs/admin-guide/mm/damon/usage: document quota goal metric file SeongJae Park
2024-02-19 19:44 ` [PATCH 20/20] Docs/admin-guide/mm/damon/reclaim: document auto-tuning parameters SeongJae Park
3 siblings, 0 replies; 5+ messages in thread
From: SeongJae Park @ 2024-02-19 19:44 UTC (permalink / raw)
To: Andrew Morton
Cc: SeongJae Park, Jonathan Corbet, damon, linux-mm, linux-doc,
linux-kernel
update DAMON design doc to explain the quota goal self-tuning, which can
be used by setting the goal's metric to metrics that kernel can
self-retrieve.
Signed-off-by: SeongJae Park <sj@kernel.org>
---
Documentation/mm/damon/design.rst | 20 ++++++++++++++++++--
1 file changed, 18 insertions(+), 2 deletions(-)
diff --git a/Documentation/mm/damon/design.rst b/Documentation/mm/damon/design.rst
index 2bd0c203dcfb..8c89d26f0baa 100644
--- a/Documentation/mm/damon/design.rst
+++ b/Documentation/mm/damon/design.rst
@@ -398,12 +398,28 @@ Aim-oriented Feedback-driven Auto-tuning
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Automatic feedback-driven quota tuning. Instead of setting the absolute quota
-value, users can repeatedly provide numbers representing how much of their goal
-for the scheme is achieved as feedback. DAMOS then automatically tunes the
+value, users can specify the metric of their interest, and what target value
+they want the metric value to be. DAMOS then automatically tunes the
aggressiveness (the quota) of the corresponding scheme. For example, if DAMOS
is under achieving the goal, DAMOS automatically increases the quota. If DAMOS
is over achieving the goal, it decreases the quota.
+The goal can be specified with three parameters, namely ``target_metric``,
+``target_value``, and ``current_value``. The auto-tuning mechanism tries to
+make ``current_value`` of ``target_metric`` be same to ``target_value``.
+Currently, two ``target_metric`` are provided.
+
+- ``user_input``: User-provided value. Users could use any metric that they
+ has interest in for the value. Use space main workload's latency or
+ throughput, system metrics like free memory ratio or memory pressure stall
+ time (PSI) could be examples. Note that users should explicitly set
+ ``current_value`` on their own in this case. In other words, users should
+ repeatedly provide the feedback.
+- ``some_mem_psi_us``: System-wide ``some`` memory pressure stall information
+ in microseconds that measured from last quota reset to next quota reset.
+ DAMOS does the measurement on its own, so only ``target_value`` need to be
+ set by users at the initial time. In other words, DAMOS does self-feedback.
+
.. _damon_design_damos_watermarks:
--
2.39.2
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 17/20] Docs/admin-guide/mm/damon/usage: document quota goal metric file
2024-02-19 19:44 [PATCH 00/20] mm/damon: let DAMOS feeds and tame/auto-tune itself SeongJae Park
2024-02-19 19:44 ` [PATCH 05/20] Docs/admin-guide/mm/damon/usage: document effective_bytes file SeongJae Park
2024-02-19 19:44 ` [PATCH 15/20] Docs/mm/damon/design: document quota goal self-tuning SeongJae Park
@ 2024-02-19 19:44 ` SeongJae Park
2024-02-19 19:44 ` [PATCH 20/20] Docs/admin-guide/mm/damon/reclaim: document auto-tuning parameters SeongJae Park
3 siblings, 0 replies; 5+ messages in thread
From: SeongJae Park @ 2024-02-19 19:44 UTC (permalink / raw)
To: Andrew Morton
Cc: SeongJae Park, Jonathan Corbet, damon, linux-mm, linux-doc,
linux-kernel
Update DAMON usage document for the quota goal target_metric file.
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 220ebbde7324..b33eecfd0e90 100644
--- a/Documentation/admin-guide/mm/damon/usage.rst
+++ b/Documentation/admin-guide/mm/damon/usage.rst
@@ -86,7 +86,7 @@ comma (",").
│ │ │ │ │ │ │ :ref:`quotas <sysfs_quotas>`/ms,bytes,reset_interval_ms,effective_bytes
│ │ │ │ │ │ │ │ weights/sz_permil,nr_accesses_permil,age_permil
│ │ │ │ │ │ │ │ :ref:`goals <sysfs_schemes_quota_goals>`/nr_goals
- │ │ │ │ │ │ │ │ │ 0/target_value,current_value
+ │ │ │ │ │ │ │ │ │ 0/target_metric,target_value,current_value
│ │ │ │ │ │ │ :ref:`watermarks <sysfs_watermarks>`/metric,interval_us,high,mid,low
│ │ │ │ │ │ │ :ref:`filters <sysfs_filters>`/nr_filters
│ │ │ │ │ │ │ │ 0/type,matching,memcg_id
@@ -366,11 +366,11 @@ number (``N``) to the file creates the number of child directories named ``0``
to ``N-1``. Each directory represents each goal and current achievement.
Among the multiple feedback, the best one is used.
-Each goal directory contains two files, namely ``target_value`` and
-``current_value``. Users can set and get any number to those files to set the
-feedback. User space main workload's latency or throughput, system metrics
-like free memory ratio or memory pressure stall time (PSI) could be example
-metrics for the values. Note that users should write
+Each goal directory contains three files, namely ``target_metric``,
+``target_value`` and ``current_value``. Users can set and get the three
+parameters for the quota auto-tuning goals that specified on the :ref:`design
+doc <damon_design_damos_quota_auto_tuning>` by writing to and reading from each
+of the files. Note that users should further write
``commit_schemes_quota_goals`` to the ``state`` file of the :ref:`kdamond
directory <sysfs_kdamond>` to pass the feedback to DAMON.
--
2.39.2
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 20/20] Docs/admin-guide/mm/damon/reclaim: document auto-tuning parameters
2024-02-19 19:44 [PATCH 00/20] mm/damon: let DAMOS feeds and tame/auto-tune itself SeongJae Park
` (2 preceding siblings ...)
2024-02-19 19:44 ` [PATCH 17/20] Docs/admin-guide/mm/damon/usage: document quota goal metric file SeongJae Park
@ 2024-02-19 19:44 ` SeongJae Park
3 siblings, 0 replies; 5+ messages in thread
From: SeongJae Park @ 2024-02-19 19:44 UTC (permalink / raw)
To: Andrew Morton
Cc: SeongJae Park, Jonathan Corbet, damon, linux-mm, linux-doc,
linux-kernel
Update DAMON_RECLAIM usage document for the user/self feedback based
auto-tuning of the quota.
Signed-off-by: SeongJae Park <sj@kernel.org>
---
.../admin-guide/mm/damon/reclaim.rst | 27 +++++++++++++++++++
1 file changed, 27 insertions(+)
diff --git a/Documentation/admin-guide/mm/damon/reclaim.rst b/Documentation/admin-guide/mm/damon/reclaim.rst
index 343e25b252f4..af05ae617018 100644
--- a/Documentation/admin-guide/mm/damon/reclaim.rst
+++ b/Documentation/admin-guide/mm/damon/reclaim.rst
@@ -117,6 +117,33 @@ milliseconds.
1 second by default.
+quota_mem_pressure_us
+---------------------
+
+Desired level of memory pressure-stall time in microseconds.
+
+While keeping the caps that set by other quotas, DAMON_RECLAIM automatically
+increases and decreases the effective level of the quota aiming this level of
+memory pressure is incurred. System-wide ``some`` memory PSI in microseconds
+per quota reset interval (``quota_reset_interval_ms``) is collected and
+compared to this value to see if the aim is satisfied. Value zero means
+disabling this auto-tuning feature.
+
+Disabled by default.
+
+quota_autotune_feedback
+-----------------------
+
+User-specifiable feedback for auto-tuning of the effective quota.
+
+While keeping the caps that set by other quotas, DAMON_RECLAIM automatically
+increases and decreases the effective level of the quota aiming receiving this
+feedback of value ``10,000`` from the user. DAMON_RECLAIM assumes the feedback
+value and the quota are positively proportional. Value zero means disabling
+this auto-tuning feature.
+
+Disabled by default.
+
wmarks_interval
---------------
--
2.39.2
^ permalink raw reply related [flat|nested] 5+ messages in thread
end of thread, other threads:[~2024-02-19 19:44 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-02-19 19:44 [PATCH 00/20] mm/damon: let DAMOS feeds and tame/auto-tune itself SeongJae Park
2024-02-19 19:44 ` [PATCH 05/20] Docs/admin-guide/mm/damon/usage: document effective_bytes file SeongJae Park
2024-02-19 19:44 ` [PATCH 15/20] Docs/mm/damon/design: document quota goal self-tuning SeongJae Park
2024-02-19 19:44 ` [PATCH 17/20] Docs/admin-guide/mm/damon/usage: document quota goal metric file SeongJae Park
2024-02-19 19:44 ` [PATCH 20/20] Docs/admin-guide/mm/damon/reclaim: document auto-tuning parameters SeongJae Park
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).