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 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 79E44C3A5A9 for ; Mon, 4 May 2020 07:54:04 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 398B7206D7 for ; Mon, 4 May 2020 07:54:04 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 398B7206D7 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 C2AF78E0007; Mon, 4 May 2020 03:54:03 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id BDBB38E0001; Mon, 4 May 2020 03:54:03 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B1FF48E0007; Mon, 4 May 2020 03:54:03 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0253.hostedemail.com [216.40.44.253]) by kanga.kvack.org (Postfix) with ESMTP id 979DF8E0001 for ; Mon, 4 May 2020 03:54:03 -0400 (EDT) Received: from smtpin29.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 61F913D12 for ; Mon, 4 May 2020 07:54:03 +0000 (UTC) X-FDA: 76778273166.29.alley04_7ab23b29fca5b X-HE-Tag: alley04_7ab23b29fca5b X-Filterd-Recvd-Size: 4985 Received: from mail-wr1-f66.google.com (mail-wr1-f66.google.com [209.85.221.66]) by imf01.hostedemail.com (Postfix) with ESMTP for ; Mon, 4 May 2020 07:54:02 +0000 (UTC) Received: by mail-wr1-f66.google.com with SMTP id l18so8966421wrn.6 for ; Mon, 04 May 2020 00:54:02 -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=xOSMbAQ2YGi5hOOpYSoZ9geJQcg2F20L+RYSniZx0j8=; b=nNIhsSq+T9ZFw4FhtRGmFA/lJ6ZH107w7JnQ+NCkqUnz2ejTKbp+8J/EjLCT2zod/s ls58ga2fjVxRk8qZABuuBcR99zH+HU/yq3GLilH0/INFy7lbtVrpqIii8nz+nJrC1Dod 0K+EyvMgdj8MFG7MW87NqeRsjWl3iRbPmHkcbFMg07HXr00F+CzyXmaPKBRbmllfIDmE JqWG4kTSMT46mBYWerdNvctfyU65lr47pYX1qdnY/drtCmpOdJ3rXZMQZBGH0Y8zvsb6 Rtub4gG36wohdsoN75EisWUrg9paDT/8knDVygiAlRcaczFy9FF8ynLA1kIF7df+/VPx 7g3Q== X-Gm-Message-State: AGi0PuaKKJsgUMXYBnnntNjHjfOefizklSzUa4gtaG3B2c5qKp97Nkpg +Fgy29hh0wAHc6Gz1J9fsJA= X-Google-Smtp-Source: APiQypLrT+6/wB73RgNWYtVCEfQMz669SQGhBRuYNipdAVd4GyLBES45e8jzePzC6f3dLeFe0LVrJQ== X-Received: by 2002:a5d:6a8b:: with SMTP id s11mr17362607wru.258.1588578841955; Mon, 04 May 2020 00:54:01 -0700 (PDT) Received: from localhost (ip-37-188-183-9.eurotel.cz. [37.188.183.9]) by smtp.gmail.com with ESMTPSA id v2sm4309657wrn.21.2020.05.04.00.54.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 May 2020 00:54:01 -0700 (PDT) Date: Mon, 4 May 2020 09:54:00 +0200 From: Michal Hocko To: Yafang Shao Cc: akpm@linux-foundation.org, linux-mm@kvack.org, Chris Down , Johannes Weiner Subject: Re: [PATCH resend] mm, memcg: fix inconsistent oom event behavior Message-ID: <20200504075400.GG22838@dhcp22.suse.cz> References: <20200502141055.7378-1-laoar.shao@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200502141055.7378-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 Sat 02-05-20 10:10:55, 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. > > Fixes: 9852ae3fe529 ("mm, memcg: consider subtrees in memory.events") > Reviewed-by: Shakeel Butt > Cc: Chris Down > Cc: Michal Hocko > Cc: Johannes Weiner > Signed-off-by: Yafang Shao Acked-by: Michal Hocko and sorry to distract you to a cgroup generic solution without doing my homework and double checking it is possible. > --- > include/linux/memcontrol.h | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h > index d275c72c4f8e..977edd3b7bd8 100644 > --- a/include/linux/memcontrol.h > +++ b/include/linux/memcontrol.h > @@ -783,6 +783,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 (!cgroup_subsys_on_dfl(memory_cgrp_subsys)) > + break; > if (cgrp_dfl_root.flags & CGRP_ROOT_MEMORY_LOCAL_EVENTS) > break; > } while ((memcg = parent_mem_cgroup(memcg)) && > -- > 2.18.2 -- Michal Hocko SUSE Labs