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=-7.0 required=3.0 tests=INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED 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 0D1F8C2BA19 for ; Tue, 14 Apr 2020 15:23:03 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id CAE9A2063A for ; Tue, 14 Apr 2020 15:23:02 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CAE9A2063A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 5CF918E0021; Tue, 14 Apr 2020 11:23:02 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 57F8E8E0007; Tue, 14 Apr 2020 11:23:02 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4945F8E0021; Tue, 14 Apr 2020 11:23:02 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 2E02B8E0007 for ; Tue, 14 Apr 2020 11:23:02 -0400 (EDT) Received: from smtpin07.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id D6662181AEF1F for ; Tue, 14 Apr 2020 15:23:01 +0000 (UTC) X-FDA: 76706828562.07.dust41_71b7932e83026 X-HE-Tag: dust41_71b7932e83026 X-Filterd-Recvd-Size: 5356 Received: from mail-wr1-f66.google.com (mail-wr1-f66.google.com [209.85.221.66]) by imf18.hostedemail.com (Postfix) with ESMTP for ; Tue, 14 Apr 2020 15:23:01 +0000 (UTC) Received: by mail-wr1-f66.google.com with SMTP id d17so7879909wrg.11 for ; Tue, 14 Apr 2020 08:23:01 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=aRl47KEui4dF8Bv2ab+oDq4Uv6Xo4dlPMMcD3meGqy0=; b=EUi6kAwRSEx25il4EUzGnM7K+4Zz4CoIw05CXrib78AzzOdkW3Pqo9oZaPxGONBFnS Mvvg0ZGQXUjE+pYw7uLeLvvJSO5aiNup/1GQm72mZdOzx7ridWMAnWD9a6O0rK8oM+ug MeeUGVCyx/mI71gjr7tpRARDS65CKghSKZCs+xumfYGteH1hKoN2YiPY2rn8AyS4zOui pNdYAMU5t4+VBBheBNVRHKSaE6RTh1/p/VPMX0/lGwlWjsWKV0FeY4GZ50H6tUQx5uTh e8TtPnnEbbx/DpkXj6OpAEk5C/o1dvCGy8ptxFnRuKBpn5zxR2ympdg3ZTLQVbd7eAwl 58HA== X-Gm-Message-State: AGi0PuaESTv7WBA+eNJKCHKOruid3pWpeAFY4KJN0jeU9TmJji50QJej oQpg0RQq1ePipPIqCLhrVn0= X-Google-Smtp-Source: APiQypIjAiphk9o29ryxVXZ1u8bQd9lJKb2OizBfNvqVBtOGgnIg0hqhpoCHGCZfLop8rjshbX0HGg== X-Received: by 2002:a5d:4286:: with SMTP id k6mr12142875wrq.222.1586877780296; Tue, 14 Apr 2020 08:23:00 -0700 (PDT) Received: from localhost (ip-37-188-180-223.eurotel.cz. [37.188.180.223]) by smtp.gmail.com with ESMTPSA id v21sm18563208wmj.8.2020.04.14.08.22.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Apr 2020 08:22:58 -0700 (PDT) Date: Tue, 14 Apr 2020 17:22:57 +0200 From: Michal Hocko To: Yafang Shao Cc: shakeelb@google.com, chris@chrisdown.name, hannes@cmpxchg.org, vdavydov.dev@gmail.com, akpm@linux-foundation.org, linux-mm@kvack.org, stable@vger.kernel.org Subject: Re: [PATCH v2] mm, memcg: fix inconsistent oom event behavior Message-ID: <20200414152257.GP4629@dhcp22.suse.cz> References: <20200414015952.3590-1-laoar.shao@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200414015952.3590-1-laoar.shao@gmail.com> 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 13-04-20 21:59:52, 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. > > Here's an example on why this behavior is inconsistent in cgroup1. > root memcg > / > memcg foo > / > memcg bar > > Suppose there's an oom_kill in memcg bar, then the oon_kill will be > > root memcg : memory.oom_control(oom_kill) 0 > / > memcg foo : memory.oom_control(oom_kill) 1 > / > memcg bar : memory.oom_control(oom_kill) 1 > > 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. Then the user > has to know whether the memcg is root or not. > > If we can't fully support it in cgroup1, for example by adding > memory.events.local into cgroup1 as well, then let's don't touch > its original behavior. So let's recover the original behavior for cgroup1. Wthe localevents was mostly cgroup v2 feature. I do not think there was an intention to have side effects on the legacy hierarchy. I thought this would be the case but it is not apparently. Would it make more sense to have CGRP_ROOT_MEMORY_LOCAL_EVENTS for legacy hierarchy by default rather than special casing it somewhere quite deep in the code? > Fixes: 9852ae3fe529 ("mm, memcg: consider subtrees in memory.events") > Cc: Chris Down > Cc: Johannes Weiner > Cc: stable@vger.kernel.org > Reviewed-by: Shakeel Butt > 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 -- Michal Hocko SUSE Labs