selftests/damon: test kdamond refresh_ms
Subsystems (3)
SJ Park
maintainerv2 cover selftests/damon: test kdamond refresh_ms
The kdamond 'refresh_ms' sysfs file makes DAMON periodically update its read-only sysfs files (DAMOS stats, tuned monitoring intervals and the kdamond pid) on its own, so users don't have to write update keywords such as 'update_schemes_stats' to the 'state' file. It has no selftest coverage.
The first patch adds refresh_ms support to the _damon_sysfs.py test control module. The second adds a test that sets refresh_ms and confirms a scheme's stats are updated under sysfs without an explicit update request; the test skips on kernels that predate the refresh_ms file.
Tested on current mainline under a DAMON-enabled kernel: the new test passes and the existing DAMON selftests show no new failures.
Changes from v1
- v1: https://lore.kernel.org/[email protected]
- Add R-b: from SJ.
- Rebase to latest mm-new.
Ruslan Valiyev (2):
selftests/damon/_damon_sysfs: support kdamond refresh_ms selftests/damon/sysfs_refresh: test kdamond refresh_ms
tools/testing/selftests/damon/Makefile | 1 + tools/testing/selftests/damon/_damon_sysfs.py | 9 ++- .../testing/selftests/damon/sysfs_refresh.py | 75 +++++++++++++++++++ 3 files changed, 84 insertions(+), 1 deletion(-) create mode 100755 tools/testing/selftests/damon/sysfs_refresh.py
base-commit: f46247bcce72b9e62868c347711c772657b00ce6
Signature · 1 line
2.47.3
SJ Park
maintainerPATCH v2 1/2 selftests/damon/_damon_sysfs: support kdamond refresh_ms
From: Ruslan Valiyev <[email protected]>
The Kdamond class has no way to set the kdamond-level 'refresh_ms' sysfs file, which makes DAMON periodically update the read-only sysfs files (DAMOS stats, tuned monitoring intervals and the kdamond pid) on its own.
Add a 'refresh_ms' parameter to Kdamond. When it is set (including to zero, to disable the periodic update), write it before turning the kdamond on, so tests can exercise the auto-update behavior. Leaving it unset keeps the previous behavior of not touching the file, so callers running against kernels without the feature are unaffected.
--- tools/testing/selftests/damon/_damon_sysfs.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
tools/testing/selftests/damon/_damon_sysfs.py +8 -1
@@ -698,12 +698,14 @@ class DamonCtx: class Kdamond: state = None pid = None + refresh_ms = None contexts = None idx = None # index of this kdamond between siblings kdamonds = None # parent - def __init__(self, contexts=[]): + def __init__(self, contexts=[], refresh_ms=None): self.contexts = contexts + self.refresh_ms = refresh_ms for idx, context in enumerate(self.contexts): context.idx = idx context.kdamond = self
@@ -726,6 +728,11 @@ class Kdamond: err = context.stage() if err is not None: return err + if self.refresh_ms is not None: + err = write_file(os.path.join(self.sysfs_dir(), 'refresh_ms'), + '%d' % self.refresh_ms) + if err is not None: + return err err = write_file(os.path.join(self.sysfs_dir(), 'state'), 'on') if err is not None: return err
Signature · 1 line
2.47.3
SJ Park
maintainerPATCH v2 2/2 selftests/damon/sysfs_refresh: test kdamond refresh_ms
In reply to SJ ParkFrom: Ruslan Valiyev <[email protected]>
Writing a non-zero value to a kdamond's 'refresh_ms' sysfs file should make DAMON periodically update the read-only sysfs files on its own, without the user writing update keywords such as 'update_schemes_stats' to the 'state' file. This behavior has no test coverage.
Add a test that starts a kdamond with refresh_ms set and a 'stat' scheme whose default access pattern matches every monitored region, then polls the scheme's 'nr_tried' stats file directly, without requesting an update. The value can become non-zero only via the periodic refresh, so the test confirms refresh_ms works; with refresh_ms disabled the stat stays zero and the test fails.
--- tools/testing/selftests/damon/Makefile | 1 + .../testing/selftests/damon/sysfs_refresh.py | 75 +++++++++++++++++++ 2 files changed, 76 insertions(+) create mode 100755 tools/testing/selftests/damon/sysfs_refresh.py
tools/testing/selftests/damon/Makefile +1 -0
@@ -13,6 +13,7 @@ TEST_PROGS += sysfs.py TEST_PROGS += sysfs_update_schemes_tried_regions_wss_estimation.py TEST_PROGS += damos_quota.py damos_quota_goal.py damos_apply_interval.py TEST_PROGS += damos_tried_regions.py damon_nr_regions.py +TEST_PROGS += sysfs_refresh.py TEST_PROGS += reclaim.sh lru_sort.sh # regression tests (reproducers of previously found bugs)
tools/testing/selftests/damon/sysfs_refresh.py new file +75 -0
75 lines not on this page · raw message
Signature · 1 line
2.47.3