Skip to contentSkip to conversation

mm: vmscan : pgdemote vmstat is not getting updated when MGLRU is enabled.

PATCH Applied Donet Tom 3 participants 4 messages Jan 9, 2025 – Jan 11, 2025

Subsystems (3)
lore
Share & tools
lore

Donet Tom

author
#0 lore raw

PATCH 1/1 mm: vmscan : pgdemote vmstat is not getting updated when MGLRU is enabled.

When MGLRU is enabled, the pgdemote_kswapd, pgdemote_direct, and pgdemote_khugepaged stats in vmstat are not being updated.

'Commit f77f0c751478 ("mm,memcg: provide per-cgroup counters for NUMA balancing operations")' moved the pgdemote vmstat update from demote_folio_list() to shrink_inactive_list(), which is in the normal LRU path. As a result, the pgdemote stats are updated correctly for the normal LRU but not for MGLRU.

To address this, we have added the pgdemote stat update in the evict_folios() function, which is in the MGLRU path. With this patch, the pgdemote stats will now be updated correctly when MGLRU is enabled.

Without this patch vmstat output when MGLRU is enabled
======================================================
pgdemote_kswapd 0
pgdemote_direct 0
pgdemote_khugepaged 0

With this patch vmstat output when MGLRU is enabled
===================================================
pgdemote_kswapd 43234
pgdemote_direct 4691
pgdemote_khugepaged 0

Fixes f77f0c751478 ("mm,memcg: provide per-cgroup counters for NUMA balancing operations")
---
 mm/vmscan.c | 3 +++
 1 file changed, 3 insertions(+)
mm/vmscan.c +3 -0
index 9a859b7d18d7..b1ec5ece067e 100644
@@ -4642,6 +4642,9 @@ static int evict_folios(struct lruvec *lruvec, struct scan_control *sc, int swap
 		reset_batch_size(walk);
 	}
 
+	__mod_lruvec_state(lruvec, PGDEMOTE_KSWAPD + reclaimer_offset(),
+					stat.nr_demoted);
+
 	item = PGSTEAL_KSWAPD + reclaimer_offset();
 	if (!cgroup_reclaim(sc))
 		__count_vm_events(item, reclaimed);
Signature · 1 line
2.43.5
Acked-by on v1 1/1
#1 lore raw
Quoted 21 lines · Donet Tom

When MGLRU is enabled, the pgdemote_kswapd, pgdemote_direct, and pgdemote_khugepaged stats in vmstat are not being updated.

'Commit f77f0c751478 ("mm,memcg: provide per-cgroup counters for NUMA balancing operations")' moved the pgdemote vmstat update from demote_folio_list() to shrink_inactive_list(), which is in the normal LRU path. As a result, the pgdemote stats are updated correctly for the normal LRU but not for MGLRU.

To address this, we have added the pgdemote stat update in the evict_folios() function, which is in the MGLRU path. With this patch, the pgdemote stats will now be updated correctly when MGLRU is enabled.

Without this patch vmstat output when MGLRU is enabled
======================================================
pgdemote_kswapd 0
pgdemote_direct 0
pgdemote_khugepaged 0

Quoted 8 lines

With this patch vmstat output when MGLRU is enabled
===================================================
pgdemote_kswapd 43234
pgdemote_direct 4691
pgdemote_khugepaged 0

Fixes f77f0c751478 ("mm,memcg: provide per-cgroup counters for NUMA balancing operations")
Tested-by on v1 1/1
#2 lore raw
In reply to Donet Tom
Quoted 20 lines

When MGLRU is enabled, the pgdemote_kswapd, pgdemote_direct, and pgdemote_khugepaged stats in vmstat are not being updated.

'Commit f77f0c751478 ("mm,memcg: provide per-cgroup counters for NUMA balancing operations")' moved the pgdemote vmstat update from demote_folio_list() to shrink_inactive_list(), which is in the normal LRU path. As a result, the pgdemote stats are updated correctly for the normal LRU but not for MGLRU.

To address this, we have added the pgdemote stat update in the evict_folios() function, which is in the MGLRU path. With this patch, the pgdemote stats will now be updated correctly when MGLRU is enabled.

