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 121A5C47247 for ; Fri, 1 May 2020 02:04:58 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id BD2F32073E for ; Fri, 1 May 2020 02:04:57 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="hqWgrff+" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BD2F32073E 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 408C88E0005; Thu, 30 Apr 2020 22:04:57 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3B89C8E0001; Thu, 30 Apr 2020 22:04:57 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2CE238E0005; Thu, 30 Apr 2020 22:04:57 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0079.hostedemail.com [216.40.44.79]) by kanga.kvack.org (Postfix) with ESMTP id 131B28E0001 for ; Thu, 30 Apr 2020 22:04:57 -0400 (EDT) Received: from smtpin03.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id C166C180AD80F for ; Fri, 1 May 2020 02:04:56 +0000 (UTC) X-FDA: 76766506992.03.wax14_655a6fa4f4651 X-HE-Tag: wax14_655a6fa4f4651 X-Filterd-Recvd-Size: 8095 Received: from mail-lf1-f68.google.com (mail-lf1-f68.google.com [209.85.167.68]) by imf11.hostedemail.com (Postfix) with ESMTP for ; Fri, 1 May 2020 02:04:56 +0000 (UTC) Received: by mail-lf1-f68.google.com with SMTP id 188so2909747lfa.10 for ; Thu, 30 Apr 2020 19:04:56 -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=xvEtBQcAc7F3ek4wdEUS9jWPcHLM+s7YTeCebZ+jMU8=; b=hqWgrff+6hxpFj99vsFqB4lkEPncpj2Ttqv8BXb+fUeVxQ3gBbOG6bcAjKYYmB/h4N sQCd5ocRjBiVjLylBSp1G1t+bp2HKoUZEgf/Z1LshZN1+h4aLpjHbVU/NXBvDGmzYLh+ zI6x3m06VsXz8EB9QgN5JouGa6FNiXSR/v1BEho06X3XcKP0/NZaYOmDSLhXCjVD9Ex5 menkv9Xc7jFF7J1OCUiYcvXSp1F0fA8+qT12pM0tHbbH20I8saoL0+rtCdF09hqXFtX2 SuxK7k6cSwaRUgA/2OJc1t78RwXvebb5Gvlc6ddNvNR8Ut1EZj8KrnYX5xu8ysNJEMRd p6WQ== 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=xvEtBQcAc7F3ek4wdEUS9jWPcHLM+s7YTeCebZ+jMU8=; b=LUy4Mq8ELxFQNNN2knG30jGR1PZhpTYRwv3jEClJ9TrY9cQENvUN47YV2MM7b5m97e rOh12cLnGKQdwjplCXuYLtp85oVph2i38C+pqswzhswELeNpCLF0mC94Toc+9fOJxqdH Hk9OZgmbeQsm0Sr5OIOZP/VfC4L6rR2gP+Ia3sZ/rtb0WILeooIDmGn2vifpoEFNsBXI nEdvoL/EInZ202XGWm3DjmqdNeViTCYyTzxvkqrV8mHCU5JGKkaIjbxpN52k5mhodtUN uZTKe399vGF0AeB9bJdMRL+o0NQmkE+fSdxwMQv+kmPF45wOunuE4aBcNdAYPQaKsyD5 3NMw== X-Gm-Message-State: AGi0PuZPsc5Tcpb+R9Vzy9c8ETzPZ4Cs2ZVMslQVVy83b+cVHNAa/O90 rPBG1aTABFx8s2dl0Rbxq9TzX6TL77YT9u7kQh+Vsg== X-Google-Smtp-Source: APiQypLK/VwayTTDJRp1VfQ6VPluP/T1Uaz/SpEaZLtNJKDUCtWjo1kyo6nBqt5Ia7fxH/1/U7UXDYGxTCDIA4rYXu8= X-Received: by 2002:a05:6512:318a:: with SMTP id i10mr1027885lfe.96.1588298694609; Thu, 30 Apr 2020 19:04:54 -0700 (PDT) MIME-Version: 1.0 References: <20200430182712.237526-1-shakeelb@google.com> In-Reply-To: From: Shakeel Butt Date: Thu, 30 Apr 2020 19:04:43 -0700 Message-ID: Subject: Re: [PATCH] memcg: oom: ignore oom warnings from memory.max To: Yafang Shao Cc: Johannes Weiner , Roman Gushchin , Michal Hocko , Greg Thelen , Andrew Morton , Linux MM , Cgroups , LKML 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 Thu, Apr 30, 2020 at 6:39 PM Yafang Shao wrote: > > On Fri, May 1, 2020 at 2:27 AM Shakeel Butt wrote: > > > > Lowering memory.max can trigger an oom-kill if the reclaim does not > > succeed. However if oom-killer does not find a process for killing, it > > dumps a lot of warnings. > > > > I have been confused by this behavior for several months and I think > it will confuse more memcg users. > We should keep the memcg oom behavior consistent with system oom - no > oom kill if no process. > > What about bellow change ? > Seems fine to me. If others are ok with this, please do send a signed-off patch. > diff --git a/mm/memcontrol.c b/mm/memcontrol.c > index e28098e13f1c..25fbc37a747f 100644 > --- a/mm/memcontrol.c > +++ b/mm/memcontrol.c > @@ -6086,6 +6086,9 @@ static ssize_t memory_max_write(struct > kernfs_open_file *of, > continue; > } > > + if (!cgroup_is_populated(memcg->css.cgroup)) > + break; > + > memcg_memory_event(memcg, MEMCG_OOM); > if (!mem_cgroup_out_of_memory(memcg, GFP_KERNEL, 0)) > break; > > > Deleting a memcg does not reclaim memory from it and the memory can > > linger till there is a memory pressure. One normal way to proactively > > reclaim such memory is to set memory.max to 0 just before deleting the > > memcg. However if some of the memcg's memory is pinned by others, this > > operation can trigger an oom-kill without any process and thus can log a > > lot un-needed warnings. So, ignore all such warnings from memory.max. > > > > Signed-off-by: Shakeel Butt > > --- > > include/linux/oom.h | 3 +++ > > mm/memcontrol.c | 9 +++++---- > > mm/oom_kill.c | 2 +- > > 3 files changed, 9 insertions(+), 5 deletions(-) > > > > diff --git a/include/linux/oom.h b/include/linux/oom.h > > index c696c265f019..6345dc55df64 100644 > > --- a/include/linux/oom.h > > +++ b/include/linux/oom.h > > @@ -52,6 +52,9 @@ struct oom_control { > > > > /* Used to print the constraint info. */ > > enum oom_constraint constraint; > > + > > + /* Do not warn even if there is no process to be killed. */ > > + bool no_warn; > > }; > > > > extern struct mutex oom_lock; > > diff --git a/mm/memcontrol.c b/mm/memcontrol.c > > index 317dbbaac603..a1f00d9b9bb0 100644 > > --- a/mm/memcontrol.c > > +++ b/mm/memcontrol.c > > @@ -1571,7 +1571,7 @@ unsigned long mem_cgroup_size(struct mem_cgroup *memcg) > > } > > > > static bool mem_cgroup_out_of_memory(struct mem_cgroup *memcg, gfp_t gfp_mask, > > - int order) > > + int order, bool no_warn) > > { > > struct oom_control oc = { > > .zonelist = NULL, > > @@ -1579,6 +1579,7 @@ static bool mem_cgroup_out_of_memory(struct mem_cgroup *memcg, gfp_t gfp_mask, > > .memcg = memcg, > > .gfp_mask = gfp_mask, > > .order = order, > > + .no_warn = no_warn, > > }; > > bool ret; > > > > @@ -1821,7 +1822,7 @@ static enum oom_status mem_cgroup_oom(struct mem_cgroup *memcg, gfp_t mask, int > > mem_cgroup_oom_notify(memcg); > > > > mem_cgroup_unmark_under_oom(memcg); > > - if (mem_cgroup_out_of_memory(memcg, mask, order)) > > + if (mem_cgroup_out_of_memory(memcg, mask, order, false)) > > ret = OOM_SUCCESS; > > else > > ret = OOM_FAILED; > > @@ -1880,7 +1881,7 @@ bool mem_cgroup_oom_synchronize(bool handle) > > mem_cgroup_unmark_under_oom(memcg); > > finish_wait(&memcg_oom_waitq, &owait.wait); > > mem_cgroup_out_of_memory(memcg, current->memcg_oom_gfp_mask, > > - current->memcg_oom_order); > > + current->memcg_oom_order, false); > > } else { > > schedule(); > > mem_cgroup_unmark_under_oom(memcg); > > @@ -6106,7 +6107,7 @@ static ssize_t memory_max_write(struct kernfs_open_file *of, > > } > > > > memcg_memory_event(memcg, MEMCG_OOM); > > - if (!mem_cgroup_out_of_memory(memcg, GFP_KERNEL, 0)) > > + if (!mem_cgroup_out_of_memory(memcg, GFP_KERNEL, 0, true)) > > break; > > } > > > > diff --git a/mm/oom_kill.c b/mm/oom_kill.c > > index 463b3d74a64a..5ace39f6fe1e 100644 > > --- a/mm/oom_kill.c > > +++ b/mm/oom_kill.c > > @@ -1098,7 +1098,7 @@ bool out_of_memory(struct oom_control *oc) > > > > select_bad_process(oc); > > /* Found nothing?!?! */ > > - if (!oc->chosen) { > > + if (!oc->chosen && !oc->no_warn) { > > dump_header(oc, NULL); > > pr_warn("Out of memory and no killable processes...\n"); > > /* > > -- > > 2.26.2.526.g744177e7f7-goog > > > > > > > -- > Thanks > Yafang