mm/damon/lru_sort: use stat generator

This commit makes DAMON_LRU_SORT to generate the module parameters for
DAMOS statistics using the generator macro to simplify the code and reduce
duplicates.

Link: https://lkml.kernel.org/r/20220913174449.50645-18-sj@kernel.org
Signed-off-by: SeongJae Park <sj@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
This commit is contained in:
SeongJae Park 2022-09-13 17:44:44 +00:00 committed by Andrew Morton
parent b71f3ea832
commit dd172fbf8f
1 changed files with 12 additions and 71 deletions

View File

@ -135,65 +135,15 @@ module_param(monitor_region_end, ulong, 0600);
static int kdamond_pid __read_mostly = -1;
module_param(kdamond_pid, int, 0400);
/*
* Number of hot memory regions that tried to be LRU-sorted.
*/
static unsigned long nr_lru_sort_tried_hot_regions __read_mostly;
module_param(nr_lru_sort_tried_hot_regions, ulong, 0400);
static struct damos_stat damon_lru_sort_hot_stat;
DEFINE_DAMON_MODULES_DAMOS_STATS_PARAMS(damon_lru_sort_hot_stat,
lru_sort_tried_hot_regions, lru_sorted_hot_regions,
hot_quota_exceeds);
/*
* Total bytes of hot memory regions that tried to be LRU-sorted.
*/
static unsigned long bytes_lru_sort_tried_hot_regions __read_mostly;
module_param(bytes_lru_sort_tried_hot_regions, ulong, 0400);
/*
* Number of hot memory regions that successfully be LRU-sorted.
*/
static unsigned long nr_lru_sorted_hot_regions __read_mostly;
module_param(nr_lru_sorted_hot_regions, ulong, 0400);
/*
* Total bytes of hot memory regions that successfully be LRU-sorted.
*/
static unsigned long bytes_lru_sorted_hot_regions __read_mostly;
module_param(bytes_lru_sorted_hot_regions, ulong, 0400);
/*
* Number of times that the time quota limit for hot regions have exceeded
*/
static unsigned long nr_hot_quota_exceeds __read_mostly;
module_param(nr_hot_quota_exceeds, ulong, 0400);
/*
* Number of cold memory regions that tried to be LRU-sorted.
*/
static unsigned long nr_lru_sort_tried_cold_regions __read_mostly;
module_param(nr_lru_sort_tried_cold_regions, ulong, 0400);
/*
* Total bytes of cold memory regions that tried to be LRU-sorted.
*/
static unsigned long bytes_lru_sort_tried_cold_regions __read_mostly;
module_param(bytes_lru_sort_tried_cold_regions, ulong, 0400);
/*
* Number of cold memory regions that successfully be LRU-sorted.
*/
static unsigned long nr_lru_sorted_cold_regions __read_mostly;
module_param(nr_lru_sorted_cold_regions, ulong, 0400);
/*
* Total bytes of cold memory regions that successfully be LRU-sorted.
*/
static unsigned long bytes_lru_sorted_cold_regions __read_mostly;
module_param(bytes_lru_sorted_cold_regions, ulong, 0400);
/*
* Number of times that the time quota limit for cold regions have exceeded
*/
static unsigned long nr_cold_quota_exceeds __read_mostly;
module_param(nr_cold_quota_exceeds, ulong, 0400);
static struct damos_stat damon_lru_sort_cold_stat;
DEFINE_DAMON_MODULES_DAMOS_STATS_PARAMS(damon_lru_sort_cold_stat,
lru_sort_tried_cold_regions, lru_sorted_cold_regions,
cold_quota_exceeds);
static struct damon_ctx *ctx;
static struct damon_target *target;
@ -397,19 +347,10 @@ static int damon_lru_sort_after_aggregation(struct damon_ctx *c)
/* update the stats parameter */
damon_for_each_scheme(s, c) {
if (s->action == DAMOS_LRU_PRIO) {
nr_lru_sort_tried_hot_regions = s->stat.nr_tried;
bytes_lru_sort_tried_hot_regions = s->stat.sz_tried;
nr_lru_sorted_hot_regions = s->stat.nr_applied;
bytes_lru_sorted_hot_regions = s->stat.sz_applied;
nr_hot_quota_exceeds = s->stat.qt_exceeds;
} else if (s->action == DAMOS_LRU_DEPRIO) {
nr_lru_sort_tried_cold_regions = s->stat.nr_tried;
bytes_lru_sort_tried_cold_regions = s->stat.sz_tried;
nr_lru_sorted_cold_regions = s->stat.nr_applied;
bytes_lru_sorted_cold_regions = s->stat.sz_applied;
nr_cold_quota_exceeds = s->stat.qt_exceeds;
}
if (s->action == DAMOS_LRU_PRIO)
damon_lru_sort_hot_stat = s->stat;
else if (s->action == DAMOS_LRU_DEPRIO)
damon_lru_sort_cold_stat = s->stat;
}
return damon_lru_sort_handle_commit_inputs();