Skip to contentSkip to conversation

mm: vmscan: consistent update to pgrefill

PATCH Applied Shakeel Butt 4 participants 5 messages Jul 11, 2020

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mm: vmscan: consistent update to pgrefill

The vmstat pgrefill is useful together with pgscan and pgsteal stats to measure the reclaim efficiency. However vmstat's pgrefill is not updated consistently at system level. It gets updated for both global and memcg reclaim however pgscan and pgsteal are updated for only global reclaim. So, update pgrefill only for global reclaim. If someone is interested in the stats representing both system level as well as memcg level reclaim, then consult the root memcg's memory.stat instead of /proc/vmstat.

---
 mm/vmscan.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
mm/vmscan.c +2 -1
index 5215840ee217..4167b0cc1784 100644
@@ -2030,7 +2030,8 @@ static void shrink_active_list(unsigned long nr_to_scan,
 
 	__mod_node_page_state(pgdat, NR_ISOLATED_ANON + file, nr_taken);
 
-	__count_vm_events(PGREFILL, nr_scanned);
+	if (!cgroup_reclaim(sc))
+		__count_vm_events(PGREFILL, nr_scanned);
 	__count_memcg_events(lruvec_memcg(lruvec), PGREFILL, nr_scanned);
 
 	spin_unlock_irq(&pgdat->lru_lock);
Signature · 1 line
2.27.0.383.g050319c2ae-goog
Acked-by on v1 1/1
#1 lore raw
Quoted 10 lines · Shakeel Butt

The vmstat pgrefill is useful together with pgscan and pgsteal stats to measure the reclaim efficiency. However vmstat's pgrefill is not updated consistently at system level. It gets updated for both global and memcg reclaim however pgscan and pgsteal are updated for only global reclaim. So, update pgrefill only for global reclaim. If someone is interested in the stats representing both system level as well as memcg level reclaim, then consult the root memcg's memory.stat instead of /proc/vmstat.

Quoted 21 lines
---
 mm/vmscan.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
mm/vmscan.c +2 -2
index 5215840ee217..4167b0cc1784 100644
@@ -2030,7 +2030,8 @@ static void shrink_active_list(unsigned long nr_to_scan,
 
        __mod_node_page_state(pgdat, NR_ISOLATED_ANON + file, nr_taken);
 
-       __count_vm_events(PGREFILL, nr_scanned);
+       if (!cgroup_reclaim(sc))
+               __count_vm_events(PGREFILL, nr_scanned);
        __count_memcg_events(lruvec_memcg(lruvec), PGREFILL, nr_scanned);
 
        spin_unlock_irq(&pgdat->lru_lock);
--

2.27.0.383.g050319c2ae-goog

Signature · 2 lines
Thanks
Yafang
Acked-by on v1 1/1
#2 lore raw
In reply to Shakeel Butt
Quoted 9 lines · Shakeel Butt

The vmstat pgrefill is useful together with pgscan and pgsteal stats to measure the reclaim efficiency. However vmstat's pgrefill is not updated consistently at system level. It gets updated for both global and memcg reclaim however pgscan and pgsteal are updated for only global reclaim. So, update pgrefill only for global reclaim. If someone is interested in the stats representing both system level as well as memcg level reclaim, then consult the root memcg's memory.stat instead of /proc/vmstat.

So you went into the opposite direction from the "previous version" ( https://lkml.org/lkml/2020/5/7/1464 ) ?

Thanks!

#3 lore raw
Quoted 10 lines · Roman Gushchin
Quoted 8 lines · Shakeel Butt

The vmstat pgrefill is useful together with pgscan and pgsteal stats to measure the reclaim efficiency. However vmstat's pgrefill is not updated consistently at system level. It gets updated for both global and memcg reclaim however pgscan and pgsteal are updated for only global reclaim. So, update pgrefill only for global reclaim. If someone is interested in the stats representing both system level as well as memcg level reclaim, then consult the root memcg's memory.stat instead of /proc/vmstat.

Quoted 5 lines
Quoted 1 line

So you went into the opposite direction from the "previous version" ( https://lkml.org/lkml/2020/5/7/1464 ) ?

Yes because we already had those stats in the root memcg and exposing root memcg's memory.stat resolved the issue.

Quoted 1 line

Thanks a lot.

Acked-by on v1 1/1
#4 lore raw
In reply to Shakeel Butt
Quoted 9 lines · Shakeel Butt

The vmstat pgrefill is useful together with pgscan and pgsteal stats to measure the reclaim efficiency. However vmstat's pgrefill is not updated consistently at system level. It gets updated for both global and memcg reclaim however pgscan and pgsteal are updated for only global reclaim. So, update pgrefill only for global reclaim. If someone is interested in the stats representing both system level as well as memcg level reclaim, then consult the root memcg's memory.stat instead of /proc/vmstat.