From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-it0-f70.google.com (mail-it0-f70.google.com [209.85.214.70]) by kanga.kvack.org (Postfix) with ESMTP id 84DF56B0038 for ; Fri, 17 Nov 2017 12:10:00 -0500 (EST) Received: by mail-it0-f70.google.com with SMTP id b11so2636330itj.0 for ; Fri, 17 Nov 2017 09:10:00 -0800 (PST) Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id x142sor2561733itc.128.2017.11.17.09.09.58 for (Google Transport Security); Fri, 17 Nov 2017 09:09:58 -0800 (PST) MIME-Version: 1.0 In-Reply-To: <20171117164531.GA23745@castle> References: <1510888199-5886-1-git-send-email-laoar.shao@gmail.com> <20171117155509.GA920@castle> <20171117164531.GA23745@castle> From: Yafang Shao Date: Sat, 18 Nov 2017 01:09:57 +0800 Message-ID: Subject: Re: [PATCH] mm/shmem: set default tmpfs size according to memcg limit Content-Type: text/plain; charset="UTF-8" Sender: owner-linux-mm@kvack.org List-ID: To: Roman Gushchin Cc: Shakeel Butt , Andrew Morton , Johannes Weiner , Vladimir Davydov , Michal Hocko , Tejun Heo , khlebnikov@yandex-team.ru, mka@chromium.org, Hugh Dickins , Cgroups , Linux MM , LKML 2017-11-18 0:45 GMT+08:00 Roman Gushchin : > On Sat, Nov 18, 2017 at 12:20:40AM +0800, Yafang Shao wrote: >> 2017-11-17 23:55 GMT+08:00 Roman Gushchin : >> > On Thu, Nov 16, 2017 at 08:43:17PM -0800, Shakeel Butt wrote: >> >> On Thu, Nov 16, 2017 at 7:09 PM, Yafang Shao 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. > > The value you're suggesting is proper only if an app which is mounting > tmpfs resides in the same memcg Yes. But maybe that's mostly used today? > and the memory limit will not be adjusted > significantly later. There's a similar issue for physical memory adjusted by memory hotplug. So what will happen if the physical memory adjusted significantly later ? > Otherwise you can end up with a default value, which > is worse than totalram/2, for instance, if tmpfs is mounted by some helper, > which is located in a separate and very limited memcg. That may happen. Maybe we could improve the solution to handle this issue ? Thanks Yafang -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org