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 93F49C433EF for ; Wed, 6 Jul 2022 02:47:27 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1C9A08E0002; Tue, 5 Jul 2022 22:47:27 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 179078E0001; Tue, 5 Jul 2022 22:47:27 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 03F7A8E0002; Tue, 5 Jul 2022 22:47:26 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id E63248E0001 for ; Tue, 5 Jul 2022 22:47:26 -0400 (EDT) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay13.hostedemail.com (Postfix) with ESMTP id A2E9D6034F for ; Wed, 6 Jul 2022 02:47:26 +0000 (UTC) X-FDA: 79655138892.05.BA2EC46 Received: from mail-ua1-f49.google.com (mail-ua1-f49.google.com [209.85.222.49]) by imf28.hostedemail.com (Postfix) with ESMTP id 55713C0003 for ; Wed, 6 Jul 2022 02:47:26 +0000 (UTC) Received: by mail-ua1-f49.google.com with SMTP id r18so3104411uan.4 for ; Tue, 05 Jul 2022 19:47:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=S9Mt83UidD28OhlwNN6+a26gUoMj9OoZPvbz6iZ0AlM=; b=Joe9DE7EU8kAGqBqAjOwKqrgE3mMBW8IwAllrOhLeyDETeCVuORC1apyRnd7dLCGrl U3+990DpayvNdMoY8AGZwxLc5Ytcj5vdoXRJKDuTSvbjRKGnmPkWrJOFLtTiRw+O3OV+ RJ4a+gpZThw1uxY2N8l5b8BLrHxg6GkWdwX8Q/7Wjs8Z+RnbEo9hDrTbDdY2Msj10Ltp 5xwWp47snGla1a2BRqRZJo9vgpw74Zv4xbn+1mkcyi0I7KLp6OypLhk7PKVTZmrH0hKu G09XhV6yVb3UncTpN64P5U5RAUaj3Tst+PatNnGJB7oQExE0ot1FVzSGY6SrsGGYrwJq TAZw== 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=S9Mt83UidD28OhlwNN6+a26gUoMj9OoZPvbz6iZ0AlM=; b=Jwr9vzAHcR507fk9XoX+UVXwRG8x4UREy8st9ejZ4LJ+XNnFf0WPzhvKVJUyM6yTWI XyrXd+LAfmA77fY1yzgFHGme9r2WMtOnHb4y+xJU4PnDJrNNxALRbhXl798wBeLoiCy0 vVwVHXtve6wIqpSmeZuELbz1t0/dhIay0zrqtw+cVacEXLToNNCSZFt0LqevGg/DLSVi UBXEFxLmhetHK/TnZZBynM+N2ftF9xzv0pbrBkm/bljVfi2DRon71V3DzQw4rhK37Tqf 0h6OA25DD23uS/kP68jpnlmiMdtdgRtLRootRjBILBCYQ/ZdO7/gb7A9RIz1DmbL1Cjp GoUA== X-Gm-Message-State: AJIora/yfub24g0T9BmCnOaRRLiehUEoqT0PRBxVFnC1/i6DFIOMNxen aG5qN3qydnGYIxaf2MVakv46aeZhKwng5nqmpWc= X-Google-Smtp-Source: AGRyM1tJaqE0DGsOmF8lAq+c2aQLkjDUk/sFWiBC3orx2Pvt/SlOM+OvevduvWaOJ1uBNJUzxOGKtvGhg/Ypk93FSys= X-Received: by 2002:a05:6130:121:b0:382:dbf7:93a1 with SMTP id h33-20020a056130012100b00382dbf793a1mr433829uag.89.1657075645679; Tue, 05 Jul 2022 19:47:25 -0700 (PDT) MIME-Version: 1.0 References: <20220702033521.64630-1-roman.gushchin@linux.dev> In-Reply-To: From: Yafang Shao Date: Wed, 6 Jul 2022 10:46:48 +0800 Message-ID: Subject: Re: [PATCH] mm: memcontrol: do not miss MEMCG_MAX events for enforced allocations To: Roman Gushchin Cc: Michal Hocko , Shakeel Butt , Andrew Morton , Johannes Weiner , Muchun Song , Cgroups , Linux MM , bpf Content-Type: text/plain; charset="UTF-8" ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1657075646; a=rsa-sha256; cv=none; b=k8/T+TLFben+xCuopdPWO4r2D3hOEpsyrk7KelATN/Twl3CtdjC7GvVbAcONRV3k2d3iIB +NQA2Se2WJEC38g7tkT3hXFWBXIxN0xBTagd07tqXpDJSWLyiGg6ODwB2/AulZYhNjs2j2 1T7t++NxDvZlEDZ+ZC1QAFVzLwQ89Ms= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=Joe9DE7E; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf28.hostedemail.com: domain of laoar.shao@gmail.com designates 209.85.222.49 as permitted sender) smtp.mailfrom=laoar.shao@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1657075646; 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=S9Mt83UidD28OhlwNN6+a26gUoMj9OoZPvbz6iZ0AlM=; b=psupnnP1cZoJXFanh74/gYJnTk4xMj/GGNE4t238GcrRmsNBBqhn7R/WX0JzSKE0HKCZs6 c4ZB9bGQ5OWh+Lbrp6suZ9WeVPPuIEUgqU4kWJ0MNK+fu2b/FXz+rbA86ZQPNep2AbLx2/ 3sYpaLdHmF9XpQgdYRehsQn/05VEdpM= Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=Joe9DE7E; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf28.hostedemail.com: domain of laoar.shao@gmail.com designates 209.85.222.49 as permitted sender) smtp.mailfrom=laoar.shao@gmail.com X-Stat-Signature: 8nwdx999rtz6yhaainy5bdsti5wpxihi X-Rspamd-Queue-Id: 55713C0003 X-Rspamd-Server: rspam05 X-Rspam-User: X-HE-Tag: 1657075646-235643 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 Wed, Jul 6, 2022 at 4:49 AM Roman Gushchin wrote: > > On Mon, Jul 04, 2022 at 05:07:30PM +0200, Michal Hocko wrote: > > On Sat 02-07-22 08:39:14, Roman Gushchin wrote: > > > On Fri, Jul 01, 2022 at 10:50:40PM -0700, Shakeel Butt wrote: > > > > On Fri, Jul 1, 2022 at 8:35 PM Roman Gushchin wrote: > > > > > > > > > > Yafang Shao reported an issue related to the accounting of bpf > > > > > memory: if a bpf map is charged indirectly for memory consumed > > > > > from an interrupt context and allocations are enforced, MEMCG_MAX > > > > > events are not raised. > > > > > > > > > > It's not/less of an issue in a generic case because consequent > > > > > allocations from a process context will trigger the reclaim and > > > > > MEMCG_MAX events. However a bpf map can belong to a dying/abandoned > > > > > memory cgroup, so it might never happen. > > > > > > > > The patch looks good but the above sentence is confusing. What might > > > > never happen? Reclaim or MAX event on dying memcg? > > > > > > Direct reclaim and MAX events. I agree it might be not clear without > > > looking into the code. How about something like this? > > > > > > "It's not/less of an issue in a generic case because consequent > > > allocations from a process context will trigger the direct reclaim > > > and MEMCG_MAX events will be raised. However a bpf map can belong > > > to a dying/abandoned memory cgroup, so there will be no allocations > > > from a process context and no MEMCG_MAX events will be triggered." > > > > Could you expand little bit more on the situation? Can those charges to > > offline memcg happen indefinetely? > > Yes. > > > How can it ever go away then? > > Bpf map should be deleted by a user first. > It can't apply to pinned bpf maps, because the user expects the bpf maps to continue working after the user agent exits. > > Also is this something that we actually want to encourage? > > Not really. We can implement reparenting (probably objcg-based), I think it's > a good idea in general. I can take a look, but can't promise it will be fast. > > In thory we can't forbid deleting cgroups with associated bpf maps, but I don't > thinks it's a good idea. > Agreed. It is not a good idea. > > In other words shouldn't those remote charges be redirected when the > > target memcg is offline? > > Reparenting is the best answer I have. > At the cost of increasing the complexity of deployment, that may not be a good idea neither. -- Regards Yafang