diff options
author | SeongJae Park <sj38.park@gmail.com> | 2024-03-17 10:58:27 -0700 |
---|---|---|
committer | SeongJae Park <sj38.park@gmail.com> | 2024-03-17 10:58:27 -0700 |
commit | 7a7ac12b68f4afd2dcadb9e7db34db39a9f02134 (patch) | |
tree | fcc2f7dca7ee290dfa30a59f0ea541c91a981efd | |
parent | d44d92e3898894e4901f38115b185b6ba59740ee (diff) | |
download | damo-7a7ac12b68f4afd2dcadb9e7db34db39a9f02134.tar.gz |
_damon_sysfs: Remove wops_for_* functions
The functions are not really used now, but only remained there for unit
test. The test is replaced to a new version using the new function that
really being used. Remove the old functions.
Signed-off-by: SeongJae Park <sj38.park@gmail.com>
-rw-r--r-- | _damon_sysfs.py | 156 |
1 files changed, 0 insertions, 156 deletions
diff --git a/_damon_sysfs.py b/_damon_sysfs.py index 6fd2193a..c72a9814 100644 --- a/_damon_sysfs.py +++ b/_damon_sysfs.py @@ -823,159 +823,3 @@ def update_supported_features(): feature_supports[ops] = ops in avail_ops err = stage_kdamonds(orig_kdamonds) return err - -# For old tests -# Below are used by only old unit test. Keep these until the new version's -# replacements of these having similar level of the test. - -def wops_for_scheme_filter(damos_filter): - wops = { - 'type': '%s' % damos_filter.filter_type, - 'memcg_path': ('%s' % damos_filter.memcg_path - if damos_filter.memcg_path != None else ''), - 'matching': 'Y' if damos_filter.matching else 'N', - } - if damos_filter.address_range != None: - wops['addr_start'] = '%d' % damos_filter.address_range.start - wops['addr_end'] = '%d' % damos_filter.address_range.end - if damos_filter.damon_target_idx != None: - wops['damon_target_idx'] = '%d' % damos_filter.damon_target_idx - return wops - -def wops_for_scheme_filters(filters): - wops = {} - for idx, damos_filter in enumerate(filters): - wops['%d' % idx] = wops_for_scheme_filter(damos_filter) - return wops - -def wops_for_scheme_watermarks(wmarks): - if wmarks == None: - return {} - return { - 'metric': wmarks.metric, - 'interval_us': '%d' % wmarks.interval_us, - 'high': '%d' % wmarks.high_permil, - 'mid': '%d' % wmarks.mid_permil, - 'low': '%d' % wmarks.low_permil, - } - -def wops_for_scheme_quota_goal(goal): - return { - 'target_value': '%s' % goal.target_value, - 'current_value': '%s' % goal.current_value, - } - -def wops_for_scheme_quota_goals(goals): - wops = {} - for idx, goal in enumerate(goals): - wops['%d' % idx] = wops_for_scheme_quota_goal(goal) - return wops - -def wops_for_scheme_quotas(quotas): - if quotas == None: - return {} - wops = { - 'ms': '%d' % quotas.time_ms, - 'bytes': '%d' % quotas.sz_bytes, - 'reset_interval_ms': '%d' % quotas.reset_interval_ms, - 'weights': { - 'sz_permil': '%d' % quotas.weight_sz_permil, - 'nr_accesses_permil': '%d' % quotas.weight_nr_accesses_permil, - 'age_permil': '%d' % quotas.weight_age_permil, - }, - } - if feature_supported('schemes_quota_goals'): - wops['goals'] = wops_for_scheme_quota_goals(quotas.goals) - - return wops - -def wops_for_scheme_access_pattern(pattern, ctx): - if pattern == None: - return {} - pattern = pattern.converted_for_units( - _damon.unit_samples, _damon.unit_aggr_intervals, - ctx.intervals) - - return { - 'sz': { - 'min': '%d' % pattern.sz_bytes[0], - 'max': '%d' % pattern.sz_bytes[1], - }, - 'nr_accesses': { - 'min': '%d' % pattern.nr_acc_min_max[0].samples, - 'max': '%d' % pattern.nr_acc_min_max[1].samples, - }, - 'age': { - 'min': '%d' % pattern.age_min_max[0].aggr_intervals, - 'max': '%d' % pattern.age_min_max[1].aggr_intervals, - }, - } - -def wops_for_schemes(ctx): - schemes = ctx.schemes - - schemes_wops = {} - for idx, scheme in enumerate(schemes): - dirname = '%d' % idx - schemes_wops[dirname] = { - 'access_pattern': wops_for_scheme_access_pattern( - scheme.access_pattern, ctx), - 'action': scheme.action, - 'quotas': wops_for_scheme_quotas(scheme.quotas), - 'watermarks': wops_for_scheme_watermarks(scheme.watermarks), - } - if feature_supported('schemes_filters'): - schemes_wops[dirname]['filters'] = wops_for_scheme_filters( - scheme.filters) - if feature_supported('schemes_apply_interval'): - schemes_wops[dirname]['apply_interval_us'] = ( - '%d' % scheme.apply_interval_us) - return schemes_wops - -def wops_for_regions(regions): - return {'%d' % region_idx: { - 'start': '%d' % region.start, - 'end': '%d' % region.end} - for region_idx, region in enumerate(regions)} - -def wops_for_targets(ctx): - return { - '%d' % idx: { - 'pid_target': '%s' % - target.pid if _damon.target_has_pid(ctx.ops) else '', - 'regions': wops_for_regions(target.regions) - } for idx, target in enumerate(ctx.targets)} - -def wops_for_monitoring_attrs(ctx): - return { - 'intervals': { - 'sample_us': '%d' % ctx.intervals.sample, - 'aggr_us': '%d' % ctx.intervals.aggr, - 'update_us': '%d' % ctx.intervals.ops_update, - }, - 'nr_regions': { - 'min': '%d' % ctx.nr_regions.minimum, - 'max': '%d' % ctx.nr_regions.maximum, - }, - } - -def wops_for_ctx(ctx): - ops = ctx.ops - if ops == 'fvaddr' and not feature_supported('fvaddr'): - ops = 'vaddr' - return [ - {'operations': ops}, - {'monitoring_attrs': wops_for_monitoring_attrs(ctx)}, - {'targets': wops_for_targets(ctx)}, - {'schemes': wops_for_schemes(ctx)}, - ] - -def wops_for_ctxs(ctxs): - return {'%d' % idx: wops_for_ctx(ctx) for idx, ctx in enumerate(ctxs)} - -def wops_for_kdamond(kdamond): - return {'contexts': wops_for_ctxs(kdamond.contexts)} - -def wops_for_kdamonds(kdamonds): - return {'%d' % idx: wops_for_kdamond(kdamond) - for idx, kdamond in enumerate(kdamonds)} |