diff mbox series

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

Message ID 1554815623-9353-1-git-send-email-laoar.shao@gmail.com (mailing list archive)
State New, archived
Headers show
Series mm/memcontrol: split pgscan into direct and kswapd for memcg | expand

Commit Message

Yafang Shao April 9, 2019, 1:13 p.m. UTC
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.

Signed-off-by: Yafang Shao <laoar.shao@gmail.com>
---
 mm/memcontrol.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Chris Down April 9, 2019, 1:25 p.m. UTC | #1
Hey Yafang,

Yafang Shao writes:
>-	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
Yafang Shao April 9, 2019, 2:04 p.m. UTC | #2
On Tue, Apr 9, 2019 at 9:25 PM Chris Down <chris@chrisdown.name> wrote:
>
> Hey Yafang,
>
> Yafang Shao writes:
> >-      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
Johannes Weiner April 9, 2019, 5:55 p.m. UTC | #3
On Tue, Apr 09, 2019 at 09:13:43PM +0800, Yafang Shao wrote:
> 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.
Yafang Shao April 10, 2019, 1:16 a.m. UTC | #4
On Wed, Apr 10, 2019 at 1:55 AM Johannes Weiner <hannes@cmpxchg.org> wrote:
>
> On Tue, Apr 09, 2019 at 09:13:43PM +0800, Yafang Shao wrote:
> > 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
diff mbox series

Patch

diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 10af4dd..abd17f8 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -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]);