Received: by 10.223.164.202 with SMTP id h10csp1156086wrb; Fri, 17 Nov 2017 15:04:28 -0800 (PST) X-Google-Smtp-Source: AGs4zMYWTOU0l3T4lwr9WqR0/bUrSfZJp/DyvNsJhWbTnAK/EWDjevXiOyrEyoVvq3oWOPh69IYm X-Received: by 10.159.247.18 with SMTP id d18mr6495604pls.265.1510959868041; Fri, 17 Nov 2017 15:04:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510959868; cv=none; d=google.com; s=arc-20160816; b=XPM5WKaTB+7MGrV74xSLRtijTpeaZfhePHXynfbMMI/ase5VF5sktvHrnlHsWKhhTd HKp8dP+aknQADD9bEkAYLsUVug6m0v64z8gn2qfIRWCmfFGQhnCtvQcRYc6XAfVTlB0G FPYN/EkGh4I5IVoQP8G8WdlKki5zoHU5gF+Km++4fYjUlVBEczXPtqXbpZAM+6jv1trv Ew80C0Jc81VxTDdKxVUmODb7pyv/WHq8pSg9Xy+45Cj+gO0RE9+qDR6cU0MuurUXTO9t CIKkxDbOVebfv3qJ27zg70MNjecczRfe61cKX3eQaiEN9inuUcYpGXL4fhFHXv7MEzJw PZ4A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=ePv3D/rwZ8fPxghg/F4OfkZ9d9P1ZBtZWnxqGxRQUtc=; b=rV+uiYpoJOzsgmVnv6ncLIDHLUlnDrgPpkHgNLBnEznzao5G2Ys1S8+6qUfyJMfXOZ I9f7Xs0mHlTet0/mZGGDppAJIl4iNzfLd2gftq6gheH2dsTpKill6rRhxDMIN5p119HK ROt/cB2OOzRcZUbTrmerK5y4fVCz/A422aOm0nLkEu0s6NuISpINPGbFCsZdD3d7JRjI karPzvrgbVQo7O33iWDtUUnAOYdkAQoe0xYVXllIeWo4hp7001+R1Blr3J3TUEnwz8Id UY419lGGQtvdbIA7iQ4MAPpEp1MINqrxFJEB3xJKd5OCsiH3uBe62b22TkZNt+Qqy4uo sCzQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=N/lD8fAY; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u59si3503188plb.550.2017.11.17.15.04.15; Fri, 17 Nov 2017 15:04:27 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=N/lD8fAY; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759262AbdKQQUt (ORCPT + 93 others); Fri, 17 Nov 2017 11:20:49 -0500 Received: from mail-it0-f65.google.com ([209.85.214.65]:41864 "EHLO mail-it0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751322AbdKQQUm (ORCPT ); Fri, 17 Nov 2017 11:20:42 -0500 Received: by mail-it0-f65.google.com with SMTP id x28so4671542ita.0; Fri, 17 Nov 2017 08:20:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=ePv3D/rwZ8fPxghg/F4OfkZ9d9P1ZBtZWnxqGxRQUtc=; b=N/lD8fAYRInGB3CtBOc/SSmYlpO+i2T9uVgL4GWI+gYm4BlCZBexYa/Lt71XqNmAf4 Pe5sGpjSgcdJmFLmGeL2+OTF2ApK6rAWaa7CZD3B7Q6fif6OS82NjVXj01E/tR+N9FY0 kmXsnISmYoNH/Zd6nP9/KKjev2FjVS4IOyjyMVsOijl1fGxQ7YLvT/LoD4jg0hUdjhK0 V7zVRYHdrfLlajmfQktKDeGJ+aoSJw949gMDehJma29n3fp8DBUCUmbmiNqAPE06hyZ/ f1z+NKMe5taK3DkpTxvYYhaxuX8P0Nu0E3wSFpTVbCGOL7mErw0Yk+mCMVWTyNTh7hVh btRg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=ePv3D/rwZ8fPxghg/F4OfkZ9d9P1ZBtZWnxqGxRQUtc=; b=nkYSQzal0DnI9DCuqnIisvf7IuaJkzFxfcafXDx2DA1TbKCy62ml1CBw+CThOgoXYV KX9s3e8sw/AFUI47SIfV/hY/QPMgJVQrlKqnTZDZkfbn1KZvIcT5ERE3u9SO0eHe5JYw IrM87qqwlS/Vat7YDVxcnjw14F+lQAPAPYvf1ja/ZgObSp6vn+sZVQgxoU8Pz51zBz8Y rDTyKJxKzrIbNZUJ3gssTJk1+zODv3j/YXuO5biUSw58D3NzWSHZzTA4smNEaxrEJEVQ 87+JrhvbHhUEnRmMYTeppcnEyysjUsJGHayDbd993zYXzjPS8UEZTXVwQxPJvSqKfZyz 1fpA== X-Gm-Message-State: AJaThX65xypkhNSaK82KmSuWq1oBaxZ1v/IFW9yG/5GzWaodB3RxtgGP 810DhGXp6DZHx0jSFcGblNLV5YidsjsZtotMg68= X-Received: by 10.36.33.23 with SMTP id e23mr7774736ita.109.1510935641432; Fri, 17 Nov 2017 08:20:41 -0800 (PST) MIME-Version: 1.0 Received: by 10.107.160.73 with HTTP; Fri, 17 Nov 2017 08:20:40 -0800 (PST) In-Reply-To: <20171117155509.GA920@castle> References: <1510888199-5886-1-git-send-email-laoar.shao@gmail.com> <20171117155509.GA920@castle> From: Yafang Shao Date: Sat, 18 Nov 2017 00:20:40 +0800 Message-ID: Subject: Re: [PATCH] mm/shmem: set default tmpfs size according to memcg limit 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 Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Thanks Yafang From 1584347340232132320@xxx Fri Nov 17 20:42:46 +0000 2017 X-GM-THRID: 1584307723039976913 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread