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 4375CC43334 for ; Wed, 6 Jul 2022 02:41:27 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B890F8E0002; Tue, 5 Jul 2022 22:41:26 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B38E38E0001; Tue, 5 Jul 2022 22:41:26 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A27BF8E0002; Tue, 5 Jul 2022 22:41:26 -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 944C38E0001 for ; Tue, 5 Jul 2022 22:41:26 -0400 (EDT) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 5E64EB58 for ; Wed, 6 Jul 2022 02:41:26 +0000 (UTC) X-FDA: 79655123772.26.6F8E2E7 Received: from mail-vk1-f174.google.com (mail-vk1-f174.google.com [209.85.221.174]) by imf24.hostedemail.com (Postfix) with ESMTP id E08CA18000B for ; Wed, 6 Jul 2022 02:41:25 +0000 (UTC) Received: by mail-vk1-f174.google.com with SMTP id m141so1625567vke.6 for ; Tue, 05 Jul 2022 19:41:25 -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=MlZR8uPETmlGuwXZgUVOik+H9LRiX+UHdzorFOkInsI=; b=Z5PXWmnGlzUEIH57fT5kT06fxp4S2kHBR0FcR1vhjDY/b8jBSwpUxSitj+VNjxGiQM yrlv9mAvDoIQ0pSB38Vq/T4EqqasWVzb1Ra8npLC1uF/tyy5d+GOq0EsucwhZsUueAYE +DiDHRiqkl+CJS2YFipFg7uo1i63XZ2/3cWXYcfPoTV0vdpwWjS0aKAmN+iqzLrTO7NJ d0AhrXLjYsZ4Hwniqc8vJVsR/UBPsk+ogUMx/APjOWdzTp02dKS0C/5or4Y4C/la4XS6 PeuNYoYF/VTJu9W47CUmkEhjyn4XSIqxS4gGza3/RiAxYD8XvlmOwpLwKlzu65KgnF1B 6QmA== 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=MlZR8uPETmlGuwXZgUVOik+H9LRiX+UHdzorFOkInsI=; b=1hBD0eV7M+F+Z6LhPTAa6k4zHPzx4fvJ+ISFu72o3QSOP0DuHy0/0yaANq+yLdIwDB TsmRcpTgribPlrunViaMQY+P0ro2NSb1ZmVDxf/ims/13ceh473ZdgHuw/jpOYT8upiV Q0yooJKNKQv3lcZnbyVk6qR044836DgRpuu00HIAjBjAiheEjsis3VVw6/sQ5GqK9JVN K/XHnB6GQVJ7FBoNWFnRwEbKx8fUxYqZZej/8aufAQTtIgY2w9nVgDfVu12t67yL40tZ 8rIUD9ipfH3K6cEqFy0PRXJuc+0RlVYDqEeHpbdna2LZyiDHP+lYSuH0r8vGjF6Vq1Mi FA7A== X-Gm-Message-State: AJIora9MGQLvjyOEfxqMUKnusdporNTTm3M8qsYVwlvyk1jB3QM+Hu21 UPcI24aNQnMUSYb4bwZtn5IhJXdBIh965TTFlbo= X-Google-Smtp-Source: AGRyM1vFrYsD8dxIlyMDKCDvUqc32NKEJvwJUfUdGYbkZf9GNPkNqxN4lONGSboyog1ULbP2etk+CzOoa7ynMI88K/8= X-Received: by 2002:ac5:cb6f:0:b0:36c:424b:6d79 with SMTP id l15-20020ac5cb6f000000b0036c424b6d79mr21724327vkn.14.1657075285164; Tue, 05 Jul 2022 19:41: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:40: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=1657075286; a=rsa-sha256; cv=none; b=bOcp9cXTQnSLE7sSZxpsqYExszHZXzJOtQWq0C7UlGlRQ4k7TXIrVgz82pm0yIYFDglApk gfElLEByJirJfxgBn9MG5tVpetweyqrvR8hKGUc6cwIy231vWycb8Mc2y+rRyRKoCJcbE6 sM3VuCnAFzdEsDrzULmOA9VkZeZhxuM= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=Z5PXWmnG; spf=pass (imf24.hostedemail.com: domain of laoar.shao@gmail.com designates 209.85.221.174 as permitted sender) smtp.mailfrom=laoar.shao@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1657075286; 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=MlZR8uPETmlGuwXZgUVOik+H9LRiX+UHdzorFOkInsI=; b=EX7npLerUbQnAMhlQkU3h37RNwY3QTjpvbMcSLr21v4ZAf9QRgAPlTsbTcQ21fltwo+Mgm iBFyT+sNeRjPDdwOChORwKfZ0uglJyox1MQKe4Cf7RLCHKYB+h3VFBsGvn+3Yt2WA5HUuT PEGIStoGSS2ZEsJ/XUumOGvVWZp5maE= Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=Z5PXWmnG; spf=pass (imf24.hostedemail.com: domain of laoar.shao@gmail.com designates 209.85.221.174 as permitted sender) smtp.mailfrom=laoar.shao@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Rspam-User: X-Rspamd-Server: rspam03 X-Stat-Signature: sc5x6u67659cgrq7g9hes19sng4f44qa X-Rspamd-Queue-Id: E08CA18000B X-HE-Tag: 1657075285-335196 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:52 AM Roman Gushchin wrote: > > 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. > Regarding the pinned bpf programs, it can run without a user agent. That means the cgroup may not be dead, but just not populated. (But in our case, the cgroup will be deleted after the user agent exits.) -- Regards Yafang