Without this patch vmstat output when MGLRU is enabled
======================================================
pgdemote_kswapd 0
pgdemote_direct 0
pgdemote_khugepaged 0

Quoted 8 lines

With this patch vmstat output when MGLRU is enabled
===================================================
pgdemote_kswapd 43234
pgdemote_direct 4691
pgdemote_khugepaged 0

Fixes f77f0c751478 ("mm,memcg: provide per-cgroup counters for NUMA balancing operations")

Great minds think alike, It's excatly same with mine[0] :)

There is another bug[1] as well.
[0] https://lore.kernel.org/linux-mm/[email protected]/ [1] https://lore.kernel.org/linux-mm/[email protected]/

Feel free to add vvv if your patch is accepted at last.

Quoted 14 lines
---
  mm/vmscan.c  <https://lore.kernel.org/lkml/[email protected]/#Z31mm:vmscan.c>  | 3 +++

1 filechanged <https://lore.kernel.org/lkml/[email protected]/#related>, 3 insertions(+)

diff <https://lore.kernel.org/lkml/[email protected]/#iZ31mm:vmscan.c>
--git a/mm/vmscan.c b/mm/vmscan.c index 9a859b7d18d7..b1ec5ece067e
100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -4642,6 +4642,9 @@ static int evict_folios(struct lruvec *lruvec, struct scan_control *sc, int swap reset_batch_size(walk);
}

+ __mod_lruvec_state(lruvec, PGDEMOTE_KSWAPD + reclaimer_offset(), +
stat.nr_demoted); + item = PGSTEAL_KSWAPD + reclaimer_offset();
if (!cgroup_reclaim(sc))
__count_vm_events(item, reclaimed);

Tested-by Reviewed-by on v1 1/1
#3 lore raw
In reply to Donet Tom
Quoted 21 lines

When MGLRU is enabled, the pgdemote_kswapd, pgdemote_direct, and pgdemote_khugepaged stats in vmstat are not being updated. 'Commit f77f0c751478 ("mm,memcg: provide per-cgroup counters for NUMA balancing operations")' moved the pgdemote vmstat update from demote_folio_list() to shrink_inactive_list(), which is in the normal LRU path. As a result, the pgdemote stats are updated correctly for the normal LRU but not for MGLRU.
To address this, we have added the pgdemote stat update in the evict_folios() function, which is in the MGLRU path. With this patch, the pgdemote stats will now be updated correctly when MGLRU is enabled.
Without this patch vmstat output when MGLRU is enabled
======================================================
pgdemote_kswapd 0
pgdemote_direct 0
pgdemote_khugepaged 0
With this patch vmstat output when MGLRU is enabled
===================================================
pgdemote_kswapd 43234
pgdemote_direct 4691
pgdemote_khugepaged 0

Quoted 2 lines
Fixes f77f0c751478 ("mm,memcg: provide per-cgroup counters for NUMA balancing operations")

Great minds think alike, It's excatly same with mine[0] :)

There is another bug[1] as well.

[0] https://lore.kernel.org/linux-mm/[email protected]/

[1] https://lore.kernel.org/linux-mm/[email protected]/

Feel free to add vvv if your patch is accepted at last.

Quoted 9 lines
---
   mm/vmscan.c  <https://lore.kernel.org/lkml/[email protected]/#Z31mm:vmscan.c>  | 3 +++
   1 filechanged  <https://lore.kernel.org/lkml/[email protected]/#related>, 3 insertions(+)
diff <https://lore.kernel.org/lkml/[email protected]/#iZ31mm:vmscan.c> --git a/mm/vmscan.c b/mm/vmscan.c index 9a859b7d18d7..b1ec5ece067e 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -4642,6 +4642,9 @@ static int evict_folios(struct lruvec *lruvec, struct scan_control *sc, int swap   		reset_batch_size(walk);
   	}
   + __mod_lruvec_state(lruvec, PGDEMOTE_KSWAPD + reclaimer_offset(), + stat.nr_demoted); +   	item = PGSTEAL_KSWAPD + reclaimer_offset();
   	if (!cgroup_reclaim(sc))
   		__count_vm_events(item, reclaimed);