Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp3356356pxb; Mon, 25 Jan 2021 13:50:58 -0800 (PST) X-Google-Smtp-Source: ABdhPJx9fkAIL3llcZfHIuzy6H4ly+0S7PVCaLCyzqIAYnVHcTYsckY2qDW0UPfWn9SiD1/G50sz X-Received: by 2002:a50:d7c7:: with SMTP id m7mr2109748edj.260.1611611458263; Mon, 25 Jan 2021 13:50:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611611458; cv=none; d=google.com; s=arc-20160816; b=iZkluvr8BtSKOOwy1LHVxoxENJMl5Or55Z5wnbzvx8xUXfVW2/nn+i412pero7Vaa0 HPTJWaE8mflUAje3qbfAEcz1uAQAQYfRca+cexA5eJPpwtkxWPqaO+C27Epg6aMHEUxn WHRfU55Jn4SIkuHBtO9VL5AFM16REmFAu10cPLRlFpTw9Gg/95ssiS9XbupsvvPWWvn5 fY6f9lQAiG+du156P4gQFX0d8hZ1YZwZcgLf1ZfszPOKiY9+B20deHAbp/97Uar+WtjD mGKNxvOtVvp90vFSimSfx9zDxEQ2Z3SZv3e7TW4YkHisg+wGbNxejUi//Q74UIek+rfn DQYQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=RjcU6BaUbjZnAUburLhiaWJ/GrRGg8jo/qmTPkQ/liY=; b=m9Vq0Rjehxtyioavw1agIXy4RWjM6uPyD00sbxZj3Zcf0APOl/ZsVOvT4G6JRe51ij IsI12qdK0PqjdOZ64/qw0AxP1gOk8FEr2VczIYyBg/LXiVZ5M3Ryz2+NddLjmlNWXz4o zhkaIwJgzyBdR5I4Bm8JMtT5JA7gPxrTJWNxodNSuB56RY14XxtR4Bf74MMqpZdYmmBa kuY0gjYIaBWOnLQnEpVZHVqoAc7ZSvsjU90xxjDoQqtJn6fg7Gykz6VP4Oq4MuOGLe/x LmNWltMEYlj5jNYNJQPPmGgK6UGdN+BHRLv/pmivgJIsG0vpZ2qo+yEf47LN+t6Q4iM9 pQNQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Cy17SSKv; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dm27si7808951edb.83.2021.01.25.13.50.33; Mon, 25 Jan 2021 13:50:58 -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=@kernel.org header.s=k20201202 header.b=Cy17SSKv; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733045AbhAYVtS (ORCPT + 99 others); Mon, 25 Jan 2021 16:49:18 -0500 Received: from mail.kernel.org ([198.145.29.99]:36284 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732834AbhAYVib (ORCPT ); Mon, 25 Jan 2021 16:38:31 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 5F8A2229C6; Mon, 25 Jan 2021 21:35:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1611610543; bh=2Di0IbIXl1xn2Q918lq0pHS35BBSv9IAQLWTpnF3034=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Cy17SSKvvNvxfTqzme3GulWvb12hmNhkF7DBhyy2a+M5IaoGf8exm+dMOhwdI3cnD O9Y6le+GeozBAOlFWKkpEB+vZ71maF7XrODlor4nn34mqAaY2SmcJJTy1/7R4Vzp0U bPshjl150D1+6AqGJJwRZluiwgpDdWOErZGjlhYbAQhuHLMYpqQxkt2okbl3QmaaEV +AvTUTAKQGnim5uoCQhk9nL/vcRX66pRqMexDaS2sIjDuNGgW078c+2BX0w5Eu0hmE oc6a5eiysTeaoVlQWOTzqTt5FOVdCY/F5kyVzE2NWYn7vW0p6El384BwmC/nQzLCGf IjSwSAhpZJ+aA== Date: Mon, 25 Jan 2021 23:35:26 +0200 From: Mike Rapoport To: Shakeel Butt 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 Subject: Re: [PATCH v16 08/11] secretmem: add memcg accounting Message-ID: <20210125213526.GK6332@kernel.org> References: <20210121122723.3446-1-rppt@kernel.org> <20210121122723.3446-9-rppt@kernel.org> <20210125161706.GE308988@casper.infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. 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. That said, having a pool per memcg will add ton of complexity with very dubious value. -- Sincerely yours, Mike.