Docs/admin-guide/cgroup-v2: fix memory.stat doc details
Subsystems (2)
PATCH 1/1 Docs/admin-guide/cgroup-v2: fix memory.stat doc details
Fix minor cgroup v2 memory.stat documentation issues. Correct the vmalloc per-node marker now that vmalloc uses the native NR_VMALLOC node stat, and document zswap_incomp as a byte-valued memory amount instead of as a page counter.
--- Documentation/admin-guide/cgroup-v2.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
Documentation/admin-guide/cgroup-v2.rst +2 -2
@@ -1570,7 +1570,7 @@ The following nested keys are defined. sock (npn) Amount of memory used in network transmission buffers - vmalloc (npn) + vmalloc Amount of memory used for vmap backed memory. shmem
@@ -1735,7 +1735,7 @@ The following nested keys are defined. Number of pages written from zswap to swap. zswap_incomp - Number of incompressible pages currently stored in zswap + Amount of memory used by incompressible pages currently stored in zswap without compression. These pages could not be compressed to a size smaller than PAGE_SIZE, so they are stored as-is.
base-commit: 1a3746ccbb0a97bed3c06ccde6b880013b1dddc1
Signature · 1 line
2.43.0
Michal Koutný
maintainerQuoted 17 lines · Doehyun Baek
Fix minor cgroup v2 memory.stat documentation issues. Correct the vmalloc per-node marker now that vmalloc uses the native
NR_VMALLOCnode stat, and documentzswap_incompas a byte-valued memory amount instead of as a page counter.Fixes c466412c73c3 ("mm: memcontrol: switch to native NR_VMALLOC vmstat counter")Fixes 5ad41a38c364 ("mm: zswap: add per-memcg stat for incompressible pages")Signed-off-by Doehyun Baek <[email protected]>--- Documentation/admin-guide/cgroup-v2.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)Documentation/admin-guide/cgroup-v2.rst +0
-0
Documentation/admin-guide/cgroup-v2.rst The following nested keys are defined. · line 1574
Quoted 6 lines
Documentation/admin-guide/cgroup-v2.rst +1
-1@@ -1570,7 +1570,7 @@ The following nested keys are defined. sock (npn) Amount of memory used in network transmission buffers - vmalloc (npn) + vmalloc Amount of memory used for vmap backed memory.
The vmalloc change looks OK...
Documentation/admin-guide/cgroup-v2.rst The following nested keys are defined. · line 1740
Quoted 10 lines
Documentation/admin-guide/cgroup-v2.rst +1
-1shmem@@ -1735,7 +1735,7 @@ The following nested keys are defined. Number of pages written from zswap to swap. zswap_incomp - Number of incompressible pages currently stored in zswap + Amount of memory used by incompressible pages currently stored in zswap without compression. These pages could not be compressed to a size smaller than PAGE_SIZE, so they are stored as-is.
...but what do you mean by this?
As I'm looking at the code in obj_cgroup_charge_zswap() and memcg_page_state_output_unit(), I'd say those are pages and the docs is thus alright.
Thanks,
Michal
Quoted 7 lines
...but what do you mean by this?
As I'm looking at the code inobj_cgroup_charge_zswap()andmemcg_page_state_output_unit(), I'd say those are pages and the docs is thus alright.Thanks,
Michal
Thanks for taking a look.
I agree that the counters are pages internally. I was talking about what gets printed in memory.stat.
The internal updates are page-count based:
mod_memcg_state(memcg, MEMCG_ZSWAPPED, 1);
if (size == PAGE_SIZE)
mod_memcg_state(memcg, MEMCG_ZSWAP_INCOMP, 1);However, both zswapped and zswap_incomp are memory_stats[] entries, so memory.stat prints them through memcg_page_state_output(). Since MEMCG_ZSWAP_INCOMP is not special-cased as a raw count, the stored page count is multiplied by the default PAGE_SIZE unit and exported as bytes.
unsigned long memcg_page_state_output(struct mem_cgroup *memcg, int item)
{
return memcg_page_state(memcg, item) *
memcg_page_state_output_unit(item);
}Separately, this matches the existing documentation style for zswapped, whose exported value is described as a memory amount:
zswapped
Amount of application memory swapped out to zswap.
Since zswap_incomp follows the same memory.stat output path, I think its documentation should describe the exported value as a memory amount too.
I also boot-tested this in QEMU with the current tree and zswap enabled. With incompressible pages pushed into zswap, memory.stat showed:
zswap 87822336
zswapped 87822336
zswap_incomp 87822336The zswap_incomp value there is byte-valued; it is not a plain page count. It also matches zswapped in this all-incompressible case, which is consistent with both being exported as memory amounts.
Best,
Doehyun Baek
Quoted 10 lines · Doehyun Baek
However, both zswapped and
zswap_incompare memory_stats[] entries, so memory.stat prints them throughmemcg_page_state_output(). SinceMEMCG_ZSWAP_INCOMPis not special-cased as a raw count, the stored page count is multiplied by the defaultPAGE_SIZEunit and exported as bytes.unsigned long memcg_page_state_output(struct mem_cgroup *memcg, int item) { return memcg_page_state(memcg, item) * memcg_page_state_output_unit(item); }
Ah, I messed up how memcg_page_state_output_unit() is used. The printed values are amounts (in bytes).
Quoted 9 lines
Separately, this matches the existing documentation style for zswapped, whose exported value is described as a memory amount:
zswapped
Amount of application memory swapped out to zswap.Since
zswap_incompfollows the same memory.stat output path, I think its documentation should describe the exported value as a memory amount too.
Quoted 6 lines
I also boot-tested this in QEMU with the current tree and zswap enabled. With incompressible pages pushed into zswap, memory.stat showed:
zswap 87822336 zswapped 87822336 zswap_incomp 87822336
Thanks for the test and for the fix!
Quoted 4 lines
The
zswap_incompvalue there is byte-valued; it is not a plain page count. It also matches zswapped in this all-incompressible case, which is consistent with both being exported as memory amounts.
Quoted 10 lines · Doehyun Baek
Fix minor cgroup v2 memory.stat documentation issues. Correct the vmalloc per-node marker now that vmalloc uses the native
NR_VMALLOCnode stat, and documentzswap_incompas a byte-valued memory amount instead of as a page counter.Fixes c466412c73c3 ("mm: memcontrol: switch to native NR_VMALLOC vmstat counter")Fixes 5ad41a38c364 ("mm: zswap: add per-memcg stat for incompressible pages")Signed-off-by Doehyun Baek <[email protected]>
Documentation/admin-guide/cgroup-v2.rst The following nested keys are defined. · line 1740
Quoted 4 lines
Documentation/admin-guide/cgroup-v2.rst +1
-1- Number of incompressible pages currently stored in zswap + Amount of memory used by incompressible pages currently stored in zswap without compression. These pages could not be compressed to a size smaller than PAGE_SIZE, so they are stored as-is.
Good catch :)
Applied to cgroup/for-7.2-fixes.
Thanks.
--
tejun