mm/damon/core: remove unnecessary si_meminfo invoke.
authorHuan Yang <link@vivo.com>
Wed, 20 Sep 2023 01:57:27 +0000 (09:57 +0800)
committerAndrew Morton <akpm@linux-foundation.org>
Mon, 16 Oct 2023 22:44:38 +0000 (15:44 -0700)
si_meminfo() will read and assign more info not just free/ram pages.  For
just DAMOS_WMARK_FREE_MEM_RATE use, only get free and ram pages is ok to
save cpu.

Link: https://lkml.kernel.org/r/20230920015727.4482-1-link@vivo.com
Signed-off-by: Huan Yang <link@vivo.com>
Reviewed-by: SeongJae Park <sj@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
mm/damon/core.c

index 5eb649bd002f8b42a7e2833f62f729d9f3f2d5a5..9f4f7c378cf377521cefb6db2c75b34de140c2cd 100644 (file)
@@ -1326,12 +1326,10 @@ static bool kdamond_need_stop(struct damon_ctx *ctx)
 
 static unsigned long damos_wmark_metric_value(enum damos_wmark_metric metric)
 {
-       struct sysinfo i;
-
        switch (metric) {
        case DAMOS_WMARK_FREE_MEM_RATE:
-               si_meminfo(&i);
-               return i.freeram * 1000 / i.totalram;
+               return global_zone_page_state(NR_FREE_PAGES) * 1000 /
+                      totalram_pages();
        default:
                break;
        }