lkml.org 
[lkml]   [2020]   [May]   [26]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[RFC v9 5/8] mm/damon/schemes: Implement statistics feature
Date
From: SeongJae Park <sjpark@amazon.de>

To tune the DAMON-based operation schemes, knowing how many and how
large regions are affected by each of the schemes will be helful. Those
stats could be used for not only the tuning, but also monitoring of the
working set size and the number of regions, if the scheme does not
change the program behavior too much.

For the reason, this commit implements the statistics for the schemes.
The total number and size of the regions that each scheme is applied are
exported to users via '->stat_count' and '->stat_sz' of 'struct damos'.
Admins can also check the number by reading 'schemes' debugfs file. The
last two integers now represents the stats. To allow collecting the
stats without changing the program behavior, this commit also adds new
scheme action, 'DAMOS_STAT'. Note that 'DAMOS_STAT' is not only making
no memory operation actions, but also does not reset the age of regions.

Signed-off-by: SeongJae Park <sjpark@amazon.de>
---
include/linux/damon.h | 6 ++++++
mm/damon.c | 13 ++++++++++---
2 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/include/linux/damon.h b/include/linux/damon.h
index d5a3e4dc5f9a..0c7f0d629648 100644
--- a/include/linux/damon.h
+++ b/include/linux/damon.h
@@ -64,6 +64,7 @@ struct damon_task {
* @DAMOS_PAGEOUT: Call ``madvise()`` for the region with MADV_PAGEOUT.
* @DAMOS_HUGEPAGE: Call ``madvise()`` for the region with MADV_HUGEPAGE.
* @DAMOS_NOHUGEPAGE: Call ``madvise()`` for the region with MADV_NOHUGEPAGE.
+ * @DAMOS_STAT: Do nothing but count the stat.
* @DAMOS_ACTION_LEN: Number of supported actions.
*/
enum damos_action {
@@ -72,6 +73,7 @@ enum damos_action {
DAMOS_PAGEOUT,
DAMOS_HUGEPAGE,
DAMOS_NOHUGEPAGE,
+ DAMOS_STAT, /* Do nothing but only record the stat */
DAMOS_ACTION_LEN,
};

@@ -84,6 +86,8 @@ enum damos_action {
* @min_age_region: Minimum age of target regions.
* @max_age_region: Maximum age of target regions.
* @action: &damo_action to be applied to the target regions.
+ * @stat_count: Total number of regions that this scheme is applied.
+ * @stat_sz: Total size of regions that this scheme is applied.
* @list: List head for siblings.
*
* For each aggregation interval, DAMON applies @action to monitoring target
@@ -97,6 +101,8 @@ struct damos {
unsigned int min_age_region;
unsigned int max_age_region;
enum damos_action action;
+ unsigned long stat_count;
+ unsigned long stat_sz;
struct list_head list;
};

diff --git a/mm/damon.c b/mm/damon.c
index bcc732e8735c..092e300a00eb 100644
--- a/mm/damon.c
+++ b/mm/damon.c
@@ -191,6 +191,8 @@ static struct damos *damon_new_scheme(
scheme->min_age_region = min_age_region;
scheme->max_age_region = max_age_region;
scheme->action = action;
+ scheme->stat_count = 0;
+ scheme->stat_sz = 0;
INIT_LIST_HEAD(&scheme->list);

return scheme;
@@ -771,6 +773,8 @@ static int damos_do_action(struct damon_task *task, struct damon_region *r,
case DAMOS_NOHUGEPAGE:
madv_action = MADV_NOHUGEPAGE;
break;
+ case DAMOS_STAT:
+ return 0;
default:
pr_warn("Wrong action %d\n", action);
return -EINVAL;
@@ -798,8 +802,11 @@ static void damon_do_apply_schemes(struct damon_ctx *c, struct damon_task *t,
(s->max_age_region &&
s->max_age_region < r->age))
continue;
+ s->stat_count++;
+ s->stat_sz += sz;
damos_do_action(t, r, s->action);
- r->age = 0;
+ if (s->action != DAMOS_STAT)
+ r->age = 0;
}
}

@@ -1385,11 +1392,11 @@ static ssize_t sprint_schemes(struct damon_ctx *c, char *buf, ssize_t len)

damon_for_each_scheme(s, c) {
rc = snprintf(&buf[written], len - written,
- "%u %u %u %u %u %u %d\n",
+ "%u %u %u %u %u %u %d %lu %lu\n",
s->min_sz_region, s->max_sz_region,
s->min_nr_accesses, s->max_nr_accesses,
s->min_age_region, s->max_age_region,
- s->action);
+ s->action, s->stat_count, s->stat_sz);
if (!rc)
return -ENOMEM;

--
2.17.1
\
 
 \ /
  Last update: 2020-05-26 10:05    [W:0.097 / U:5.680 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site