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 73DAFCCA47B for ; Tue, 5 Jul 2022 20:49:56 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E87B46B0071; Tue, 5 Jul 2022 16:49:55 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E36FA6B0073; Tue, 5 Jul 2022 16:49:55 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D26518E0001; Tue, 5 Jul 2022 16:49:55 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id C36856B0071 for ; Tue, 5 Jul 2022 16:49:55 -0400 (EDT) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 79E0020570 for ; Tue, 5 Jul 2022 20:49:55 +0000 (UTC) X-FDA: 79654237950.06.5CABE68 Received: from out2.migadu.com (out2.migadu.com [188.165.223.204]) by imf02.hostedemail.com (Postfix) with ESMTP id E75D880009 for ; Tue, 5 Jul 2022 20:49:54 +0000 (UTC) Date: Tue, 5 Jul 2022 13:49:46 -0700 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= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Roman Gushchin To: Michal Hocko Cc: Shakeel Butt , Andrew Morton , Yafang Shao , 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=1657054195; 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=ZL1inWFLGV9UgwEooxuzbRN3JK3YNLKuwki2WG5dOXg=; b=SNiWTZV0KKgItFJcB7W56nnvKEHNKKb2vrrSHODOHn22Ku7vL0uJPrdoSmMBknYGI/06uX ujplUmoK6GZALJ3BZE38SBD7lZYitEWHF17mygC11nfDrvsc2F4iPc8Ig4qgKN8E8rKfXZ Qq4cayf/KBxxzhTiHF9mz6K8e3etwak= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=kCVke3t5; 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=1657054195; a=rsa-sha256; cv=none; b=hrf5uhwK9oZTY0cPEkqLt4Spf9t/FG0RMgUb3ZaPzM/XozKb+AYfnbz/ovGu78/BYw5kU9 scMzjcaYwqVLiTEeXPEXWTyR5tqvT3tr+NbB+d6RniSEwHflTUyK3+gNG217coJm8YtZMv 6b2hBc7XqbxoRSHKXXTCxiAgmh445hI= X-Rspamd-Server: rspam11 X-Rspam-User: X-Stat-Signature: 6m19qdgq7ghixwhbk615xmoq9xjw3zr7 X-Rspamd-Queue-Id: E75D880009 Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=kCVke3t5; 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: 1657054194-538558 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 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!