From: SeongJae Park Date: Sat, 28 Jun 2025 16:04:28 +0000 (-0700) Subject: selftests/damon/sysfs.py: test DAMOS schemes parameters setup X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=603cb4aa09a14157ba412ba4db9dffebb79eb598;p=thirdparty%2Fkernel%2Flinux.git selftests/damon/sysfs.py: test DAMOS schemes parameters setup Add DAMON sysfs interface functionality tests for basic DAMOS schemes parameters setup. Link: https://lkml.kernel.org/r/20250628160428.53115-7-sj@kernel.org Signed-off-by: SeongJae Park Cc: Shuah Khan Signed-off-by: Andrew Morton --- diff --git a/tools/testing/selftests/damon/sysfs.py b/tools/testing/selftests/damon/sysfs.py index 3b085268f342c..e67008fd055df 100755 --- a/tools/testing/selftests/damon/sysfs.py +++ b/tools/testing/selftests/damon/sysfs.py @@ -29,7 +29,9 @@ def main(): kdamonds = _damon_sysfs.Kdamonds( [_damon_sysfs.Kdamond( contexts=[_damon_sysfs.DamonCtx( - targets=[_damon_sysfs.DamonTarget(pid=-1)])])]) + targets=[_damon_sysfs.DamonTarget(pid=-1)], + schemes=[_damon_sysfs.Damos()], + )])]) err = kdamonds.start() if err is not None: print('kdamond start failed: %s' % err) @@ -66,8 +68,46 @@ def main(): { 'pid': 0, 'nr_regions': 0, 'regions_list': []}]: fail('adaptive targets', status) - if ctx['schemes'] != []: - fail('schemes') + if len(ctx['schemes']) != 1: + fail('number of schemes', status) + + scheme = ctx['schemes'][0] + if scheme['pattern'] != { + 'min_sz_region': 0, + 'max_sz_region': 2**64 - 1, + 'min_nr_accesses': 0, + 'max_nr_accesses': 2**32 - 1, + 'min_age_region': 0, + 'max_age_region': 2**32 - 1, + }: + fail('damos pattern', status) + if scheme['action'] != 9: # stat + fail('damos action', status) + if scheme['apply_interval_us'] != 0: + fail('damos apply interval', status) + if scheme['target_nid'] != -1: + fail('damos target nid', status) + + if scheme['quota'] != { + 'reset_interval': 0, + 'ms': 0, + 'sz': 0, + 'goals': [], + 'esz': 0, + 'weight_sz': 0, + 'weight_nr_accesses': 0, + 'weight_age': 0, + }: + fail('damos quota', status) + + if scheme['wmarks'] != { + 'metric': 0, + 'interval': 0, + 'high': 0, + 'mid': 0, + 'low': 0, + }: + fail('damos wmarks', status) kdamonds.stop()