Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1010760pxb; Thu, 28 Jan 2021 06:09:08 -0800 (PST) X-Google-Smtp-Source: ABdhPJyqk2kMBthtOgLabzgGXVY1ksUe28RP0K90PKu7cdlIwGNWZJJk84mduMLTyX7Ye45CffTj X-Received: by 2002:a17:906:a113:: with SMTP id t19mr11173480ejy.253.1611842947488; Thu, 28 Jan 2021 06:09:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611842947; cv=none; d=google.com; s=arc-20160816; b=E+G4CtJbdxUTWa4m431NuNXtGL0uWm6IHeZXq/sSutg32WwF+IfBaBruOG2yvujsEF 7l5Gfc0q0eIF60V3q9VAsG5c4Gt/pwh1EVgNTcZmIhldBQ4F71wHhh5GROtbXLAGOLbF BGHxHGveGUFA1nzXdxgTi4MlL7Bf4VLXC94ySBIh8j9G/E0dbx15BHsn3eMTXQUTvd5U aPGutka/F+xLvJibK444dNOcqWpr75NF0SecxeDvsyFK1w2xdSwpCAErJ3pFeoIET2te kuroDN4UorCwf3BC88k0uLfYa6FCXPXSBEVH4j7VUMSrLMo6mxajBlESfLzTkE+QClHR /9Rw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=y3gG47U5h6Z0ms3PRQUM8QBx0aKm7Kdbts1+blceg04=; b=YbOBeSj5/umY1ODOnPTw0YFdzWCosPHdgtTc2mnAcSB8sLbPwq3BvxwtmK6yF+IOpQ /yavFPb2TURGRdY9foyjX+lxpGzKGxVRYbmsFIn2lQMPPAqROBXd9/k5rAWANIs46yP2 UWmvHebZGhQ5fEG5gkjOTDrugAs1NpY85ZwAUUIozMKqms/UDYwxfi64MbzMHa5UabUi mwiIRtVRiF6skJxPbu6GiE9TRT47v2XOIFPCZnkhwiC2Vu9Y6d+SzTsbHdAZ/1qhy+7Y lOYIz5tyQq2J26KLeD1NpoOeq1dazkyLMqqMPWV8LhOcpClLs2n8Y2ImeGdjGDe7txtH ignA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=CfsrBQTG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s7si2987047edw.47.2021.01.28.06.08.41; Thu, 28 Jan 2021 06:09:07 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=CfsrBQTG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231218AbhA1OGL (ORCPT + 99 others); Thu, 28 Jan 2021 09:06:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37850 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231159AbhA1OGF (ORCPT ); Thu, 28 Jan 2021 09:06:05 -0500 Received: from mail-lj1-x229.google.com (mail-lj1-x229.google.com [IPv6:2a00:1450:4864:20::229]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 141E9C061756 for ; Thu, 28 Jan 2021 06:05:25 -0800 (PST) Received: by mail-lj1-x229.google.com with SMTP id r14so6462161ljc.2 for ; Thu, 28 Jan 2021 06:05:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=y3gG47U5h6Z0ms3PRQUM8QBx0aKm7Kdbts1+blceg04=; b=CfsrBQTGs0Esbt43WsOC7Vky4axjxTddmdc93F7OYhDFG0xRi8EFPzo+ljigoe2pot nl08e50onWdGXMFNApzFBAnmpeofi5yYUDo1CTz9cqW42zyNQd9HH0L/9STRoEjZ5zJc fTQNEKQF+kRCuFHnyz08L6kuBS11UhljPl/rF/qd+Dep7b9BbEiHXcPCIznldnx2v/az YhUiFaD5ezD3+239rpnSr1++mcg29oPu7pI5YQLwKfPBN7dvfoXrUj0cu4J0tiwMoTNG iQABFGbqct02pstWAwbScdjSu0GGO2jqtYNWDU9LQ7vjkegvI5234iUqZC4wfqsWXuRJ Fycg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=y3gG47U5h6Z0ms3PRQUM8QBx0aKm7Kdbts1+blceg04=; b=K7OE2Bk7zqrEZWRahN8zjeDgewvdlLEycNSspMJz/ZAHBCoVB8rudEEK2sdT/yrr2Y j+5NW1qcst+ZVVUUKLAJ457AyJfzT8wlRGo6VqSle0jIP2+ycuDsqEv8UmMZWlBXENQT 2La18/PhhtCkSkXY7NYm9UC7EmdmyEeRwv19EkH5eKs5H007swDpl27bTQlu5rvFAgm/ Di/qBJyqcDtS0EJ/lZQwhLBEa0EMt27Xz8xXtAus4iMXb5DhTyOktxGyO+gnLzgUUB0L jfXxQOfyKq76zadbYp2Ws/+XUP1RB0yYey0dYPbCs+6IyTPmi38Scs/wLTJPSGLxBeDW k7GQ== X-Gm-Message-State: AOAM531NwaSdP+tg8UdRyFEBXkN+c6GgljrfAXyYWq4aGRNxDVQtMVPe u7HdpifZIx9uDWvWa++gHy3zVsnmz6UkOZfKWUVoSQ== X-Received: by 2002:a2e:9ed1:: with SMTP id h17mr8071290ljk.160.1611842723157; Thu, 28 Jan 2021 06:05:23 -0800 (PST) MIME-Version: 1.0 References: <20210121122723.3446-1-rppt@kernel.org> <20210121122723.3446-9-rppt@kernel.org> <20210125165451.GT827@dhcp22.suse.cz> <20210125213817.GM6332@kernel.org> <20210126144838.GL308988@casper.infradead.org> <20210126150555.GU827@dhcp22.suse.cz> <20210127184213.GA919963@carbon.dhcp.thefacebook.com> In-Reply-To: From: Shakeel Butt Date: Thu, 28 Jan 2021 06:05:11 -0800 Message-ID: Subject: Re: [PATCH v16 08/11] secretmem: add memcg accounting To: Michal Hocko Cc: Roman Gushchin , Matthew Wilcox , Mike Rapoport , Andrew Morton , Alexander Viro , Andy Lutomirski , Arnd Bergmann , Borislav Petkov , Catalin Marinas , Christopher Lameter , Dan Williams , Dave Hansen , David Hildenbrand , Elena Reshetova , "H. Peter Anvin" , Ingo Molnar , James Bottomley , "Kirill A. Shutemov" , Mark Rutland , Mike Rapoport , Michael Kerrisk , Palmer Dabbelt , Paul Walmsley , Peter Zijlstra , Rick Edgecombe , Shuah Khan , Thomas Gleixner , Tycho Andersen , Will Deacon , linux-api@vger.kernel.org, linux-arch@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-fsdevel , Linux MM , LKML , linux-kselftest@vger.kernel.org, linux-nvdimm@lists.01.org, linux-riscv@lists.infradead.org, x86@kernel.org, Hagen Paul Pfeifer , Palmer Dabbelt Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jan 27, 2021 at 11:59 PM Michal Hocko wrote: > > On Wed 27-01-21 10:42:13, Roman Gushchin wrote: > > On Tue, Jan 26, 2021 at 04:05:55PM +0100, Michal Hocko wrote: > > > On Tue 26-01-21 14:48:38, Matthew Wilcox wrote: > > > > On Mon, Jan 25, 2021 at 11:38:17PM +0200, Mike Rapoport wrote: > > > > > I cannot use __GFP_ACCOUNT because cma_alloc() does not use gfp. > > > > > Besides, kmem accounting with __GFP_ACCOUNT does not seem > > > > > to update stats and there was an explicit request for statistics: > > > > > > > > > > https://lore.kernel.org/lkml/CALo0P13aq3GsONnZrksZNU9RtfhMsZXGWhK1n=xYJWQizCd4Zw@mail.gmail.com/ > > > > > > > > > > As for (ab)using NR_SLAB_UNRECLAIMABLE_B, as it was already discussed here: > > > > > > > > > > https://lore.kernel.org/lkml/20201129172625.GD557259@kernel.org/ > > > > > > > > > > I think that a dedicated stats counter would be too much at the moment and > > > > > NR_SLAB_UNRECLAIMABLE_B is the only explicit stat for unreclaimable memory. > > > > > > > > That's not true -- Mlocked is also unreclaimable. And doesn't this > > > > feel more like mlocked memory than unreclaimable slab? It's also > > > > Unevictable, so could be counted there instead. > > > > > > yes, that is indeed true, except the unreclaimable counter is tracking > > > the unevictable LRUs. These pages are not on any LRU and that can cause > > > some confusion. Maybe they shouldn't be so special and they should live > > > on unevistable LRU and get their stats automagically. > > > > > > I definitely do agree that this would be a better fit than NR_SLAB > > > abuse. But considering that this is somehow even more special than mlock > > > then a dedicated counter sounds as even better fit. > > > > I think it depends on how large these areas will be in practice. > > If they will be measured in single or double digits MBs, a separate entry > > is hardly a good choice: because of the batching the displayed value > > will be in the noise range, plus every new vmstat item adds to the > > struct mem_cgroup size. > > > > If it will be measured in GBs, of course, a separate counter is preferred. > > So I'd suggest to go with NR_SLAB (which should have been named NR_KMEM) > > as now and conditionally switch to a separate counter later. > > I really do not think the overall usage matters when it comes to abusing > other counters. Changing this in future will be always tricky and there > always be our favorite "Can this break userspace" question. Yes we dared > to change meaning of some counters but this is not generally possible. > Just have a look how accounting shmem as a page cache has turned out > being much more tricky than many like. > > Really if a separate counter is a big deal, for which I do not see any > big reason, then this should be accounted as unevictable (as suggested > by Matthew) and ideally pages of those mappings should be sitting in the > unevictable LRU as well unless there is a strong reason against. > Why not decide based on the movability of these pages? If movable then unevictable LRU seems like the right way otherwise NR_SLAB.