Re: Access rules for current->memcg

Johannes Weiner
2015-07-21T09:24:11Z

On Tue, Jul 21, 2015 at 12:08:40PM +0300, Nikolay Borisov wrote:
> On 07/21/2015 10:48 AM, Michal Hocko wrote:
> > On Mon 20-07-15 14:22:32, Nikolay Borisov wrote:
> >> What about memsw.limit_in_bytes - memory.limit_in_bytes for the total swap
> >
> > No this is not how the swap extension works. memsw counter covers
> > usage+swap. You can have up to memsw.limit_in_bytes swapped out. So
>
> I think you are wrong with that assumption. According to the
> documentation here:
> https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/6/html/Resource_Management_Guide/sec-memory.html
> (the box titled "Setting the memory.memsw.limit_in_bytes and
> memory.limit_in_bytes parameters") it seems that the space that could be
> swapped is actually memsw.limit_in_bytes - memory.limit_in_bytes.
>
> The way I understand is you will only start swapping after the limit in
> memory.limit_in_bytes has been exhausted and you will be able to swap
> only until memsw.limit_in_bytes is exhausted (but since
> memory.usage_in_bytes is already calculated in, which would equal to
> memory.limit_in_bytes in a memory pressure situation) you effectively
> have memsw.limit_in_bytes - memory.limit_in_bytes, no?

No, the cgroup can also swap due to global/parental memory pressure,
not just due to memory.limit_in_bytes. In that case, it can get its
pages swapped out until it reaches memsw.limit_in_bytes, with memory
consumption well below memory.limit or even 0.