selftests/damon/_damon_sysfs: implement updat_schemes_tried_bytes command
Implement update_schemes_tried_bytes command of DAMON sysfs interface in _damon_sysfs.py. It is not only making the update, but also read the updated value from the sysfs interface and store it in the Kdamond python objects so that the user of the module can easily get the value. Link: https://lkml.kernel.org/r/20231212194810.54457-4-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:
committed by
Andrew Morton
parent
f5f0e5a2be
commit
3402c6ce39
@@ -76,6 +76,7 @@ class Damos:
|
||||
# todo: Support quotas, watermarks, stats, tried_regions
|
||||
idx = None
|
||||
context = None
|
||||
tried_bytes = None
|
||||
|
||||
def __init__(self, action='stat', access_pattern=DamosAccessPattern()):
|
||||
self.action = action
|
||||
@@ -284,6 +285,19 @@ class Kdamond:
|
||||
err = write_file(os.path.join(self.sysfs_dir(), 'state'), 'on')
|
||||
return err
|
||||
|
||||
def update_schemes_tried_bytes(self):
|
||||
err = write_file(os.path.join(self.sysfs_dir(), 'state'),
|
||||
'update_schemes_tried_bytes')
|
||||
if err != None:
|
||||
return err
|
||||
for context in self.contexts:
|
||||
for scheme in context.schemes:
|
||||
content, err = read_file(os.path.join(scheme.sysfs_dir(),
|
||||
'tried_regions', 'total_bytes'))
|
||||
if err != None:
|
||||
return err
|
||||
scheme.tried_bytes = int(content)
|
||||
|
||||
class Kdamonds:
|
||||
kdamonds = []
|
||||
|
||||
|
||||
Reference in New Issue
Block a user