A cgroup's memory.stat file lists the page cache usage for that cgroup (in cache and total_cache fields). How is the page cache usage derived?
For example, file a.txt is opened by both cgroup A and B. Do A and B both maintain their own cache of a.txt? Or is the cache of a.txt shared between A and B? If it's shared, will memory.stat's page cache usage for both A and B be incremented by the same amount (total amount)?
Also, why doesn't memory.stat include a field for buffer cache or swap cache?
Distro is Linux Mint 18.2.
Best Answer
This is discussed in section 2.3 of https://www.kernel.org/doc/Documentation/cgroup-v1/memory.txt...
As for the other questions...
Since Linux 2.4, the buffer has been added to the cache (see https://stackoverflow.com/a/14671569). As such, you won't find a separate field for buffer in memory.stat.
For swap to be listed in memory.stat, it's likely that the kernel needs to be compiled with CONFIG_MEMCG_SWAP_ENABLED.