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 X-Spam-Level: X-Spam-Status: No, score=-14.4 required=3.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 021BCC2BA2B for ; Tue, 14 Apr 2020 00:54:00 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id A752F20732 for ; Tue, 14 Apr 2020 00:53:59 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="BX7abmlW" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A752F20732 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 3C6DE8E0003; Mon, 13 Apr 2020 20:53:59 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3A68A8E0001; Mon, 13 Apr 2020 20:53:59 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2B3DE8E0003; Mon, 13 Apr 2020 20:53:59 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0181.hostedemail.com [216.40.44.181]) by kanga.kvack.org (Postfix) with ESMTP id 1515C8E0001 for ; Mon, 13 Apr 2020 20:53:59 -0400 (EDT) Received: from smtpin02.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id C45F4499616 for ; Tue, 14 Apr 2020 00:53:58 +0000 (UTC) X-FDA: 76704638556.02.oil49_5ce6efa4dd517 X-HE-Tag: oil49_5ce6efa4dd517 X-Filterd-Recvd-Size: 6326 Received: from mail-lj1-f193.google.com (mail-lj1-f193.google.com [209.85.208.193]) by imf07.hostedemail.com (Postfix) with ESMTP for ; Tue, 14 Apr 2020 00:53:58 +0000 (UTC) Received: by mail-lj1-f193.google.com with SMTP id q22so10715312ljg.0 for ; Mon, 13 Apr 2020 17:53:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=h8xNayC7YcuUcaurWUeJhCdSpydLb0VGHQawugkx5xU=; b=BX7abmlWFd3qhTcmL/fw5xelrl/8ISjbDRDIyxmcGV7ndT9PS8tIwl87ZDfEq62XEg DjYfzR5v7VbWD2x4nxw+wykU8paIU4Fe9GA8MY7n90C8oyIjZxbkkuNKjIbEinSseLXs dj4wgOBjMdFq7RK6O4f18JwIsdsXT+BgpuK/u8uMVdL/0LFhh8381OvGBAQtYNp54bF4 yNdCg1aOTtsmRK4QEOIh5wMy+wfLNrIZQdVsp1/erHXHAVAt3DJ78AES4V/PTdz0+87A zZvm1R7mT1dXFpUtjCFKQ3nxndJ76+2No6JegzVfii2bXsMB2ijhFJfxSnhKsRzYUccq cJnQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=h8xNayC7YcuUcaurWUeJhCdSpydLb0VGHQawugkx5xU=; b=M0UdDdACNspjtoTZuiT71vWtbi84qkbONLFe45x7Nq8Xr7bSq8j0JIF5t36AaD7Pro vz9IiSOS6cbEIIfFUO0HvjV6wb0xqJv49hZqkvuHmywVlh6aF15XMXhn3W4yeAIZaa5y YFN4Su9dfxHWPOf/fFWi89ro7jZ4tK7ImSlxxRsg8HtTQWapVzETFpQdbRJ5pny2haj3 HlsO5GSGdyaAPbqLwGSVxvLvqp1OgQN/fkMrREzStQfdQovr+4NyuJ0jTtktAkG7f6qV zxjxJYxHDVT9UWiwUmSQTNL6QjBgZ8P6w+fF6nThOO4jNWlFY7HXLylwUyYoGRScE0d5 lZyA== X-Gm-Message-State: AGi0PubIqWDtjqv2GfbobXLYXMneYJlPjgVlzf1i1VOwEO4Tuclw4j9q SuFd7CTX8zCM534/SLez7A30jFqwLV+Sx9HUlELQcw== X-Google-Smtp-Source: APiQypLHkgobWqPrkThizFCIWPFgRkjLlwlQebgNYVDJX0w4/t3UC77n+Q151fiL7bn5D5MxJhjRRJ++91meeqdmr9E= X-Received: by 2002:a2e:b6cf:: with SMTP id m15mr2422420ljo.168.1586825636460; Mon, 13 Apr 2020 17:53:56 -0700 (PDT) MIME-Version: 1.0 References: <20200412140427.6732-1-laoar.shao@gmail.com> In-Reply-To: From: Shakeel Butt Date: Mon, 13 Apr 2020 17:53:45 -0700 Message-ID: Subject: Re: [PATCH] mm, memcg: fix inconsistent oom event behavior To: Yafang Shao Cc: Chris Down , Johannes Weiner , Michal Hocko , Vladimir Davydov , Andrew Morton , Linux MM , stable@vger.kernel.org Content-Type: text/plain; charset="UTF-8" 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, Apr 13, 2020 at 5:36 PM Yafang Shao wrote: > > On Tue, Apr 14, 2020 at 1:06 AM Shakeel Butt wrote: > > > > On Sun, Apr 12, 2020 at 7:04 AM Yafang Shao wrote: > > > > > > A recent commit 9852ae3fe529 ("mm, memcg: consider subtrees in > > > memory.events") changes the behavior of memcg events, which will > > > consider subtrees in memory.events. But oom_kill event is a special one > > > as it is used in both cgroup1 and cgroup2. In cgroup1, it is displayed > > > in memory.oom_control. The file memory.oom_control is in both root memcg > > > and non root memcg, that is different with memory.event as it only in > > > non-root memcg. That commit is okay for cgroup2, but it is not okay for > > > cgroup1 as it will cause inconsistent behavior between root memcg and > > > non-root memcg. > > > > I still couldn't understand the cgroup v1's root vs non_root behavior > > change. The behavior change I see is the hierarchical one i.e. > > MEMCG_OOM_KILL event in the descendant will cause the notification and > > count increment in the ancestors even in the cgroup v1. > > For the non-root memcg, its memory.oom_control(oom_kill) includes its > descendants' oom_kill, but for root memcg, it doesn't include its > descendants' oom_kill. That means, memory.oom_control(oom_kill) has > different meanings in different memcgs. That is inconsistent. > > [snip] > > I suppose we > > don't want that behavior change in v1. > > > > That is another topic. I think this feature is welcomed to cgroup1, if > we can fully support it, for example by adding memory.events.local > into cgroup1 as well, but as far as I know the cgroup1 is frozen. > Please note that after your patch the non-root memcg's memory.oom_control(oom_kill) will not include the descendant's oom_kill anymore. The non-root and root memcg's memory.oom_control(oom_kill) will not be hierarchical anymore but consistent. I think that was the intention of the patch, right? > > > Let's recover the original behavior for cgroup1. > > > > > > Fixes: 9852ae3fe529 ("mm, memcg: consider subtrees in memory.events") > > > Cc: Chris Down > > > Cc: Johannes Weiner > > > Cc: Shakeel Butt > > > Cc: stable@vger.kernel.org > > > Signed-off-by: Yafang Shao > > > --- > > > include/linux/memcontrol.h | 3 ++- > > > 1 file changed, 2 insertions(+), 1 deletion(-) > > > > > > diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h > > > index 8c340e6b347f..a0ae080a67d1 100644 > > > --- a/include/linux/memcontrol.h > > > +++ b/include/linux/memcontrol.h > > > @@ -798,7 +798,8 @@ static inline void memcg_memory_event(struct mem_cgroup *memcg, > > > atomic_long_inc(&memcg->memory_events[event]); > > > cgroup_file_notify(&memcg->events_file); > > > > > > - if (cgrp_dfl_root.flags & CGRP_ROOT_MEMORY_LOCAL_EVENTS) > > > + if (cgrp_dfl_root.flags & CGRP_ROOT_MEMORY_LOCAL_EVENTS || > > > + !cgroup_subsys_on_dfl(memory_cgrp_subsys)) > > > break; > > > } while ((memcg = parent_mem_cgroup(memcg)) && > > > !mem_cgroup_is_root(memcg)); > > > -- > > > 2.18.2 > > > > > > Thanks > Yafang