mirror of
https://github.com/torvalds/linux.git
synced 2026-05-30 18:13:41 +02:00
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>
This commit is contained in:
parent
faf4977ef0
commit
a0f87454c0
|
|
@ -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 = []
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user