Skip to content

Commit 5ac9ade

Browse files
sjp38akpm00
authored andcommitted
_damon_sysfs: implement commit() for online parameters update
Users can update DAMON parameters while it is running, using 'commit' DAMON sysfs interface command. For testing the feature in future tests, implement a function for doing that on the test-purpose DAMON sysfs interface wrapper Python module. Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: SeongJae Park <[email protected]> Cc: Shuah Khan <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent 7814973 commit 5ac9ade

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

tools/testing/selftests/damon/_damon_sysfs.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -481,6 +481,25 @@ def update_schemes_effective_quotas(self):
481481
goal.effective_bytes = int(content)
482482
return None
483483

484+
def commit(self):
485+
nr_contexts_file = os.path.join(self.sysfs_dir(),
486+
'contexts', 'nr_contexts')
487+
content, err = read_file(nr_contexts_file)
488+
if err is not None:
489+
return err
490+
if int(content) != len(self.contexts):
491+
err = write_file(nr_contexts_file, '%d' % len(self.contexts))
492+
if err is not None:
493+
return err
494+
495+
for context in self.contexts:
496+
err = context.stage()
497+
if err is not None:
498+
return err
499+
err = write_file(os.path.join(self.sysfs_dir(), 'state'), 'commit')
500+
return err
501+
502+
484503
def commit_schemes_quota_goals(self):
485504
for context in self.contexts:
486505
for scheme in context.schemes:

0 commit comments

Comments
 (0)