summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSeongJae Park <sj@kernel.org>2024-02-07 21:31:28 +0100
committerAndrew Morton <akpm@linux-foundation.org>2024-02-22 19:24:56 +0100
commita0f87454c0e397431d1eb0bb1d9e6c0fab0fbe2b (patch)
treed6a69b948307e00c611c3dbfd6bd59d5adcbbdcf
parentselftests/damon/_damon_sysfs: support DAMOS quota (diff)
downloadlinux-a0f87454c0e397431d1eb0bb1d9e6c0fab0fbe2b.tar.xz
linux-a0f87454c0e397431d1eb0bb1d9e6c0fab0fbe2b.zip
selftests/damon/_damon_sysfs: support DAMOS stats
Update the test-purpose DAMON sysfs control Python module to support DAMOS stats. Link: https://lkml.kernel.org/r/20240207203134.69976-3-sj@kernel.org Signed-off-by: SeongJae Park <sj@kernel.org> Cc: Shuah Khan <shuah@kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
-rw-r--r--tools/testing/selftests/damon/_damon_sysfs.py32
1 files changed, 32 insertions, 0 deletions
diff --git a/tools/testing/selftests/damon/_damon_sysfs.py b/tools/testing/selftests/damon/_damon_sysfs.py
index b4f6e385c564..a75244451684 100644
--- a/tools/testing/selftests/damon/_damon_sysfs.py
+++ b/tools/testing/selftests/damon/_damon_sysfs.py
@@ -96,6 +96,20 @@ class DamosQuota:
if err != None:
return err
+class DamosStats:
+ nr_tried = None
+ sz_tried = None
+ nr_applied = None
+ sz_applied = None
+ qt_exceeds = None
+
+ def __init__(self, nr_tried, sz_tried, nr_applied, sz_applied, qt_exceeds):
+ self.nr_tried = nr_tried
+ self.sz_tried = sz_tried
+ self.nr_applied = nr_applied
+ self.sz_applied = sz_applied
+ self.qt_exceeds = qt_exceeds
+
class Damos:
action = None
access_pattern = None
@@ -104,6 +118,7 @@ class Damos:
idx = None
context = None
tried_bytes = None
+ stats = None
def __init__(self, action='stat', access_pattern=DamosAccessPattern(),
quota=DamosQuota()):
@@ -322,6 +337,23 @@ class Kdamond:
return err
scheme.tried_bytes = int(content)
+ def update_schemes_stats(self):
+ err = write_file(os.path.join(self.sysfs_dir(), 'state'),
+ 'update_schemes_stats')
+ if err != None:
+ return err
+ for context in self.contexts:
+ for scheme in context.schemes:
+ stat_values = []
+ for stat in ['nr_tried', 'sz_tried', 'nr_applied',
+ 'sz_applied', 'qt_exceeds']:
+ content, err = read_file(
+ os.path.join(scheme.sysfs_dir(), 'stats', stat))
+ if err != None:
+ return err
+ stat_values.append(int(content))
+ scheme.stats = DamosStats(*stat_values)
+
class Kdamonds:
kdamonds = []