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 834F4C433EF for ; Wed, 6 Jul 2022 03:28:12 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0ECDF8E0002; Tue, 5 Jul 2022 23:28:12 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 09CFC8E0001; Tue, 5 Jul 2022 23:28:12 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id ECD488E0002; Tue, 5 Jul 2022 23:28:11 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id DF6888E0001 for ; Tue, 5 Jul 2022 23:28:11 -0400 (EDT) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay12.hostedemail.com (Postfix) with ESMTP id B369312121F for ; Wed, 6 Jul 2022 03:28:11 +0000 (UTC) X-FDA: 79655241582.27.09FB782 Received: from out2.migadu.com (out2.migadu.com [188.165.223.204]) by imf02.hostedemail.com (Postfix) with ESMTP id E699C80005 for ; Wed, 6 Jul 2022 03:28:10 +0000 (UTC) Date: Tue, 5 Jul 2022 20:28:02 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1657078088; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=ACbHyPUw/fAolXYPmVBDr0eAu+Rvh8PM98nV0nyIlmY=; b=Ns/6xee6VM4j8jDw8Kgwz2R9BfyaO99Rx3J+xic+uyLwjj5939AcJGLoCHA8xRCmo3TCoI 5sDHDeSCB/tp1PBMhqNfn03XgdP9aJ37e4KstRqtyZHWrUj3DT0ctUGfehP0mhqQ2suAYT T095O6oIhspyV2YQV45ulUx8AS3iVaE= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Roman Gushchin To: Yafang Shao Cc: Michal Hocko , Shakeel Butt , Andrew Morton , Johannes Weiner , Muchun Song , Cgroups , Linux MM , bpf Subject: Re: [PATCH] mm: memcontrol: do not miss MEMCG_MAX events for enforced allocations Message-ID: References: <20220702033521.64630-1-roman.gushchin@linux.dev> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Migadu-Flow: FLOW_OUT X-Migadu-Auth-User: linux.dev ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1657078091; 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=ACbHyPUw/fAolXYPmVBDr0eAu+Rvh8PM98nV0nyIlmY=; b=gR66uD3nsFr8k9oRu1m7fpJHVU/qYuR63nFLGw7/7CFq5mhl3hardpZFmRmzeCBVcEgQXN pNV2FQDQs4+wlBauE6yANZOX4lI05j0VmkEYRY0qzkRZWCkbn+OD0wcZXlHgZjcIc63Um0 03QcSF6d6OBg3jAaYAsSMLVCxLe6vEs= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b="Ns/6xee6"; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf02.hostedemail.com: domain of roman.gushchin@linux.dev designates 188.165.223.204 as permitted sender) smtp.mailfrom=roman.gushchin@linux.dev ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1657078091; a=rsa-sha256; cv=none; b=ZhYmuNRHQ+BKduALGlnO5vcJQeK6b+qJpRd3Qi5vDxiXM/JqMJZkSJ8TYcF/TD6vd7HULL yHuqE+uGxyricHS9bs7dlxvC4IzbhVAK4GVmrTyckEehMAL5tIyp1yaD52jnwDMqFYs0JX ATnexszT1XQH5vaCkMVwpsTlEzCmJvY= X-Rspamd-Server: rspam11 X-Rspam-User: X-Stat-Signature: hy6azqrdmsrn66btxu84um5e9ue6nzdo X-Rspamd-Queue-Id: E699C80005 Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b="Ns/6xee6"; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf02.hostedemail.com: domain of roman.gushchin@linux.dev designates 188.165.223.204 as permitted sender) smtp.mailfrom=roman.gushchin@linux.dev X-HE-Tag: 1657078090-537013 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 06, 2022 at 10:46:48AM +0800, Yafang Shao wrote: > 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. What do you mean? Can you please elaborate on it? Thanks!