diff options
author | SeongJae Park <sj38.park@gmail.com> | 2024-03-17 11:24:07 -0700 |
---|---|---|
committer | SeongJae Park <sj38.park@gmail.com> | 2024-03-17 11:24:07 -0700 |
commit | b88b0032633faffae17882569f54d9bfafc92bb3 (patch) | |
tree | 32ab9ac974df97b8b3a5a8205eb5c935be90d7ce | |
parent | b6b2fd08a53e5a8585324ef841e8a181d40585fd (diff) | |
download | damo-b88b0032633faffae17882569f54d9bfafc92bb3.tar.gz |
_damon_dbgfs: Implement an interactive version of kdamonds writer
Signed-off-by: SeongJae Park <sj38.park@gmail.com>
-rw-r--r-- | _damon_dbgfs.py | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/_damon_dbgfs.py b/_damon_dbgfs.py index d4addc28..c497ba8e 100644 --- a/_damon_dbgfs.py +++ b/_damon_dbgfs.py @@ -240,6 +240,32 @@ def write_target(dir_path, target, target_has_pid): return err return None +def write_kdamonds(dir_path, kdamonds): + if len(kdamonds) > 1: + raise Exception('Currently only <=one kdamond is supported') + if len(kdamonds) == 1 and len(kdamonds[0].contexts) > 1: + raise Exception('currently only <= one damon_ctx is supported') + if (len(kdamonds) == 1 and len(kdamonds[0].contexts) == 1 and + len(kdamonds[0].contexts[0].targets) > 1): + raise Exception('currently only <= one target is supported') + ctx = kdamonds[0].contexts[0] + + err = _damo_fs.write_file( + os.path.join(dir_path, 'attrs'), attr_str_ctx(ctx)) + if err is not None: + return err + + if len(ctx.targets) > 0: + err = write_target( + dir_path, ctx.targets[0], _damon.target_has_pid(ctx.ops)) + if err: + return err + if not feature_supported('schemes'): + return None + + err = write_schemes(dir_path, ctx.schemes, ctx.intervals) + return err + def stage_kdamonds(kdamonds): '''Return error''' if _damon.any_kdamond_running(): |