linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mm, memcg: add workingset_restore in memory.stat
@ 2020-05-02 14:18 Yafang Shao
  2020-05-02 14:48 ` Johannes Weiner
  2020-05-04  9:10 ` Michal Hocko
  0 siblings, 2 replies; 4+ messages in thread
From: Yafang Shao @ 2020-05-02 14:18 UTC (permalink / raw)
  To: akpm; +Cc: mhocko, hannes, linux-mm, Yafang Shao

There's a new workingset counter introduced in commit 1899ad18c607 ("mm:
workingset: tell cache transitions from workingset thrashing"). With the
help of this counter we can know the workingset is transitioning or
thrashing. To leverage the benifit of this counter to memcg, we should
introduce it into memory.stat. Then we could know the workingset of the
workload inside a memcg better.

Bellow is the verification of this new counter in memory.stat.
Read a file into the memory and then read it again to make these pages be
active. The size of this file is 1G. (memory.max is greater than file size)
The counters in memory.stat will be,
	inactive_file 0
	active_file 1073639424

	workingset_refault 0
	workingset_activate 0
	workingset_restore 0
	workingset_nodereclaim 0
Trigger the memcg reclaim by setting a lower value to memory.high, and
then some pages will be demoted into inactive list, and then some pages
in the inactive list will be evicted into the storage.
	inactive_file 498094080
	active_file 310063104

	workingset_refault 0
	workingset_activate 0
	workingset_restore 0
	workingset_nodereclaim 0
Then recover the memory.high and read the file into memory again. As a
result of it, the transitioning will occur. Bellow is the result of this
transitioning,
	inactive_file 498094080
	active_file 575397888

	workingset_refault 64746
	workingset_activate 64746
	workingset_restore 64746
	workingset_nodereclaim 0

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

diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 5beea03dd58a..0395e479995b 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -1451,6 +1451,8 @@ static char *memory_stat_format(struct mem_cgroup *memcg)
 		       memcg_page_state(memcg, WORKINGSET_REFAULT));
 	seq_buf_printf(&s, "workingset_activate %lu\n",
 		       memcg_page_state(memcg, WORKINGSET_ACTIVATE));
+	seq_buf_printf(&s, "workingset_restore %lu\n",
+		       memcg_page_state(memcg, WORKINGSET_RESTORE));
 	seq_buf_printf(&s, "workingset_nodereclaim %lu\n",
 		       memcg_page_state(memcg, WORKINGSET_NODERECLAIM));
 
-- 
2.18.2



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] mm, memcg: add workingset_restore in memory.stat
  2020-05-02 14:18 [PATCH] mm, memcg: add workingset_restore in memory.stat Yafang Shao
@ 2020-05-02 14:48 ` Johannes Weiner
  2020-05-04  9:10 ` Michal Hocko
  1 sibling, 0 replies; 4+ messages in thread
From: Johannes Weiner @ 2020-05-02 14:48 UTC (permalink / raw)
  To: Yafang Shao; +Cc: akpm, mhocko, linux-mm

On Sat, May 02, 2020 at 10:18:49AM -0400, Yafang Shao wrote:
> There's a new workingset counter introduced in commit 1899ad18c607 ("mm:
> workingset: tell cache transitions from workingset thrashing"). With the
> help of this counter we can know the workingset is transitioning or
> thrashing. To leverage the benifit of this counter to memcg, we should
> introduce it into memory.stat. Then we could know the workingset of the
> workload inside a memcg better.
> 
> Bellow is the verification of this new counter in memory.stat.
>
> Read a file into the memory and then read it again to make these pages be
> active. The size of this file is 1G. (memory.max is greater than file size)
> The counters in memory.stat will be,
> 	inactive_file 0
> 	active_file 1073639424
> 
> 	workingset_refault 0
> 	workingset_activate 0
> 	workingset_restore 0
> 	workingset_nodereclaim 0
> Trigger the memcg reclaim by setting a lower value to memory.high, and
> then some pages will be demoted into inactive list, and then some pages
> in the inactive list will be evicted into the storage.
> 	inactive_file 498094080
> 	active_file 310063104
> 
> 	workingset_refault 0
> 	workingset_activate 0
> 	workingset_restore 0
> 	workingset_nodereclaim 0
> Then recover the memory.high and read the file into memory again. As a
> result of it, the transitioning will occur. Bellow is the result of this
> transitioning,
> 	inactive_file 498094080
> 	active_file 575397888
> 
> 	workingset_refault 64746
> 	workingset_activate 64746
> 	workingset_restore 64746
> 	workingset_nodereclaim 0
> 
> Signed-off-by: Yafang Shao <laoar.shao@gmail.com>

