mm/damon: simplify scheme create in damon_lru_sort_apply_parameters
In damon_lru_sort_apply_parameters(), we can use damon_set_schemes() to replace the way of creating the first 'scheme' in original code, this makes the code look cleaner. Link: https://lkml.kernel.org/r/20220911005917.835-1-xhao@linux.alibaba.com Signed-off-by: Xin Hao <xhao@linux.alibaba.com> Reviewed-by: SeongJae Park <sj@kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
This commit is contained in:
parent
f9bceb2f41
commit
3791bc7bf1
|
@ -350,7 +350,7 @@ static struct damos *damon_lru_sort_new_cold_scheme(unsigned int cold_thres)
|
||||||
|
|
||||||
static int damon_lru_sort_apply_parameters(void)
|
static int damon_lru_sort_apply_parameters(void)
|
||||||
{
|
{
|
||||||
struct damos *scheme, *next_scheme;
|
struct damos *scheme;
|
||||||
struct damon_addr_range addr_range;
|
struct damon_addr_range addr_range;
|
||||||
unsigned int hot_thres, cold_thres;
|
unsigned int hot_thres, cold_thres;
|
||||||
int err = 0;
|
int err = 0;
|
||||||
|
@ -360,17 +360,15 @@ static int damon_lru_sort_apply_parameters(void)
|
||||||
if (err)
|
if (err)
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
/* free previously set schemes */
|
|
||||||
damon_for_each_scheme_safe(scheme, next_scheme, ctx)
|
|
||||||
damon_destroy_scheme(scheme);
|
|
||||||
|
|
||||||
/* aggr_interval / sample_interval is the maximum nr_accesses */
|
/* aggr_interval / sample_interval is the maximum nr_accesses */
|
||||||
hot_thres = aggr_interval / sample_interval * hot_thres_access_freq /
|
hot_thres = aggr_interval / sample_interval * hot_thres_access_freq /
|
||||||
1000;
|
1000;
|
||||||
scheme = damon_lru_sort_new_hot_scheme(hot_thres);
|
scheme = damon_lru_sort_new_hot_scheme(hot_thres);
|
||||||
if (!scheme)
|
if (!scheme)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
damon_add_scheme(ctx, scheme);
|
err = damon_set_schemes(ctx, &scheme, 1);
|
||||||
|
if (err)
|
||||||
|
return err;
|
||||||
|
|
||||||
cold_thres = cold_min_age / aggr_interval;
|
cold_thres = cold_min_age / aggr_interval;
|
||||||
scheme = damon_lru_sort_new_cold_scheme(cold_thres);
|
scheme = damon_lru_sort_new_cold_scheme(cold_thres);
|
||||||
|
|
Loading…
Reference in New Issue