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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id F0FC0C433EF for ; Tue, 19 Jul 2022 19:47:53 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 696AB6B0071; Tue, 19 Jul 2022 15:47:53 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 61DAF6B0073; Tue, 19 Jul 2022 15:47:53 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4BEF56B0074; Tue, 19 Jul 2022 15:47:53 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 35BD96B0071 for ; Tue, 19 Jul 2022 15:47:53 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id EE245A02C6 for ; Tue, 19 Jul 2022 19:47:52 +0000 (UTC) X-FDA: 79704884784.22.60B784C Received: from mail-vs1-f47.google.com (mail-vs1-f47.google.com [209.85.217.47]) by imf01.hostedemail.com (Postfix) with ESMTP id 9545D4006F for ; Tue, 19 Jul 2022 19:47:52 +0000 (UTC) Received: by mail-vs1-f47.google.com with SMTP id x125so14358823vsb.13 for ; Tue, 19 Jul 2022 12:47:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=nboYEa7rJCR7CNGdTDaXIoV9fIPi91CmCuY7BiHHgHo=; b=BAfyUT9RiCWibO94CefV3FwsBy1jICTyq07/tU+6Vx39pg3dFWlCq5ndJXgr+QF7eK ORoA+nYLgOBFYUsVMWu4iDcR9dgc6EtHuBG7x+gOayvA4Ror3Wk3H5fdgmdY712uJ9UJ H8Lma3pfF6Ntl18zGZgo8KhM3nQXOd2S4M2OBlfc0XvXVQaXs0kYyEa3D5jkdLK3xNwc 5reXSMBGQjTc7UBTblY2e9OgqlV84PhnpO/hPLmMYD5Lus10MLjEDB6C6p2NJFUqQNOM o+C2oRwbs4fwJnylPoBNxJjQYq1CqZlSdE9DKyQQkGLp65vdJ8xR/0MT+z9fK5YLWKHI dRjA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=nboYEa7rJCR7CNGdTDaXIoV9fIPi91CmCuY7BiHHgHo=; b=HoPtg69rW36+dfy9qeu2GoUTes8rpZF2xAcSvKOFARhIA+rSThAPXtR4Ga0A3TSJnO Ag2dhvsAmz0T9P9Bi9PgJK/y1HD4bz9LSSSXfP1oFqcjuT/+4tPd287ZvgCoC9XKMR/T qhNzb6DBdNd7j9MFhRH/g/72OTsANcADZaW3l7K3iAOwdzvcEGxdrDIiTITg4p6NljxI ILB83JOzNAkxc/NkzPyrUFee7xBh5X0cyJ076ZDvOqRcgAA6PlJwnUn7zcpQW+9d8MDI inrSTXU9s3wy7eAIn2RP8oJUZdHHrqouaUR8Mz5OOmyOJgsUG0WnK9As2kyPx89R7Eww WwMg== X-Gm-Message-State: AJIora+biEaBiQ6i0p++jB4/cLDnn93ixAOrUxg1aDYfiMWqGvF7dec5 LuWsnlQb18CCLxB6hSDHjTNV9lkjbMo6MvIZV7fCpg== X-Google-Smtp-Source: AGRyM1uk/F30eIWrOe+KR3j7evKm1u8f1CIe/rrQaFGwkhYiXPVA41KSu5BCM3I19yu9N8Vu7znxwHsI+IGLnuYctfM= X-Received: by 2002:a05:6102:30a4:b0:357:ae78:c415 with SMTP id y4-20020a05610230a400b00357ae78c415mr6961650vsd.72.1658260071710; Tue, 19 Jul 2022 12:47:51 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Mina Almasry Date: Tue, 19 Jul 2022 12:47:39 -0700 Message-ID: Subject: Re: cgroup specific sticky resources (was: Re: [PATCH bpf-next 0/5] bpf: BPF specific memory allocator.) To: Tejun Heo Cc: Yosry Ahmed , Michal Hocko , Roman Gushchin , Yafang Shao , Alexei Starovoitov , Shakeel Butt , Matthew Wilcox , Christoph Hellwig , "David S. Miller" , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , bpf , Kernel Team , linux-mm , Christoph Lameter , Pekka Enberg , David Rientjes , Joonsoo Kim , Andrew Morton , Vlastimil Babka Content-Type: text/plain; charset="UTF-8" ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1658260072; a=rsa-sha256; cv=none; b=4QvVMsJcc/JGHEzNuALdx7/Kbaz+CZlNYFxhO0gCJSdgYuO/g5Cmm6QhD16KDkLJ13ywcK HH3mFG9afAYSPnyix0ZDRwE+1ORFb+Ri5fmaxNi3BIdOH9t8aXSAfgRs5BuJby6K2+Ntsa SiSLiIPRsUnsBMUoovcEYUkA8zMMNoY= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=BAfyUT9R; spf=pass (imf01.hostedemail.com: domain of almasrymina@google.com designates 209.85.217.47 as permitted sender) smtp.mailfrom=almasrymina@google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1658260072; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=nboYEa7rJCR7CNGdTDaXIoV9fIPi91CmCuY7BiHHgHo=; b=H8WCCGjfLNLZTeuLCsQBjUuzuGFKqlHhtlbXwOKZpzHpWxqk1GQuzxYPFAHt/fKZz14LCr oqFYhiG0C4Nj0kLcTGUPrKRQ9v9zyxQ+d0OFii6VX03ZdgdTFUv8uT5ZsDFM2QEvNvyXgr QYHXb4fxwM/2z77AiAwdRRj5bNOdfUI= X-Rspam-User: X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 9545D4006F Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=BAfyUT9R; spf=pass (imf01.hostedemail.com: domain of almasrymina@google.com designates 209.85.217.47 as permitted sender) smtp.mailfrom=almasrymina@google.com; dmarc=pass (policy=reject) header.from=google.com X-Stat-Signature: 3n86jry9t7b48jhejro86dxxb4a6znuu X-HE-Tag: 1658260072-562023 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Tue, Jul 19, 2022 at 12:38 PM Tejun Heo wrote: > > On Tue, Jul 19, 2022 at 12:30:17PM -0700, Yosry Ahmed wrote: > > Is there a reason why these resources cannot be moved across cgroups > > dynamically? The only scenario I imagine is if you already have tmpfs > > mounted and files charged to different cgroups, but once you attribute > > tmpfs to one cgroup.charge_for.tmpfs (or sticky,..), I assume that we > > can dynamically move the resources, right? > > > > In fact, is there a reason why we can't move the tmpfs charges in that > > scenario as well? When we move processes we loop their pages tables > > and move pages and their stats, is there a reason why we wouldn't be > > able to do this with tmpfs mounts or bpf maps as well? > > Nothing is impossible but nothing is free as well. Moving charges around > traditionally caused a lot of headaches in the past and never became > reliable. There are inherent trade-offs here. You can make things more > dynamic usually by making hot paths more expensive or doing some > synchronization dancing which tends to be pretty hairy. People generally > don't wanna make hot paths slower, so we tend to end up with something > twisted which unfortunately turns out to be a headache in the long term. > > In general, I'd rather keep resource associations as static as possible. > It's okay if we do something neat inside the kernel but if we create > userspace expectation that resources can be moved around dynamically, we'll > be stuck with that for a long time likely forfeiting future simplification / > optimization opportunities. > > So, that's gonna be a fairly strong nack from my end. > Hmm, sorry I might be missing something but I don't think we have the same thing in mind? My understanding is that the sysadmin can do something like this which is relatively inexpensive to implement in the kernel: mount -t tmpfs /mnt/mymountpoint echo "/mnt/mymountpoint" > /path/to/cgroup/cgroup.charge_for.tmpfs At that point all tmpfs charges for this tmpfs are directed to /path/to/cgroup/memory.current. Then the sysadmin can do something like: echo "/mnt/mymountpoint" > /path/to/cgroup2/cgroup.charge_for.tmpfs At that point all _future_ charges of that tmpfs will go to cgroup2/memory.current. All existing charges remain at cgroup/memory.current and get uncharged from there. Per my understanding there is no need to move all the _existing_ charges from cgroup/memory.current to cgroup2/memory.current. Sorry, I don't mean to be insistent, just wanted to make sure we have the same thing in mind. Speaking for ourselves we have a very similar implementation locally and is perfectly usable (and in fact addresses a number of pain points related to shared memory charging) without dynamically moving existing charges on reassignment (the second echo in my example). > Thanks. > > -- > tejun