Re: Clarification on anon and anon_thp meanings from memory.stat in cgroup v2

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 11.07.23 20:25, Caden Ellis wrote:
I had a question about anon and anon_thp, values that come from
memory.stat in cgroups v2.
 From this doc https://docs.kernel.org/admin-guide/cgroup-v2.html#memory-interface-files
:

anon
Amount of memory used in anonymous mappings such as brk(), sbrk(), and
mmap(MAP_ANONYMOUS)
...
anon_thp
Amount of memory used in anonymous mappings backed by transparent hugepages


My understanding is, that the semantics are the same as the values shown in /proc/meminfo:

1) anon <-> "AnonPages"

"(PTE/PMD/PUD/...)-mapped anonymous pages" (IOW, any mapped anon page)

2) anon_thp <-> "AnonHugePages"

"PMD-mapped anonymous pages only"


Any anon page that is mapped gets accounted under anon/AnonPages.

A THP that is PMD-mapped gets accounted under anon_thp/AnonHugePages AND anon/AnonPages.

A THP that is mot PMD-mapped (but PTE-mapped) gets accounted as anon/AnonPages only.


So "AnonHugePages" should actually have been called "AnonPMDMapped", to resemble ShmemPmdMapped/FilePmdMapped in /proc/meminfo.

... and "AnonPages" should have been called "AnonMapped" to resemble "Mapped".



I read that as anon_thp being a subset of anon, however it is not
explicit. The cgroup v1 documentation was explicit about the "rss"
stat including transparent hugepages. I have tested a few memory
eating programs (making sure that I have the transparent_hugepages
kernel parameter set to "always"), and anon always seems to be bigger
than anon_thp by a little. This helps but doesn't definitively prove
that anon_thp is a subset of anon.

It really should be a subset.


Does anyone know for sure if anon_thp is a subset of anon? Preferable
if you can cite the source code. I have dug in the code for a while
but have not found the answer.

mm/rmap.c:

* page_add_anon_rmap()
* page_remove_rmap()

See how they adjust NR_ANON_MAPPED (anon/AnonPages) and NR_ANON_THPS (anon_thp/AnonHugePages).

[NR_ANON_THPS should be called NR_ANON_PMDMAPPED to resemble NR_SHMEM_PMDMAPPED/NR_FILE_PMDMAPPED]


One last related question: Is the cgroups v2 equivalent of "rss" in v1
anon + swapcached?

IIUC, that would not consider pagecache pages.

--
Cheers,

David / dhildenb





[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux