]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
mm-vmscan-accumulate-nr_demoted-for-accurate-demotion-statistics-v2
authorLi Zhijian <lizhijian@fujitsu.com>
Sat, 11 Jan 2025 01:52:53 +0000 (09:52 +0800)
committerAndrew Morton <akpm@linux-foundation.org>
Sun, 26 Jan 2025 23:05:00 +0000 (15:05 -0800)
introduce local nr_demoted to fix nr_reclaimed double counting

Link: https://lkml.kernel.org/r/20250111015253.425693-1-lizhijian@fujitsu.com
Fixes: f77f0c751478 ("mm,memcg: provide per-cgroup counters for NUMA balancing operations")
Signed-off-by: Li Zhijian <lizhijian@fujitsu.com>
Cc: Kaiyang Zhao <kaiyang2@cs.cmu.edu>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
mm/vmscan.c

index 7fd84c7a99b05dfc63cabbb288efdad7a3fe3427..8c229744e3010544e82dd624def1dcdd8436bcd1 100644 (file)
@@ -1053,7 +1053,7 @@ static unsigned int shrink_folio_list(struct list_head *folio_list,
        struct folio_batch free_folios;
        LIST_HEAD(ret_folios);
        LIST_HEAD(demote_folios);
-       unsigned int nr_reclaimed = 0;
+       unsigned int nr_reclaimed = 0, nr_demoted = 0;
        unsigned int pgactivate = 0;
        bool do_demote_pass;
        struct swap_iocb *plug = NULL;
@@ -1522,8 +1522,9 @@ keep:
        /* 'folio_list' is always empty here */
 
        /* Migrate folios selected for demotion */
-       stat->nr_demoted += demote_folio_list(&demote_folios, pgdat);
-       nr_reclaimed += stat->nr_demoted;
+       nr_demoted = demote_folio_list(&demote_folios, pgdat);
+       nr_reclaimed += nr_demoted;
+       stat->nr_demoted += nr_demoted;
        /* Folios that could not be demoted are still in @demote_folios */
        if (!list_empty(&demote_folios)) {
                /* Folios which weren't demoted go back on @folio_list */