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=-6.6 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,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 B751AC2BA2B for ; Tue, 14 Apr 2020 00:58:07 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 355FF20732 for ; Tue, 14 Apr 2020 00:58:07 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="GvkbuAge" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 355FF20732 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id C4F918E0003; Mon, 13 Apr 2020 20:58:06 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id BFFF98E0001; Mon, 13 Apr 2020 20:58:06 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AEF528E0003; Mon, 13 Apr 2020 20:58:06 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0171.hostedemail.com [216.40.44.171]) by kanga.kvack.org (Postfix) with ESMTP id 950808E0001 for ; Mon, 13 Apr 2020 20:58:06 -0400 (EDT) Received: from smtpin14.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 57C5E8245571 for ; Tue, 14 Apr 2020 00:58:06 +0000 (UTC) X-FDA: 76704648972.14.vase32_80f3647ad9e37 X-HE-Tag: vase32_80f3647ad9e37 X-Filterd-Recvd-Size: 6710 Received: from mail-il1-f196.google.com (mail-il1-f196.google.com [209.85.166.196]) by imf27.hostedemail.com (Postfix) with ESMTP for ; Tue, 14 Apr 2020 00:58:06 +0000 (UTC) Received: by mail-il1-f196.google.com with SMTP id u5so3390138ilb.5 for ; Mon, 13 Apr 2020 17:58:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=ZqkrksRk7re0hRKtlrZsF+grvKJamkQFapywAZ5fzpc=; b=GvkbuAgeOz28xqq0UJPQu4JetE/PfJfqENsy5eWn12Ek5xdUUuy3+/T6pr4Or2uAYh dxL8dQoqLBv6c96xJnxsSFIIYDk4UeeOhuP849acvuxCHicA68jjh50uOx4AgNvlMcQ3 OnXimnNXBsyyIQ3Q9p7w8jYtsMRhl0IPyhyCLyybYGxxG3ZNZvZqNZf6Iw1QBLCCauLZ 7JwjcQX6/R9uEdsHGvbWkyM0+Qmx6qPZQ0g21/Lu0uUTDZSnY5XkZSmdpWzgG+jsa2BS UVNruvli0rQ4mQSNK/yvDlQk0CRJcSsWdF60nSWcouOBZ5ozh/joo8dLzmQCgFrGiFt7 nQrA== 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=ZqkrksRk7re0hRKtlrZsF+grvKJamkQFapywAZ5fzpc=; b=QDp5LO72TA9TcYSIzv2dB8TW11v5coXQI2csnoxisrr7vlvan55+Gl7CRn4MKNtnQ4 6k3lJYKIUYOTUQPmwHmksLOgxFAKCR22b0bzaphs+wnsKKaes2qQbJomxCYm6R2ZNKaO 7KucEePDgBbWf4i2m2lFS6NHFC9rDd4WBFgn+cEUOQYUzpVkdd8iWxK7agvlTS0c9JkC fVjKLtJKxYVTY7hugr316T67AmCIJG/4m2ar5YG/h0sQvzp1piwMzP2exhDQE6+ZRm3G CFHdD3KHfC9pEczSIfwMbDnCoL6yZG/rWKlqYiCxWf8qqq2i++tjghELNvt0/k1AewuD HVVA== X-Gm-Message-State: AGi0PuZQDlKt9yXPWDch0T+54s2HQBsnTUBTyrWtrHfNnUuqY0Fxe6XJ omNW0S7aqxSEMQFQwEEIT8k/nxBa4/jk1gC2V0k= X-Google-Smtp-Source: APiQypIdnHdErTdJX57nLG+N5KtUzADwXiXWt/43gqS68PA7gakqAq3jo/XEBtImfNc8Eg1jxHR7jp1DfyaGur1ZUwQ= X-Received: by 2002:a92:5c57:: with SMTP id q84mr6475898ilb.203.1586825885499; Mon, 13 Apr 2020 17:58:05 -0700 (PDT) MIME-Version: 1.0 References: <20200412140427.6732-1-laoar.shao@gmail.com> In-Reply-To: From: Yafang Shao Date: Tue, 14 Apr 2020 08:57:29 +0800 Message-ID: Subject: Re: [PATCH] mm, memcg: fix inconsistent oom event behavior To: Shakeel Butt 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 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. > > > > 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