Skip to content

Commit a479b07

Browse files
zhijianli88akpm00
authored andcommitted
mm/vmscan: accumulate nr_demoted for accurate demotion statistics
In shrink_folio_list(), demote_folio_list() can be called 2 times. Currently stat->nr_demoted will only store the last nr_demoted( the later nr_demoted is always zero, the former nr_demoted will get lost), as a result number of demoted pages is not accurate. Accumulate the nr_demoted count across multiple calls to demote_folio_list(), ensuring accurate reporting of demotion statistics. [[email protected]: introduce local nr_demoted to fix nr_reclaimed double counting] Link: https://lkml.kernel.org/r/[email protected] Link: https://lkml.kernel.org/r/[email protected] Fixes: f77f0c7 ("mm,memcg: provide per-cgroup counters for NUMA balancing operations") Signed-off-by: Li Zhijian <[email protected]> Acked-by: Kaiyang Zhao <[email protected]> Tested-by: Donet Tom <[email protected]> Reviewed-by: Donet Tom <[email protected]> Cc: <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent f921da2 commit a479b07

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

mm/vmscan.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1086,7 +1086,7 @@ static unsigned int shrink_folio_list(struct list_head *folio_list,
10861086
struct folio_batch free_folios;
10871087
LIST_HEAD(ret_folios);
10881088
LIST_HEAD(demote_folios);
1089-
unsigned int nr_reclaimed = 0;
1089+
unsigned int nr_reclaimed = 0, nr_demoted = 0;
10901090
unsigned int pgactivate = 0;
10911091
bool do_demote_pass;
10921092
struct swap_iocb *plug = NULL;
@@ -1550,8 +1550,9 @@ static unsigned int shrink_folio_list(struct list_head *folio_list,
15501550
/* 'folio_list' is always empty here */
15511551

15521552
/* Migrate folios selected for demotion */
1553-
stat->nr_demoted = demote_folio_list(&demote_folios, pgdat);
1554-
nr_reclaimed += stat->nr_demoted;
1553+
nr_demoted = demote_folio_list(&demote_folios, pgdat);
1554+
nr_reclaimed += nr_demoted;
1555+
stat->nr_demoted += nr_demoted;
15551556
/* Folios that could not be demoted are still in @demote_folios */
15561557
if (!list_empty(&demote_folios)) {
15571558
/* Folios which weren't demoted go back on @folio_list */

0 commit comments

Comments
 (0)