Skip to contentSkip to conversation

mm/memcontrol: split pgscan into direct and kswapd for memcg

PATCH In review Yafang Shao 3 participants 5 messages Apr 9, 2019 – Apr 10, 2019

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

PATCH 1/1 mm/memcontrol: split pgscan into direct and kswapd for memcg

Now we count PGSCAN_KSWAPD and PGSCAN_DIRECT into one single item 'pgscan', that's not proper.

PGSCAN_DIRECT is triggered by the tasks in this memcg, which directly indicates the memory status of this memcg;
while PGSCAN_KSWAPD is triggered by the kswapd(which always reflects the system level memory status) and it happens to scan the pages in this memcg.

So we should better split 'pgscan' into 'pgscan_direct' and 'pgscan_kswapd'.

BTW, softlimit reclaim will never happen in cgroup v2.

---
 mm/memcontrol.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
mm/memcontrol.c +2 -2
index 10af4dd..abd17f8 100644
@@ -5635,8 +5635,8 @@ static int memory_stat_show(struct seq_file *m, void *v)
 		   acc.vmstats[WORKINGSET_NODERECLAIM]);
 
 	seq_printf(m, "pgrefill %lu\n", acc.vmevents[PGREFILL]);
-	seq_printf(m, "pgscan %lu\n", acc.vmevents[PGSCAN_KSWAPD] +
-		   acc.vmevents[PGSCAN_DIRECT]);
+	seq_printf(m, "pgscan_direct %lu\n", acc.vmevents[PGSCAN_DIRECT]);
+	seq_printf(m, "pgscan_kswapd %lu\n", acc.vmevents[PGSCAN_KSWAPD]);
 	seq_printf(m, "pgsteal %lu\n", acc.vmevents[PGSTEAL_KSWAPD] +
 		   acc.vmevents[PGSTEAL_DIRECT]);
 	seq_printf(m, "pgactivate %lu\n", acc.vmevents[PGACTIVATE]);
Signature · 1 line
1.8.3.1
#1 lore raw

Hey Yafang,

mm/memcontrol.c static int memory_stat_show(struct seq_file *m, void *v) · line 5639

Quoted 4 lines · Yafang Shao
mm/memcontrol.c +2 -2
-	seq_printf(m, "pgscan %lu\n", acc.vmevents[PGSCAN_KSWAPD] +
-		   acc.vmevents[PGSCAN_DIRECT]);
+	seq_printf(m, "pgscan_direct %lu\n", acc.vmevents[PGSCAN_DIRECT]);
+	seq_printf(m, "pgscan_kswapd %lu\n", acc.vmevents[PGSCAN_KSWAPD]);

I don't think we can remove the overall pgscan counter now, we already have people relying on it in prod. At least from my perspective, this patch would be fine, as long as pgscan was kept.

Thanks,

Chris

#2 lore raw
Quoted 4 lines · Chris Down

Hey Yafang,

Yafang Shao writes:

Quoted 9 lines

mm/memcontrol.c static int memory_stat_show(struct seq_file *m, void *v) · line 5639

Quoted 4 lines
mm/memcontrol.c +2 -2
-      seq_printf(m, "pgscan %lu\n", acc.vmevents[PGSCAN_KSWAPD] +
-                 acc.vmevents[PGSCAN_DIRECT]);
+      seq_printf(m, "pgscan_direct %lu\n", acc.vmevents[PGSCAN_DIRECT]);
+      seq_printf(m, "pgscan_kswapd %lu\n", acc.vmevents[PGSCAN_KSWAPD]);

I don't think we can remove the overall pgscan counter now, we already have people relying on it in prod. At least from my perspective, this patch would be fine, as long as pgscan was kept.

HI Chirs,

Thanks for your feedback.
I will keep 'pgscan' and only introduce 'pgscan_kswapd'.

Thanks
Yafang

maintainer
#3 lore raw
In reply to Yafang Shao
Quoted 5 lines · Yafang Shao

Now we count PGSCAN_KSWAPD and PGSCAN_DIRECT into one single item 'pgscan', that's not proper.

PGSCAN_DIRECT is triggered by the tasks in this memcg, which directly indicates the memory status of this memcg;

PGSCAN_DIRECT occurs independent of cgroups when kswapd is overwhelmed or when allocations don't pass __GFP_KSWAPD_RECLAIM. You'll get direct reclaim inside memcgs that don't have a limit.

#4 lore raw
Quoted 11 lines · Johannes Weiner
Quoted 5 lines · Yafang Shao

Now we count PGSCAN_KSWAPD and PGSCAN_DIRECT into one single item 'pgscan', that's not proper.

PGSCAN_DIRECT is triggered by the tasks in this memcg, which directly indicates the memory status of this memcg;

PGSCAN_DIRECT occurs independent of cgroups when kswapd is overwhelmed or when allocations don't pass __GFP_KSWAPD_RECLAIM. You'll get direct reclaim inside memcgs that don't have a limit.

Oh yes.
Plus PGSCAN_DIRECT may also triggered by the tasks in the parent memcg.

'pgscan' here only cares about the memory in this memcg, other than the tasks in this memcg.
Seems we'd better introduce another counter to reflect the tasks in this memcg.

Thanks
Yafang