Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1062679pxb; Thu, 28 Jan 2021 07:13:54 -0800 (PST) X-Google-Smtp-Source: ABdhPJxPJSQP0g0QfX1Wg+t7ak/CxrYke9G4v3uWzFUmuk3uteWsczOBGYYng697hgk0L1x9lSgI X-Received: by 2002:a17:906:1c0c:: with SMTP id k12mr11889150ejg.354.1611846834211; Thu, 28 Jan 2021 07:13:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611846834; cv=none; d=google.com; s=arc-20160816; b=r6bE/pLPgNwf13ZcjkPORmXue/SbSIoGnI6OOF3/rAmaK2l1bKQA6Q2DqpZXieF4V8 htEAprUQmO5hHzXZstW5uB/qIBMN9ugkWedzVAJOBvnNHUbxujiz5C2YZibJZ23++iRt 4XsQDpMzJTueddWIgwz6ipn9Ddms2IaBcTQ5qkoJaSOaLW/V6O+JIIQoBC49x+4vzh1Q q3JkQRyETgRJSJ9DVx5FWYPcZv7Q9Z4BCgT5HFmUM4DeVvLa6Jb/p7Cj9TkDpmjkwUmy oZebYlLSyLZdAsMsEYiGodiQKU5DAAwiOb+j9XOnbURMJHnQvgFQ4breKybcFHsJAi9u s3sg== 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=gx1FZQ1uHuDZkl2l0QuCyhlDjtM4hAvEVSjKq4XHXek=; b=Udc34/jSDRYd49mfepq4TEYvhmBZe6tZW8Jb1h/cdCMxKSBoH9+OwBdyqseRiy9uw4 PrabwZDKlPmn5vVLWWN1V8iFTEEo/BFrROzM4UgAok4tpZLTAiQJZNXFIhRIynYvlPPe o0voz1MniGS8C7ySIwcYxFB9qNWdK+kaLQ3YGagqxcmcKyymsjVUhQcHmWeMK0L/TTm1 r3Vc3D2W/hT1GVcPzgJTnPeus+07mn6rGFe+F7XWK1mA6ovdR+1W/3W51/D8UTy3SYbj 7MmCp5pw9muA8/ECgyi5G7zV6FgAZIruySWfuTDtVK9KafJWRFV8xCQIlxHpDKC2wZFB lfwQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=rNDrJmir; 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 zl6si2686723ejb.747.2021.01.28.07.13.28; Thu, 28 Jan 2021 07:13:54 -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=rNDrJmir; 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 S232515AbhA1PJi (ORCPT + 99 others); Thu, 28 Jan 2021 10:09:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51306 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232500AbhA1PIV (ORCPT ); Thu, 28 Jan 2021 10:08:21 -0500 Received: from mail-lf1-x132.google.com (mail-lf1-x132.google.com [IPv6:2a00:1450:4864:20::132]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 20AF3C061756 for ; Thu, 28 Jan 2021 07:07:39 -0800 (PST) Received: by mail-lf1-x132.google.com with SMTP id v24so8002566lfr.7 for ; Thu, 28 Jan 2021 07:07:39 -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=gx1FZQ1uHuDZkl2l0QuCyhlDjtM4hAvEVSjKq4XHXek=; b=rNDrJmirIdtuQRNEjYCJqIahTLFcoP8DR9oYw737/DvxJ19UDGdrbCsIGle2umy0jD NXWAsRT1flRccegDPvkf55kCw2DNk8SqDIL58JVr3fvRjKunbCHaj8KABu2swU23b+Tn x+NU2ZIn6ek86dpsaDWMjLSj4H8o+tTQ3yC4aFlrBvOa8XcqzmKF2TQDerrN2R5pYJu+ fAMFlALz41f7QuqjuFdkX9Gq9MHturSOMu64f3KjxUu+KSfCnR6HUHqw812RnfVk6aYa yoVqSkXCV6LgmIAb66X006PCDW1Z8Wnv3RYQ7I2XqpROsvJE5rsKOwyxmgJqOxI69qOR rdKQ== 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=gx1FZQ1uHuDZkl2l0QuCyhlDjtM4hAvEVSjKq4XHXek=; b=O6u7SjVkfRv6xCF3yQniBFW3HlmzX2wG6JGyIIji/T2adNbD1Y4MmKddaWLT//ln5Y whURLzLpnKQi0Zlzqb4pP2A2Mmwd0JAJz7W7sdQpO0zFGDc1YsLttCh/PxeA6QIA1a7i 03s/TMW/ihVs/xuYvD72LRopkUHpkvTt6Ht4FTi0duxbTP9Y59yYxrMovTm4zCre5VWV WFIyLOhx+TfcPPv4OF/kgsuw1J7XkR05zFB1mENFjxI3L7O+SoZtuNrwMkeKkoxQyFqm kjdGpRWQpA2J3cgBGaAzeKZFt3nKW3qITCCHMgTRVVnPEHlDywWHCI4zlPRxPSpXP4BS IG6A== X-Gm-Message-State: AOAM532Fxzs7uEmG+WUPaVLlBXNZcl1y1HdKMiVPNC8Mm1DWHv5t5zjQ rb7okb61lLcoQPHCdGrXDsvZImJvV1YLWnhz+3fwUQ== X-Received: by 2002:ac2:5a41:: with SMTP id r1mr7813210lfn.117.1611846457199; Thu, 28 Jan 2021 07:07:37 -0800 (PST) MIME-Version: 1.0 References: <20210121122723.3446-1-rppt@kernel.org> <20210121122723.3446-9-rppt@kernel.org> <20210125161706.GE308988@casper.infradead.org> <20210125213526.GK6332@kernel.org> In-Reply-To: <20210125213526.GK6332@kernel.org> From: Shakeel Butt Date: Thu, 28 Jan 2021 07:07:26 -0800 Message-ID: Subject: Re: [PATCH v16 08/11] secretmem: add memcg accounting To: Mike Rapoport Cc: Matthew Wilcox , 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 , Roman Gushchin , 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 Mon, Jan 25, 2021 at 1:35 PM Mike Rapoport wrote: > > On Mon, Jan 25, 2021 at 09:18:04AM -0800, Shakeel Butt wrote: > > On Mon, Jan 25, 2021 at 8:20 AM Matthew Wilcox wrote: > > > > > > On Thu, Jan 21, 2021 at 02:27:20PM +0200, 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. > > I though about doing per-page accounting, but then one would be able to > create a lot of secretmem file descriptors, use only a page from each while > actual memory consumption will be way higher. > > > > I think this is wrong. It fails to account subsequent allocators from > > > the same PMD. If you want to track like this, you need separate pools > > > per memcg. > > > > > > > Are these secretmem pools shared between different jobs/memcgs? > > A secretmem pool is per anonymous file descriptor and this file descriptor > can be shared only explicitly between several processes. So, the secretmem > pool should not be shared between different jobs/memcg. Of course, it's > possible to spread threads of a process across different memcgs, but in > that case the accounting will be similar to what's happening today with > sl*b. I don't think memcg accounting for sl*b works like that. > The first thread to cause kmalloc() will be charged for the > allocation of the entire slab and subsequent allocations from that slab > will not be accounted. The latest kernel does object level memcg accounting. So, each allocation from these threads will correctly charge their own memcgs.