diff options
author | SeongJae Park <sj38.park@gmail.com> | 2024-03-09 13:22:44 -0800 |
---|---|---|
committer | SeongJae Park <sj38.park@gmail.com> | 2024-03-09 13:22:44 -0800 |
commit | f9a7e833a3ff099f2db37c5d6a583ef34f1df98c (patch) | |
tree | 2fe10dcad7a2047a9d0e83755a81dab96271cc8b | |
parent | c18761850ec3b6a990692e89fa2d3f9f6588eeca (diff) | |
download | damo-f9a7e833a3ff099f2db37c5d6a583ef34f1df98c.tar.gz |
_damon_sysfs: Impelment DAMON version inference function
Signed-off-by: SeongJae Park <sj38.park@gmail.com>
-rw-r--r-- | _damon_sysfs.py | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/_damon_sysfs.py b/_damon_sysfs.py index a4a508c4..fe7832b8 100644 --- a/_damon_sysfs.py +++ b/_damon_sysfs.py @@ -710,6 +710,53 @@ def scheme_tried_regions_dir_of(kdamond_idx, context_idx, scheme_idx): scheme_dir_of(kdamond_idx, context_idx, scheme_idx), 'tried_regions') +def infer_damon_version(): + version = '<5.15' + orig_kdamonds = current_kdamonds() + kdamonds = [ + _damon.Kdamond( + state=None, pid=None, contexts=[ + _damon.DamonCtx( + ops='paddr', targets=[], + intervals=_damon.DamonIntervals(), + nr_regions=_damon.DamonNrRegionsRange(), + schemes=[ + _damon.Damos( + access_pattern=None, action='stat', + quotas=_damon.DamosQuotas(), + watermarks=None, + filters=[_damon.DamosFilter('young', True)] + )])])] + err = stage_kdamonds(kdamonds) + if err is None: + err = stage_kdamonds(orig_kdamonds) + return '>6.9' + + kdamonds[0].contexts[0].schemes[0].filters = [] + err = stage_kdamonds(kdamonds) + + if os.path.isfile(os.path.join(scheme_dir_of(0, 0, 0), 'quotas', + 'effective_bytes')): + return '6.9' + + if os.path.isdir(os.path.join(scheme_dir_of(0, 0, 0), 'quotas', 'goals')): + return '6.8' + + if os.path.isfile(os.path.join(scheme_dir_of(0, 0, 0), 'apply_interval_us')): + return '6.7' + + if os.path.isfile(os.path.join(scheme_tried_regions_dir_of(0, 0, 0), + 'total_bytes')): + return '6.6' + + if os.path.isdir(os.path.join(scheme_dir_of(0, 0, 0), 'filters')): + return '6.3' + + if os.path.isdir(scheme_tried_regions_dir_of(0, 0, 0)): + return '6.2' + + return '<6.2' + def update_supported_features(): global feature_supports |