Commit faf4977e authored by SeongJae Park's avatar SeongJae Park Committed by Andrew Morton

selftests/damon/_damon_sysfs: support DAMOS quota

Patch series "selftests/damon: add more tests for core functionalities and
corner cases".

Continue DAMON selftests' test coverage improvement works with a trivial
improvement of the test code itself.  The sequence of the patches in
patchset is as follows.

The first five patches add two DAMON core functionalities tests.  Those
begins with three patches (patches 1-3) that update the test-purpose DAMON
sysfs interface wrapper to support DAMOS quota, stats, and apply interval
features, respectively.  The fourth patch implements and adds a selftest
for DAMOS quota feature, using the DAMON sysfs interface wrapper's newly
added support of the quota and the stats feature.  The fifth patch further
implements and adds a selftest for DAMOS apply interval using the DAMON
sysfs interface wrapper's newly added support of the apply interval and
the stats feature.

Two patches (patches 6 and 7) for implementing and adding two corner cases
handling selftests follow.  Those try to avoid two previously fixed bugs
from recurring.

Finally, a patch for making DAMON debugfs selftests dependency checker to
use /proc/mounts instead of the hard-coded mount point assumption follows.


This patch (of 8):

Update the test-purpose DAMON sysfs control Python module to support DAMOS
quota.

Link: https://lkml.kernel.org/r/20240207203134.69976-1-sj@kernel.org
Link: https://lkml.kernel.org/r/20240207203134.69976-2-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 0c32c9f7
...@@ -70,18 +70,48 @@ class DamosAccessPattern: ...@@ -70,18 +70,48 @@ class DamosAccessPattern:
if err != None: if err != None:
return err return err
class DamosQuota:
sz = None # size quota, in bytes
ms = None # time quota
reset_interval_ms = None # quota reset interval
scheme = None # owner scheme
def __init__(self, sz=0, ms=0, reset_interval_ms=0):
self.sz = sz
self.ms = ms
self.reset_interval_ms = reset_interval_ms
def sysfs_dir(self):
return os.path.join(self.scheme.sysfs_dir(), 'quotas')
def stage(self):
err = write_file(os.path.join(self.sysfs_dir(), 'bytes'), self.sz)
if err != None:
return err
err = write_file(os.path.join(self.sysfs_dir(), 'ms'), self.ms)
if err != None:
return err
err = write_file(os.path.join(self.sysfs_dir(), 'reset_interval_ms'),
self.reset_interval_ms)
if err != None:
return err
class Damos: class Damos:
action = None action = None
access_pattern = None access_pattern = None
# todo: Support quotas, watermarks, stats, tried_regions quota = None
# todo: Support watermarks, stats, tried_regions
idx = None idx = None
context = None context = None
tried_bytes = None tried_bytes = None
def __init__(self, action='stat', access_pattern=DamosAccessPattern()): def __init__(self, action='stat', access_pattern=DamosAccessPattern(),
quota=DamosQuota()):
self.action = action self.action = action
self.access_pattern = access_pattern self.access_pattern = access_pattern
self.access_pattern.scheme = self self.access_pattern.scheme = self
self.quota = quota
self.quota.scheme = self
def sysfs_dir(self): def sysfs_dir(self):
return os.path.join( return os.path.join(
...@@ -94,13 +124,7 @@ class Damos: ...@@ -94,13 +124,7 @@ class Damos:
err = self.access_pattern.stage() err = self.access_pattern.stage()
if err != None: if err != None:
return err return err
err = self.quota.stage()
# disable quotas
err = write_file(os.path.join(self.sysfs_dir(), 'quotas', 'ms'), '0')
if err != None:
return err
err = write_file(
os.path.join(self.sysfs_dir(), 'quotas', 'bytes'), '0')
if err != None: if err != None:
return err return err
......
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