Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp2196724ybz; Thu, 30 Apr 2020 12:36:04 -0700 (PDT) X-Google-Smtp-Source: APiQypJNZz/kYh+r8lixMx3mYqIE7G3lRQktl8h+OCvE95jJw4ROo8KU0IcoSizX2ULXApoQIWu3 X-Received: by 2002:a17:906:48ce:: with SMTP id d14mr4724ejt.113.1588275364309; Thu, 30 Apr 2020 12:36:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588275364; cv=none; d=google.com; s=arc-20160816; b=ZUiP7SC9VDJX6PkUYnP7H1DrQQREEsv/+qLlRx50jUkMgKJQDb5G1YoGcMYNG5qeIi 1aRRCtVVQuwe1l3CxY4Av6otPg7M1DqIltar5pOeKQtXZylprVsDxAXiLnpDkMag/Pbf JgwMDq81vT/axvYWOKVlXSXLtScRvBTtJHHNmNZQBOTh+cItZMVEkBAAl0JGDKWw9JlL OfPVw2I9yU21htBQjgCXqDZoad1/7YX9Fhkl9OIng+5BU2KdwxWaadsr5jZXDweRIpR0 gF4Gqv3CNqBqJW7M2MT6zX245t90slZL3MBUTYZPLQG++F4/vJxihovxdDC6oLEgee73 +vSQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=cpNuhLG27M2LY+OOiLxKTk8CvH0axJBvq+gwTXFPBUw=; b=bPvh5qWV0FDCpW4IohRIJrDi4RJp87ak/3jIvFZTOafGAm8cSoB43uxFNKB630jljN ahfgjVphu4puEFQtYxVmh4S8izixk9g+gm8TMtNxpVsFOTDmbXsSxeIu7xEeLEoWmcty E1gSGxPbx6WV/IYSpXDHob82SaFkzubAPFMfUEDQD5KDkR6X5Z5bO3ont4kZQ2pzf2dP DsLpCLnNZsbP3SznA6+Bm4PAkSE84IF7m+5qMelYB+JuqTjVRIFPTYwiDOrpptSzCcte 5znGmHdGzkdDtj3wgtx6lHPNvdyFEVSd4+ImpRxZ/nvHPd386Czir2yhIpQOjK0+FIOh vrSA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=H7PU8veV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f4si407416ejd.83.2020.04.30.12.35.41; Thu, 30 Apr 2020 12:36:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=H7PU8veV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726580AbgD3Tbs (ORCPT + 99 others); Thu, 30 Apr 2020 15:31:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52060 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726377AbgD3Tbr (ORCPT ); Thu, 30 Apr 2020 15:31:47 -0400 Received: from mail-lf1-x142.google.com (mail-lf1-x142.google.com [IPv6:2a00:1450:4864:20::142]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 67EEDC035494 for ; Thu, 30 Apr 2020 12:31:47 -0700 (PDT) Received: by mail-lf1-x142.google.com with SMTP id g10so2196731lfj.13 for ; Thu, 30 Apr 2020 12:31:47 -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=cpNuhLG27M2LY+OOiLxKTk8CvH0axJBvq+gwTXFPBUw=; b=H7PU8veVNF+gc5hrBF2gDUfDMOVuiQ465ISM3u5O9VOlsXrR95GB0x08wFhDWOEG8d LMhX3dmPirJkEZf6LCI8kLisP5w0SesJa7YUTb2Jy4oizvDR/2f+kwoa1UGQ+tgllXv5 rpRXjfhU5HUxOBwREgWybDRSXv3MDbdYnILoNZ7InA5Gwy7NMCiw0yUQvTcCzpwhdVgq S6GXQKKzziEhSL3ltV/MksxJBz2Dvyak7tZTx+s3Tolw5HqsgAoseH2NVGDTibNmEZ5w +UquDn6daGjrVzFocqQSgiQ8+dDTf4FKgYOOWmd5oszy6er0CJ3vQaow6En/aaXYbEcJ pusA== 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=cpNuhLG27M2LY+OOiLxKTk8CvH0axJBvq+gwTXFPBUw=; b=F5hG7QWDvg44UOs3XxGAXOOOREB5Kv2qp9q7CsdpG316j0smYYRS7nfYEtjwMQrgvL Lfe2dTKBDp40h5UZctBbbZuTVp5rOgTyL+akejfeMFhRejBkF1BnV/s+XZ9UrnWzZlUa JG2IwP5Vf9R34x64G2w1CtOecPXeM/KlYya/DG0oWTbkKinMn6D3UkeOa/XJK5hvJWBM 63YMVE5SMKnVkt5hn9c9+IMUXHIhm6+xUqIaQW2uYEBktHNNX2MCobHMIoDKq9ke6Tft HjpOoKAfdQWdPHcH/R+egITDofww1fF+dC5YJ5unISvUWKJgakWcm05TlLxiUkul7qbc rT/w== X-Gm-Message-State: AGi0PuYcKCT6tgjkScxE0LnMsRMWlhOPCzeJ/kO8RdghJqIvZBX83L9c x1z5XV57cE+Lu7ETcJUrrsCqEWIU3pLEw+9aNMALnA== X-Received: by 2002:ac2:5e65:: with SMTP id a5mr110232lfr.189.1588275105505; Thu, 30 Apr 2020 12:31:45 -0700 (PDT) MIME-Version: 1.0 References: <20200430182712.237526-1-shakeelb@google.com> <20200430190610.GD339283@carbon.dhcp.thefacebook.com> In-Reply-To: <20200430190610.GD339283@carbon.dhcp.thefacebook.com> From: Shakeel Butt Date: Thu, 30 Apr 2020 12:31:32 -0700 Message-ID: Subject: Re: [PATCH] memcg: oom: ignore oom warnings from memory.max To: Roman Gushchin Cc: Johannes Weiner , Michal Hocko , Greg Thelen , Andrew Morton , Linux MM , Cgroups , LKML Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Apr 30, 2020 at 12:06 PM Roman Gushchin wrote: > > Hello, Shakeel! > > On Thu, Apr 30, 2020 at 11:27:12AM -0700, 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. > > Makes total sense to me. > > > > > 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; > > I'd invert it to warn. Or maybe even warn_on_no_proc? > Sure. > > }; > > > > 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)) > > I wonder if we can handle it automatically from the oom_killer side? > We can suppress warnings if oc->memcg is set and the cgroup scanning > showed that there are no belonging processes? > What about the charging path? Do we not want such warnings from charging paths? It might be due to some misconfiguration.