* Clarification on anon and anon_thp meanings from memory.stat in cgroup v2
@ 2023-07-11 18:25 Caden Ellis
2023-07-17 10:52 ` David Hildenbrand
0 siblings, 1 reply; 2+ messages in thread
From: Caden Ellis @ 2023-07-11 18:25 UTC (permalink / raw)
To: linux-mm
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
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.
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.
One last related question: Is the cgroups v2 equivalent of "rss" in v1
anon + swapcached?
Thank you,
Caden
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Clarification on anon and anon_thp meanings from memory.stat in cgroup v2
2023-07-11 18:25 Clarification on anon and anon_thp meanings from memory.stat in cgroup v2 Caden Ellis
@ 2023-07-17 10:52 ` David Hildenbrand
0 siblings, 0 replies; 2+ messages in thread
From: David Hildenbrand @ 2023-07-17 10:52 UTC (permalink / raw)
To: Caden Ellis, linux-mm; +Cc: Michal Hocko
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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-07-17 10:52 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-11 18:25 Clarification on anon and anon_thp meanings from memory.stat in cgroup v2 Caden Ellis
2023-07-17 10:52 ` David Hildenbrand
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox