Received: by 10.223.164.202 with SMTP id h10csp1031818wrb; Fri, 17 Nov 2017 12:42:46 -0800 (PST) X-Google-Smtp-Source: AGs4zMYDClOQTJ+yUaEZ0asiDbpzBb+w4MWXEq3gyCtD5vwjreSDglglr/lYIt9EeAUu7tGjLpF3 X-Received: by 10.159.207.149 with SMTP id z21mr6356714plo.258.1510951366636; Fri, 17 Nov 2017 12:42:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510951366; cv=none; d=google.com; s=arc-20160816; b=xpyC9QoFzagTOqTSwRKgWFb4JVCHPERPYLnRVpO2zbAtjPT6nSKmhTchLZAQluzpiJ RMHdvSF0S1hrYau3qj16/jrLqhCJ9NEfa9ti5u5NubxZ079gq5v+E8oHPBWMyUnT9Vn7 w3vGeChtTGEq03A8CMn6WBqIjqyD/TF+ZSF1fvRfW62Hqtv0No3boVv/rtgG04ZNXpi5 gB/tZXySI7tIlvDqZI05APVfWRRb8SCtHUgUuCnKQ+vbENuO75ZO9X/hWZk1GWnRHuEv yfA2WmAwgSkCx1pUJvyKgibrUKUVzABmJQU7uIgLuABT11tAipAawd6WiriNJD/czKFJ S56g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:spamdiagnosticmetadata :spamdiagnosticoutput:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature:dkim-signature:arc-authentication-results; bh=XAkyKyCW/kChb+IycSS2zaJhl2Y32I1nwASlOuJAiYc=; b=AW7RxSMjSdx02ZsHk0XiQdTgoVNYqcbSS1vRVx1r+wKCFxKUosgrjqq+J1Yf3egwhT FQ5nvhx1eU2H0TxxLjCpdvL7F6jEM+WJH4Q4mqel+j45S2UPQw3amw4QvwfoDDBV1/Ft 7FgfTloswXJYKticjn6eGRpbq0uw/eHMWv/6r2E4Gl2YADU1M1gAMHtK3RlHqHArGCwS zGcFhjFurFns7vFxukVkvm6tnZLAPh/yowAiGUFHhF93epGgbV+NNU4MZlE2PwY8S49R nrVbEfJThkufIEX8yX0aB2rUaxBc8yJSposUlig7capiXmhkWMTuriFgErYaJu6iYU5J JrQA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@fb.com header.s=facebook header.b=gClfWQcL; dkim=fail header.i=@fb.onmicrosoft.com header.s=selector1-fb-com header.b=jqo0ErmM; 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=fb.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i2si3669528pfi.269.2017.11.17.12.42.33; Fri, 17 Nov 2017 12:42:46 -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=@fb.com header.s=facebook header.b=gClfWQcL; dkim=fail header.i=@fb.onmicrosoft.com header.s=selector1-fb-com header.b=jqo0ErmM; 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=fb.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965793AbdKQQqb (ORCPT + 93 others); Fri, 17 Nov 2017 11:46:31 -0500 Received: from mx0a-00082601.pphosted.com ([67.231.145.42]:56836 "EHLO mx0a-00082601.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751070AbdKQQqX (ORCPT ); Fri, 17 Nov 2017 11:46:23 -0500 Received: from pps.filterd (m0044008.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id vAHGhxKh004801; Fri, 17 Nov 2017 08:46:08 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.com; h=date : from : to : cc : subject : message-id : references : mime-version : content-type : in-reply-to; s=facebook; bh=XAkyKyCW/kChb+IycSS2zaJhl2Y32I1nwASlOuJAiYc=; b=gClfWQcLpW4em1x/f+c7uRyHssWyZXxj+gcrKUruu0+qsfHV85WKbC4nX87qMNyrs/lV EOhKWYGKGGwm6zqXTuDfaMhslYrbjAxKTdZS7qDTSXRT6rwMFkBHkwfBe+NInmQorymP S4CpfG2/hloboMufwMpqUqtiN77rIk8g2Yg= Received: from maileast.thefacebook.com ([199.201.65.23]) by mx0a-00082601.pphosted.com with ESMTP id 2ea2ya042v-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Fri, 17 Nov 2017 08:46:08 -0800 Received: from NAM01-BY2-obe.outbound.protection.outlook.com (192.168.183.28) by o365-in.thefacebook.com (192.168.177.21) with Microsoft SMTP Server (TLS) id 14.3.361.1; Fri, 17 Nov 2017 11:46:05 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.onmicrosoft.com; s=selector1-fb-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=XAkyKyCW/kChb+IycSS2zaJhl2Y32I1nwASlOuJAiYc=; b=jqo0ErmMWogqOpQUbXypVYJvvFy1ItWnbT/L8rjF6jCQBpCPDoZOidOThW+HKQb/xIFwfPyrVW4q7HLv8bootpTOltLvIirx2rB+ekEd7P76wkT2aluLgtNCWtg7/CVxcVhAwrZIHwZzydcaedUbtRff7y5CigE0AWDEgr8axaI= Received: from castle (2620:10d:c092:200::1:405d) by SN2PR15MB1088.namprd15.prod.outlook.com (2603:10b6:804:22::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.218.12; Fri, 17 Nov 2017 16:46:00 +0000 Date: Fri, 17 Nov 2017 16:45:48 +0000 From: Roman Gushchin To: Yafang Shao CC: Shakeel Butt , Andrew Morton , Johannes Weiner , Vladimir Davydov , Michal Hocko , Tejun Heo , , , Hugh Dickins , Cgroups , Linux MM , LKML Subject: Re: [PATCH] mm/shmem: set default tmpfs size according to memcg limit Message-ID: <20171117164531.GA23745@castle> References: <1510888199-5886-1-git-send-email-laoar.shao@gmail.com> <20171117155509.GA920@castle> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.1 (2017-09-22) X-Originating-IP: [2620:10d:c092:200::1:405d] X-ClientProxiedBy: DB6PR0501CA0010.eurprd05.prod.outlook.com (2603:10a6:4:8f::20) To SN2PR15MB1088.namprd15.prod.outlook.com (2603:10b6:804:22::10) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 98b75e00-3ae0-4a02-80b1-08d52ddab040 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001)(4534020)(4602075)(4627115)(201703031133081)(201702281549075)(2017052603199);SRVR:SN2PR15MB1088; X-Microsoft-Exchange-Diagnostics: 1;SN2PR15MB1088;3:0pmdq/poEeGxZ9kgL7NYvWbrhN1E06y2DSeKxKm2dk78ze2q2x39BEviRHi8OmgsP5HLYeGuf60MW3olLdyTLI7RTyHKu6CVxA3omdINIwHgTY60gwxea81iGNZyjDVPAPBnHW6WQwyZ+lTdXsIVkfGuZKd3DlH2Ftsg1NlqAGTP0Ho1WBHh8zGeNKVWdVqm71f//gRuB0D3O4TVOc1isltDJy2XGcgGVqEdFkBf0RW+G4hsi3gkgDfWac/wj3/9;25:tybmM0e6RlyEPv6Nh3smSo4X3xZs+jq2A8yYKf5z10CGW0z+V+u4FmbVOGcB/1Nh9nEp4mlewCoyt1yggcD6wK426Dccm8AIzQv2VXX//K1OD6ewugRkY3qiFARhPnOeqsDo0ZUJawpqE3gifX/mEa+9iErWP059kvrxeuWoPeUmh/5JAMqwOpRQTBKD7bI7vfBuYVVcVj+uXOM/JWcz9g2l2o4ET6o/x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iAIwsPEW+5y0sFKK1M9ShtaROpg/PhkFuDw+867ZroZHZsFgt+2IOk0D598uHfVlYbggVJT5tcOk2+aHH//KjfPc4B9J5XbTp4LcTBwf/0OlhEgjRbTFMaA9dxGNZjw6Zb4nEpZo6kPWhyHSwhv5gEkEzQNFsthrXJ7Qe0ejI1DAM54HwqSo0FeYzasHIY0jfR0m0imIrD0QfmocT6kjJLG/MLMk= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(278428928389397)(67672495146484); X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(11241501159)(6040450)(2401047)(5005006)(8121501046)(3002001)(3231022)(100000703101)(100105400095)(10201501046)(93006095)(93001095)(6041248)(20161123560025)(20161123564025)(20161123562025)(20161123555025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123558100)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095);SRVR:SN2PR15MB1088;BCL:0;PCL:0;RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095);SRVR:SN2PR15MB1088; X-Forefront-PRVS: 049486C505 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(6009001)(346002)(376002)(24454002)(189002)(377424004)(199003)(478600001)(54356999)(7416002)(76176999)(4326008)(50986999)(106356001)(83506002)(229853002)(93886005)(316002)(105586002)(33656002)(16586007)(86362001)(25786009)(50466002)(189998001)(101416001)(58126008)(305945005)(8936002)(47776003)(39060400002)(54906003)(81166006)(7736002)(55016002)(6246003)(2906002)(8676002)(23726003)(9686003)(6116002)(81156014)(97736004)(6666003)(4001150100001)(33716001)(1076002)(68736007)(2950100002)(53936002)(6496005)(6916009)(5660300001)(53546010)(18370500001)(21314002)(42262002);DIR:OUT;SFP:1102;SCL:1;SRVR:SN2PR15MB1088;H:castle;FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A:1;LANG:; Received-SPF: None (protection.outlook.com: fb.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;SN2PR15MB1088;23:2KGVKUbQ8JPioL74f8ZwssYPdhY8JPIuTnfjSpu3J?= =?us-ascii?Q?wRUMMRV5BnLUqDg/wM01t6scphCMEFaKCf55ca8Rat2lr+s7CvIPh+HU6H5n?= =?us-ascii?Q?ktIihfR5QSz3QXsaY8oLEV4a/XGmsNGZ+AsollMsdBEQcfRxOuf+T9lnAulW?= =?us-ascii?Q?srVqtsxDqiSri6pFTuKugfGu9HBxx0z7KYb3oyeai7/EAuphWftb55FN7dg6?= =?us-ascii?Q?8WimLQp9KJDSQxn1LaMlxuna8YwIMWXCB18Gn5CU1Hf9i+drBPSq6Ov2yWF2?= =?us-ascii?Q?axahbw1DrQQKKWG/crKp2h+FGVyIpU/VU/dV8jW7FAL9ly0khdDrVBWIXche?= =?us-ascii?Q?1EZNXux/QJqJzJqI34TlBITY0sVXOUuyMdptCW17ip+u96Mwbv72/9mTjUva?= =?us-ascii?Q?W6FzTzMAml0O/PpsD3s2DO/9mRzMU/hbvaEY0Oj1ofoQW1hPSIFKueowUE7q?= =?us-ascii?Q?gRX8nIT/8KTbfWMAvi8jN2MVdx66co2O5DmehyXHpSkQNYh2x3b/uZVhan/6?= =?us-ascii?Q?pgPikYLVLbs7RFIGBB2HwR2mU2Noo5goVmQ21vJfyYeIT+dF4EUJg14LkIje?= =?us-ascii?Q?ddCgMqRDeYH6A26uFLov+u3CL98BXaDmLA8W4uLrsFuuH04/ykvWjIIbIBsj?= =?us-ascii?Q?HCQmZL4IfhPgVBT0C1OjTfkcABgpNTlwnCR0OoStP8ZaQpz9QgrlsNdF/trv?= =?us-ascii?Q?DYuMCZdEosmUy8Xh1yb/57er4KRI4jweltFOmVKe53g1aZSIaRQqdIbsD2bu?= =?us-ascii?Q?arBfJsjtuM4Z2mAdaJHdNG/0r9csFPg7dmQ/06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GIENExqGZTz2AnUGyXm2GlXcvD4XtcNw3dEu5iEsM6Xp2HQZqDH+rGBOtq+Lu69OUTNjt7wTzmJLye1T1XDFubROdl5D8y42ipVaeeF/qIQL2v36cXDOl5CFvzjaaaoBq2CXOpQknYx5mobg5LaYsmw4feIyFo5gPr4z3wSTI=;24:L4NS3zrvzdkLX8VGqai7f03q8ig80D0c5HtwxGUxGCAtqXOq86puLQW8cGkv6IcEM9Oz/Gi/ybbFZQRof04GOwM/GCu5OS7pjMFqsDdjBDM=;7:MZ9czN5LBVOOArNDyUHGIlq0KVUBTQQq1XU//KBuK5c2yQBTwcgynSx9PIQE8YgKGcN1pfQuRcUEpUSrkDItA9fWO9uVwOgMHBluwDp1+zJqsT8MEiDoupXLxs8o3F9UY0AwDHioIq/GHav2bR3Yic5rwd5OJMDdzJWFjTm25GLptfWOtrFYUqtPbOUodTXFhktsPbOnR/u00PQIhREO2ga40zhrui5Sr96aZ8aFpkGHM8wUDIGExPGO4uDGLQBB SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;SN2PR15MB1088;20:c6WqhgN8zVt12nN59deGhYxjkPWgeT7LqIW97Xsz91khakt9mfVFVEzyNl40AoxEfqa5EM6igPTNs7twoBly3RRbIt/+pTxEbqJvIyUodsSblIZuNh1C+w87NbnUg6PPnjzfFKsz+U7KKiAuaqc8ZhOa13u/b2Grg7tOCW3HQKI= X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Nov 2017 16:46:00.3742 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 98b75e00-3ae0-4a02-80b1-08d52ddab040 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 8ae927fe-1255-47a7-a2af-5f3a069daaa2 X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN2PR15MB1088 X-OriginatorOrg: fb.com X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2017-11-17_05:,, signatures=0 X-Proofpoint-Spam-Reason: safe X-FB-Internal: Safe Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 and the memory limit will not be 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. From 1584343614968435481@xxx Fri Nov 17 19:43:33 +0000 2017 X-GM-THRID: 1584307723039976913 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread