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 329D6C28CBC for ; Sun, 3 May 2020 23:00:04 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id B7D3D206E9 for ; Sun, 3 May 2020 23:00:03 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="NKibpGYD" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B7D3D206E9 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 1ACEB8E0005; Sun, 3 May 2020 19:00:03 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 15D6A8E0001; Sun, 3 May 2020 19:00:03 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 073158E0005; Sun, 3 May 2020 19:00:03 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0135.hostedemail.com [216.40.44.135]) by kanga.kvack.org (Postfix) with ESMTP id E1A358E0001 for ; Sun, 3 May 2020 19:00:02 -0400 (EDT) Received: from smtpin18.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 9A904180AD811 for ; Sun, 3 May 2020 23:00:02 +0000 (UTC) X-FDA: 76776927444.18.cats90_74c2024780406 X-HE-Tag: cats90_74c2024780406 X-Filterd-Recvd-Size: 5385 Received: from mail-lj1-f193.google.com (mail-lj1-f193.google.com [209.85.208.193]) by imf37.hostedemail.com (Postfix) with ESMTP for ; Sun, 3 May 2020 23:00:02 +0000 (UTC) Received: by mail-lj1-f193.google.com with SMTP id e25so7890873ljg.5 for ; Sun, 03 May 2020 16:00:02 -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=mVK0R6Fb63Vy7+23Zj2s/TrLJwjl7k6JRmwB4LkinqA=; b=NKibpGYDcJieF0fWWyoRdg5c8kX1FUi2frbnTRAyCrlDoh6YAEWkzpF7pFF5Wk88W+ usACTYhKx53u3TrHSX1ZNKmyOCB9Ettovw8znKI8yAVz3hK4+lwjREQBXe0rER+IxbxS nglnp7Nuyv4bSpU2F/PSSMO7ga+mcZTaYyYp4FR+LnCy6bKjFo4rxo8VMjYPkDztTi2L EiXVlhdPqiUeL2rSuzzjC3kngmP4tt/rvE3Mi7vPcZgS4UayoxTYtP1IK4SgRw6GctuU K+BRfBcmyG8IpRmJUg62YM8AsgRCetKvak8Ht0tmIw0kN9EHdGtujBeO+CPJpo7duEib qVdQ== 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=mVK0R6Fb63Vy7+23Zj2s/TrLJwjl7k6JRmwB4LkinqA=; b=PLXXEZdyF2YngKpNq9NiaYQhbuxGjqPVt3VoHcWDB10b1uzyLC7gWvtqtJ/uj1sObV h/UBG9somo5R5GzE95B+bkzFLu0y/tcJ3cliIyVBzjjGNw8ey6aDt8A3FBvw9fvR3q1e yiOhiVF9K3pLqsokpdA68xZhUGh4Xt1K41Dpb/Wa0t8bdYw51GVnemTMBalkL3ZsgdXn O3NoAKdk6WN3XYRArdSfmqeLUYd68m9URgXb10YIUnJpi7kAsT2fqE8XxsEBkf4oCPTe 0e437G32eE5aXHnFyl/3uuRP5LRXI1AGL+OuuTBmV1+rYjA3BDmFVGdtBe4yLlWdQPci dHew== X-Gm-Message-State: AGi0PuYY5SR4XqvU1D2pxaEuZP6vBdENvAi/Gd64H3/L5qBXAjRHOOur XsIY5+ecry0Bi0+M7l7tYz+V6YaBclsNvk/Sw2UDRQ== X-Google-Smtp-Source: APiQypKL9sELw1Ag9Zjmys2VEVdfP07kkFG8srj/AhytoLSbBxXlbff5fyRJ5lSKxYg//pgghJ+r/Q3WdIdu6o1fIFE= X-Received: by 2002:a2e:9a54:: with SMTP id k20mr9252189ljj.265.1588546800471; Sun, 03 May 2020 16:00:00 -0700 (PDT) MIME-Version: 1.0 References: <20200502143452.7640-1-laoar.shao@gmail.com> <20200502143452.7640-3-laoar.shao@gmail.com> In-Reply-To: <20200502143452.7640-3-laoar.shao@gmail.com> From: Shakeel Butt Date: Sun, 3 May 2020 15:59:49 -0700 Message-ID: Subject: Re: [PATCH 2/2] mm, memcg: don't try to kill a process if memcg is not populated To: Yafang Shao Cc: Andrew Morton , Johannes Weiner , Michal Hocko , Roman Gushchin , Greg Thelen , Linux MM 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 Sat, May 2, 2020 at 7:35 AM Yafang Shao wrote: > > Recently Shakeel reported a issue which also confused me serveral months > earlier. Bellow is his report - > > 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. > > 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. lot *of* un-needed > > [shakeelb@google.com: commit log above] > > A better way to avoid this issue is to avoid trying to kill a process if > memcg is not populated. > Note that OOM is different with OOM kill. different *from* > OOM is a status that the > system or memcg is out of memory, while OOM kill is a result that a > process inside this memcg is killed when this memcg is in OOM status. > That is the same reason why there're both MEMCG_OOM event and > MEMCG_OOM_KILL event. If we have already known that there's nothing to > kill, i.e. the memcg is not populated, then we don't need to have a try. need to try I think adding the discussion of memory.high is also useful in the commit message. Basically why setting memory.max to 0 is better than setting memory.high to 0 before deletion. The reason is remote charging. > > Cc: Shakeel Butt > Cc: Johannes Weiner > Cc: Michal Hocko > Cc: Roman Gushchin > Cc: Greg Thelen > Signed-off-by: Yafang Shao Reviewed-by: Shakeel Butt > --- > mm/memcontrol.c | 4 ++++ > 1 file changed, 4 insertions(+) > > diff --git a/mm/memcontrol.c b/mm/memcontrol.c > index 985edce98491..29afe3df9d98 100644 > --- a/mm/memcontrol.c > +++ b/mm/memcontrol.c > @@ -6102,6 +6102,10 @@ static ssize_t memory_max_write(struct kernfs_open_file *of, > } > > memcg_memory_event(memcg, MEMCG_OOM); > + > + if (!cgroup_is_populated(memcg->css.cgroup)) > + break; > + > if (!mem_cgroup_oom_kill(memcg, GFP_KERNEL, 0)) > break; > } > -- > 2.18.2 >