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=-8.5 required=3.0 tests=INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 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 29A4BC432C0 for ; Tue, 26 Nov 2019 13:16:08 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id E933E2071E for ; Tue, 26 Nov 2019 13:16:07 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E933E2071E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 624776B030D; Tue, 26 Nov 2019 08:16:07 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 5D5066B030E; Tue, 26 Nov 2019 08:16:07 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4EA016B030F; Tue, 26 Nov 2019 08:16:07 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0237.hostedemail.com [216.40.44.237]) by kanga.kvack.org (Postfix) with ESMTP id 3C2CC6B030D for ; Tue, 26 Nov 2019 08:16:07 -0500 (EST) Received: from smtpin04.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with SMTP id E61F75845 for ; Tue, 26 Nov 2019 13:16:06 +0000 (UTC) X-FDA: 76198476732.04.twist43_1837cb6f69652 X-HE-Tag: twist43_1837cb6f69652 X-Filterd-Recvd-Size: 5301 Received: from mail-wr1-f65.google.com (mail-wr1-f65.google.com [209.85.221.65]) by imf16.hostedemail.com (Postfix) with ESMTP for ; Tue, 26 Nov 2019 13:16:06 +0000 (UTC) Received: by mail-wr1-f65.google.com with SMTP id t2so22415793wrr.1 for ; Tue, 26 Nov 2019 05:16:06 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=4+Q5MtsXxYK5RX84IyXK96gqcz9PIlqxNKiKsjGrCHM=; b=pmfDKpdWiXFRJJ997l5UH7kviXDV/7F85DhODQVqvbQ/AdaKlaO63TuUiBeHIwuLAh JgXqID24vreh13LCL3GJJA6W4CDSx0TTJ9B+ZvJdH1VlvJF3i2pugHp5logRtacg63eU 5LIPYD5lGOZdGBs6kjknHrW6zShr1SyhYbWCnRHW1doo7aqVrGToIX4MpyxFBbydCA5G 1XCC4d7Q6ua14ZzUWxTroLY4x0TsX4WEVtAUaPnKsW9UIJ/ZF98Db0cQQniaCAg5e0// NaSb+NgzLFy7nrsx9LUIWIHyzXRkQ1Bo07HVSgtTuPDUctVmd0a6kEphi/PYQo//AVpw Mmnw== X-Gm-Message-State: APjAAAW1lyQOQbEuN01mkZ2Mp4mvCr5XcPp90xiEOBmeMUs1JFozI28y eWMhIowjqbicU+7VTuLwvmc= X-Google-Smtp-Source: APXvYqzZnzlCui4+A3+AvT+MCMAmyztIu5wAIRYr/XwWP4kBCjvVYs0w6l45yAcXr/iP2+iMbQJcZA== X-Received: by 2002:adf:ec4b:: with SMTP id w11mr36441295wrn.243.1574774165227; Tue, 26 Nov 2019 05:16:05 -0800 (PST) Received: from localhost (prg-ext-pat.suse.com. [213.151.95.130]) by smtp.gmail.com with ESMTPSA id b63sm2820206wmb.40.2019.11.26.05.16.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Nov 2019 05:16:04 -0800 (PST) Date: Tue, 26 Nov 2019 14:16:04 +0100 From: Michal Hocko To: Yafang Shao Cc: hannes@cmpxchg.org, vdavydov.dev@gmail.com, akpm@linux-foundation.org, linux-mm@kvack.org Subject: Re: [PATCH] mm, memcg: avoid oom if cgroup is not populated Message-ID: <20191126131604.GF20912@dhcp22.suse.cz> References: <1574773369-1634-1-git-send-email-laoar.shao@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1574773369-1634-1-git-send-email-laoar.shao@gmail.com> User-Agent: Mutt/1.10.1 (2018-07-13) 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 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. > 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. > 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. > 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