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 7ED38C43334 for ; Tue, 5 Jul 2022 20:52:12 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 168E16B0071; Tue, 5 Jul 2022 16:52:12 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 118688E0001; Tue, 5 Jul 2022 16:52:12 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 006F86B0074; Tue, 5 Jul 2022 16:52:11 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id E53076B0071 for ; Tue, 5 Jul 2022 16:52:11 -0400 (EDT) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay13.hostedemail.com (Postfix) with ESMTP id B01D061091 for ; Tue, 5 Jul 2022 20:52:11 +0000 (UTC) X-FDA: 79654243662.29.C21F74C Received: from out1.migadu.com (out1.migadu.com [91.121.223.63]) by imf23.hostedemail.com (Postfix) with ESMTP id EE84314000F for ; Tue, 5 Jul 2022 20:52:10 +0000 (UTC) Date: Tue, 5 Jul 2022 13:51:54 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1657054328; 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=2XQLP0LMyl8MnEcyS+UNpbGDzxmEbywyn31NiQU5Lx0=; b=JSr8O0thgf/8K240RoHRwhrkNoV024GJhwM/fP5acSkn/ZlhiUCb5TdczmMwSDNlrpGuXu G7GwKy3IX13X5RNdKmf5nh9Zu48Mq1X/TRdewiKS5uZfzwpdcZ1Oxrp+bp6rhrbcaN46Pj xjy2u5+H4Mk43OwREgYrJ00f2vBjN8E= 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=1657054331; 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=2XQLP0LMyl8MnEcyS+UNpbGDzxmEbywyn31NiQU5Lx0=; b=ml4v2/5Q5Gjc8sAaka/FTbmqxsmn2tLcMUKYm8l9y1tr2nWee6rIfaAMhbYcQ/4fDoERzm dwUk+VMaAP+STZ9OBBQKq/qpSFe3aULtl4r/8hmGJVLA+TARY5GIaRuXbRvS3kySmUsjxx LDdcQ4neBldU/nS2l5TgZdkB4JVvo8w= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1657054331; a=rsa-sha256; cv=none; b=NI1fo9+07TXDC3swsmLWyvgLex3J7J+BdSmnC/0l2a8eYBgmkDbxzaB5WMG5Xa+oZihddW dcJt/hk9CUPxKriVp7tHh4S6+gw/8W0oluy6HK7hdXN5I+OdsXzIzOKbiTMVXBaRSf5oP0 GyXfSaxdIJ4Wu0oOgwkFIBlvsvDc0Eg= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=JSr8O0th; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf23.hostedemail.com: domain of roman.gushchin@linux.dev designates 91.121.223.63 as permitted sender) smtp.mailfrom=roman.gushchin@linux.dev X-Rspam-User: Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=JSr8O0th; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf23.hostedemail.com: domain of roman.gushchin@linux.dev designates 91.121.223.63 as permitted sender) smtp.mailfrom=roman.gushchin@linux.dev X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: EE84314000F X-Stat-Signature: zwe9cekkztje8s6na8ghc9cfjbs9cqkq X-HE-Tag: 1657054330-198582 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:30:25PM +0200, Michal Hocko wrote: > On Mon 04-07-22 17:07:32, 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? How can it ever go away then? Also is > > this something that we actually want to encourage? > > One more question. Mostly out of curiosity. How is userspace actually > acting on those events? Are watchers still active on those dead memcgs? Idk, the whole problem was reported by Yafang, so he probably has a better answer. But in general events are recursive and the cgroup doesn't have to be dying, it can be simple abandoned. Thanks!