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,URIBL_BLOCKED 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 3569FC432C0 for ; Tue, 26 Nov 2019 14:26:03 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id E16CF20722 for ; Tue, 26 Nov 2019 14:26:02 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="jH4uzIvk" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E16CF20722 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 7C3926B0313; Tue, 26 Nov 2019 09:26:02 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 7745D6B0316; Tue, 26 Nov 2019 09:26:02 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 662936B0318; Tue, 26 Nov 2019 09:26:02 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0174.hostedemail.com [216.40.44.174]) by kanga.kvack.org (Postfix) with ESMTP id 52E436B0313 for ; Tue, 26 Nov 2019 09:26:02 -0500 (EST) Received: from smtpin08.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with SMTP id 040C11EF2 for ; Tue, 26 Nov 2019 14:26:02 +0000 (UTC) X-FDA: 76198652964.08.gold83_34a04d1799701 X-HE-Tag: gold83_34a04d1799701 X-Filterd-Recvd-Size: 6714 Received: from mail-io1-f68.google.com (mail-io1-f68.google.com [209.85.166.68]) by imf14.hostedemail.com (Postfix) with ESMTP for ; Tue, 26 Nov 2019 14:26:01 +0000 (UTC) Received: by mail-io1-f68.google.com with SMTP id k1so20749973ioj.6 for ; Tue, 26 Nov 2019 06:26:01 -0800 (PST) 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=RlDLw91mKqOfcZL/4UW6FByVC4DV3CZsm4LSKjwb0L4=; b=jH4uzIvks+DWnm7bp15DQPO2ctXpPG/weKPZOuUzwk7rRUz7T0Rz5Wqn1ibtEAx2/P 76/oS+Z/afu26nvaW9testR/kmy6aeoEhzbF2ykgnrihNt9c0RV00iSl4LAKGz6Ls6wo EAnQqZKUR9hMhAU7KhBVhHBRO849SJTyd6V5q2Si4YpgrVLnjHbdYWOALd4st6AzV+U3 3miAAEM0cpqkV/kkXguX91e9wFWUeajNwspSjZ3HbRVb1oXn77B3a9L7OhNrPfx+6tBg I35iGhrAiS7j39a1yaa52kin4TdQ1c3i7uakuqEzsBznqGNy2Ab5IxBi1fLsqHz0CcNb A5qA== 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=RlDLw91mKqOfcZL/4UW6FByVC4DV3CZsm4LSKjwb0L4=; b=Fl/V7U4aV0lf4AkY7IarPbLym2XNrkVIj5ujaTqMZ3RtK5fMELYvChJ5eV/XteTFIp BuinknQZnl326Myzfz97zbg+WrLHy9tzPoNvOOYCXyQa8T8qPjA+XvC6/xcwOgK7xeYJ Ef4Aui6IDnxtJibZN0lWQgLHO494eTtoT8d/UWq8iqR9LFuQDQCsxYnw2yL6O4OynHvH 5LhTMhqcVss2LNCsy3GM19yBk+3z9/M51V/cczNegRa3HuHLIMXg+7Doy0Y3Ef8mW5Nb 3BJ7K8WJXgVt/ivDJkNs7GSLVOaTa3bKaPSzdC7VkVdC1ODHgyXqM3b74hxw2q+IBIBU bX7g== X-Gm-Message-State: APjAAAWl+VMryY8YxxPl9dbouk2CT52bpK8mbZ2y+K1CsSuoT2IJDG8h OmI3HWYLkOEg7FutpzapCbGBDvbc13WQnafBR/k= X-Google-Smtp-Source: APXvYqzWUNraqYiFb8HfP0IHDDRwGxmJZLjLt2fgfC8R+K8Y+ZRQTsLSSWARogrnm1KhIx5XHRfzkss+wzj9TRXrqDw= X-Received: by 2002:a6b:fd0b:: with SMTP id c11mr2448994ioi.203.1574778360772; Tue, 26 Nov 2019 06:26:00 -0800 (PST) MIME-Version: 1.0 References: <1574773369-1634-1-git-send-email-laoar.shao@gmail.com> <20191126131604.GF20912@dhcp22.suse.cz> In-Reply-To: <20191126131604.GF20912@dhcp22.suse.cz> From: Yafang Shao Date: Tue, 26 Nov 2019 22:25:27 +0800 Message-ID: Subject: Re: [PATCH] mm, memcg: avoid oom if cgroup is not populated To: Michal Hocko Cc: Johannes Weiner , Vladimir Davydov , Andrew Morton , 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 Tue, Nov 26, 2019 at 9:16 PM Michal Hocko wrote: > > On Tue 26-11-19 08:02:49, Yafang Shao wrote: > > There's one case that the processes in a memcg are all exit (due to OOM > > group or some other reasons), but the file page caches are still exist. > > These file page caches may be protected by memory.min so can't be > > reclaimed. If we can't success to restart the processes in this memcg or > > don't want to make this memcg offline, then we want to drop the file page > > caches. > > The advantage of droping this file caches is it can avoid the reclaimer > > (either kswapd or direct) scanning and reclaiming pages from all memcgs > > exist in this system, because currently the reclaimer will fairly reclaim > > pages from all memcgs if the system is under memory pressure. > > The possible method to drop these file page caches is setting the > > hard limit of this memcg to 0. Unfortunately this may invoke the OOM killer > > and generates lots of misleading outputs, that should not happen. > > I disagree that the output is misleading. Quite contrary, it provides a > useful lead on the unreclaimable memory. > We can show the unreclaimable memory independently, rather than print the full oom output. OOM killer is used to kill process, why do we invoke it when there's no process ? What's the advantage of doing it ? > > One misleading output is "Out of memory and no killable processes...", > > while really there is no tasks rather than no killable tasks. > > Again, this is nothing misleading. No task is a trivial subset of no > killable task. I do not see why we should treat one differently than the > other. > No killable tasks means there's task and the OOM killer may be invoked. While no tasks means the OOM killer is useless. > > Furthermore, > > the OOM output is not expected by the admin if he or she only wants to drop > > the cahes and knows there're no processes running in this memcg. > > But this is not what hard limit reduced to 0 really does. No matter > whether there is some task or not. It simply reclaims _all_ the memory > as explained in other email. > Are there any way to reclaim page cache only ? No. I know it will relcaim all the memory. If you really think this expression is a prolem, but does it improtant that we should distingush between caches (both page caches and kmem) and _all_ memory, especially when there's no processes ? > > If memcg is not populated, we should not invoke the OOM killer. > > I have already explained why I believe this is not correct in other > email and this description doesn't provide any real justification. It is > merely your intepretation of what should happen and I believe you > haven't thought through it really. > > > Fixes: b6e6edcf ("mm: memcontrol: reclaim and OOM kill when shrinking memory.max below usage") > > Signed-off-by: Yafang Shao > > Cc: Johannes Weiner > > Cc: Michal Hocko > > --- > > mm/memcontrol.c | 8 ++++++-- > > 1 file changed, 6 insertions(+), 2 deletions(-) > > > > diff --git a/mm/memcontrol.c b/mm/memcontrol.c > > index 1c4c08b..4e08905 100644 > > --- a/mm/memcontrol.c > > +++ b/mm/memcontrol.c > > @@ -6139,9 +6139,13 @@ static ssize_t memory_max_write(struct kernfs_open_file *of, > > continue; > > } > > > > - memcg_memory_event(memcg, MEMCG_OOM); > > - if (!mem_cgroup_out_of_memory(memcg, GFP_KERNEL, 0)) > > + if (cgroup_is_populated(memcg->css.cgroup)) { > > + memcg_memory_event(memcg, MEMCG_OOM); > > + if (!mem_cgroup_out_of_memory(memcg, GFP_KERNEL, 0)) > > + break; > > + } else { > > break; > > + } > > } > > > > memcg_wb_domain_size_changed(memcg); > > -- > > 1.8.3.1 > > -- > Michal Hocko > SUSE Labs