lkml.org 
[lkml]   [2017]   [Nov]   [17]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH] mm/shmem: set default tmpfs size according to memcg limit
2017-11-17 23:55 GMT+08:00 Roman Gushchin <guro@fb.com>:
> On Thu, Nov 16, 2017 at 08:43:17PM -0800, Shakeel Butt wrote:
>> On Thu, Nov 16, 2017 at 7:09 PM, Yafang Shao <laoar.shao@gmail.com> wrote:
>> > Currently the default tmpfs size is totalram_pages / 2 if mount tmpfs
>> > without "-o size=XXX".
>> > When we mount tmpfs in a container(i.e. docker), it is also
>> > totalram_pages / 2 regardless of the memory limit on this container.
>> > That may easily cause OOM if tmpfs occupied too much memory when swap is
>> > off.
>> > So when we mount tmpfs in a memcg, the default size should be limited by
>> > the memcg memory.limit.
>> >
>>
>> The pages of the tmpfs files are charged to the memcg of allocators
>> which can be in memcg different from the memcg in which the mount
>> operation happened. So, tying the size of a tmpfs mount where it was
>> mounted does not make much sense.
>
> Also, memory limit is adjustable,

Yes. But that's irrelevant.

> and using a particular limit value
> at a moment of tmpfs mounting doesn't provide any warranties further.
>

I can not agree.
The default size of tmpfs is totalram / 2, the reason we do this is to
provide any warranties further IMHO.

> Is there a reason why the userspace app which is mounting tmpfs can't
> set the size based on memory.limit?

That's because of misuse.
The application should set size with "-o size=" when mount tmpfs, but
not all applications do this.
As we can't guarantee that all applications will do this, we should
give them a proper default value.

Thanks
Yafang

\
 
 \ /
  Last update: 2017-11-17 17:21    [W:0.049 / U:1.448 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site