efficiently expose damos action tried regions information
Subsystems (5)
SeongJae Park
maintainercover efficiently expose damos action tried regions information
Changes from RFC
(https://lore.kernel.org/damon/[email protected]/):
- Split out cleanup/refactoring parts[1]
[1] https://lore.kernel.org/damon/[email protected]/
-----------------------------------------------------------------------
DAMON users can retrieve the monitoring results via 'after_aggregation' callbacks if the user is using the kernel API, or 'damon_aggregated' tracepoint if the user is in the user space. Those are useful if full monitoring results are necessary. However, if the user has interest in only a snapshot of the results for some regions having specific access pattern, the interfaces could be inefficient. For example, some users only want to know which memory regions are not accessed for more than a specific time at the moment.
Also, some DAMOS users would want to know exactly to what memory regions the schemes' actions tried to be applied, for a debugging or a tuning. As DAMOS has its internal mechanism for quota and regions prioritization, the users would need to simulate DAMOS' mechanism against the monitoring results. That's unnecessarily complex.
This patchset implements DAMON kernel API callbacks and sysfs directory for efficient exposure of the information for the use cases. The new callback will be called for each region when a DAMOS action is gonna tried to be applied to it. The sysfs directory will be called 'tried_regions' and placed under each scheme sysfs directory. Users can write a special keyworkd, 'update_schemes_regions', to the 'state' file of a kdamond sysfs directory. Then, DAMON sysfs interface will fill the directory with the information of regions that corresponding scheme action was tried to be applied for next one aggregation interval.
Patches Sequence
----------------
The first one (patch 1) implements the callback for the kernel space users. Following two patches (patches 2 and 3) implements sysfs directories for the information and its sub directories. Two patches (patches 4 and 5) for implementing the special keywords for filling the data to and cleaning up the directories follow. Patch 6 adds a selftest for the new sysfs directory. Finally, two patches (patches 7 and 8) document the new feature in the administrator guide and the ABI document.
Assembled Tree
--------------
This patchset is based on the latest mm-unstable tree[1]. Assembled tree is also available at the damon/next tree[2].
[1] https://git.kernel.org/akpm/mm/h/mm-unstable
[2] https://git.kernel.org/sj/h/damon/next
SeongJae Park (8):
mm/damon/core: add a callback for scheme target regions check mm/damon/sysfs-schemes: implement schemes/tried_regions directory mm/damon/sysfs-schemes: implement scheme region directory mm/damon/sysfs: implement DAMOS tried regions update command mm/damon/sysfs-schemes: implement DAMOS-tried regions clear command tools/selftets/damon/sysfs: test tried_regions directory existence Docs/admin-guide/mm/damon/usage: document schemes/<s>/tried_regions
sysfs directory
Docs/ABI/damon: document 'schemes/<s>/tried_regions' sysfs directory
.../ABI/testing/sysfs-kernel-mm-damon | 32 +++ Documentation/admin-guide/mm/damon/usage.rst | 45 ++- include/linux/damon.h | 5 + mm/damon/core.c | 6 +- mm/damon/sysfs-common.h | 10 + mm/damon/sysfs-schemes.c | 261 ++++++++++++++++++ mm/damon/sysfs.c | 77 +++++- tools/testing/selftests/damon/sysfs.sh | 7 + 8 files changed, 437 insertions(+), 6 deletions(-)
Signature · 1 line
2.25.1
SeongJae Park
maintainerPATCH 1/8 mm/damon/core: add a callback for scheme target regions check
Getting DAMON monitoring results of only specific access pattern (e.g., getting address ranges of memory that not accessed at all for two minutes) can be useful for efficient monitoring of the system. The information can also be helpful for deep level investigation of DAMON-based operation schemes.
For that, users need to record (in case of the user space users) or iterate (in case of the kernel space users) full monitoring results and filter it out for the specific access pattern. In case of the DAMOS investigation, users will even need to simulate DAMOS' quota and prioritization mechanisms. It's inefficient and complex.
Add a new DAMON callback that will be called before each scheme is applied to each region. DAMON kernel API users will be able to do the query-like monitoring results collection, or DAMOS investigation in an efficient and simple way using it.
Commits for providing the capability to the user space users will follow.
--- include/linux/damon.h | 5 +++++ mm/damon/core.c | 6 +++++- 2 files changed, 10 insertions(+), 1 deletion(-)
include/linux/damon.h +5 -0
@@ -357,6 +357,7 @@ struct damon_operations {* @after_wmarks_check: Called after each schemes' watermarks check. * @after_sampling: Called after each sampling. * @after_aggregation: Called after each aggregation. +* @before_damos_apply: Called before applying DAMOS action. * @before_terminate: Called before terminating the monitoring. * @private: User private data. *
@@ -385,6 +386,10 @@ struct damon_callback {int (*after_wmarks_check)(struct damon_ctx *context);int (*after_sampling)(struct damon_ctx *context);int (*after_aggregation)(struct damon_ctx *context); +int (*before_damos_apply)(struct damon_ctx *context, +struct damon_target *target, +struct damon_region *region, +struct damos *scheme);void (*before_terminate)(struct damon_ctx *context); };
mm/damon/core.c +5 -1
@@ -772,6 +772,7 @@ static void damos_apply_scheme(struct damon_ctx *c, struct damon_target *t,unsigned long sz =damon_sz_region (r);struct timespec64 begin, end;unsigned long sz_applied =0 ; +int err =0 ;if (c->ops.apply_scheme) {if (quota->esz && quota->charged_sz + sz > quota->esz) {
@@ -782,7 +783,10 @@ static void damos_apply_scheme(struct damon_ctx *c, struct damon_target *t,damon_split_region_at (t, r, sz); }ktime_get_coarse_ts64 (&begin); - sz_applied = c->ops.apply_scheme (c, t, r, s); +if (c->callback.before_damos_apply) + err = c->callback.before_damos_apply (c, t, r, s); +if (!err) + sz_applied = c->ops.apply_scheme (c, t, r, s);ktime_get_coarse_ts64 (&end); quota->total_charged_ns +=timespec64_to_ns (&end) -timespec64_to_ns (&begin);
Signature · 1 line
2.25.1
SeongJae Park
maintainerPATCH 2/8 mm/damon/sysfs-schemes: implement schemes/tried_regions directory
In reply to SeongJae ParkFor efficient and simple query-like DAMON monitoring results readings and deep level investigations of DAMOS, DAMON kernel API (include/linux/damon.h) users can use 'before_damos_apply' DAMON callback. However, DAMON sysfs interface users don't have such option.
Add a directory, namely 'tried_regions', under each scheme directory to use it as the interface for the purpose. Note that this commit is implementing only the directory but the data filling.
After the data filling change is made, users will be able to signal DAMON to fill the directory with the regions that corresponding scheme has tried to be applied. By setting the access pattern of the scheme, users could do the efficient query-like monitoring.
--- mm/damon/sysfs-schemes.c | 57 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+)
mm/damon/sysfs-schemes.c +57 -0
@@ -9,6 +9,36 @@#include "sysfs-common.h" +/* +* scheme regions directory +*/ + +struct damon_sysfs_scheme_regions { +struct kobject kobj; +}; + +static struct damon_sysfs_scheme_regions * +damon_sysfs_scheme_regions_alloc (void ) +{ +return kzalloc (sizeof (struct damon_sysfs_scheme_regions ),GFP_KERNEL ); +} + +static void damon_sysfs_scheme_regions_release (struct kobject *kobj) +{ +kfree (container_of(kobj ,struct damon_sysfs_scheme_regions ,kobj )); +} + +static struct attribute *damon_sysfs_scheme_regions_attrs[] = { +NULL , +}; +ATTRIBUTE_GROUPS (damon_sysfs_scheme_regions); + +static struct kobj_type damon_sysfs_scheme_regions_ktype = { + .release = damon_sysfs_scheme_regions_release, + .sysfs_ops = &kobj_sysfs_ops, + .default_groups = damon_sysfs_scheme_regions_groups, +}; +/* * schemes/stats directory */
@@ -635,6 +665,7 @@ struct damon_sysfs_scheme {struct damon_sysfs_quotas *quotas;struct damon_sysfs_watermarks *watermarks;struct damon_sysfs_stats *stats; +struct damon_sysfs_scheme_regions *tried_regions; };/* This should match with enum damos_action */
@@ -743,6 +774,25 @@ static int damon_sysfs_scheme_set_stats(struct damon_sysfs_scheme *scheme)return err; } +static int damon_sysfs_scheme_set_tried_regions ( +struct damon_sysfs_scheme *scheme) +{ +struct damon_sysfs_scheme_regions *tried_regions = +damon_sysfs_scheme_regions_alloc (); +int err; + +if (!tried_regions) +return -ENOMEM ; + err =kobject_init_and_add (&tried_regions->kobj, + &damon_sysfs_scheme_regions_ktype, &scheme->kobj, +"tried_regions" ); +if (err) +kobject_put (&tried_regions->kobj); +else + scheme->tried_regions = tried_regions; +return err; +} +static int damon_sysfs_scheme_add_dirs (struct damon_sysfs_scheme *scheme) {int err;
@@ -759,8 +809,14 @@ static int damon_sysfs_scheme_add_dirs(struct damon_sysfs_scheme *scheme) err =damon_sysfs_scheme_set_stats (scheme);if (err) goto put_watermarks_quotas_access_pattern_out; + err =damon_sysfs_scheme_set_tried_regions (scheme); +if (err) + goto put_tried_regions_out;return 0 ; +put_tried_regions_out: +kobject_put (&scheme->tried_regions->kobj); + scheme->tried_regions =NULL ; put_watermarks_quotas_access_pattern_out:kobject_put (&scheme->watermarks->kobj); scheme->watermarks =NULL ;
@@ -781,6 +837,7 @@ static void damon_sysfs_scheme_rm_dirs(struct damon_sysfs_scheme *scheme)kobject_put (&scheme->quotas->kobj);kobject_put (&scheme->watermarks->kobj);kobject_put (&scheme->stats->kobj); +kobject_put (&scheme->tried_regions->kobj); } static ssize_t action_show(struct kobject *kobj, struct kobj_attribute *attr,
Signature · 1 line
2.25.1
SeongJae Park
maintainerPATCH 3/8 mm/damon/sysfs-schemes: implement scheme region directory
In reply to SeongJae ParkImplement region directories under 'tried_regions' directory of each scheme DAMON sysfs directory. This directory will provide the address range, the monitored access frequency ('nr_accesses'), and the age of each DAMON region that corresponding DAMON-based operation scheme has tried to be applied. Note that this commit doesn't implement the code for filling the data but only the sysfs directory.
--- mm/damon/sysfs-schemes.c | 123 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 122 insertions(+), 1 deletion(-)
mm/damon/sysfs-schemes.c +122 -1
@@ -9,18 +9,138 @@#include "sysfs-common.h" +/* +* scheme region directory +*/ + +struct damon_sysfs_scheme_region { +struct kobject kobj; +struct damon_addr_range ar; +unsigned int nr_accesses; +unsigned int age; +struct list_head list; +}; + +static struct damon_sysfs_scheme_region *damon_sysfs_scheme_region_alloc ( +struct damon_region *region) +{ +struct damon_sysfs_scheme_region *sysfs_region =kmalloc ( +sizeof (*sysfs_region),GFP_KERNEL ); + +if (!sysfs_region) +return NULL ; + sysfs_region->kobj = (struct kobject ){}; + sysfs_region->ar = region->ar; + sysfs_region->nr_accesses = region->nr_accesses; + sysfs_region->age = region->age; +INIT_LIST_HEAD (&sysfs_region->list); +return sysfs_region; +} + +static ssize_t start_show (struct kobject *kobj,struct kobj_attribute *attr, +char *buf) +{ +struct damon_sysfs_scheme_region *region =container_of (kobj, + struct damon_sysfs_scheme_region, kobj); + +return sysfs_emit (buf,"%lu\n" , region->ar.start); +} + +static ssize_t end_show (struct kobject *kobj,struct kobj_attribute *attr, +char *buf) +{ +struct damon_sysfs_scheme_region *region =container_of (kobj, + struct damon_sysfs_scheme_region, kobj); + +return sysfs_emit (buf,"%lu\n" , region->ar.end); +} + +static ssize_t nr_accesses_show (struct kobject *kobj, +struct kobj_attribute *attr,char *buf) +{ +struct damon_sysfs_scheme_region *region =container_of (kobj, + struct damon_sysfs_scheme_region, kobj); + +return sysfs_emit (buf,"%u\n" , region->nr_accesses); +} + +static ssize_t age_show (struct kobject *kobj,struct kobj_attribute *attr, +char *buf) +{ +struct damon_sysfs_scheme_region *region =container_of (kobj, + struct damon_sysfs_scheme_region, kobj); + +return sysfs_emit (buf,"%u\n" , region->age); +} + +static void damon_sysfs_scheme_region_release (struct kobject *kobj) +{ +struct damon_sysfs_scheme_region *region =container_of (kobj, + struct damon_sysfs_scheme_region, kobj); + +list_del (®ion->list); +kfree (region); +} + +static struct kobj_attribute damon_sysfs_scheme_region_start_attr = +__ATTR_RO_MODE (start,0400 ); + +static struct kobj_attribute damon_sysfs_scheme_region_end_attr = +__ATTR_RO_MODE (end,0400 ); + +static struct kobj_attribute damon_sysfs_scheme_region_nr_accesses_attr = +__ATTR_RO_MODE (nr_accesses,0400 ); + +static struct kobj_attribute damon_sysfs_scheme_region_age_attr = +__ATTR_RO_MODE (age,0400 ); + +static struct attribute *damon_sysfs_scheme_region_attrs[] = { + &damon_sysfs_scheme_region_start_attr.attr, + &damon_sysfs_scheme_region_end_attr.attr, + &damon_sysfs_scheme_region_nr_accesses_attr.attr, + &damon_sysfs_scheme_region_age_attr.attr, +NULL , +}; +ATTRIBUTE_GROUPS (damon_sysfs_scheme_region); + +static struct kobj_type damon_sysfs_scheme_region_ktype = { + .release = damon_sysfs_scheme_region_release, + .sysfs_ops = &kobj_sysfs_ops, + .default_groups = damon_sysfs_scheme_region_groups, +}; +/* * scheme regions directory */ struct damon_sysfs_scheme_regions {struct kobject kobj; +struct list_head regions_list; +int nr_regions; };static struct damon_sysfs_scheme_regions *damon_sysfs_scheme_regions_alloc (void ) { -return kzalloc (sizeof (struct damon_sysfs_scheme_regions ),GFP_KERNEL ); +struct damon_sysfs_scheme_regions *regions =kmalloc (sizeof (*regions), +GFP_KERNEL ); + + regions->kobj = (struct kobject ){}; +INIT_LIST_HEAD (®ions->regions_list); + regions->nr_regions =0 ; +return regions; +} + +static void damon_sysfs_scheme_regions_rm_dirs ( +struct damon_sysfs_scheme_regions *regions) +{ +struct damon_sysfs_scheme_region *r, *next; + +list_for_each_entry_safe (r, next, ®ions->regions_list, list) { +/* release function deletes it from the list */ +kobject_put (&r->kobj); + regions->nr_regions--; + } }static void damon_sysfs_scheme_regions_release (struct kobject *kobj)
@@ -837,6 +957,7 @@ static void damon_sysfs_scheme_rm_dirs(struct damon_sysfs_scheme *scheme)kobject_put (&scheme->quotas->kobj);kobject_put (&scheme->watermarks->kobj);kobject_put (&scheme->stats->kobj); +damon_sysfs_scheme_regions_rm_dirs (scheme->tried_regions);kobject_put (&scheme->tried_regions->kobj); }
Signature · 1 line
2.25.1
SeongJae Park
maintainerPATCH 4/8 mm/damon/sysfs: implement DAMOS tried regions update command
In reply to SeongJae ParkImplement the code for filling the data of 'tried_regions' DAMON sysfs directory. With this commit, DAMON sysfs interface users can write a special keyword, 'update_schemes_tried_regions' to the corresponding 'state' file of the kdamond. Then, DAMON sysfs interface will collect the tried regions information using the 'before_damos_apply()' callback for one aggregation interval and populate scheme region directories with the values.
--- mm/damon/sysfs-common.h | 6 ++++ mm/damon/sysfs-schemes.c | 75 ++++++++++++++++++++++++++++++++++++++++ mm/damon/sysfs.c | 57 ++++++++++++++++++++++++++++-- 3 files changed, 136 insertions(+), 2 deletions(-)
mm/damon/sysfs-common.h +6 -0
@@ -44,3 +44,9 @@ int damon_sysfs_set_schemes(struct damon_ctx *ctx,void damon_sysfs_schemes_update_stats (struct damon_sysfs_schemes *sysfs_schemes,struct damon_ctx *ctx); + +int damon_sysfs_schemes_update_regions_start ( +struct damon_sysfs_schemes *sysfs_schemes, +struct damon_ctx *ctx); + +int damon_sysfs_schemes_update_regions_stop (struct damon_ctx *ctx);
mm/damon/sysfs-schemes.c +75 -0
78 lines not on this page · raw message
mm/damon/sysfs.c +55 -2
102 lines not on this page · raw message
Signature · 1 line
2.25.1
SeongJae Park
maintainerPATCH 5/8 mm/damon/sysfs-schemes: implement DAMOS-tried regions clear command
In reply to SeongJae ParkWhen there are huge number of DAMON regions that specific scheme actions are tried to be applied, directories and files under 'tried_regions' scheme directory could waste some memory. Add another special input keyword ('clear_schemes_tried_regions') for 'state' file of each kdamond sysfs directory that can be used for cleanup of the 'tried_regions' sub-directories.
--- mm/damon/sysfs-common.h | 4 ++++ mm/damon/sysfs-schemes.c | 10 +++++++++- mm/damon/sysfs.c | 20 ++++++++++++++++++++ 3 files changed, 33 insertions(+), 1 deletion(-)
mm/damon/sysfs-common.h +4 -0
@@ -50,3 +50,7 @@ int damon_sysfs_schemes_update_regions_start( struct damon_ctx *ctx);int damon_sysfs_schemes_update_regions_stop (struct damon_ctx *ctx); + +int damon_sysfs_schemes_clear_regions ( +struct damon_sysfs_schemes *sysfs_schemes, +struct damon_ctx *ctx);
mm/damon/sysfs-schemes.c +9 -1
@@ -1241,7 +1241,7 @@ static int damon_sysfs_before_damos_apply(struct damon_ctx *ctx, }/* Called from damon_sysfs_cmd_request_callback under damon_sysfs_lock */ -int damon_sysfs_schemes_update_regions_start ( +int damon_sysfs_schemes_clear_regions (struct damon_sysfs_schemes *sysfs_schemes,struct damon_ctx *ctx) {
@@ -1255,7 +1255,15 @@ int damon_sysfs_schemes_update_regions_start(damon_sysfs_scheme_regions_rm_dirs ( sysfs_scheme->tried_regions); } +return 0 ; +} +/* Called from damon_sysfs_cmd_request_callback under damon_sysfs_lock */ +int damon_sysfs_schemes_update_regions_start ( +struct damon_sysfs_schemes *sysfs_schemes, +struct damon_ctx *ctx) +{ +damon_sysfs_schemes_clear_regions (sysfs_schemes, ctx); damon_sysfs_schemes_for_damos_callback = sysfs_schemes; ctx->callback.before_damos_apply = damon_sysfs_before_damos_apply;return 0 ;
mm/damon/sysfs.c +20 -0
@@ -1004,6 +1004,11 @@ enum damon_sysfs_cmd {* regions */ DAMON_SYSFS_CMD_UPDATE_SCHEMES_TRIED_REGIONS , +/* +* @DAMON_SYSFS_CMD_CLEAR_SCHEMES_TRIED_REGIONS: Clear schemes tried +* regions +*/ + DAMON_SYSFS_CMD_CLEAR_SCHEMES_TRIED_REGIONS,/* * @NR_DAMON_SYSFS_CMDS: Total number of DAMON sysfs commands. */
@@ -1017,6 +1022,7 @@ static const char * const damon_sysfs_cmd_strs[] = {"commit" ,"update_schemes_stats" ,"update_schemes_tried_regions" , + "clear_schemes_tried_regions", };/*
@@ -1262,6 +1268,17 @@ static int damon_sysfs_upd_schemes_regions_stop(return damon_sysfs_schemes_update_regions_stop (ctx); } +static int damon_sysfs_clear_schemes_regions ( +struct damon_sysfs_kdamond *kdamond) +{ +struct damon_ctx *ctx = kdamond->damon_ctx; + +if (!ctx) +return -EINVAL ; +return damon_sysfs_schemes_clear_regions ( + kdamond->contexts->contexts_arr[0 ]->schemes, ctx); +} +static inline bool damon_sysfs_kdamond_running (struct damon_sysfs_kdamond *kdamond) {
@@ -1343,6 +1360,9 @@ static int damon_sysfs_cmd_request_callback(struct damon_ctx *c) damon_sysfs_schemes_regions_updating = false; }break ; +case DAMON_SYSFS_CMD_CLEAR_SCHEMES_TRIED_REGIONS : + err =damon_sysfs_clear_schemes_regions (kdamond); +break ;default :break ; }
Signature · 1 line
2.25.1
SeongJae Park
maintainerPATCH 6/8 tools/selftets/damon/sysfs: test tried_regions directory existence
In reply to SeongJae ParkAdd a simple test case for ensuring tried_regions directory existence.
--- tools/testing/selftests/damon/sysfs.sh | 7 +++++++ 1 file changed, 7 insertions(+)
tools/testing/selftests/damon/sysfs.sh +7 -0
@@ -80,6 +80,12 @@ test_range() ensure_file "$range_dir/max" "exist" 600 } +test_tried_regions() +{ + tried_regions_dir=$1 + ensure_dir "$tried_regions_dir" "exist" +} + test_stats() { stats_dir=$1
@@ -138,6 +144,7 @@ test_scheme() test_quotas "$scheme_dir/quotas" test_watermarks "$scheme_dir/watermarks" test_stats "$scheme_dir/stats" + test_tried_regions "$scheme_dir/tried_regions" } test_schemes()
Signature · 1 line
2.25.1
SeongJae Park
maintainerPATCH 7/8 Docs/admin-guide/mm/damon/usage: document schemes/<s>/tried_regions sysfs directory
In reply to SeongJae ParkDocument 'tried_regions' directory in DAMON sysfs interface usage in the administrator guide.
--- Documentation/admin-guide/mm/damon/usage.rst | 45 ++++++++++++++++++-- 1 file changed, 42 insertions(+), 3 deletions(-)
Documentation/admin-guide/mm/damon/usage.rst +42 -3
@@ -88,6 +88,9 @@ comma (","). :: │ │ │ │ │ │ │ │ weights/sz_permil,nr_accesses_permil,age_permil │ │ │ │ │ │ │ watermarks/metric,interval_us,high,mid,low │ │ │ │ │ │ │ stats/nr_tried,sz_tried,nr_applied,sz_applied,qt_exceeds + │ │ │ │ │ │ │ tried_regions/ + │ │ │ │ │ │ │ │ 0/start,end,nr_accesses,age + │ │ │ │ │ │ │ │ ... │ │ │ │ │ │ ... │ │ │ │ ... │ │ ...
@@ -125,7 +128,14 @@ in the state. Writing ``commit`` to the ``state`` file makes kdamond reads the user inputs in the sysfs files except ``state`` file again. Writing ``update_schemes_stats`` to ``state`` file updates the contents of stats files for each DAMON-based operation scheme of the kdamond. For details of the -stats, please refer to :ref:`stats section <sysfs_schemes_stats>`. +stats, please refer to :ref:`stats section <sysfs_schemes_stats>`. Writing +``update_schemes_tried_regions`` to ``state`` file updates the DAMON-based +operation scheme action tried regions directory for each DAMON-based operation +scheme of the kdamond. Writing ``clear_schemes_tried_regions`` to ``state`` +file clears the DAMON-based operating scheme action tried regions directory for +each DAMON-based operation scheme of the kdamond. For details of the +DAMON-based operation scheme action tried regions directory, please refer to +:ref:tried_regions section <sysfs_schemes_tried_regions>`. If the state is ``on``, reading ``pid`` shows the pid of the kdamond thread.
@@ -166,6 +176,8 @@ You can set and get what type of monitoring operations DAMON will use for the context by writing one of the keywords listed in ``avail_operations`` file and reading from the ``operations`` file. +.. _sysfs_monitoring_attrs: + contexts/<N>/monitoring_attrs/ ------------------------------
@@ -255,8 +267,9 @@ to ``N-1``. Each directory represents each DAMON-based operation scheme. schemes/<N>/ ------------ -In each scheme directory, four directories (``access_pattern``, ``quotas``, -``watermarks``, and ``stats``) and one file (``action``) exist. +In each scheme directory, five directories (``access_pattern``, ``quotas``, +``watermarks``, ``stats``, and ``tried_regions``) and one file (``action``) +exist. The ``action`` file is for setting and getting what action you want to apply to memory regions having specific access pattern of the interest. The keywords
@@ -351,6 +364,32 @@ should ask DAMON sysfs interface to updte the content of the files for the stats by writing a special keyword, ``update_schemes_stats`` to the relevant ``kdamonds/<N>/state`` file. +.. _sysfs_schemes_tried_regions: + +schemes/<N>/tried_regions/ +-------------------------- + +When a special keyword, ``update_schemes_tried_regions``, is written to the +relevant ``kdamonds/<N>/state`` file, DAMON creates directories named integer +starting from ``0`` under this directory. Each directory contains files +exposing detailed information about each of the memory region that the +corresponding scheme's ``action`` has tried to be applied under this directory, +during next :ref:`aggregation interval <sysfs_monitoring_attrs>`. The +information includes address range, ``nr_accesses``, , and ``age`` of the +region. + +The directories will be removed when another special keyword, +``clear_schemes_tried_regions``, is written to the relevant +``kdamonds/<N>/state`` file. + +tried_regions/<N>/ +------------------ + +In each region directory, you will find four files (``start``, ``end``, +``nr_accesses``, and ``age``). Reading the files will show the start and end +addresses, ``nr_accesses``, and ``age`` of the region that corresponding +DAMON-based operation scheme ``action`` has tried to be applied. + Example ~~~~~~~
Signature · 1 line
2.25.1
SeongJae Park
maintainerPATCH 8/8 Docs/ABI/damon: document 'schemes/<s>/tried_regions' sysfs directory
In reply to SeongJae ParkUpdate DAMON ABI document for the 'tried_regions' directory of DAMON sysfs interface.
--- .../ABI/testing/sysfs-kernel-mm-damon | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+)
Documentation/ABI/testing/sysfs-kernel-mm-damon +32 -0
@@ -27,6 +27,10 @@ Description: Writing 'on' or 'off' to this file makes the kdamond starts or makes the kdamond reads the user inputs in the sysfs files except 'state' again. Writing 'update_schemes_stats' to the file updates contents of schemes stats files of the kdamond. + Writing 'update_schemes_tried_regions' to the file updates + contents of 'tried_regions' directory of every scheme directory + of this kdamond. Writing 'clear_schemes_tried_regions' to the + file removes contents of the 'tried_regions' directory. What: /sys/kernel/mm/damon/admin/kdamonds/<K>/pid Date: Mar 2022
@@ -283,3 +287,31 @@ Date: Mar 2022 Contact: SeongJae Park <[email protected]> Description: Reading this file returns the number of the exceed events of the scheme's quotas. + +What: /sys/kernel/mm/damon/admin/kdamonds/<K>/contexts/<C>/schemes/<S>/tried_regions/<R>/start +Date: Oct 2022 +Contact: SeongJae Park <[email protected]> +Description: Reading this file returns the start address of a memory region + that corresponding DAMON-based Operation Scheme's action has + tried to be applied. + +What: /sys/kernel/mm/damon/admin/kdamonds/<K>/contexts/<C>/schemes/<S>/tried_regions/<R>/end +Date: Oct 2022 +Contact: SeongJae Park <[email protected]> +Description: Reading this file returns the end address of a memory region + that corresponding DAMON-based Operation Scheme's action has + tried to be applied. + +What: /sys/kernel/mm/damon/admin/kdamonds/<K>/contexts/<C>/schemes/<S>/tried_regions/<R>/nr_accesses +Date: Oct 2022 +Contact: SeongJae Park <[email protected]> +Description: Reading this file returns the 'nr_accesses' of a memory region + that corresponding DAMON-based Operation Scheme's action has + tried to be applied. + +What: /sys/kernel/mm/damon/admin/kdamonds/<K>/contexts/<C>/schemes/<S>/tried_regions/<R>/age +Date: Oct 2022 +Contact: SeongJae Park <[email protected]> +Description: Reading this file returns the 'age' of a memory region that + corresponding DAMON-based Operation Scheme's action has tried + to be applied.
Signature · 1 line
2.25.1