From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7AF2EC63777 for ; Mon, 30 Nov 2020 20:18:20 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id DE09F2073C for ; Mon, 30 Nov 2020 20:18:19 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="wbSeg7kM"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=fb.com header.i=@fb.com header.b="nSqAW4vw"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=fb.onmicrosoft.com header.i=@fb.onmicrosoft.com header.b="eBU3S5Ng" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DE09F2073C Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=fb.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:In-Reply-To:References:Message-ID: Subject:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=0H2k5GRz/7CG5Y6cJzNOGadG3SyZiDK0/xKPExmXdjA=; b=wbSeg7kME+vX2rbuFH2B3YQJk m0BZrtrQEzu66u+ojCZQnhQ5MfvO3gLaRkhyxNgK7zx14OIJg+qUuCCAj1vRblEmDqsxHCO9pLtSR BM9y3v/r6PsuK/9s4QRQgiI7hOxljkZZmwJkSaNZpJcw8P9r6E9kdVgfjizc/dNBK0ZzQgUQY1LoY PLYlMWR31/crWba5JwktTyDJ5RG+AKCFO139wBScvxBxEulV3FnfywSVVTQHHXDvy2Qg4nK5nwStY S86aPJaWYT92mrHz9jERwwGOEAkyR5z8kth8jcfRGqHug78/ntgnsFK+RDAWS/q5rfrHDAmj8kYgx 2Y6Y8UadQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kjpbO-00065L-NN; Mon, 30 Nov 2020 20:16:50 +0000 Received: from mx0b-00082601.pphosted.com ([67.231.153.30] helo=mx0a-00082601.pphosted.com) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kjpbL-00064f-EO; Mon, 30 Nov 2020 20:16:48 +0000 Received: from pps.filterd (m0001303.ppops.net [127.0.0.1]) by m0001303.ppops.net (8.16.0.42/8.16.0.42) with SMTP id 0AUK3FZg016588; Mon, 30 Nov 2020 12:15:51 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.com; h=date : from : to : cc : subject : message-id : references : content-type : in-reply-to : mime-version; s=facebook; bh=RdtE83tmijXt7lplw7hDnEBho3pDThFvGVCdYYGG35I=; b=nSqAW4vwU6oVyrGEJH2/4ywRu9W63IFUP0nqh5g6HwKyLyFVUDGw0xQ5u6K1VHMkQ/34 xomjxmLC+k8Viyb1Hvbu6ImFWSagcQDABnLygi05a5oiCZr2UtASfFmqT1mDypjY9UFV le8GBXiswToepDgUNoOXLYb7BtuwHp2ns1k= Received: from maileast.thefacebook.com ([163.114.130.16]) by m0001303.ppops.net with ESMTP id 354g9udq5e-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT); Mon, 30 Nov 2020 12:15:51 -0800 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (100.104.31.183) by o365-in.thefacebook.com (100.104.35.174) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Mon, 30 Nov 2020 12:15:49 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GkIYp2xxBnak4MYL+YwfQdCKuXQHncjttEeBD+SaEHcuokoHtqewZWfcvdwRjkO0ioBLfP63SqAt9JO7tEoJW+7k1IL7IbMU3RGNe0aNmnQPMR7gfwfDv2yHjQUBfSWcQf31Fv4b3yj1OdmqbKhARgISgDNoDM2pcBKtmMN3UzI6ssuWK4R9m8NDNhhm2xd57igcHl5ks1ODPexBa3G9Q6Bfi5n7BSZMLpF5GQhKedg0FsB/+xJPQySqf7nLV0FQeaDpBVhk6yKtNKPHFT0tnbpXJ9ukRdf4krq4W9bZaiQjKpStK6V4qEc0zxJY534Vtil237quYqJ2zoAq0SHDsw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=RdtE83tmijXt7lplw7hDnEBho3pDThFvGVCdYYGG35I=; b=bq6YyXjrkrClMnjVts8q5/EuEyvRQh02BV4MdsfDLMhFqVKBSeGamu6wIKUIcL/MTcaiYsY5rBXkRN0dOjmLJG5oe5aYcam3uxq+8ZWxuKoS1pFD4KAJrz6v+BJMUwt9JOGPpfsDIllZaAYyUv8H7tjp8F7xYqlkg427QIBuNkfh+cyspriRUmLLS7pH0p55FrVA/2tkdMsSFiLp/5F5YYkPvxrtAzkfsnORs0dn98k+TCTHQtftfCvqyYu7bKt3gkWjCl+Gmltv5uTrGYWHzdGFeroaOyY6zVJXUW0ZrQbqgDuh621XqvVYD6kdwXZPIB3171Ch9tOH0Z6e/+VYVw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=fb.com; dmarc=pass action=none header.from=fb.com; dkim=pass header.d=fb.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.onmicrosoft.com; s=selector2-fb-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=RdtE83tmijXt7lplw7hDnEBho3pDThFvGVCdYYGG35I=; b=eBU3S5NgHMbF10FsFYbZHo5zkCpDWEtLJwDYUG/uc3VtQYTy5dNVteyIeW9A4ZnJ8ksRtrawvFxuzlucGAVs3+8+mzKhyaDj4F+opoZuLf2fW6CIOXfhP2qVqjafv9nhEtbLXcfU8EarIBBbj8RPZjRV8WPr6W2+6TpkszjlOto= Authentication-Results: kernel.org; dkim=none (message not signed) header.d=none;kernel.org; dmarc=none action=none header.from=fb.com; Received: from BYAPR15MB4136.namprd15.prod.outlook.com (2603:10b6:a03:96::24) by BYAPR15MB2933.namprd15.prod.outlook.com (2603:10b6:a03:f6::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3611.24; Mon, 30 Nov 2020 20:15:47 +0000 Received: from BYAPR15MB4136.namprd15.prod.outlook.com ([fe80::3925:e1f9:4c6a:9396]) by BYAPR15MB4136.namprd15.prod.outlook.com ([fe80::3925:e1f9:4c6a:9396%6]) with mapi id 15.20.3611.025; Mon, 30 Nov 2020 20:15:47 +0000 Date: Mon, 30 Nov 2020 12:15:40 -0800 From: Roman Gushchin To: Mike Rapoport Subject: Re: [PATCH v12 07/10] secretmem: add memcg accounting Message-ID: <20201130201540.GB1354703@carbon.DHCP.thefacebook.com> References: <20201125092208.12544-1-rppt@kernel.org> <20201125092208.12544-8-rppt@kernel.org> <20201129172625.GD557259@kernel.org> Content-Disposition: inline In-Reply-To: <20201129172625.GD557259@kernel.org> X-Originating-IP: [2620:10d:c090:400::5:6c8f] X-ClientProxiedBy: MWHPR11CA0009.namprd11.prod.outlook.com (2603:10b6:301:1::19) To BYAPR15MB4136.namprd15.prod.outlook.com (2603:10b6:a03:96::24) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from carbon.DHCP.thefacebook.com (2620:10d:c090:400::5:6c8f) by MWHPR11CA0009.namprd11.prod.outlook.com (2603:10b6:301:1::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3611.22 via Frontend Transport; Mon, 30 Nov 2020 20:15:43 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: e7f1d3a8-1199-45e7-b2c4-08d8956cb943 X-MS-TrafficTypeDiagnostic: BYAPR15MB2933: X-Microsoft-Antispam-PRVS: X-FB-Source: Internal X-MS-Oob-TLC-OOBClassifiers: OLM:9508; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: iFw2mu0Q/5xaFtwWblPc7d2PWZFOYxBg0jDr/XqenwXz3u99bM9acqJomsgPR5WxBM5aCZXp8f1E9jMhHEnhBkyFvcNU/8l38hInIaiyJSc6wcMBiv0o/2dXOdIXaLWlHCWwJIktO9YAR+gGaXQEKzxYFbj9odOUxVOeW9qQAEW70eeDAvQuknrpzThyRLOrBF9uaqPL7yV2Of7mHP5UNa6jyHddWh95WE53cveQQ9r+xeRDZlpNg7erOyZnpt0EMxokJWAlPigOhTjPR7gGV2zdG4hBDdaIOz7S5UM3W7wnVLnJl6/pfj8dJVgCvRjdnsWBeqhueN6TEbbwas92Rw== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR15MB4136.namprd15.prod.outlook.com; PTR:; CAT:NONE; SFS:(366004)(136003)(396003)(346002)(376002)(39860400002)(6506007)(16526019)(186003)(7416002)(15650500001)(83380400001)(53546011)(1076003)(66946007)(54906003)(66556008)(316002)(7406005)(8936002)(55016002)(4326008)(7696005)(8676002)(33656002)(5660300002)(478600001)(52116002)(6916009)(86362001)(2906002)(9686003)(66476007); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: =?us-ascii?Q?iqlKOIi4ERXHU7Zr75N4bB44+GuU4q4I8FYiclh5fY/GvAbfOuoM/f8YUfpg?= =?us-ascii?Q?6/cFcANL1nVfp4xGxT3aMqGaCbTRhvLcfotICeBRZ9peZlsOgWIl5+Ij2b/n?= =?us-ascii?Q?bHxxlJgpwojdK1Mxp4AZhHQvXA+QzIwlpOf6Yd9Grr4ESPjw+SqWEt5J659S?= =?us-ascii?Q?jtdL6e6qXjOJs5hKC2QjY2XDEEa6JOB36rTpBhwbHwtmuM7MmuNsou7vNkNC?= =?us-ascii?Q?3T63IhemfFLIw9vQ7ITZjHUc186mbqeuaDHEyFdIberhEloiV0vnJi5G6s68?= =?us-ascii?Q?uJ1tzp2KSRGr4I6WUAgQy1lUdAUgYbdMEaL3cjp8cuiseIdC7YyFhJINN72W?= =?us-ascii?Q?PDMgg7QSGn8+0uyDHjfj7sMI2tpvQHMosLa4/YIRoyQria8orEBi3Yy+1wvL?= =?us-ascii?Q?LilFlt4scpTRYeCarn4ZvuQ4go71G0AbPHcX3/pXEQ/sTU0qhLxd9gIrlfyZ?= =?us-ascii?Q?rmv804Vx18OS5gP1RTVKDOk+mUUxLAZS8diqejZSchcy2HDrt1BIyAqS86DG?= =?us-ascii?Q?PZbyQUsOsh/37xR2QwgvX6ayDusqhF6tBlOhqTu/sjBhODYf3wVWJJpdzzWr?= =?us-ascii?Q?98kmD03cHklbtsievGHl5CoCbgbpuagCaIqiQ4e1jEBwQm7YQc+mqjRMA8xI?= =?us-ascii?Q?xHBTsHFj0a6uhc1gvurE6C24zqxbyLoU49G3tMAs74vQ94csy2z2r7BYOETj?= =?us-ascii?Q?SPlpITSFaY3CeV7kCiWJhL7+ZGjTnpOyfBG5v3CHqpLyuNq9isQvD6rk57vj?= =?us-ascii?Q?ljFwk982AoWdOF+VEOIWCk+7Qpzbsn8w5ZLBzWBcbqY6ofnv8ZW8XYSA/8lS?= =?us-ascii?Q?KyZVbDUXwvwbvYSQ5OZ41wVds49x/F9q5e/XOvKPoNUNXGUH7e6MgTFJ3G12?= =?us-ascii?Q?k7/Rt6bOSXgiVQ7ZQMd4bVPwIvHYIg/873+tjdhlLTyqHprEdU9yWBhEM5V0?= =?us-ascii?Q?O6ebtIys0H+9AKoMnERpQX2zFbiiphRLaZ5VA5FZI3saa50oufwArQWERwnT?= =?us-ascii?Q?3zla4tmiBEZnteoNG/MxW32oXA=3D=3D?= X-MS-Exchange-CrossTenant-Network-Message-Id: e7f1d3a8-1199-45e7-b2c4-08d8956cb943 X-MS-Exchange-CrossTenant-AuthSource: BYAPR15MB4136.namprd15.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Nov 2020 20:15:47.2482 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 8ae927fe-1255-47a7-a2af-5f3a069daaa2 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: /HRyLj7WzWrk8wEPiGyiQ7NpXUvMt3C5xgAH0q9VadSFMowQvih6G/Ng+JbVE7Lx X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR15MB2933 X-OriginatorOrg: fb.com X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.312, 18.0.737 definitions=2020-11-30_08:2020-11-30, 2020-11-30 signatures=0 X-Proofpoint-Spam-Details: rule=fb_default_notspam policy=fb_default score=0 lowpriorityscore=0 malwarescore=0 suspectscore=1 clxscore=1015 impostorscore=0 mlxlogscore=999 bulkscore=0 phishscore=0 spamscore=0 adultscore=0 mlxscore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2011300129 X-FB-Internal: deliver X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201130_151647_587950_28FDFC50 X-CRM114-Status: GOOD ( 32.73 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , David Hildenbrand , Peter Zijlstra , Catalin Marinas , Dave Hansen , Linux MM , linux-kselftest@vger.kernel.org, "H. Peter Anvin" , Christopher Lameter , Shuah Khan , Thomas Gleixner , Elena Reshetova , linux-arch@vger.kernel.org, Tycho Andersen , linux-nvdimm@lists.01.org, Will Deacon , x86@kernel.org, Matthew Wilcox , Mike Rapoport , Ingo Molnar , Michael Kerrisk , Arnd Bergmann , James Bottomley , Borislav Petkov , Alexander Viro , Andy Lutomirski , Paul Walmsley , "Kirill A. Shutemov" , Dan Williams , linux-arm-kernel@lists.infradead.org, linux-api@vger.kernel.org, LKML , linux-riscv@lists.infradead.org, Palmer Dabbelt , linux-fsdevel , Shakeel Butt , Andrew Morton , Rick Edgecombe Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Sun, Nov 29, 2020 at 07:26:25PM +0200, Mike Rapoport wrote: > On Sun, Nov 29, 2020 at 07:53:45AM -0800, Shakeel Butt wrote: > > On Wed, Nov 25, 2020 at 1:51 AM Mike Rapoport wrote: > > > > > > From: Mike Rapoport > > > > > > Account memory consumed by secretmem to memcg. The accounting is updated > > > when the memory is actually allocated and freed. > > > > > > Signed-off-by: Mike Rapoport > > > Acked-by: Roman Gushchin > > > --- > > > mm/filemap.c | 3 ++- > > > mm/secretmem.c | 36 +++++++++++++++++++++++++++++++++++- > > > 2 files changed, 37 insertions(+), 2 deletions(-) > > > > > > diff --git a/mm/filemap.c b/mm/filemap.c > > > index 249cf489f5df..cf7f1dc9f4b8 100644 > > > --- a/mm/filemap.c > > > +++ b/mm/filemap.c > > > @@ -42,6 +42,7 @@ > > > #include > > > #include > > > #include > > > +#include > > > #include "internal.h" > > > > > > #define CREATE_TRACE_POINTS > > > @@ -844,7 +845,7 @@ static noinline int __add_to_page_cache_locked(struct page *page, > > > page->mapping = mapping; > > > page->index = offset; > > > > > > - if (!huge) { > > > + if (!huge && !page_is_secretmem(page)) { > > > error = mem_cgroup_charge(page, current->mm, gfp); > > > if (error) > > > goto error; > > > diff --git a/mm/secretmem.c b/mm/secretmem.c > > > index 52a900a135a5..eb6628390444 100644 > > > --- a/mm/secretmem.c > > > +++ b/mm/secretmem.c > > > @@ -18,6 +18,7 @@ > > > #include > > > #include > > > #include > > > +#include > > > #include > > > #include > > > > > > @@ -44,6 +45,32 @@ struct secretmem_ctx { > > > > > > static struct cma *secretmem_cma; > > > > > > +static int secretmem_account_pages(struct page *page, gfp_t gfp, int order) > > > +{ > > > + int err; > > > + > > > + err = memcg_kmem_charge_page(page, gfp, order); > > > + if (err) > > > + return err; > > > + > > > + /* > > > + * seceremem caches are unreclaimable kernel allocations, so treat > > > + * them as unreclaimable slab memory for VM statistics purposes > > > + */ > > > + mod_node_page_state(page_pgdat(page), NR_SLAB_UNRECLAIMABLE_B, > > > + PAGE_SIZE << order); > > > > Please use mod_lruvec_page_state() instead, so we get the memcg stats too. > > Ok > > > BTW I think secretmem deserves a vmstat entry instead of overloading > > NR_SLAB_UNRECLAIMABLE_B. > > I'd prefer to wait with a dedicated vmstat for now. We can always add it > later, once we have better picture of secremem usage. +1 here. >From what I understand it's not clear now how big typical secret areas will be. If there will be few 2Mb areas per container (like for storing some keys), IMO it doesn't justify adding a separate counter. If they will be measured in GBs, then we'll add it later. Thanks! _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel