Received: by 10.223.164.202 with SMTP id h10csp1174917wrb; Fri, 17 Nov 2017 15:28:43 -0800 (PST) X-Google-Smtp-Source: AGs4zMajr6lu1Ho59+7PgsPCaH5oL7tmY5+U64WyqAZrR3jeumWVINBhpClu3iPtN7BMPQfWo3Qq X-Received: by 10.101.93.140 with SMTP id f12mr6553679pgt.60.1510961323647; Fri, 17 Nov 2017 15:28:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510961323; cv=none; d=google.com; s=arc-20160816; b=Bl8b0fdSJMYkforrOmZb2l8LXtUyOiEEK/l4r9L411/J5UqNKm5zbWWBw7e+f8DUKX Pir9bV4EAzvSdWSEn63Yv6BputxB8ducqgWq0odIiRqgEXPfyLuVP313/BPECwjRwL47 FKrEMoWwFY40OC8C+jhdSnJa6OWN1OQWCdAt6CCi1Bp/VmEelllH+mhS6dmBL53LjacD FNdX3uXJ5A9Pt4z64GgAFhB6velbp4QhWgdgGbANQkoKCJH8N3777Ns2omNXAh8it/dY e/hs1/zl5Nz3Cj/dnwShFl8wPhIuFQE9H3wKsXDR4DtfzrSA8gt4gTafk+Jv8dEL2UqA vYcA== 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=3EDpbS28DswgLbvlsz3HM93a1nKCnXfz27zuY+aUCyU=; b=0s11j/HARl6KPCXF+pRKxcQMp/PEEHQmRu1FwGwjxeEazmIFLB8r4kzAAddwW8hwP4 c5JsW0fvPxROLTasH0MW9ZHVExt7WIkNQqW8jymR4XxTNB7yGHNyla+Aibco9CrLY2rT btL2MEpR4ap8F0vC4Kb+sPYdCy2nH+bHP8RfK7mNvu8fGlnRn6D1W/WIM6MDZ7tjVtyk SDG6cF2O9oF8iJSOZyBDxOeWiED34smqBWNsMWQB5Me9oEa/xOQoEXLLPQ/eOueAcR0u VQziTQQm/Z97TFG9Tqztxl1cUbiuFOAROAQZjLgGMvmY4RYm6we02iVHOVE5SbrmYZpZ VGng== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=sS6/St00; 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 202si3467738pge.274.2017.11.17.15.28.30; Fri, 17 Nov 2017 15:28:43 -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=sS6/St00; 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 S1759505AbdKQRKG (ORCPT + 93 others); Fri, 17 Nov 2017 12:10:06 -0500 Received: from mail-it0-f66.google.com ([209.85.214.66]:42370 "EHLO mail-it0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752192AbdKQRJ7 (ORCPT ); Fri, 17 Nov 2017 12:09:59 -0500 Received: by mail-it0-f66.google.com with SMTP id n134so4851267itg.1; Fri, 17 Nov 2017 09:09:58 -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=3EDpbS28DswgLbvlsz3HM93a1nKCnXfz27zuY+aUCyU=; b=sS6/St00rXPqdPPy1BtgNImxHBi2fU4ssCy9PYql9AH7CflEwXFlQeBjx7gKTvIsI1 7CpOGYQ+klqeZxIPrGFBKh6Qe9OV/w/742/1SwxaBHZofTpwKsg1ly5bwyI9qs2QUE5F OSfoAkod4e3vINjKMTPMQIxg/1lFfS7pYYiAUAACjpjga+t01Ci3xHfOs13H8o8w8qlN c8e0MVjRPwxvaLUcaJozMM2Vva9av+YQ5vwquC24C7xz2bREsTG6T1QY8DmxhTYgauTi deJsvBnFyGEyZamJj15IF8bslJ3+ruMlAuSBxHJfOZEhUEKcBo7Tp2zPcWO3s/rsyaye QETw== 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=3EDpbS28DswgLbvlsz3HM93a1nKCnXfz27zuY+aUCyU=; b=U4Yvau6Mmgz6gH8BXWR1er6YVbBULcOckVQNQHT8wK7wCX1z/5DU13dzkE50jgmLOJ bujhA6rK7mH5BZhN1TK39JGPEevEVodnxggg8sL9yNwFWIVXZ3UMeqZfy6Ura7VPFUEX Nmi+TCt80JMyqL/o5QrmnNJnjdOYrwYUZ3pC2CKQsdHlVIjo1ZGTfwXm5sz9lll+xqYx 8FtuxNVV+Hq4PPLOWh3lIhrT7PuCeG1PbWhQquwgrOi9/oBHxEdAbIli+9pBGSB8n/Sw eiLOdQPZ48cUkWmsMjhvkQTnhFGx+ybAZ4vcY03hN/IFMFebTFchJ483ewK1EtO2kdIO eNWQ== X-Gm-Message-State: AJaThX7/SeTN5BK2eCUzOZg04N3DURyAij4uQbGglRqyppUu7Tr8xGIg V8OzNEx6StHB4xDZ4+iTTdXswTIXkBCvtnpMNow= X-Received: by 10.36.25.2 with SMTP id b2mr7850449itb.31.1510938598419; Fri, 17 Nov 2017 09:09:58 -0800 (PST) MIME-Version: 1.0 Received: by 10.107.160.73 with HTTP; Fri, 17 Nov 2017 09:09:57 -0800 (PST) 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 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-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 From 1584356254652874504@xxx Fri Nov 17 23:04:28 +0000 2017 X-GM-THRID: 1584307723039976913 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread