Skip to contentSkip to conversation

Docs/admin-guide/cgroup-v2: fix memory.stat doc details

PATCH Applied Doehyun Baek 4 participants 6 messages Jun 20 – Jun 24

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

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.

Fixes c466412c73c3 ("mm: memcontrol: switch to native NR_VMALLOC vmstat counter")
Fixes 5ad41a38c364 ("mm: zswap: add per-memcg stat for incompressible pages")
---
 Documentation/admin-guide/cgroup-v2.rst | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
Documentation/admin-guide/cgroup-v2.rst +2 -2
index 993446ab66d0..ce6741f78f4f 100644
@@ -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
maintainer
#1 lore raw
Quoted 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_VMALLOC node stat, and document zswap_incomp as 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")
---
 Documentation/admin-guide/cgroup-v2.rst | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
Documentation/admin-guide/cgroup-v2.rst +0 -0
index 993446ab66d0..ce6741f78f4f 100644

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 -1
 	  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.

...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

#2 lore raw
Quoted 7 lines

...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

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 87822336

The 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

maintainer Acked-by
#3 lore raw
Quoted 10 lines · Doehyun Baek

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);
    }

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_incomp follows 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_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.

Reviewed-by on v1 1/1
#4 lore raw
In reply to Doehyun Baek
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_VMALLOC node stat, and document zswap_incomp as 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")

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 :)