Skip to contentSkip to conversation

mm, memcg: add workingset_restore in memory.stat

PATCH Superseded Yafang Shao 2 participants 3 messages May 4, 2020

Subsystems (4)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 mm, memcg: add workingset_restore in memory.stat

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
---
 Documentation/admin-guide/cgroup-v2.rst | 3 +++
 mm/memcontrol.c                         | 2 ++
 2 files changed, 5 insertions(+)
Documentation/admin-guide/cgroup-v2.rst +3 -0
index bcc80269bb6a..0733b659e757 100644
@@ -1329,6 +1329,9 @@ PAGE_SIZE multiple when read back.
 	  workingset_activate
 		Number of refaulted pages that were immediately activated
 
+	  workingset_restore
+		Number of transitioning of refaulted pages
+
 	  workingset_nodereclaim
 		Number of times a shadow node has been reclaimed
 
mm/memcontrol.c +2 -0
index 5beea03dd58a..0395e479995b 100644
@@ -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));
 
Signature · 1 line
2.18.2
maintainer
#1 lore raw

On Mon 04-05-20 09:17:39, Yafang Shao wrote:
[...]

Documentation/admin-guide/cgroup-v2.rst PAGE_SIZE multiple when read back. · line 1334

Quoted 11 lines
Documentation/admin-guide/cgroup-v2.rst +3 -0
index bcc80269bb6a..0733b659e757 100644
@@ -1329,6 +1329,9 @@ PAGE_SIZE multiple when read back.
 	  workingset_activate
 		Number of refaulted pages that were immediately activated
 
+	  workingset_restore
+		Number of transitioning of refaulted pages
+

I believe something like the following would be more comprehensible "Number of restored pages which have been detected as an active workingset before they got reclaimed."

Quoted 3 lines
Documentation/admin-guide/cgroup-v2.rst +0 -0
 	  workingset_nodereclaim
 		Number of times a shadow node has been reclaimed
 
Signature · 2 lines
Michal Hocko
SUSE Labs
#2 lore raw
Quoted 11 lines · Michal Hocko

On Mon 04-05-20 09:17:39, Yafang Shao wrote:
[...]

Quoted 8 lines
Documentation/admin-guide/cgroup-v2.rst +0 -0
index bcc80269bb6a..0733b659e757 100644
@@ -1329,6 +1329,9 @@ PAGE_SIZE multiple when read back.
        workingset_activate
              Number of refaulted pages that were immediately activated
 
Quoted 8 lines

Documentation/admin-guide/cgroup-v2.rst PAGE_SIZE multiple when read back. · line 1334

Quoted 3 lines
Documentation/admin-guide/cgroup-v2.rst +3 -0
+       workingset_restore
+             Number of transitioning of refaulted pages
+

I believe something like the following would be more comprehensible "Number of restored pages which have been detected as an active workingset before they got reclaimed."

Thanks.
Will update it.

Quoted 6 lines

Documentation/admin-guide/cgroup-v2.rst PAGE_SIZE multiple when read back. · line 1337

Quoted 3 lines
Documentation/admin-guide/cgroup-v2.rst +0 -0
        workingset_nodereclaim
              Number of times a shadow node has been reclaimed
 

--
Michal Hocko
SUSE Labs

Signature · 2 lines
Thanks
Yafang