Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D72BBC636D3 for ; Mon, 6 Feb 2023 23:25:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229865AbjBFXZj (ORCPT ); Mon, 6 Feb 2023 18:25:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56104 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229571AbjBFXZh (ORCPT ); Mon, 6 Feb 2023 18:25:37 -0500 Received: from mail-pf1-x42a.google.com (mail-pf1-x42a.google.com [IPv6:2607:f8b0:4864:20::42a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EB33724484; Mon, 6 Feb 2023 15:25:36 -0800 (PST) Received: by mail-pf1-x42a.google.com with SMTP id t17so9586107pfj.0; Mon, 06 Feb 2023 15:25:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:sender:from:to:cc:subject:date:message-id :reply-to; bh=HNyTUpgbSKzrwdLKzf32iJthR0x3bB6/K+FM9veAVxs=; b=FM7dnXdDgTi6Jr47ShxElcXjWHf8/UeXvO3sG8rOKcpJeNHNS3yZ2XMQ09gojvSZUS jMC4v/s3fIbXEZcN/hWXAinwIoADwF54gqpJzyAmLG/jbFAHMl9869uZNSn/EQ/c3cU/ sSbheM93Ql1q1GVQvGm5T8KF3HjrEq/J8nYdjQhM5vzRpmxJChWw6ik0kM0HJ9yPYm5c kyLv7nW5pIeY74Pf81p5FQy9U5vEoHktgkH91nRhqZSmdrkaH8/x6bPrRvCzwgjpIw1M Wri0s5FTjjOgIiWOKdnX3XaJkImD65FY8TNru+AdsHrWWqYjwDJTotnvtTfaZDP4NWUu 2NlA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:sender:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=HNyTUpgbSKzrwdLKzf32iJthR0x3bB6/K+FM9veAVxs=; b=BmQzU0IXPwI34VypDHTsemhKXSIfw6oh1PcvFr3O/6dKA/HJ6BlGeew675R+OwspqR Gmy/OQhrva2Y57lGFhdu8T5T4a5yHRPIk/1Trcn7DPqEjA3mIXvLmLAvVwcnDzYsy5uI Yv+FRCFg1ffMHzAZzKa0y5266R7NVA9a0aujwwKnC6b34aPPk4aFw7A/YCLjTPv2A+wu C+B/bnso5lP+Yw2PFfrT/NbxMA/hUDPjldnHxtMLURsHMI8v1xA87kfYnezeIC7NiXjV 0ly4eQQAM/AfqfNsJrIua21ueO/iPGdgxPEBxF6rIBvVlWOsSuyuMf8qQ/WdGSJwIDP8 +rEA== X-Gm-Message-State: AO0yUKV/mRerLYKYkpbRq5ZfgqvGk3TxwPt2n6E1zNbVFQOf84kGfPW+ 77e40Z6Th6zYyN7InisNZyDmw93xkhM= X-Google-Smtp-Source: AK7set+OLNZIETla8KPC9TCHUzFLdHiTMYTyvd0ctdu9+qHe6fVJvB2/KVw0/D/ECLFVYvUjoRV7kw== X-Received: by 2002:a62:1c88:0:b0:593:893f:81d7 with SMTP id c130-20020a621c88000000b00593893f81d7mr800938pfc.16.1675725936087; Mon, 06 Feb 2023 15:25:36 -0800 (PST) Received: from localhost (2603-800c-1a02-1bae-a7fa-157f-969a-4cde.res6.spectrum.com. [2603:800c:1a02:1bae:a7fa:157f:969a:4cde]) by smtp.gmail.com with ESMTPSA id b205-20020a621bd6000000b0058bc37f3d1csm7694842pfb.44.2023.02.06.15.25.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Feb 2023 15:25:35 -0800 (PST) Sender: Tejun Heo Date: Mon, 6 Feb 2023 13:25:33 -1000 From: Tejun Heo To: Yosry Ahmed Cc: Alistair Popple , linux-mm@kvack.org, cgroups@vger.kernel.org, linux-kernel@vger.kernel.org, jgg@nvidia.com, jhubbard@nvidia.com, tjmercier@google.com, hannes@cmpxchg.org, surenb@google.com, mkoutny@suse.com, daniel@ffwll.ch, "Daniel P . Berrange" , Alex Williamson , Zefan Li , Andrew Morton Subject: Re: [PATCH 14/19] mm: Introduce a cgroup for pinned memory Message-ID: References: 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, Feb 06, 2023 at 02:39:17PM -0800, Yosry Ahmed wrote: > On Mon, Feb 6, 2023 at 2:36 PM Tejun Heo wrote: > > > > On Mon, Feb 06, 2023 at 02:32:10PM -0800, Yosry Ahmed wrote: > > > I guess it boils down to which we want: > > > (a) Limit the amount of memory processes in a cgroup can be pinned/locked. > > > (b) Limit the amount of memory charged to a cgroup that can be pinned/locked. > > > > > > The proposal is doing (a), I suppose if this was part of memcg it > > > would be (b), right? > > > > > > I am not saying it should be one or the other, I am just making sure > > > my understanding is clear. > > > > I don't quite understand what the distinction would mean in practice. It's > > just odd to put locked memory in a separate controller from interface POV. > > Assume we have 2 cgroups, A and B. A process in cgroup A creates a > tmpfs file and writes to it, so the memory is now charged to cgroup A. > Now imagine a process in cgroup B tries to lock this memory. > - With (a) the amount of locked memory will count toward's cgroup A's > limit, because cgroup A is charged for the memory. > - With (b) the amount of locked memory will count toward's cgroup B's > limit, because a process in cgroup B is locking the memory. > > I agree that it is confusing from an interface POV. Oh yeah, that's confusing. I'd go with (a) for consistency with the rest of memcg - locked memory should fit inside e.g. memory.max. The problem with shared memory accounting exists for non-locked memory as well and prolly best to handle the same way rather than handling differently. Thanks. -- tejun