Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp5460905imm; Tue, 19 Jun 2018 10:42:17 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIqtBHwtpIx39JYKJ1x7mxaV476eaq14loOcZZwYBkVfJOeaPlFzoZkRAtEPFCL9fmf0LzJ X-Received: by 2002:a63:6e44:: with SMTP id j65-v6mr16057260pgc.14.1529430137011; Tue, 19 Jun 2018 10:42:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529430136; cv=none; d=google.com; s=arc-20160816; b=Qq7lzI3xoeZlL/80nJrG/U3SSi3yrJu9LSKRJrcNmniyEowOe3Y491i3dMiBbASJtD NWrzAoCRYyqaTZIc06X+52oEbY5ntVvOQ7isbXcgh+mn3oVVgk15lg1Gh8lYKDLCaBeR 2uLdvuKB2ObqmbP7iKKY2HG1se9ORyBML0X0dJgGrUfBiIii+BOidG2njMXfgwACawnQ ZLlezwrcgJXWp52/hwzKsR69qP2BeIwCAK/9uujsfF5MDWDQ2PkSaYA9drqSFlMe7WuO kzuGqWpjopmBjovZvYNyerCTxnFmt1fF9XBe+1I7u91x+oOxN0k0QNA4fLab1RoFcM20 wDNQ== 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=yvZV8MufaMcnkhb+wrsj2vgmLmmJ5wakwvUO7Tz/cBY=; b=El/4TvLwdhq7V0FLADIwrTuC2D6P792PFSKJLL9DB1NcqnDle8T0Dg89WyjOq0D+jx Zx6DP8jTSuoP7HT/gnDtGMmuQJbHz4nQrqElk25NV6yrmifsSOHRWv3jbZHuMODMcQ5o iK/Icy9hujMKETw9F2nTY6lRO+BPCewpAwKmF0mmFUyAuIk7H7xoWwqjLC0mJ5JUAOwG JG9N/NNcoZQNvAYOkQiiOJ7J+W8tcrthjHyRWume3YXY8g1FJq8XxlKGHrwGp8S8u6K5 KZ1HAy7JaAHdmQb+B34hRZ/7Nxin7tufUtvbV7NX9yM7YSLvxkCzHu6fhVNe4q1iIAge OdJw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@fb.com header.s=facebook header.b=IMSGJY5N; dkim=fail header.i=@fb.onmicrosoft.com header.s=selector1-fb-com header.b=FfmNtS7I; 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 p29-v6si187822pgc.199.2018.06.19.10.42.03; Tue, 19 Jun 2018 10:42:16 -0700 (PDT) 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=IMSGJY5N; dkim=fail header.i=@fb.onmicrosoft.com header.s=selector1-fb-com header.b=FfmNtS7I; 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 S1030340AbeFSRlP (ORCPT + 99 others); Tue, 19 Jun 2018 13:41:15 -0400 Received: from mx0b-00082601.pphosted.com ([67.231.153.30]:33002 "EHLO mx0a-00082601.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1030273AbeFSRlM (ORCPT ); Tue, 19 Jun 2018 13:41:12 -0400 Received: from pps.filterd (m0001303.ppops.net [127.0.0.1]) by m0001303.ppops.net (8.16.0.22/8.16.0.22) with SMTP id w5JHdQND003208; Tue, 19 Jun 2018 10:40:56 -0700 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=yvZV8MufaMcnkhb+wrsj2vgmLmmJ5wakwvUO7Tz/cBY=; b=IMSGJY5Nqf2NPkCqMVsvKLfPGR0tggwZ6mx71+Yv0Dhm6WaHs71ErLkqDpkuYr0kA9eH mQ0T3F2Nh9Kss7ei5vrzhqbgsSCuIef5AiwH0XtWrNlcetWOta/qP3qqSh8XhI//xL9z kwx09R+yVrWLo18Q81MaFwMUF+vjkwT23yw= Received: from maileast.thefacebook.com ([199.201.65.23]) by m0001303.ppops.net with ESMTP id 2jq2my8rrj-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Tue, 19 Jun 2018 10:40:56 -0700 Received: from NAM02-SN1-obe.outbound.protection.outlook.com (192.168.183.28) by o365-in.thefacebook.com (192.168.177.24) with Microsoft SMTP Server (TLS) id 14.3.361.1; Tue, 19 Jun 2018 13:40:53 -0400 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:X-MS-Exchange-SenderADCheck; bh=yvZV8MufaMcnkhb+wrsj2vgmLmmJ5wakwvUO7Tz/cBY=; b=FfmNtS7IYJOimhMQhCmU0QHXx3MOueMAQXMRTAq2JliUDlip//uf1+94GRLAHm7FXn9BqXcGJnW9Zp05xXfRbw5IXNx++qO0gWaMPgDQq5uutQcc5Cj6G0vNglqAzjxkd+yebDhY/rc/hJ/M8WIJwP6SQaI0WrdlwHbAjK58Hjk= Received: from castle.DHCP.thefacebook.com (2620:10d:c090:180::1:fa20) by SN2PR15MB1085.namprd15.prod.outlook.com (2603:10b6:804:22::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.863.17; Tue, 19 Jun 2018 17:40:49 +0000 Date: Tue, 19 Jun 2018 10:40:44 -0700 From: Roman Gushchin To: Johannes Weiner CC: Shakeel Butt , Andrew Morton , Michal Hocko , Vladimir Davydov , Jan Kara , Greg Thelen , , , , , Jan Kara , Alexander Viro Subject: Re: [PATCH 3/3] fs, mm: account buffer_head to kmemcg Message-ID: <20180619174040.GA4304@castle.DHCP.thefacebook.com> References: <20180619051327.149716-1-shakeelb@google.com> <20180619051327.149716-4-shakeelb@google.com> <20180619162741.GC27423@cmpxchg.org> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <20180619162741.GC27423@cmpxchg.org> User-Agent: Mutt/1.9.2 (2017-12-15) X-Originating-IP: [2620:10d:c090:180::1:fa20] X-ClientProxiedBy: MWHPR20CA0036.namprd20.prod.outlook.com (2603:10b6:300:ed::22) To SN2PR15MB1085.namprd15.prod.outlook.com (2603:10b6:804:22::7) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: bb40bc96-8033-49ac-4afe-08d5d60bcc65 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(4534165)(4627221)(201703031133081)(201702281549075)(5600026)(711020)(2017052603328)(7153060)(7193020);SRVR:SN2PR15MB1085; X-Microsoft-Exchange-Diagnostics: 1;SN2PR15MB1085;3:/lYhaKZwghzgwfefR0lw/MqwEEhv3ru8Jm1fDEcjZ/VtL3d+IMIhY3Mj6YORhxR9B+0z1MahTnWDoUZmOovzJcMQyGcaPp9QbekTrYE/YaFlXYUP6ZCxwN2oL5BT5nOfeu3a0FZyS8YL5FR0fIyjFfK7w+PKChfquYezR8G/ixq0DKc78W/Ukv8x/l6UPWbLIkK0ScaJ63IM6ZtY/NOSGiFsYkqx1Q32F8KzwzCl05o6MrzDkD3nEH3JJ4rMQAQs;25:W1G+zukgq2My/+6uSYTgrDKXZCBdjMvO84CgSQw2lf8ebKFdHyCnVwpRp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b5wI33OfiPrsnIK3XvUseLGgrm;4:CcGf097UrnZVDc3n6i602VPHi3k+yrw5VFbKHe46u1rvRwc59XegNA7T3Sz02S+TJq9TXv1VzRnkIkMjAfqQWZNDB9Qni1xDs+g9PXFnhoAUbFjhBVqjJRsmoyBpaNQXSid5UAjw06RhZJ+6GasmRZTElaDuYy9ho8GcO/ZhDbXxF8gsLDvYIX5VnFEjcnL3QPKRZTZereA+M4GsQjNjWaiwz6jV+++WS0dkS8Lv/3trWNr1aJbTkzrYuIeT/Mt+mFtXOzPMSUuv0G8LGjVC4JNskmp47PgrI0ryO2SNibg0Ok1GzNHKFr6uUnq8IElwTeWBuodFnxcabFkARYDAH7QFVuYpzBm/3vJJgT+eKGH0L8SJBahdrkkkMJnVJ6Vk X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(85827821059158)(211936372134217)(153496737603132); X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(10201501046)(3231254)(11241501184)(944501410)(52105095)(93006095)(93001095)(3002001)(149027)(150027)(6041310)(20161123564045)(20161123558120)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(6072148)(201708071742011)(7699016);SRVR:SN2PR15MB1085;BCL:0;PCL:0;RULEID:;SRVR:SN2PR15MB1085; X-Forefront-PRVS: 07083FF734 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(396003)(376002)(346002)(366004)(39860400002)(39380400002)(189003)(199004)(33656002)(186003)(16526019)(76176011)(52116002)(68736007)(16586007)(7696005)(6506007)(52396003)(106356001)(446003)(386003)(54906003)(316002)(9686003)(97736004)(2906002)(1076002)(7416002)(23726003)(486006)(58126008)(11346002)(105586002)(476003)(6246003)(6116002)(5660300001)(59450400001)(478600001)(305945005)(4326008)(229853002)(6666003)(7736002)(39060400002)(86362001)(25786009)(55016002)(8936002)(8676002)(81156014)(6916009)(81166006)(53936002)(50466002)(47776003)(46003)(18370500001)(42262002);DIR:OUT;SFP:1102;SCL:1;SRVR:SN2PR15MB1085;H:castle.DHCP.thefacebook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:1; Received-SPF: None (protection.outlook.com: fb.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;SN2PR15MB1085;23:jtZPnFVF9XXCc7Xp9blYrjEmocyHXxA/nZVN+XVlr?= =?us-ascii?Q?R6ctjW8nq9eKbnAqVMjyIYqLOQOziw47pQJ0WNe8i3odHZXFu4hdzjgnPZU2?= =?us-ascii?Q?mOw8by08KEAbm8n3v9T31Ijsr8YjTUrdTRCeq5mgYwVXltGb9sYAof99V1QA?= =?us-ascii?Q?JF61JMFz47YTHBw/t/0muhH7C1rpSilIgWgCRVjMXVA+OC/SdIPQOhXrvmPC?= =?us-ascii?Q?+lwseYD1xOxtH3dD/bn4+booVYFPOO7VEUpkGpZBxwlB0iz+sBymmboFCr/7?= =?us-ascii?Q?QSg1sYe72FzvTYt+8X0LlTUSUJbu2QYWoJ3evSvesT8yxRmL9CR+B3ZFMfR+?= =?us-ascii?Q?F/Q+TxUYLLlcKDw7QW1zqV+rhMuDbyrQ32H34wnp1urT/FBU9Q1nQtSowTjl?= =?us-ascii?Q?IdH1fRqKLz3tvhr2/r3JhQF+9xGcTBafjjexLblEfSVUZibDNv8qoFRZhKmx?= =?us-ascii?Q?FHYlfPjwSLlL0fiI0asaYEem523FxJqPTsd9JvTLFWoXtHBGpeLY8fWCGLNz?= =?us-ascii?Q?tkpIFrdW+/mcgjsu2Vjr8C6ckm+tDI+0ltePA09asPzbuN1yfXg02RkivLLm?= =?us-ascii?Q?cvyW9Mh3jQTJs9RgdV/HDWk2/8nSFXbZdorF/qhqLggrDnbuxjzRKUDiVYMj?= =?us-ascii?Q?iaOTCECfR+sH6RQRoFPdFDc1ZnrLSo1LQ0aT8zn4rC74FpMtl70U8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3A4spbw6h5alhViWNkSPwWHKO/8GihRmIVlT663eLdbpsbWo5o5HY8mh2q05Lm5taIxNLz5YD1hPQchHg6YGS4DObxRyGa5OooHZiIiR6WxCSKEECBHYJJPwJoX9z2na7s9;20:NWyS3Sr/Qo1QipAPi2AJJrJIIEGUfitEH9PnaQ7FhZFN3Pg6jqxhL1Xiwhc2fHYbs8d9DaZnhP5daakQxpGv4NgUJ3DpJm6qhvPc8CC+ktgxojzLXtkZ5QGVtZYe2fGIZcuXvEvzFXKWXl6tS1omm3Fe5oDc6PCPkFIMmqT29v4= X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Jun 2018 17:40:49.1236 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: bb40bc96-8033-49ac-4afe-08d5d60bcc65 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 8ae927fe-1255-47a7-a2af-5f3a069daaa2 X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN2PR15MB1085 X-OriginatorOrg: fb.com X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-06-19_09:,, 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 Tue, Jun 19, 2018 at 12:27:41PM -0400, Johannes Weiner wrote: > On Mon, Jun 18, 2018 at 10:13:27PM -0700, Shakeel Butt wrote: > > The buffer_head can consume a significant amount of system memory and > > is directly related to the amount of page cache. In our production > > environment we have observed that a lot of machines are spending a > > significant amount of memory as buffer_head and can not be left as > > system memory overhead. > > > > Charging buffer_head is not as simple as adding __GFP_ACCOUNT to the > > allocation. The buffer_heads can be allocated in a memcg different from > > the memcg of the page for which buffer_heads are being allocated. One > > concrete example is memory reclaim. The reclaim can trigger I/O of pages > > of any memcg on the system. So, the right way to charge buffer_head is > > to extract the memcg from the page for which buffer_heads are being > > allocated and then use targeted memcg charging API. > > > > Signed-off-by: Shakeel Butt > > Cc: Jan Kara > > Cc: Greg Thelen > > Cc: Michal Hocko > > Cc: Johannes Weiner > > Cc: Vladimir Davydov > > Cc: Alexander Viro > > Cc: Andrew Morton > > --- > > fs/buffer.c | 14 +++++++++++++- > > include/linux/memcontrol.h | 7 +++++++ > > mm/memcontrol.c | 21 +++++++++++++++++++++ > > 3 files changed, 41 insertions(+), 1 deletion(-) > > > > diff --git a/fs/buffer.c b/fs/buffer.c > > index 8194e3049fc5..26389b7a3cab 100644 > > --- a/fs/buffer.c > > +++ b/fs/buffer.c > > @@ -815,10 +815,17 @@ struct buffer_head *alloc_page_buffers(struct page *page, unsigned long size, > > struct buffer_head *bh, *head; > > gfp_t gfp = GFP_NOFS; > > long offset; > > + struct mem_cgroup *old_memcg; > > + struct mem_cgroup *memcg = get_mem_cgroup_from_page(page); > > > > if (retry) > > gfp |= __GFP_NOFAIL; > > > > + if (memcg) { > > + gfp |= __GFP_ACCOUNT; > > + old_memcg = memalloc_memcg_save(memcg); > > + } > > Please move the get_mem_cgroup_from_page() call out of the > declarations and down to right before the if (memcg) branch. > > > head = NULL; > > offset = PAGE_SIZE; > > while ((offset -= size) >= 0) { > > @@ -835,6 +842,11 @@ struct buffer_head *alloc_page_buffers(struct page *page, unsigned long size, > > /* Link the buffer to its page */ > > set_bh_page(bh, page, offset); > > } > > +out: > > + if (memcg) { > > + memalloc_memcg_restore(old_memcg); > > +#ifdef CONFIG_MEMCG > > + css_put(&memcg->css); > > +#endif > > Please add a put_mem_cgroup() ;) I've added such helper by commit 8a34a8b7fd62 ("mm, oom: cgroup-aware OOM killer"). It's in the mm tree. Thanks!