Thanks, yes, I've missed that counter a few times while debugging
something but never gotten around to actually adding it.

Acked-by: Johannes Weiner <hannes@cmpxchg.org>


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] mm, memcg: add workingset_restore in memory.stat
  2020-05-02 14:18 [PATCH] mm, memcg: add workingset_restore in memory.stat Yafang Shao
  2020-05-02 14:48 ` Johannes Weiner
@ 2020-05-04  9:10 ` Michal Hocko
  2020-05-04 12:35   ` Yafang Shao
  1 sibling, 1 reply; 4+ messages in thread
From: Michal Hocko @ 2020-05-04  9:10 UTC (permalink / raw)
  To: Yafang Shao; +Cc: akpm, hannes, linux-mm

On Sat 02-05-20 10:18:49, Yafang Shao wrote:
> There's a new workingset counter introduced in commit 1899ad18c607 ("mm:
> workingset: tell cache transitions from workingset thrashing"). With the
> help of this counter we can know the workingset is transitioning or
> thrashing. To leverage the benifit of this counter to memcg, we should
> introduce it into memory.stat. Then we could know the workingset of the
> workload inside a memcg better.
> 
> Bellow is the verification of this new counter in memory.stat.
> Read a file into the memory and then read it again to make these pages be
> active. The size of this file is 1G. (memory.max is greater than file size)
> The counters in memory.stat will be,
> 	inactive_file 0
> 	active_file 1073639424
> 
> 	workingset_refault 0
> 	workingset_activate 0
> 	workingset_restore 0
> 	workingset_nodereclaim 0
> Trigger the memcg reclaim by setting a lower value to memory.high, and
> then some pages will be demoted into inactive list, and then some pages
> in the inactive list will be evicted into the storage.
> 	inactive_file 498094080
> 	active_file 310063104
> 
> 	workingset_refault 0
> 	workingset_activate 0
> 	workingset_restore 0
> 	workingset_nodereclaim 0
> Then recover the memory.high and read the file into memory again. As a
> result of it, the transitioning will occur. Bellow is the result of this
> transitioning,
> 	inactive_file 498094080
> 	active_file 575397888
> 
> 	workingset_refault 64746
> 	workingset_activate 64746
> 	workingset_restore 64746
> 	workingset_nodereclaim 0

Could you update Documentation/admin-guide/cgroup-v2.rst as well please?

> Signed-off-by: Yafang Shao <laoar.shao@gmail.com>

Acked-by: Michal Hocko <mhocko@suse.com>

> ---
>  mm/memcontrol.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/mm/memcontrol.c b/mm/memcontrol.c
> index 5beea03dd58a..0395e479995b 100644
> --- a/mm/memcontrol.c
> +++ b/mm/memcontrol.c
> @@ -1451,6 +1451,8 @@ static char *memory_stat_format(struct mem_cgroup *memcg)
>  		       memcg_page_state(memcg, WORKINGSET_REFAULT));
>  	seq_buf_printf(&s, "workingset_activate %lu\n",
>  		       memcg_page_state(memcg, WORKINGSET_ACTIVATE));
> +	seq_buf_printf(&s, "workingset_restore %lu\n",
> +		       memcg_page_state(memcg, WORKINGSET_RESTORE));
>  	seq_buf_printf(&s, "workingset_nodereclaim %lu\n",
>  		       memcg_page_state(memcg, WORKINGSET_NODERECLAIM));
>  
> -- 
> 2.18.2

-- 
Michal Hocko
SUSE Labs


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] mm, memcg: add workingset_restore in memory.stat
  2020-05-04  9:10 ` Michal Hocko
