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 2DCFFC2BA2B for ; Tue, 14 Apr 2020 01:08:01 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id CFCC2206B6 for ; Tue, 14 Apr 2020 01:08:00 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="ijQBsp2+" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CFCC2206B6 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 458B98E0003; Mon, 13 Apr 2020 21:08:00 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 409038E0001; Mon, 13 Apr 2020 21:08:00 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 31EF58E0003; Mon, 13 Apr 2020 21:08:00 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0073.hostedemail.com [216.40.44.73]) by kanga.kvack.org (Postfix) with ESMTP id 17D668E0001 for ; Mon, 13 Apr 2020 21:08:00 -0400 (EDT) Received: from smtpin21.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id C76CF52BA for ; Tue, 14 Apr 2020 01:07:59 +0000 (UTC) X-FDA: 76704673878.21.floor85_45c4554d68160 X-HE-Tag: floor85_45c4554d68160 X-Filterd-Recvd-Size: 7094 Received: from mail-lj1-f195.google.com (mail-lj1-f195.google.com [209.85.208.195]) by imf21.hostedemail.com (Postfix) with ESMTP for ; Tue, 14 Apr 2020 01:07:59 +0000 (UTC) Received: by mail-lj1-f195.google.com with SMTP id n17so10693509lji.8 for ; Mon, 13 Apr 2020 18:07:59 -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=pjKjWwmtlCHlQBhC2Wm4xBBadnDi4o65zOBIN4PLMlI=; b=ijQBsp2+A2t90IUsKbF/GaLT+GPF7+lql0FGFbEUrJ9SWZYDx/SsdOg0TknLwYsG++ md25Z6qZ5FQhnITWu3VWSOYbzCZtz4WS6DDCoY/hCZqCUFTw7FS47iyp910Q79XAN2AK TArmllJSsQDty1euXIT+Km8uCQehaWHzZMhaLh4yG972F/QLPWfkOZHfXaQ9OqDhz1DO iTt5CNwY5/7MFFmUXN4srPuJs8TX8JCz8TCQDc1jWTeZ4AYTabmge4n1PXmd2licupHx G0gm1+3t5+t4PCCJNOrXr3xLpcEuBdMLcXHTNnnZc+RBUtAwEsHWHWu4YjUwFjivA9/l 2/rg== 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=pjKjWwmtlCHlQBhC2Wm4xBBadnDi4o65zOBIN4PLMlI=; b=lr1nilUXzuuwXX0/NL0obzy5AyHdNSkbpK8w/CLa/+tKhCYwJt73dff8DgX7BROM6f tOF/bkNtkoC/MV84luN4JdYU80PDrgzBMZrLVlxHZ47jOPgWIwDNQHamEVsIdk5YYxr6 CKmxahp9Q4UPw55qAHj7T3cQ6TduB8bccnxgWy68Dnb0f3GLPbTwcUldDW71dD/KLawZ 7m27K30VKPmj0rXKvaXFg3GvbSGEh8YSQJYoLBZOsJqt17Aqjr5Sw7DNHU0MOsaIq5tZ J2cH3YbZeLCDavKPkU/GBAamOsigRWfDy6PC4rk7osLfEBlJTnzSxXaIg/hLZLp45b0/ ymXQ== X-Gm-Message-State: AGi0PubbRGmAfny5vwcPbIhDQBvxuTPP2OPmdGBi2TEmYPCSXKLatx13 RvziXco/YOvueHc4tbijDqTkLzy6XC7nr7CEiJ5OoA== X-Google-Smtp-Source: APiQypLjbWUm/qK6itzRjVlSBbeT6SHfeSxUeQT28VOQXCHBkPSPfWn1D1k+/ku3wX3dn+ykLz2TxY0WXsaw4RouFTk= X-Received: by 2002:a2e:9a4a:: with SMTP id k10mr2168225ljj.115.1586826477624; Mon, 13 Apr 2020 18:07:57 -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 18:07:46 -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:58 PM Yafang Shao wrote: > > On Tue, Apr 14, 2020 at 8:53 AM Shakeel Butt wrote: > > > > 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? > > > > Right. If we can't fully support it in cgroup1, then let's don't touch > its original behavior. > Agreed. > > > > > 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 Reviewed-by: Shakeel Butt > > > > > --- > > > > > 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