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 7E150C00140 for ; Thu, 18 Aug 2022 22:25:00 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 16CFE8D0005; Thu, 18 Aug 2022 18:25:00 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0F69B8D0002; Thu, 18 Aug 2022 18:25:00 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EB1B18D0005; Thu, 18 Aug 2022 18:24:59 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id D9F088D0002 for ; Thu, 18 Aug 2022 18:24:59 -0400 (EDT) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id B7506141B1B for ; Thu, 18 Aug 2022 22:24:59 +0000 (UTC) X-FDA: 79814144718.13.4D03B9F Received: from mail-pj1-f50.google.com (mail-pj1-f50.google.com [209.85.216.50]) by imf09.hostedemail.com (Postfix) with ESMTP id C2CA2140E64 for ; Thu, 18 Aug 2022 22:20:40 +0000 (UTC) Received: by mail-pj1-f50.google.com with SMTP id o14-20020a17090a0a0e00b001fabfd3369cso3161055pjo.5 for ; Thu, 18 Aug 2022 15:20:40 -0700 (PDT) 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; bh=tr2YfKFFpUU37xf4ManQv+y3/4pV4AbAVOF71yP0UDM=; b=KY80Ec2EYHn5WFnbgKROZvwVrPBKR9TCPDJ4Bw/+YH1nWvZ8zBC4HiM3kL62FVSIHI V0sdJqE1+X9/hYSAmkHX0ttVunBfUUbxdDrijYE1S/aTAyrKetMJtSJdoIjYHfPOQ3gD BQwpS4K/1PXEiiH3xvM+lKbDEHg7ytztTUVJXVqOAJI9gHejz/CO3QZAQx8IfbGXsn4J 5bGMKpnl8EWu/l4SxhTYFUOiXMIhjxYbCo3JCHVlgJw0rKdbSnaJKuxVV3Hg2XNzKGy/ ykd1zcDd2xq+d6sycmuHscFeHGXchvlK3L+cVKS4i45SaDcrLIhwWniy+rYMw7SUKrM1 BomA== 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; bh=tr2YfKFFpUU37xf4ManQv+y3/4pV4AbAVOF71yP0UDM=; b=C4Dx8dkXRod6tie9jrmbFDMMVk2q/Nj1b93h6hOpHFqSPyw0ClzZuNwndh1e27EpYz jtHriD0+9DCxPfxE3l1N9arAH/WZRtrCKJZ7234999R/QIauGeeTIMCV+3Xb8A7aIGHW Tt/Fx5py7qYnhTIfwblmCkl9gAnVQvHzooheBiEyitPck391YFY5ALaKoCVXtbmnp/va 3OTNuC8pFtO+09m0vKt2SaxzsAz5wJbuza6kzoVBfobaV4+ggWIdoVb2g8xB97XxOk5u r5InaAK6BrU1Izrbtdp9Wk1dAWN/No7Y5nn7AiVIbLTObA5xGgWzxF/gOFF8RGt5mgHP iCZQ== X-Gm-Message-State: ACgBeo0S9QPW+JjvMsy/zLxDuwL4QMiiUfvCk/1k9THWdnUdcCVYRA+U 4DV6RUOfpTZXs3ats9te4ZI= X-Google-Smtp-Source: AA6agR6n9/ROxNFwoI1/6v2qOdwWNT55R5GNh1WmF2RNjQvaps8yoCjJOuhOltGV9kEx+rTK8QvldQ== X-Received: by 2002:a17:903:1205:b0:171:4f8d:22a8 with SMTP id l5-20020a170903120500b001714f8d22a8mr4336955plh.11.1660861235443; Thu, 18 Aug 2022 15:20:35 -0700 (PDT) Received: from localhost ([2620:10d:c090:400::5:3b7]) by smtp.gmail.com with ESMTPSA id j2-20020a63fc02000000b0041a615381d5sm1736207pgi.4.2022.08.18.15.20.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Aug 2022 15:20:34 -0700 (PDT) Date: Thu, 18 Aug 2022 12:20:33 -1000 From: Tejun Heo To: Yafang Shao Cc: ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org, kafai@fb.com, songliubraving@fb.com, yhs@fb.com, john.fastabend@gmail.com, kpsingh@kernel.org, sdf@google.com, haoluo@google.com, jolsa@kernel.org, hannes@cmpxchg.org, mhocko@kernel.org, roman.gushchin@linux.dev, shakeelb@google.com, songmuchun@bytedance.com, akpm@linux-foundation.org, lizefan.x@bytedance.com, cgroups@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, linux-mm@kvack.org Subject: Re: [PATCH bpf-next v2 00/12] bpf: Introduce selectable memcg for bpf map Message-ID: References: <20220818143118.17733-1-laoar.shao@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220818143118.17733-1-laoar.shao@gmail.com> ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1660861242; a=rsa-sha256; cv=none; b=Th6fVrvHmOQ9g3Q7sM3BGRrkYMld0dWkGhQHCRavEbaDDzCSUzdnWH2CM5o0Zb8tEgW4+7 ufercQ3VA9O7PzxjR/uYZa6QrbLwJSemjlz3HGZoHodqcqaMRvTfQwJ5/zUQLVVHaNYBzl Pd/kAdvhC6hinr81mc0td+hfT0PWuKY= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=KY80Ec2E; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=kernel.org (policy=none); spf=pass (imf09.hostedemail.com: domain of htejun@gmail.com designates 209.85.216.50 as permitted sender) smtp.mailfrom=htejun@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1660861242; h=from:from:sender: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=tr2YfKFFpUU37xf4ManQv+y3/4pV4AbAVOF71yP0UDM=; b=EyvNmwxzTT7c5wyLf7nPEMWAXoBKPQ+mMrgFpk6qKDZcV2VO/ruq8fGTIb7/TJIqRYiFD/ iclYbn1hTJxTMyq1B+m1rURBiiTEQ/8WAG7QKgy5zHxYoBqCWP1OATZDx4WgeFs1fvgNL/ eZxbHORnPqZ6EnCIeNJR0ppL3mq9bAw= X-Rspamd-Server: rspam06 X-Rspam-User: X-Stat-Signature: 8ey939jxg3krmt9yaue7dkh6t8xw64kc Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=KY80Ec2E; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=kernel.org (policy=none); spf=pass (imf09.hostedemail.com: domain of htejun@gmail.com designates 209.85.216.50 as permitted sender) smtp.mailfrom=htejun@gmail.com X-Rspamd-Queue-Id: C2CA2140E64 X-HE-Tag: 1660861240-40215 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000001, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Hello, On Thu, Aug 18, 2022 at 02:31:06PM +0000, Yafang Shao wrote: > After switching to memcg-based bpf memory accounting to limit the bpf > memory, some unexpected issues jumped out at us. > 1. The memory usage is not consistent between the first generation and > new generations. > 2. After the first generation is destroyed, the bpf memory can't be > limited if the bpf maps are not preallocated, because they will be > reparented. > > This patchset tries to resolve these issues by introducing an > independent memcg to limit the bpf memory. memcg folks would have better informed opinions but from generic cgroup pov I don't think this is a good direction to take. This isn't a problem limited to bpf progs and it doesn't make whole lot of sense to solve this for bpf. We have the exact same problem for any resources which span multiple instances of a service including page cache, tmpfs instances and any other thing which can persist longer than procss life time. My current opinion is that this is best solved by introducing an extra cgroup layer to represent the persistent entity and put the per-instance cgroup under it. It does require reorganizing how things are organized from userspace POV but the end result is really desirable. We get entities accurately representing what needs to be tracked and control over the granularity of accounting and control (e.g. folks who don't care about telling apart the current instance's usage can simply not enable controllers at the persistent entity level). We surely can discuss other approaches but my current intuition is that it'd be really difficult to come up with a better solution than layering to introduce persistent service entities. So, please consider the approach nacked for the time being. Thanks. -- tejun