@ 2020-05-04 12:35   ` Yafang Shao
  0 siblings, 0 replies; 4+ messages in thread
From: Yafang Shao @ 2020-05-04 12:35 UTC (permalink / raw)
  To: Michal Hocko; +Cc: Andrew Morton, Johannes Weiner, Linux MM

On Mon, May 4, 2020 at 5:10 PM Michal Hocko <mhocko@kernel.org> wrote:
>
> On Sat 02-05-20 10:18:49, Yafang Shao wrote:
> > There's a new workingset counter introduced in commit 1899ad18c607 ("mm:
> > workingset: tell cache transitions from workingset thrashing"). With the
> > help of this counter we can know the workingset is transitioning or
> > thrashing. To leverage the benifit of this counter to memcg, we should
> > introduce it into memory.stat. Then we could know the workingset of the
> > workload inside a memcg better.
> >
> > Bellow is the verification of this new counter in memory.stat.
> > Read a file into the memory and then read it again to make these pages be
> > active. The size of this file is 1G. (memory.max is greater than file size)
> > The counters in memory.stat will be,
> >       inactive_file 0
> >       active_file 1073639424
> >
> >       workingset_refault 0
> >       workingset_activate 0
> >       workingset_restore 0
> >       workingset_nodereclaim 0
> > Trigger the memcg reclaim by setting a lower value to memory.high, and
> > then some pages will be demoted into inactive list, and then some pages
> > in the inactive list will be evicted into the storage.
> >       inactive_file 498094080
> >       active_file 310063104
> >
> >       workingset_refault 0
> >       workingset_activate 0
> >       workingset_restore 0
> >       workingset_nodereclaim 0
> > Then recover the memory.high and read the file into memory again. As a
> > result of it, the transitioning will occur. Bellow is the result of this
> > transitioning,
> >       inactive_file 498094080
> >       active_file 575397888
> >
> >       workingset_refault 64746
> >       workingset_activate 64746
> >       workingset_restore 64746
> >       workingset_nodereclaim 0
>
> Could you update Documentation/admin-guide/cgroup-v2.rst as well please?
>

Thanks for your reminder. I will update it.

> > Signed-off-by: Yafang Shao <laoar.shao@gmail.com>
>
> Acked-by: Michal Hocko <mhocko@suse.com>
>

Thanks.

> > ---
> >  mm/memcontrol.c | 2 ++
> >  1 file changed, 2 insertions(+)
> >
> > diff --git a/mm/memcontrol.c b/mm/memcontrol.c
> > index 5beea03dd58a..0395e479995b 100644
> > --- a/mm/memcontrol.c
> > +++ b/mm/memcontrol.c
> > @@ -1451,6 +1451,8 @@ static char *memory_stat_format(struct mem_cgroup *memcg)
> >                      memcg_page_state(memcg, WORKINGSET_REFAULT));
> >       seq_buf_printf(&s, "workingset_activate %lu\n",
> >                      memcg_page_state(memcg, WORKINGSET_ACTIVATE));
> > +     seq_buf_printf(&s, "workingset_restore %lu\n",
> > +                    memcg_page_state(memcg, WORKINGSET_RESTORE));
> >       seq_buf_printf(&s, "workingset_nodereclaim %lu\n",
> >                      memcg_page_state(memcg, WORKINGSET_NODERECLAIM));
> >
> > --
> > 2.18.2
>
> --
> Michal Hocko
> SUSE Labs



-- 
Thanks
Yafang


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-05-04 12:36 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-02 14:18 [PATCH] mm, memcg: add workingset_restore in memory.stat Yafang Shao
2020-05-02 14:48 ` Johannes Weiner
2020-05-04  9:10 ` Michal Hocko
2020-05-04 12:35   ` Yafang Shao

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox