From mboxrd@z Thu Jan 1 00:00:00 1970 From: Roman Gushchin Subject: Re: [PATCH] mm: memcontrol: do not miss MEMCG_MAX events for enforced allocations Date: Tue, 5 Jul 2022 13:49:46 -0700 Message-ID: References: <20220702033521.64630-1-roman.gushchin@linux.dev> Mime-Version: 1.0 Return-path: DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1657054193; 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=ZL1inWFLGV9UgwEooxuzbRN3JK3YNLKuwki2WG5dOXg=; b=kCVke3t5FDKaxkIrHS1H/14RQTV84TwUH51/tbwRWowp4YhthXpkcyZ3YxaDl8vOo/RrLa azzizRzOZe9hDPtZ/UAxb/bpngZ0Fh8WxCI6hvlinXwwz45seWSxnVwKUmMevI7haVcE/4 wZOGWoqbDcM9a1X75+iOQnG0k6Wh8OM= Content-Disposition: inline In-Reply-To: List-ID: Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: Michal Hocko Cc: Shakeel Butt , Andrew Morton , Yafang Shao , Johannes Weiner , Muchun Song , Cgroups , Linux MM , bpf 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. > 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. > In other words shouldn't those remote charges be redirected when the > target memcg is offline? Reparenting is the best answer I have. Thanks!