Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751469AbdH3Mqc (ORCPT ); Wed, 30 Aug 2017 08:46:32 -0400 Received: from mx0a-00082601.pphosted.com ([67.231.145.42]:52878 "EHLO mx0a-00082601.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751302AbdH3MpY (ORCPT ); Wed, 30 Aug 2017 08:45:24 -0400 Date: Wed, 30 Aug 2017 13:44:59 +0100 From: Roman Gushchin To: Michal Hocko CC: , Johannes Weiner , Vladimir Davydov , , , Subject: Re: [PATCH] mm: memcontrol: use per-cpu stocks for socket memory uncharging Message-ID: <20170830124459.GA10438@castle.DHCP.thefacebook.com> References: <20170829100150.4580-1-guro@fb.com> <20170830123655.6kce7yfkrhrhwubu@dhcp22.suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <20170830123655.6kce7yfkrhrhwubu@dhcp22.suse.cz> User-Agent: Mutt/1.8.3 (2017-05-23) X-Originating-IP: [2620:10d:c092:200::1:4542] X-ClientProxiedBy: DB6PR07CA0148.eurprd07.prod.outlook.com (2603:10a6:6:16::41) To SN2PR15MB1088.namprd15.prod.outlook.com (2603:10b6:804:22::10) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 9821bcd3-4549-49ea-99f5-08d4efa4f609 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(22001)(300000502095)(300135100095)(2017030254152)(300000503095)(300135400095)(2017052603199)(201703131423075)(201703031133081)(201702281549075)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095);SRVR:SN2PR15MB1088; X-Microsoft-Exchange-Diagnostics: 1;SN2PR15MB1088;3:haHRSdVEjggBXQxYCiWaeYpMBN7v/rBVwl5VbMHnxPTvqaXsSJc7yYl5ts5t2qF2AaEGaR+8aPLkS+SkQ5XJ4+WuSqc5M/f8uhnE4wvK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ehMPGv5LPOqB7OwoBLllDPP+RKoZ4HsuLYbrHowd2mXvD6DqLyr6WZscwj8+/3AYHKfamJ7+GOmzawUPKrTgUr+UdtK3pYgRBfQp2MgSlO/QEZoGHdQTwLAZ4ipK/bOx6N4AOHJ42OaNnmUMrZWtO/VIbfTCqJTA3uJbqx6BG3mmSRGYJOh8Vw2cdyRZTF2AsU4NdvTpwLgA59kuFCM6zZCUrk2+iPQ4659Z5YGNCtOba+rvldF2eKRE4;4:MqnSyYaO4hniKIb130y9UySEQQZ95g9L5j/mtuYXgmmvxjNonxoQU/NuRlKl+rlexw8vTWDDqIURmgZobVQnnt7f6/hMKXvOUNo/X/OQHV878aLKk5kKlnVg0T9ENFCzatvQ47n5xlMbNqkGMKhFY5lMOxReIv0Gia9fnTo2z9tmLptCPvOo5L0okhCx5idy+fnlcms2F1dGh6xy5DDdDJSLlCdm8yhbUOAZ89rrZvpHcFjUYQiKsGy+J1PWS3Q2 X-Exchange-Antispam-Report-Test: UriScan:; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(601004)(2401047)(8121501046)(5005006)(100000703101)(100105400095)(10201501046)(93006095)(93001095)(3002001)(6041248)(20161123562025)(20161123555025)(20161123560025)(20161123558100)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123564025)(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: 041517DFAB X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(6009001)(24454002)(199003)(377424004)(189002)(57704003)(42186005)(86362001)(53936002)(2906002)(110136004)(6246003)(5660300001)(1076002)(68736007)(97736004)(189998001)(76176999)(9686003)(54356999)(33656002)(50986999)(4326008)(55016002)(23726003)(4001350100001)(6916009)(54906002)(2950100002)(6666003)(6116002)(6506006)(101416001)(83506001)(81166006)(229853002)(8676002)(25786009)(305945005)(7736002)(39060400002)(47776003)(105586002)(478600001)(50466002)(8936002)(106356001)(81156014)(18370500001)(42262002);DIR:OUT;SFP:1102;SCL:1;SRVR:SN2PR15MB1088;H:castle.DHCP.thefacebook.com;FPR:;SPF:None;PTR:InfoNoRecords;A:1;MX:1;LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;SN2PR15MB1088;23:n7JokxuA6NuS7kqDGSmpLZUyZAnDWhYDigw/fhfPt?= =?us-ascii?Q?Nui9wxye22i4iWJMFXCFhTpaGUhZlef5L3gtouduoS5UyCgLTdTJwatE+0iD?= =?us-ascii?Q?H7kRSQVmBxy/EFWG2mMhIauB/I/5lPQJNVBm3HMkvsdFAJLdNc2Jyqw4bOku?= =?us-ascii?Q?+hLek3ci9Z7/pxxViXI7ZzWpyjjt3De4lOn9QSoDNin3FFUiD7zq5bKHuwOr?= =?us-ascii?Q?CD5dbSbYs23yM+KkohbuEj4K5EYQFEYgdMvFsmMNrjZp/kX61sEdfMCHZMT8?= =?us-ascii?Q?oLyOZy/A2V3K4YoVNFgKch0dm/tAwiZSnuSCjVsof/eIMXfpDNrS4n+WRW7I?= =?us-ascii?Q?C44fN9nIZiyyr4q0iBPoMDO+dUIsW3owIgTiNdyBZwRGymtL4683s9ul4Vzw?= =?us-ascii?Q?v/cBIMFKNTkP2pdeVCaBaHaeKdpRQA7Y002jnw0FKeKR6Zg8q9Qe+4dQKihG?= =?us-ascii?Q?WxmLQ5pEY1bRfXEbJ0nevZIjvqKOdG+po/RIWHxLhVzIKVPV7KIyYfpQeQHP?= =?us-ascii?Q?dAxdHA9hSKJOW/gWiPm30DxYleqvrkR1z480sBvWA2Qn8KYp2xIGEyvkrI6/?= =?us-ascii?Q?lAQR0cixeWydb9e8v+wv3bDzLHO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E5faNOlgyAXSQJvFxzxyAZh+MsiuHmBsV34Wi2sII1UpFrysf98qA==;5:JtxfIaWqXLJbOnEdWwen7QpmMppPGq564nQlb64nNiIFHqrd2O3jcR/HHA7SRhNw3PmgycP2Fje+JoIpi1/7BVMee09hoaxS99TM897X0PqaFX5PVzVkyHEYzCDBHg39LJwiEEkHKM7IpSGbhpfUig==;24:kdmd7yIzlMlzRLEgTveiZUeP7l2DoFa+H4o5etQ1LaSnZ6zX2yfm1XnuHu9GkYfXFLsitHLEiaUNhyppnEHEafipCMucU0nXRcE5kExWIlk=;7:b1/vdqmodoxwkU8MJxMdmNiOMWLp5DP0h4pxmPxKlnIJt2Y2gtg4MDfAEPxWwU1XEbW7fzx5ZYdXnrnZAXGR5FVl8x/v+SYLfwE1xPX9grKOlD3G4tZeAVn9yRfBiysdrtYVkVlYn6OiNEux0Z/A0oQ5euhdncBJ9AyGaLVVvMQyhl46m7CfKW1WYmtzPvCCbyLr7FaZbuQcYHCs+NfATalYonzM0N6OJUnrjzRTV9g= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;SN2PR15MB1088;20:E+5rGKgZiNK+jH9if0Rq5pCfuhgoxkzdzsDlV9b7pyDaZ/Z3thi8pzfkG86TqEc5pfqoPKLRVH/V/9+f4l+lihm3xS/745TKl+JDCa/pnu0RpM7B4Of0J3vtj9zql3x68P0BYmhJNu8zeBPsl2JVGJ3IOjWodcJJwjRaNAV21N0= X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Aug 2017 12:45:13.4300 (UTC) 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-Spam-Reason: safe X-FB-Internal: Safe X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2017-08-30_06:,, signatures=0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 829 Lines: 25 On Wed, Aug 30, 2017 at 02:36:55PM +0200, Michal Hocko wrote: > On Tue 29-08-17 11:01:50, Roman Gushchin wrote: > [...] > > diff --git a/mm/memcontrol.c b/mm/memcontrol.c > > index b9cf3cf4a3d0..a69d23082abf 100644 > > --- a/mm/memcontrol.c > > +++ b/mm/memcontrol.c > > @@ -1792,6 +1792,9 @@ static void refill_stock(struct mem_cgroup *memcg, unsigned int nr_pages) > > } > > stock->nr_pages += nr_pages; > > > > + if (stock->nr_pages > CHARGE_BATCH) > > + drain_stock(stock); > > + > > local_irq_restore(flags); > > } > > Why do we need this? In other words, why cannot we rely on draining we > already do? The existing draining depends on memory pressure, so to keep the accounting (which we expose to a user) reasonable accurate even without memory pressure, we need to limit the size of per-cpu stocks. Thanks!