* [PATCH V2] mm/damon: simplify scheme create in damon_lru_sort_apply_parameters
@ 2022-09-11 0:59 Xin Hao
2022-09-11 11:57 ` SeongJae Park
0 siblings, 1 reply; 2+ messages in thread
From: Xin Hao @ 2022-09-11 0:59 UTC (permalink / raw)
To: sj; +Cc: akpm, damon, linux-mm, linux-kernel, xhao
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.
Signed-off-by: Xin Hao <xhao@linux.alibaba.com>
---
Changes from v1
(https://lore.kernel.org/linux-mm/20220910165536.99023-1-xhao@linux.alibaba.com/T/)
- Fix complile warning about unused 'next_schemes' variable
---
mm/damon/lru_sort.c | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/mm/damon/lru_sort.c b/mm/damon/lru_sort.c
index b8ec52739e0f..1eb824ab8a98 100644
--- a/mm/damon/lru_sort.c
+++ b/mm/damon/lru_sort.c
@@ -340,7 +340,7 @@ static struct damos *damon_lru_sort_new_cold_scheme(unsigned int cold_thres)
static int damon_lru_sort_apply_parameters(void)
{
- struct damos *scheme, *next_scheme;
+ struct damos *scheme;
struct damon_addr_range addr_range;
unsigned int hot_thres, cold_thres;
int err = 0;
@@ -350,17 +350,15 @@ static int damon_lru_sort_apply_parameters(void)
if (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 */
hot_thres = aggr_interval / sample_interval * hot_thres_access_freq /
1000;
scheme = damon_lru_sort_new_hot_scheme(hot_thres);
if (!scheme)
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;
scheme = damon_lru_sort_new_cold_scheme(cold_thres);
--
2.31.0
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [PATCH V2] mm/damon: simplify scheme create in damon_lru_sort_apply_parameters
2022-09-11 0:59 [PATCH V2] mm/damon: simplify scheme create in damon_lru_sort_apply_parameters Xin Hao
@ 2022-09-11 11:57 ` SeongJae Park
0 siblings, 0 replies; 2+ messages in thread
From: SeongJae Park @ 2022-09-11 11:57 UTC (permalink / raw)
To: Xin Hao; +Cc: sj, akpm, damon, linux-mm, linux-kernel
Hi Xin,
On Sun, 11 Sep 2022 08:59:17 +0800 Xin Hao <xhao@linux.alibaba.com> wrote:
> 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.
>
> Signed-off-by: Xin Hao <xhao@linux.alibaba.com>
Reviewed-by: SeongJae Park <sj@kernel.org>
Thanks,
SJ
[...]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-09-11 11:57 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-11 0:59 [PATCH V2] mm/damon: simplify scheme create in damon_lru_sort_apply_parameters Xin Hao
2022-09-11 11:57 ` SeongJae Park
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox