* [RFC PATCH 00/10] mm/damon: extend DAMOS filters for inclusion of target memory
@ 2024-12-26 22:14 SeongJae Park
2024-12-26 22:14 ` [RFC PATCH 07/10] Docs/mm/damon/design: document pass/block filters behaviors SeongJae Park
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: SeongJae Park @ 2024-12-26 22:14 UTC (permalink / raw)
Cc: SeongJae Park, Andrew Morton, Jonathan Corbet, damon, kernel-team,
linux-doc, linux-kernel, linux-mm
DAMOS fitlers are exclusive filters. It only excludes memory of
specific types from the DAMOS action targets. This has below problems.
First, the name is not explicitly explaining the behavior. This
actually resulted in confusions[1] and works to improve the siaution[2],
including wordsmithing documentations and adding features to DAMON
user-space tool, damo.
Secondly, the functionality is restrictive. This is especially
problematic when multiple filters need to be used. For example,
building a DAMOS scheme that applies the action to memory that belongs
to cgroup A "or" cgroup B is impossible. A workaroudn is using two
schemes, each filtering out memory that not belong to cgroup A and
cgroup B, respectively. It is cumbersome, and makes control of
quota-like additional factors difficult.
Extend DAMOS filters to support not only excluding (blocking), but also
including (pass-through) behavior. For the extension, add a new
damos_filter struct field called 'pass' for DAMON kernel API users.
Using the API, add a DAMON sysfs file of same name under DAMOS filter
sysfs directory, for DAMON user-space ABI users. To prevent breaking
old users with a behavioral change, set the blocking as the default
behavior.
Note that DAMOS' default behavior without DAMOS filters is applying the
action to any memory. And DAMOS filters work for only memory that
satisfies 'type' and 'matching'. Hence installing pass filter without
any block filter after them makes no filter-behavioral change.
[1] https://lore.kernel.org/20240320165619.71478-1-sj@kernel.org
[2] https://git.kernel.org/sj/damo/c/b6a722c85ff91e5abe9dd47135e300df243da056
SeongJae Park (10):
mm/damon: fixup damos_filter kernel-doc
mm/damon/core: add damos_filter->pass field
mm/damon/core: support damos_filter->pass
mm/damon/paddr: support damos_filter->pass
mm/damon: add pass argument to damos_new_filter()
mm/damon/sysfs-schemes: add a file for setting damos_filter->pass
Docs/mm/damon/design: document pass/block filters behaviors
Docs/ABI/damon: document DAMOS filter pass sysfs file
Docs/admin-guide/mm/damon/usage: omit DAMOS filter details in favor of
design doc
Docs/admin-guide/mm/damon/usage: document DAMOS filter 'pass' sysfs
file
.../ABI/testing/sysfs-kernel-mm-damon | 14 +++--
Documentation/admin-guide/mm/damon/usage.rst | 55 ++++++++++---------
Documentation/mm/damon/design.rst | 29 ++++++++--
include/linux/damon.h | 15 +++--
mm/damon/core.c | 12 ++--
mm/damon/paddr.c | 9 +--
mm/damon/reclaim.c | 2 +-
mm/damon/sysfs-schemes.c | 32 ++++++++++-
mm/damon/tests/core-kunit.h | 14 ++---
9 files changed, 125 insertions(+), 57 deletions(-)
--
2.39.5
^ permalink raw reply [flat|nested] 5+ messages in thread
* [RFC PATCH 07/10] Docs/mm/damon/design: document pass/block filters behaviors
2024-12-26 22:14 [RFC PATCH 00/10] mm/damon: extend DAMOS filters for inclusion of target memory SeongJae Park
@ 2024-12-26 22:14 ` SeongJae Park
2024-12-26 22:14 ` [RFC PATCH 09/10] Docs/admin-guide/mm/damon/usage: omit DAMOS filter details in favor of design doc SeongJae Park
2024-12-26 22:14 ` [RFC PATCH 10/10] Docs/admin-guide/mm/damon/usage: document DAMOS filter 'pass' sysfs file SeongJae Park
2 siblings, 0 replies; 5+ messages in thread
From: SeongJae Park @ 2024-12-26 22:14 UTC (permalink / raw)
Cc: SeongJae Park, Andrew Morton, Jonathan Corbet, damon, kernel-team,
linux-doc, linux-kernel, linux-mm
Update DAMOS filters design document to describe the pass/block
behavior of filters.
Signed-off-by: SeongJae Park <sj@kernel.org>
---
Documentation/mm/damon/design.rst | 29 +++++++++++++++++++++++++----
1 file changed, 25 insertions(+), 4 deletions(-)
diff --git a/Documentation/mm/damon/design.rst b/Documentation/mm/damon/design.rst
index 5ebb572d0999..0265aaef2544 100644
--- a/Documentation/mm/damon/design.rst
+++ b/Documentation/mm/damon/design.rst
@@ -504,9 +504,30 @@ have a list of latency-critical processes.
To let users optimize DAMOS schemes with such special knowledge, DAMOS provides
a feature called DAMOS filters. The feature allows users to set an arbitrary
-number of filters for each scheme. Each filter specifies the type of target
-memory, and whether it should exclude the memory of the type (filter-out), or
-all except the memory of the type (filter-in).
+number of filters for each scheme. Each filter specifies
+
+- a type of memory (``type``),
+- whether it is for the memory of the type or all except the type
+ (``matching``), and
+- whether it is to allow (pass through the filter) or reject (block) applying
+ the scheme's action to the memory (``pass``).
+
+When multiple filters are installed, each filter is applied in the installed
+order. If a memory is matched to one of the filter, followup filters are
+ignored. For example, let's assume a filter for passing anonymous pages and
+another filter for blocking young pages are installed in the order. If a page
+of a region that eligible to apply the scheme's action is an anonymous page,
+the scheme's action will be applied to the page regardless of whether it is
+young, since it matches with the first filter. On the other hand, if a page of
+the region is a non-anonymous page, the scheme's action will be applied only if
+the page is young, since the second filter is also applied.
+
+Note that DAMOS action is eligible to be applied to any memory that satisfies
+other conditions if no filter is isntalled. Meanwhile, DAMOS filters work for
+only memory that satisfies ``type`` and ``matching``. It means installing only
+pass filters is same to installing no filter, because pass filters dont' block
+memory of type that not specified to pass. For any use case, at least one
+block filter should be installed as the last one.
For efficient handling of filters, some types of filters are handled by the
core layer, while others are handled by operations set. In the latter case,
@@ -516,7 +537,7 @@ filter are not counted as the scheme has tried to the region. In contrast, if
a memory regions is filtered by an operations set layer-handled filter, it is
counted as the scheme has tried. This difference affects the statistics.
-Below types of filters are currently supported.
+Below ``type`` of filters are currently supported.
- anonymous page
- Applied to pages that containing data that not stored in files.
--
2.39.5
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [RFC PATCH 09/10] Docs/admin-guide/mm/damon/usage: omit DAMOS filter details in favor of design doc
2024-12-26 22:14 [RFC PATCH 00/10] mm/damon: extend DAMOS filters for inclusion of target memory SeongJae Park
2024-12-26 22:14 ` [RFC PATCH 07/10] Docs/mm/damon/design: document pass/block filters behaviors SeongJae Park
@ 2024-12-26 22:14 ` SeongJae Park
2024-12-26 22:14 ` [RFC PATCH 10/10] Docs/admin-guide/mm/damon/usage: document DAMOS filter 'pass' sysfs file SeongJae Park
2 siblings, 0 replies; 5+ messages in thread
From: SeongJae Park @ 2024-12-26 22:14 UTC (permalink / raw)
Cc: SeongJae Park, Andrew Morton, Jonathan Corbet, damon, kernel-team,
linux-doc, linux-kernel, linux-mm
DAMON usage document is describing some details about DAMOS filters,
which are also documented on the design doc. Deduplicate the details in
favor of the design doc.
Signed-off-by: SeongJae Park <sj@kernel.org>
---
Documentation/admin-guide/mm/damon/usage.rst | 29 ++++++++++----------
1 file changed, 14 insertions(+), 15 deletions(-)
diff --git a/Documentation/admin-guide/mm/damon/usage.rst b/Documentation/admin-guide/mm/damon/usage.rst
index a891e830c2a1..fa8a5e4199b1 100644
--- a/Documentation/admin-guide/mm/damon/usage.rst
+++ b/Documentation/admin-guide/mm/damon/usage.rst
@@ -417,13 +417,17 @@ Each filter directory contains six files, namely ``type``, ``matcing``,
file, you can write one of five special keywords: ``anon`` for anonymous pages,
``memcg`` for specific memory cgroup, ``young`` for young pages, ``addr`` for
specific address range (an open-ended interval), or ``target`` for specific
-DAMON monitoring target filtering. In case of the memory cgroup filtering, you
-can specify the memory cgroup of the interest by writing the path of the memory
-cgroup from the cgroups mount point to ``memcg_path`` file. In case of the
-address range filtering, you can specify the start and end address of the range
-to ``addr_start`` and ``addr_end`` files, respectively. For the DAMON
-monitoring target filtering, you can specify the index of the target between
-the list of the DAMON context's monitoring targets list to ``target_idx`` file.
+DAMON monitoring target filtering. Meaning of the types are same to the
+description on the :ref:`design doc <damon_design_damos_filters>`.
+
+In case of the memory cgroup filtering, you can specify the memory cgroup of
+the interest by writing the path of the memory cgroup from the cgroups mount
+point to ``memcg_path`` file. In case of the address range filtering, you can
+specify the start and end address of the range to ``addr_start`` and
+``addr_end`` files, respectively. For the DAMON monitoring target filtering,
+you can specify the index of the target between the list of the DAMON context's
+monitoring targets list to ``target_idx`` file.
+
You can write ``Y`` or ``N`` to ``matching`` file to filter out pages that does
or does not match to the type, respectively. Then, the scheme's action will
not be applied to the pages that specified to be filtered out.
@@ -440,14 +444,9 @@ pages of all memory cgroups except ``/having_care_already``.::
echo /having_care_already > 1/memcg_path
echo Y > 1/matching
-Note that ``anon`` and ``memcg`` filters are currently supported only when
-``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
-out by other type filters are counted as the scheme has tried to. The
-difference is applied to :ref:`stats <damos_stats>` and
-:ref:`tried regions <sysfs_schemes_tried_regions>`.
+Refer to the :ref:`DAMOS filters design documentation
+<damon_design_damos_filters>` for more details including when each of the
+filters are supported and differences on stats.
.. _sysfs_schemes_stats:
--
2.39.5
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [RFC PATCH 10/10] Docs/admin-guide/mm/damon/usage: document DAMOS filter 'pass' sysfs file
2024-12-26 22:14 [RFC PATCH 00/10] mm/damon: extend DAMOS filters for inclusion of target memory SeongJae Park
2024-12-26 22:14 ` [RFC PATCH 07/10] Docs/mm/damon/design: document pass/block filters behaviors SeongJae Park
2024-12-26 22:14 ` [RFC PATCH 09/10] Docs/admin-guide/mm/damon/usage: omit DAMOS filter details in favor of design doc SeongJae Park
@ 2024-12-26 22:14 ` SeongJae Park
2024-12-26 22:27 ` SeongJae Park
2 siblings, 1 reply; 5+ messages in thread
From: SeongJae Park @ 2024-12-26 22:14 UTC (permalink / raw)
Cc: SeongJae Park, Andrew Morton, Jonathan Corbet, damon, kernel-team,
linux-doc, linux-kernel, linux-mm
Update DAMON usage document for the newly added 'pass' sysfs file for
DAMOS filters.
Signed-off-by: SeongJae Park <sj@kernel.org>
---
Documentation/admin-guide/mm/damon/usage.rst | 34 ++++++++++++--------
1 file changed, 20 insertions(+), 14 deletions(-)
diff --git a/Documentation/admin-guide/mm/damon/usage.rst b/Documentation/admin-guide/mm/damon/usage.rst
index fa8a5e4199b1..ab343d6ac771 100644
--- a/Documentation/admin-guide/mm/damon/usage.rst
+++ b/Documentation/admin-guide/mm/damon/usage.rst
@@ -89,7 +89,7 @@ comma (",").
\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd \ufffd\ufffd\ufffd \ufffd\ufffd\ufffd \ufffd\ufffd\ufffd \ufffd\ufffd\ufffd \ufffd\ufffd\ufffd \ufffd\ufffd\ufffd \ufffd\ufffd\ufffd 0/target_metric,target_value,current_value
\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd \ufffd\ufffd\ufffd \ufffd\ufffd\ufffd \ufffd\ufffd\ufffd \ufffd\ufffd\ufffd \ufffd\ufffd\ufffd :ref:`watermarks <sysfs_watermarks>`/metric,interval_us,high,mid,low
\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd \ufffd\ufffd\ufffd \ufffd\ufffd\ufffd \ufffd\ufffd\ufffd \ufffd\ufffd\ufffd \ufffd\ufffd\ufffd :ref:`filters <sysfs_filters>`/nr_filters
- \ufffd\ufffd\ufffd \ufffd\ufffd\ufffd \ufffd\ufffd\ufffd \ufffd\ufffd\ufffd \ufffd\ufffd\ufffd \ufffd\ufffd\ufffd \ufffd\ufffd\ufffd \ufffd\ufffd\ufffd 0/type,matching,memcg_id
+ \ufffd\ufffd\ufffd \ufffd\ufffd\ufffd \ufffd\ufffd\ufffd \ufffd\ufffd\ufffd \ufffd\ufffd\ufffd \ufffd\ufffd\ufffd \ufffd\ufffd\ufffd \ufffd\ufffd\ufffd 0/type,matching,memcg_id,pass
\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd \ufffd\ufffd\ufffd \ufffd\ufffd\ufffd \ufffd\ufffd\ufffd \ufffd\ufffd\ufffd \ufffd\ufffd\ufffd :ref:`stats <sysfs_schemes_stats>`/nr_tried,sz_tried,nr_applied,sz_applied,sz_ops_filter_passed,qt_exceeds
\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd \ufffd\ufffd\ufffd \ufffd\ufffd\ufffd \ufffd\ufffd\ufffd \ufffd\ufffd\ufffd \ufffd\ufffd\ufffd :ref:`tried_regions <sysfs_schemes_tried_regions>`/total_bytes
\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd \ufffd\ufffd\ufffd \ufffd\ufffd\ufffd \ufffd\ufffd\ufffd \ufffd\ufffd\ufffd \ufffd\ufffd\ufffd \ufffd\ufffd\ufffd 0/start,end,nr_accesses,age,sz_filter_passed
@@ -412,13 +412,14 @@ number (``N``) to the file creates the number of child directories named ``0``
to ``N-1``. Each directory represents each filter. The filters are evaluated
in the numeric order.
-Each filter directory contains six files, namely ``type``, ``matcing``,
-``memcg_path``, ``addr_start``, ``addr_end``, and ``target_idx``. To ``type``
-file, you can write one of five special keywords: ``anon`` for anonymous pages,
-``memcg`` for specific memory cgroup, ``young`` for young pages, ``addr`` for
-specific address range (an open-ended interval), or ``target`` for specific
-DAMON monitoring target filtering. Meaning of the types are same to the
-description on the :ref:`design doc <damon_design_damos_filters>`.
+Each filter directory contains seven files, namely ``type``, ``matcing``,
+``pass``, ``memcg_path``, ``addr_start``, ``addr_end``, and ``target_idx``. To
+``type`` file, you can write one of five special keywords: ``anon`` for
+anonymous pages, ``memcg`` for specific memory cgroup, ``young`` for young
+pages, ``addr`` for specific address range (an open-ended interval), or
+``target`` for specific DAMON monitoring target filtering. Meaning of the
+types are same to the description on the :ref:`design doc
+<damon_design_damos_filters>`.
In case of the memory cgroup filtering, you can specify the memory cgroup of
the interest by writing the path of the memory cgroup from the cgroups mount
@@ -428,25 +429,30 @@ specify the start and end address of the range to ``addr_start`` and
you can specify the index of the target between the list of the DAMON context's
monitoring targets list to ``target_idx`` file.
-You can write ``Y`` or ``N`` to ``matching`` file to filter out pages that does
-or does not match to the type, respectively. Then, the scheme's action will
-not be applied to the pages that specified to be filtered out.
+You can write ``Y`` or ``N`` to ``matching`` file to specify whether the filter
+is for memory that matches the ``type``. You can write ``Y`` or ``N`` to
+``pass`` file to specify should this filter let the memory that satisfies the
+``type`` and ``matching`` pass though (allow) or be blocked by (reject) the
+filter. Allowing means the scheme's action will be applied to the memory.
For example, below restricts a DAMOS action to be applied to only non-anonymous
pages of all memory cgroups except ``/having_care_already``.::
# echo 2 > nr_filters
- # # filter out anonymous pages
+ # # block anonymous pages
echo anon > 0/type
echo Y > 0/matching
+ echo N > 0/pass
# # further filter out all cgroups except one at '/having_care_already'
echo memcg > 1/type
echo /having_care_already > 1/memcg_path
echo Y > 1/matching
+ echo N > 1/pass
Refer to the :ref:`DAMOS filters design documentation
-<damon_design_damos_filters>` for more details including when each of the
-filters are supported and differences on stats.
+<damon_design_damos_filters>` for more details including how multiple filters
+of different ``pass`` works, when each of the filters are supported, and
+differences on stats.
.. _sysfs_schemes_stats:
--
2.39.5
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [RFC PATCH 10/10] Docs/admin-guide/mm/damon/usage: document DAMOS filter 'pass' sysfs file
2024-12-26 22:14 ` [RFC PATCH 10/10] Docs/admin-guide/mm/damon/usage: document DAMOS filter 'pass' sysfs file SeongJae Park
@ 2024-12-26 22:27 ` SeongJae Park
0 siblings, 0 replies; 5+ messages in thread
From: SeongJae Park @ 2024-12-26 22:27 UTC (permalink / raw)
To: SeongJae Park
Cc: Andrew Morton, Jonathan Corbet, damon, kernel-team, linux-doc,
linux-kernel, linux-mm
On Thu, 26 Dec 2024 14:14:45 -0800 SeongJae Park <sj@kernel.org> wrote:
> Update DAMON usage document for the newly added 'pass' sysfs file for
> DAMOS filters.
>
> Signed-off-by: SeongJae Park <sj@kernel.org>
> ---
> Documentation/admin-guide/mm/damon/usage.rst | 34 ++++++++++++--------
> 1 file changed, 20 insertions(+), 14 deletions(-)
>
> diff --git a/Documentation/admin-guide/mm/damon/usage.rst b/Documentation/admin-guide/mm/damon/usage.rst
> index fa8a5e4199b1..ab343d6ac771 100644
> --- a/Documentation/admin-guide/mm/damon/usage.rst
> +++ b/Documentation/admin-guide/mm/damon/usage.rst
> @@ -89,7 +89,7 @@ comma (",").
> \ufffd\ufffd\ufffd \ufffd\ufffd\ufffd \ufffd\ufffd\ufffd \ufffd\ufffd\ufffd \ufffd\ufffd\ufffd \ufffd\ufffd\ufffd \ufffd\ufffd\ufffd \ufffd\ufffd\ufffd \ufffd\ufffd\ufffd 0/target_metric,target_value,current_value
> \ufffd\ufffd\ufffd \ufffd\ufffd\ufffd \ufffd\ufffd\ufffd \ufffd\ufffd\ufffd \ufffd\ufffd\ufffd \ufffd\ufffd\ufffd \ufffd\ufffd\ufffd :ref:`watermarks <sysfs_watermarks>`/metric,interval_us,high,mid,low
> \ufffd\ufffd\ufffd \ufffd\ufffd\ufffd \ufffd\ufffd\ufffd \ufffd\ufffd\ufffd \ufffd\ufffd\ufffd \ufffd\ufffd\ufffd \ufffd\ufffd\ufffd :ref:`filters <sysfs_filters>`/nr_filters
> - \ufffd\ufffd\ufffd \ufffd\ufffd\ufffd \ufffd\ufffd\ufffd \ufffd\ufffd\ufffd \ufffd\ufffd\ufffd \ufffd\ufffd\ufffd \ufffd\ufffd\ufffd \ufffd\ufffd\ufffd 0/type,matching,memcg_id
> + \ufffd\ufffd\ufffd \ufffd\ufffd\ufffd \ufffd\ufffd\ufffd \ufffd\ufffd\ufffd \ufffd\ufffd\ufffd \ufffd\ufffd\ufffd \ufffd\ufffd\ufffd \ufffd\ufffd\ufffd 0/type,matching,memcg_id,pass
> \ufffd\ufffd\ufffd \ufffd\ufffd\ufffd \ufffd\ufffd\ufffd \ufffd\ufffd\ufffd \ufffd\ufffd\ufffd \ufffd\ufffd\ufffd \ufffd\ufffd\ufffd :ref:`stats <sysfs_schemes_stats>`/nr_tried,sz_tried,nr_applied,sz_applied,sz_ops_filter_passed,qt_exceeds
> \ufffd\ufffd\ufffd \ufffd\ufffd\ufffd \ufffd\ufffd\ufffd \ufffd\ufffd\ufffd \ufffd\ufffd\ufffd \ufffd\ufffd\ufffd \ufffd\ufffd\ufffd :ref:`tried_regions <sysfs_schemes_tried_regions>`/total_bytes
> \ufffd\ufffd\ufffd \ufffd\ufffd\ufffd \ufffd\ufffd\ufffd \ufffd\ufffd\ufffd \ufffd\ufffd\ufffd \ufffd\ufffd\ufffd \ufffd\ufffd\ufffd \ufffd\ufffd\ufffd 0/start,end,nr_accesses,age,sz_filter_passed
Oops, seems my new patch format script has an encoding handling bug. I will
fix this on next spin...
Thanks,
SJ
[...]
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2024-12-26 22:27 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-12-26 22:14 [RFC PATCH 00/10] mm/damon: extend DAMOS filters for inclusion of target memory SeongJae Park
2024-12-26 22:14 ` [RFC PATCH 07/10] Docs/mm/damon/design: document pass/block filters behaviors SeongJae Park
2024-12-26 22:14 ` [RFC PATCH 09/10] Docs/admin-guide/mm/damon/usage: omit DAMOS filter details in favor of design doc SeongJae Park
2024-12-26 22:14 ` [RFC PATCH 10/10] Docs/admin-guide/mm/damon/usage: document DAMOS filter 'pass' sysfs file SeongJae Park
2024-12-26 22:27 ` 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).