Commit 209e6313 authored by SeongJae Park's avatar SeongJae Park Committed by Andrew Morton

selftests/damon/_damon_sysfs: support schemes_update_tried_regions

Implement schemes_update_tried_regions DAMON sysfs command on
_damon_sysfs.py, to use on implementations of future tests for the
feature.

Link: https://lkml.kernel.org/r/20240625180538.73134-3-sj@kernel.orgSigned-off-by: default avatarSeongJae Park <sj@kernel.org>
Cc: Shuah Khan <shuah@kernel.org>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
parent 34ec4344
...@@ -175,16 +175,24 @@ class DamosStats: ...@@ -175,16 +175,24 @@ class DamosStats:
self.sz_applied = sz_applied self.sz_applied = sz_applied
self.qt_exceeds = qt_exceeds self.qt_exceeds = qt_exceeds
class DamosTriedRegion:
def __init__(self, start, end, nr_accesses, age):
self.start = start
self.end = end
self.nr_accesses = nr_accesses
self.age = age
class Damos: class Damos:
action = None action = None
access_pattern = None access_pattern = None
quota = None quota = None
apply_interval_us = None apply_interval_us = None
# todo: Support watermarks, stats, tried_regions # todo: Support watermarks, stats
idx = None idx = None
context = None context = None
tried_bytes = None tried_bytes = None
stats = None stats = None
tried_regions = None
def __init__(self, action='stat', access_pattern=DamosAccessPattern(), def __init__(self, action='stat', access_pattern=DamosAccessPattern(),
quota=DamosQuota(), apply_interval_us=0): quota=DamosQuota(), apply_interval_us=0):
...@@ -398,6 +406,31 @@ class Kdamond: ...@@ -398,6 +406,31 @@ class Kdamond:
err = write_file(os.path.join(self.sysfs_dir(), 'state'), 'on') err = write_file(os.path.join(self.sysfs_dir(), 'state'), 'on')
return err return err
def update_schemes_tried_regions(self):
err = write_file(os.path.join(self.sysfs_dir(), 'state'),
'update_schemes_tried_regions')
if err is not None:
return err
for context in self.contexts:
for scheme in context.schemes:
tried_regions = []
tried_regions_dir = os.path.join(
scheme.sysfs_dir(), 'tried_regions')
for filename in os.listdir(
os.path.join(scheme.sysfs_dir(), 'tried_regions')):
tried_region_dir = os.path.join(tried_regions_dir, filename)
if not os.path.isdir(tried_region_dir):
continue
region_values = []
for f in ['start', 'end', 'nr_accesses', 'age']:
content, err = read_file(
os.path.join(tried_region_dir, f))
if err is not None:
return err
region_values.append(int(content))
tried_regions.append(DamosTriedRegion(*region_values))
scheme.tried_regions = tried_regions
def update_schemes_tried_bytes(self): def update_schemes_tried_bytes(self):
err = write_file(os.path.join(self.sysfs_dir(), 'state'), err = write_file(os.path.join(self.sysfs_dir(), 'state'),
'update_schemes_tried_bytes') 'update_schemes_tried_bytes')
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment