mm/damon: minor fixes and cleanups
Subsystems (5)
SeongJae Park
maintainercover mm/damon: minor fixes and cleanups
This patchset contains minor fixes and cleanups for DAMON including
- selftest for a bug we found before (Patch 1),
- fix of region holes in vaddr corner case and a kunit test for it (Patches 2 and 3), and
- documents/Kconfig updates for title wordsmithing (Patch 4) and more aggressive DAMON debugfs interface deprecation announcement (Patches 5-7).
SeongJae Park (7):
selftest/damon: add a test for duplicate context dirs creation mm/damon/core: avoid holes in newly set monitoring target ranges mm/damon/core-test: test damon_set_regions Docs/admin-guide/mm/damon: rename the title of the document mm/damon/Kconfig: Notify debugfs deprecation plan Docs/DAMON/start: mention the dependency as sysfs instead of debugfs Docs/admin-guide/mm/damon/usage: note DAMON debugfs interface
deprecation plan
Documentation/admin-guide/mm/damon/index.rst | 6 ++--- Documentation/admin-guide/mm/damon/start.rst | 13 +++------ Documentation/admin-guide/mm/damon/usage.rst | 5 ++++ mm/damon/Kconfig | 3 +++ mm/damon/core-test.h | 23 ++++++++++++++++ mm/damon/core.c | 24 +++++++++++++++++ tools/testing/selftests/damon/Makefile | 1 + .../debugfs_duplicate_context_creation.sh | 27 +++++++++++++++++++ 8 files changed, 89 insertions(+), 13 deletions(-) create mode 100644 tools/testing/selftests/damon/debugfs_duplicate_context_creation.sh
Signature · 1 line
2.25.1
SeongJae Park
maintainerPATCH 1/7 selftest/damon: add a test for duplicate context dirs creation
Commit d26f60703606 ("mm/damon/dbgfs: avoid duplicate context directory creation") fixes a bug which could result in memory leak and DAMON disablement. This commit adds a selftest for verifying the fix and avoid regression.
--- tools/testing/selftests/damon/Makefile | 1 + .../debugfs_duplicate_context_creation.sh | 27 +++++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 tools/testing/selftests/damon/debugfs_duplicate_context_creation.sh
tools/testing/selftests/damon/Makefile +1 -0
@@ -6,6 +6,7 @@ TEST_GEN_FILES += huge_count_read_write TEST_FILES = _chk_dependency.sh _debugfs_common.sh TEST_PROGS = debugfs_attrs.sh debugfs_schemes.sh debugfs_target_ids.sh TEST_PROGS += debugfs_empty_targets.sh debugfs_huge_count_read_write.sh +TEST_PROGS += debugfs_duplicate_context_creation.sh TEST_PROGS += sysfs.sh include ../lib.mk
tools/testing/selftests/damon/debugfs_duplicate_context_creation.sh new file +27 -0
@@ -0,0 +1,27 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-2.0 + +source _debugfs_common.sh + +# Test duplicated context creation +# ================================ + +if ! echo foo > "$DBGFS/mk_contexts" +then + echo "context creation failed" + exit 1 +fi + +if echo foo > "$DBGFS/mk_contexts" +then + echo "duplicate context creation success" + exit 1 +fi + +if ! echo foo > "$DBGFS/rm_contexts" +then + echo "context deletion failed" + exit 1 +fi + +exit 0
Signature · 1 line
2.25.1
SeongJae Park
maintainerPATCH 2/7 mm/damon/core: avoid holes in newly set monitoring target ranges
In reply to SeongJae ParkWhen there are two or more non-contiguous regions intersecting with given new ranges, 'damon_set_regions()' does not fill the holes. This commit makes the function to fill the holes with newly created regions.
--- mm/damon/core.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+)
mm/damon/core.c +24 -0
@@ -168,6 +168,27 @@ static bool damon_intersect(struct damon_region *r,return !(r->ar.end <= re->start || re->end <= r->ar.start); } +/* +* Fill holes in regions with new regions. +*/ +static void damon_fill_regions_holes (struct damon_region *first, +struct damon_region *last,struct damon_target *t) +{ +struct damon_region *r = first; + +damon_for_each_region_from (r, t) { +struct damon_region *next, *newr; + +if (r == last) +break ; + next =damon_next_region (r); +if (r->ar.end != next->ar.start) { + newr =damon_new_region (r->ar.end, next->ar.start); +damon_insert_region (newr, r, next, t); + } + } +} +/* * damon_set_regions() - Set regions of a target for given address ranges. * @t: the given target.
@@ -226,6 +247,9 @@ int damon_set_regions(struct damon_target *t, struct damon_addr_range *ranges, first->ar.start =ALIGN_DOWN (range->start,DAMON_MIN_REGION ); last->ar.end =ALIGN (range->end,DAMON_MIN_REGION ); + +/* fill possible holes in the range */ +damon_fill_regions_holes (first, last, t); } }return 0 ;
Signature · 1 line
2.25.1
SeongJae Park
maintainerPATCH 3/7 mm/damon/core-test: test damon_set_regions
In reply to SeongJae ParkPreceding commit fixes a bug in 'damon_set_regions()', which allows holes in the new monitoring target ranges. This commit adds a kunit test case for the problem to avoid any regression.
--- mm/damon/core-test.h | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+)
mm/damon/core-test.h +23 -0
@@ -267,6 +267,28 @@ static void damon_test_ops_registration(struct kunit *test)KUNIT_EXPECT_EQ (test,damon_register_ops (&ops), -EINVAL ); } +static void damon_test_set_regions (struct kunit *test) +{ +struct damon_target *t =damon_new_target (); +struct damon_region *r1 =damon_new_region (4 ,16 ); +struct damon_region *r2 =damon_new_region (24 ,32 ); +struct damon_addr_range range = {.start =8 , .end =28 }; +unsigned long expects[] = {8 ,16 ,16 ,24 ,24 ,28 }; +int expect_idx =0 ; +struct damon_region *r; + +damon_add_region (r1, t); +damon_add_region (r2, t); +damon_set_regions (t, &range,1 ); + +KUNIT_EXPECT_EQ (test,damon_nr_regions (t),3 ); +damon_for_each_region (r, t) { +KUNIT_EXPECT_EQ (test, r->ar.start, expects[expect_idx++]); +KUNIT_EXPECT_EQ (test, r->ar.end, expects[expect_idx++]); + } +damon_destroy_target (t); +} +static struct kunit_case damon_test_cases[] = {KUNIT_CASE (damon_test_target),KUNIT_CASE (damon_test_regions),
@@ -276,6 +298,7 @@ static struct kunit_case damon_test_cases[] = {KUNIT_CASE (damon_test_merge_regions_of),KUNIT_CASE (damon_test_split_regions_of),KUNIT_CASE (damon_test_ops_registration), + KUNIT_CASE(damon_test_set_regions), {}, };
Signature · 1 line
2.25.1
SeongJae Park
maintainerPATCH 4/7 Docs/admin-guide/mm/damon: rename the title of the document
In reply to SeongJae ParkThe title of the DAMON document for admin-guide, 'Monitoring Data Accesses', could confuse readers in some ways. First of all, DAMON is not the only single way for data access monitoring. And the document is for not only the data access monitoring but also data access pattern based memory management optimizations (DAMOS). This commit updates the title to 'DAMON: Data Access MONitor', which more explicitly explains what the document describes.
--- Documentation/admin-guide/mm/damon/index.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
Documentation/admin-guide/mm/damon/index.rst +3 -3
@@ -1,8 +1,8 @@ .. SPDX-License-Identifier: GPL-2.0 -======================== -Monitoring Data Accesses -======================== +========================== +DAMON: Data Access MONitor +========================== :doc:`DAMON </mm/damon/index>` allows light-weight data access monitoring. Using DAMON, users can analyze the memory access patterns of their systems and
Signature · 1 line
2.25.1
SeongJae Park
maintainerPATCH 5/7 mm/damon/Kconfig: Notify debugfs deprecation plan
In reply to SeongJae ParkCommit b18402726bd1 ("Docs/admin-guide/mm/damon/usage: document DAMON sysfs interface") announced the DAMON debugfs interface deprecation plan, but it is not so aggressively announced. As the deprecation time is coming, this commit makes the announce more easy to be found by adding the note to the config menu of DAMON debugfs interface.
--- mm/damon/Kconfig | 3 +++ 1 file changed, 3 insertions(+)
mm/damon/Kconfig +3 -0
@@ -68,6 +68,9 @@ config DAMON_DBGFS If unsure, say N. + This will be removed after >5.15.y LTS kernel is released, so users + should move to the sysfs interface (DAMON_SYSFS). + config DAMON_DBGFS_KUNIT_TEST bool "Test for damon debugfs interface" if !KUNIT_ALL_TESTS depends on DAMON_DBGFS && KUNIT=y
Signature · 1 line
2.25.1
SeongJae Park
maintainerPATCH 6/7 Docs/admin-guide/mm/damon/start: mention the dependency as sysfs instead of debugfs
In reply to SeongJae Park'Getting Started' document of DAMON says DAMON user-space tool, damo[1], is using DAMON debugfs interface, and therefore it needs to ensure debugfs is mounted. However, the latest version of the tool is using DAMON sysfs interface. Moreover, DAMON debugfs interface is going to be deprecated as announced by commit b18402726bd1 ("Docs/admin-guide/mm/damon/usage: document DAMON sysfs interface").
This commit therefore update the document to tell readers about DAMON sysfs interface dependency instead and never mention about debugfs interface, which will be deprecated.
[1] https://github.com/awslabs/damo
--- Documentation/admin-guide/mm/damon/start.rst | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-)
Documentation/admin-guide/mm/damon/start.rst +3 -10
@@ -29,16 +29,9 @@ called DAMON Operator (DAMO). It is available at https://github.com/awslabs/damo. The examples below assume that ``damo`` is on your ``$PATH``. It's not mandatory, though. -Because DAMO is using the debugfs interface (refer to :doc:`usage` for the -detail) of DAMON, you should ensure debugfs is mounted. Mount it manually as -below:: - - # mount -t debugfs none /sys/kernel/debug/ - -or append the following line to your ``/etc/fstab`` file so that your system -can automatically mount debugfs upon booting:: - - debugfs /sys/kernel/debug debugfs defaults 0 0 +Because DAMO is using the sysfs interface (refer to :doc:`usage` for the +detail) of DAMON, you should ensure :doc:`sysfs </filesystems/sysfs>` is +mounted. Recording Data Access Patterns
Signature · 1 line
2.25.1
SeongJae Park
maintainerPATCH 7/7 Docs/admin-guide/mm/damon/usage: note DAMON debugfs interface deprecation plan
In reply to SeongJae ParkCommit b18402726bd1 ("Docs/admin-guide/mm/damon/usage: document DAMON sysfs interface") announced the DAMON debugfs interface deprecation plan, but it is not so aggressively announced. As the deprecation time is coming, this commit makes the announce more easy to be found by adding the note at the beginning of the DAMON debugfs interface usage document.
--- Documentation/admin-guide/mm/damon/usage.rst | 5 +++++ 1 file changed, 5 insertions(+)
Documentation/admin-guide/mm/damon/usage.rst +5 -0
@@ -393,6 +393,11 @@ the files as above. Above is only for an example. debugfs Interface ================= +.. note:: + + DAMON debugfs interface will be removed after next LTS kernel is released, so + users should move to the :ref:`sysfs interface <sysfs_interface>`. + DAMON exports eight files, ``attrs``, ``target_ids``, ``init_regions``, ``schemes``, ``monitor_on``, ``kdamond_pid``, ``mk_contexts`` and ``rm_contexts`` under its debugfs directory, ``<debugfs>/damon/``.
Signature · 1 line
2.25.1