[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-Id: <20230918111107.85008-1-sj@kernel.org>
Date: Mon, 18 Sep 2023 11:11:07 +0000
From: SeongJae Park <sj@...nel.org>
To: Huan Yang <link@...o.com>
Cc: SeongJae Park <sj@...nel.org>,
Andrew Morton <akpm@...ux-foundation.org>,
damon@...ts.linux.dev (open list:DATA ACCESS MONITOR),
linux-mm@...ck.org (open list:DATA ACCESS MONITOR),
linux-kernel@...r.kernel.org (open list),
opensource.kernel@...o.com
Subject: Re: [PATCH] mm/damon/core: remove unnecessary si_meminfo invoke.
Hi Huan,
On Mon, 18 Sep 2023 17:49:34 +0800 Huan Yang <link@...o.com> wrote:
> si_meminfo() will read and assign more info not just free/ram pages.
Nice catch :)
> For just DAMOS_WMARK_FREE_MEM_RATE use, only get free and ram pages
> is ok to save cpu.
>
> Signed-off-by: Huan Yang <link@...o.com>
> ---
> mm/damon/core.c | 10 ++++++----
> 1 file changed, 6 insertions(+), 4 deletions(-)
>
> diff --git a/mm/damon/core.c b/mm/damon/core.c
> index bcd2bd9d6c10..1cddee9ae73b 100644
> --- a/mm/damon/core.c
> +++ b/mm/damon/core.c
> @@ -1278,14 +1278,16 @@ static bool kdamond_need_stop(struct damon_ctx *ctx)
> return true;
> }
>
> -static unsigned long damos_wmark_metric_value(enum damos_wmark_metric metric)
> +static unsigned long __damons_get_wmark_free_mem_rate(void)
Nit. s/damons/damos/ would look more consistently, in my opinion?
> {
> - struct sysinfo i;
> + return global_zone_page_state(NR_FREE_PAGES) * 1000 / totalram_pages();
> +}
>
> +static unsigned long damos_wmark_metric_value(enum damos_wmark_metric metric)
> +{
> switch (metric) {
> case DAMOS_WMARK_FREE_MEM_RATE:
> - si_meminfo(&i);
> - return i.freeram * 1000 / i.totalram;
> + return __damons_get_wmark_free_mem_rate();
Since __damons_get_wmark_free_mem_rate() is just one line function and
damos_wmark_metric_value() is the only user of the code, I think we could just
writ the code here?
> default:
> break;
> }
> --
> 2.34.1
Thanks,
SJ
Powered by blists - more mailing lists