misc fixups for DAMON {self,kunit} tests
Subsystems (3)
SeongJae Park
maintainercover misc fixups for DAMON {self,kunit} tests
This patchset is for minor fixups of DAMON selftests and kunit tests. First three patches make DAMON selftests more cleanly maintained (patches 1 and 2) without unnecessary warnings (patch 3). Following six patches remove unnecessary test case (patch 4), handle configs combinations that can make tests fail (patches 5-7), reorganize the test files following the new guideline (patch 8), and add reference kunitconfig for DAMON kunit tests (patch 9).
SeongJae Park (9):
selftests/damon: add access_memory_even to .gitignore selftests/damon: cleanup __pycache__/ with 'make clean' selftests/damon: add execute permissions to test scripts mm/damon/core-test: test only vaddr case on ops registration test mm/damon/core-test: fix damon_test_ops_registration() for DAMON_VADDR
unset case
mm/damon/dbgfs-test: skip dbgfs_set_targets() test if PADDR is not
registered
mm/damon/dbgfs-test: skip dbgfs_set_init_regions() test if PADDR is
not registered
mm/damon: move kunit tests to tests/ subdirectory with _kunit suffix mm/damon/tests: add .kunitconfig file for DAMON kunit tests
mm/damon/core.c | 2 +-
mm/damon/dbgfs.c | 2 +-
mm/damon/sysfs.c | 2 +-
mm/damon/tests/.kunitconfig | 22 ++++++++++++++++++
mm/damon/{core-test.h => tests/core-kunit.h} | 23 ++++++++++++++-----
.../{dbgfs-test.h => tests/dbgfs-kunit.h} | 10 ++++++++
.../{sysfs-test.h => tests/sysfs-kunit.h} | 0
.../{vaddr-test.h => tests/vaddr-kunit.h} | 0
mm/damon/vaddr.c | 2 +-
tools/testing/selftests/damon/.gitignore | 1 +
tools/testing/selftests/damon/Makefile | 2 ++
.../selftests/damon/damon_nr_regions.py | 0
.../selftests/damon/damos_apply_interval.py | 0
tools/testing/selftests/damon/damos_quota.py | 0
.../selftests/damon/damos_quota_goal.py | 0
.../selftests/damon/damos_tried_regions.py | 0
.../damon/debugfs_target_ids_pid_leak.sh | 0
...s_target_ids_read_before_terminate_race.sh | 0
...sysfs_update_schemes_tried_regions_hang.py | 0
...te_schemes_tried_regions_wss_estimation.py | 0
20 files changed, 56 insertions(+), 10 deletions(-)
create mode 100644 mm/damon/tests/.kunitconfig
rename mm/damon/{core-test.h => tests/core-kunit.h} (96%)
rename mm/damon/{dbgfs-test.h => tests/dbgfs-kunit.h} (94%)
rename mm/damon/{sysfs-test.h => tests/sysfs-kunit.h} (100%)
rename mm/damon/{vaddr-test.h => tests/vaddr-kunit.h} (100%)
mode change 100644 => 100755 tools/testing/selftests/damon/damon_nr_regions.py
mode change 100644 => 100755 tools/testing/selftests/damon/damos_apply_interval.py
mode change 100644 => 100755 tools/testing/selftests/damon/damos_quota.py
mode change 100644 => 100755 tools/testing/selftests/damon/damos_quota_goal.py
mode change 100644 => 100755 tools/testing/selftests/damon/damos_tried_regions.py
mode change 100644 => 100755 tools/testing/selftests/damon/debugfs_target_ids_pid_leak.sh
mode change 100644 => 100755 tools/testing/selftests/damon/debugfs_target_ids_read_before_terminate_race.sh
mode change 100644 => 100755 tools/testing/selftests/damon/sysfs_update_schemes_tried_regions_hang.py
mode change 100644 => 100755 tools/testing/selftests/damon/sysfs_update_schemes_tried_regions_wss_estimation.pybase-commit: ac23a0bb201e9916faa357d51c387e523813b4ad
Signature · 1 line
2.39.2
SeongJae Park
maintainerPATCH 1/9 selftests/damon: add access_memory_even to .gitignore
DAMON selftests build access_memory_even, but its not on the .gitignore list. Add it to make 'git status' output cleaner.
--- tools/testing/selftests/damon/.gitignore | 1 + 1 file changed, 1 insertion(+)
tools/testing/selftests/damon/.gitignore +1 -0
@@ -3,3 +3,4 @@ huge_count_read_write debugfs_target_ids_read_before_terminate_race debugfs_target_ids_pid_leak access_memory +access_memory_even
Signature · 1 line
2.39.2
SeongJae Park
maintainerPATCH 2/9 selftests/damon: cleanup __pycache__/ with 'make clean'
In reply to SeongJae ParkPython-based tests creates __pycache__/ directory. Remove it with 'make clean' by defining it as EXTRA_CLEAN.
--- tools/testing/selftests/damon/Makefile | 2 ++ 1 file changed, 2 insertions(+)
tools/testing/selftests/damon/Makefile +2 -0
@@ -25,4 +25,6 @@ TEST_PROGS += debugfs_target_ids_pid_leak.sh TEST_PROGS += sysfs_update_removed_scheme_dir.sh TEST_PROGS += sysfs_update_schemes_tried_regions_hang.py +EXTRA_CLEAN = __pycache__ + include ../lib.mk
Signature · 1 line
2.39.2
SeongJae Park
maintainerPATCH 3/9 selftests/damon: add execute permissions to test scripts
In reply to SeongJae ParkSome test scripts are missing executable permissions. It causes warnings that make the test output unnecessarily verbose. Add executable permissions.
---
Andrew, please note that this patch is for adding the execution permission to the files. I guess these need a special handling for your tooling.
tools/testing/selftests/damon/damon_nr_regions.py | 0 tools/testing/selftests/damon/damos_apply_interval.py | 0 tools/testing/selftests/damon/damos_quota.py | 0 tools/testing/selftests/damon/damos_quota_goal.py | 0 tools/testing/selftests/damon/damos_tried_regions.py | 0 tools/testing/selftests/damon/debugfs_target_ids_pid_leak.sh | 0 .../damon/debugfs_target_ids_read_before_terminate_race.sh | 0 .../selftests/damon/sysfs_update_schemes_tried_regions_hang.py | 0 .../damon/sysfs_update_schemes_tried_regions_wss_estimation.py | 0 9 files changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 tools/testing/selftests/damon/damon_nr_regions.py mode change 100644 => 100755 tools/testing/selftests/damon/damos_apply_interval.py mode change 100644 => 100755 tools/testing/selftests/damon/damos_quota.py mode change 100644 => 100755 tools/testing/selftests/damon/damos_quota_goal.py mode change 100644 => 100755 tools/testing/selftests/damon/damos_tried_regions.py mode change 100644 => 100755 tools/testing/selftests/damon/debugfs_target_ids_pid_leak.sh mode change 100644 => 100755 tools/testing/selftests/damon/debugfs_target_ids_read_before_terminate_race.sh mode change 100644 => 100755 tools/testing/selftests/damon/sysfs_update_schemes_tried_regions_hang.py mode change 100644 => 100755 tools/testing/selftests/damon/sysfs_update_schemes_tried_regions_wss_estimation.py
tools/testing/selftests/damon/damon_nr_regions.py +0 -0
tools/testing/selftests/damon/damos_apply_interval.py +0 -0
tools/testing/selftests/damon/damos_quota.py +0 -0
tools/testing/selftests/damon/damos_quota_goal.py +0 -0
tools/testing/selftests/damon/damos_tried_regions.py +0 -0
tools/testing/selftests/damon/debugfs_target_ids_pid_leak.sh +0 -0
tools/testing/selftests/damon/debugfs_target_ids_read_before_terminate_race.sh +0 -0
tools/testing/selftests/damon/sysfs_update_schemes_tried_regions_hang.py +0 -0
tools/testing/selftests/damon/sysfs_update_schemes_tried_regions_wss_estimation.py +0 -0
Signature · 1 line
2.39.2
SeongJae Park
maintainerPATCH 4/9 mm/damon/core-test: test only vaddr case on ops registration test
In reply to SeongJae ParkDAMON ops registration kunit test tests both vaddr and paddr use cases in parts of the whole test cases. Basically testing only one ops use case is enough. Do the test with only vaddr use case.
--- mm/damon/core-test.h | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)
mm/damon/core-test.h +2 -6
@@ -246,16 +246,12 @@ static void damon_test_split_regions_of(struct kunit *test)static void damon_test_ops_registration (struct kunit *test) {struct damon_ctx *c =damon_new_ctx (); -struct damon_operations ops, bak; +struct damon_operations ops = {.id =DAMON_OPS_VADDR }, bak; -/* DAMON_OPS_{V,P}ADDR are registered on subsys_initcall */ +/* DAMON_OPS_VADDR is registered on subsys_initcall */ KUNIT_EXPECT_EQ (test,damon_select_ops (c,DAMON_OPS_VADDR ),0 ); -KUNIT_EXPECT_EQ (test,damon_select_ops (c,DAMON_OPS_PADDR ),0 );/* Double-registration is prohibited */ - ops.id =DAMON_OPS_VADDR ; -KUNIT_EXPECT_EQ (test,damon_register_ops (&ops), -EINVAL ); - ops.id =DAMON_OPS_PADDR ;KUNIT_EXPECT_EQ (test,damon_register_ops (&ops), -EINVAL );/* Unknown ops id cannot be registered */
Signature · 1 line
2.39.2
SeongJae Park
maintainerPATCH 5/9 mm/damon/core-test: fix damon_test_ops_registration() for DAMON_VADDR unset case
In reply to SeongJae ParkDAMON core kunit test can be executed without CONFIG_DAMON_VADDR. In the case, vaddr DAMON ops is not registered. Meanwhile, ops registration kunit test assumes the vaddr ops is registered. Check and handle the case by registrering fake vaddr ops inside the test code.
--- mm/damon/core-test.h | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-)
mm/damon/core-test.h +16 -1
@@ -247,8 +247,16 @@ static void damon_test_ops_registration(struct kunit *test) {struct damon_ctx *c =damon_new_ctx ();struct damon_operations ops = {.id =DAMON_OPS_VADDR }, bak; +bool need_cleanup = false; -/* DAMON_OPS_VADDR is registered on subsys_initcall */ +/* DAMON_OPS_VADDR is registered only if CONFIG_DAMON_VADDR is set */ +if (!damon_is_registered_ops (DAMON_OPS_VADDR )) { + bak.id =DAMON_OPS_VADDR ; +KUNIT_EXPECT_EQ (test,damon_register_ops (&bak),0 ); + need_cleanup = true; + } + +/* DAMON_OPS_VADDR is ensured to be registered */ KUNIT_EXPECT_EQ (test,damon_select_ops (c,DAMON_OPS_VADDR ),0 );/* Double-registration is prohibited */
@@ -274,6 +282,13 @@ static void damon_test_ops_registration(struct kunit *test)KUNIT_EXPECT_EQ (test,damon_register_ops (&ops), -EINVAL );damon_destroy_ctx (c); + +if (need_cleanup) { +mutex_lock (&damon_ops_lock); + damon_registered_ops[DAMON_OPS_VADDR ] = + (struct damon_operations ){}; +mutex_unlock (&damon_ops_lock); + } }static void damon_test_set_regions (struct kunit *test)
Signature · 1 line
2.39.2
SeongJae Park
maintainerPATCH 6/9 mm/damon/dbgfs-test: skip dbgfs_set_targets() test if PADDR is not registered
In reply to SeongJae ParkThe test depends on registration of DAMON_OPS_PADDR. It would be registered only when CONFIG_DAMON_PADDR is set. DAMON core kunit tests do fake ops registration for such case. However, the functions for such fake ops registration is not available to DAMON debugfs interface. Just skip the test in the case.
--- mm/damon/dbgfs-test.h | 5 +++++ 1 file changed, 5 insertions(+)
mm/damon/dbgfs-test.h +5 -0
@@ -73,6 +73,11 @@ static void damon_dbgfs_test_set_targets(struct kunit *test)struct damon_ctx *ctx =dbgfs_new_ctx ();char buf[64 ]; +if (!damon_is_registered_ops (DAMON_OPS_PADDR )) { +dbgfs_destroy_ctx (ctx); +kunit_skip (test,"PADDR not registered" ); + } +/* Make DAMON consider target has no pid */ damon_select_ops (ctx,DAMON_OPS_PADDR );
Signature · 1 line
2.39.2
SeongJae Park
maintainerPATCH 7/9 mm/damon/dbgfs-test: skip dbgfs_set_init_regions() test if PADDR is not registered
In reply to SeongJae ParkThe test depends on registration of DAMON_OPS_PADDR. It would be registered only when CONFIG_DAMON_PADDR is set. DAMON core kunit tests do fake ops registration for such case. However, the functions for such fake ops registration is not available to DAMON debugfs interface. Just skip the test in the case.
--- mm/damon/dbgfs-test.h | 5 +++++ 1 file changed, 5 insertions(+)
mm/damon/dbgfs-test.h +5 -0
@@ -116,6 +116,11 @@ static void damon_dbgfs_test_set_init_regions(struct kunit *test)int i, rc;char buf[256 ]; +if (!damon_is_registered_ops (DAMON_OPS_PADDR )) { +damon_destroy_ctx (ctx); +kunit_skip (test,"PADDR not registered" ); + } +damon_select_ops (ctx,DAMON_OPS_PADDR );dbgfs_set_targets (ctx,3 ,NULL );
Signature · 1 line
2.39.2
SeongJae Park
maintainerPATCH 8/9 mm/damon: move kunit tests to tests/ subdirectory with _kunit suffix
In reply to SeongJae ParkThere was a discussion about better places for kunit test code[1] and test file name suffix[2]. Folowwing the conclusion, move kunit tests for DAMON to mm/damon/tests/ subdirectory and rename those.
[1] https://lore.kernel.org/CABVgOS=pUdWb6NDHszuwb1HYws4a1-b1UmN=i8U_ED7HbDT0mg@mail.gmail.com
[2] https://lore.kernel.org/CABVgOSmKwPq7JEpHfS6sbOwsR0B-DBDk_JP-ZD9s9ZizvpUjbQ@mail.gmail.com
---
mm/damon/core.c | 2 +-
mm/damon/dbgfs.c | 2 +-
mm/damon/sysfs.c | 2 +-
mm/damon/{core-test.h => tests/core-kunit.h} | 0
mm/damon/{dbgfs-test.h => tests/dbgfs-kunit.h} | 0
mm/damon/{sysfs-test.h => tests/sysfs-kunit.h} | 0
mm/damon/{vaddr-test.h => tests/vaddr-kunit.h} | 0
mm/damon/vaddr.c | 2 +-
8 files changed, 4 insertions(+), 4 deletions(-)
rename mm/damon/{core-test.h => tests/core-kunit.h} (100%)
rename mm/damon/{dbgfs-test.h => tests/dbgfs-kunit.h} (100%)
rename mm/damon/{sysfs-test.h => tests/sysfs-kunit.h} (100%)
rename mm/damon/{vaddr-test.h => tests/vaddr-kunit.h} (100%)mm/damon/core.c +1 -1
@@ -2275,4 +2275,4 @@ static int __init damon_init(void)subsys_initcall (damon_init); -#include "core-test.h" +#include "tests/core-kunit.h"
mm/damon/dbgfs.c +1 -1
@@ -1145,4 +1145,4 @@ static int __init damon_dbgfs_init(void)module_init (damon_dbgfs_init); -#include "dbgfs-test.h" +#include "tests/dbgfs-kunit.h"
mm/damon/sysfs.c +1 -1
@@ -1908,4 +1908,4 @@ static int __init damon_sysfs_init(void) }subsys_initcall (damon_sysfs_init); -#include "sysfs-test.h" +#include "tests/sysfs-kunit.h"
mm/damon/tests/core-kunit.h renamed from mm/damon/core-test.h +0 -0
mm/damon/tests/dbgfs-kunit.h renamed from mm/damon/dbgfs-test.h +0 -0
mm/damon/tests/sysfs-kunit.h renamed from mm/damon/sysfs-test.h +0 -0
mm/damon/tests/vaddr-kunit.h renamed from mm/damon/vaddr-test.h +0 -0
mm/damon/vaddr.c +1 -1
@@ -730,4 +730,4 @@ static int __init damon_va_initcall(void)subsys_initcall (damon_va_initcall); -#include "vaddr-test.h" +#include "tests/vaddr-kunit.h"
Signature · 1 line
2.39.2
SeongJae Park
maintainerPATCH 9/9 mm/damon/tests: add .kunitconfig file for DAMON kunit tests
In reply to SeongJae Park'--kunitconfig' option of 'kunit.py run' supports '.kunitconfig' file name convention. Add the file for DAMON kunit tests for more convenient kunit run.
--- mm/damon/tests/.kunitconfig | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 mm/damon/tests/.kunitconfig
mm/damon/tests/.kunitconfig new file +22 -0
@@ -0,0 +1,22 @@ +# for DAMON core +CONFIG_KUNIT=y +CONFIG_DAMON=y +CONFIG_DAMON_KUNIT_TEST=y + +# for DAMON vaddr ops +CONFIG_MMU=y +CONFIG_PAGE_IDLE_FLAG=y +CONFIG_DAMON_VADDR=y +CONFIG_DAMON_VADDR_KUNIT_TEST=y + +# for DAMON sysfs interface +CONFIG_SYSFS=y +CONFIG_DAMON_SYSFS=y +CONFIG_DAMON_SYSFS_KUNIT_TEST=y + +# for DAMON debugfs interface +CONFIG_DEBUG_FS=y +CONFIG_DAMON_PADDR=y +CONFIG_DAMON_DBGFS_DEPRECATED=y +CONFIG_DAMON_DBGFS=y +CONFIG_DAMON_DBGFS_KUNIT_TEST=y
Signature · 1 line
2.39.2