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 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 27190C433F5 for ; Wed, 20 Oct 2021 08:43:16 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id C597E61361 for ; Wed, 20 Oct 2021 08:43:15 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org C597E61361 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=suse.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 63CA76B0072; Wed, 20 Oct 2021 04:43:15 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5EC8A900002; Wed, 20 Oct 2021 04:43:15 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4DBB86B0074; Wed, 20 Oct 2021 04:43:15 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0177.hostedemail.com [216.40.44.177]) by kanga.kvack.org (Postfix) with ESMTP id 409C56B0072 for ; Wed, 20 Oct 2021 04:43:15 -0400 (EDT) Received: from smtpin08.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id EE2FF181AF5C6 for ; Wed, 20 Oct 2021 08:43:14 +0000 (UTC) X-FDA: 78716176308.08.35ECB1F Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by imf08.hostedemail.com (Postfix) with ESMTP id C1C0630000AE for ; Wed, 20 Oct 2021 08:43:10 +0000 (UTC) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id 5470D1FD9D; Wed, 20 Oct 2021 08:43:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1634719393; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=U9ANNFhF9o/o+ybyDXRcaxGyWu+m+P0WrCO6fsbyGfU=; b=uY6Nxgcj9JvrEu906q2eodXCBQHjLtNTT6g2fU2aC1AVTPGmitU6Q5Wuj8Ke/poJn9cDfx RgpiGjvRE05Q/17lHdQCAkfbUu3aNpsMOqiKGT7T7678VtAkJml8vKI0dWPTviJ9hhTLAU Q5W6VT/MOGukER12jvgZSq9zCYd9JDM= Received: from suse.cz (unknown [10.100.201.86]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id B765FA3B8A; Wed, 20 Oct 2021 08:43:12 +0000 (UTC) Date: Wed, 20 Oct 2021 10:43:12 +0200 From: Michal Hocko To: Vasily Averin Cc: Johannes Weiner , Vladimir Davydov , Andrew Morton , Roman Gushchin , Uladzislau Rezki , Vlastimil Babka , Shakeel Butt , Mel Gorman , Tetsuo Handa , cgroups@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, kernel@openvz.org Subject: Re: [PATCH memcg v4] memcg: prohibit unconditional exceeding the limit of dying tasks Message-ID: References: <3c76e2d7-e545-ef34-b2c3-a5f63b1eff51@virtuozzo.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Stat-Signature: 699zyjrzaupcrpjak99jr8d6bbnz9mo4 X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: C1C0630000AE Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=suse.com header.s=susede1 header.b=uY6Nxgcj; spf=pass (imf08.hostedemail.com: domain of mhocko@suse.com designates 195.135.220.29 as permitted sender) smtp.mailfrom=mhocko@suse.com; dmarc=pass (policy=quarantine) header.from=suse.com X-HE-Tag: 1634719390-582251 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 Wed 20-10-21 11:07:02, Vasily Averin wrote: [...] I haven't read through the changelog and only focused on the patch this time. [...] > @@ -1810,11 +1810,21 @@ 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)) { > ret = OOM_SUCCESS; > - else > + } else { > ret = OOM_FAILED; > - > + /* > + * In some rare cases mem_cgroup_out_of_memory() can return false. > + * If it was called from #PF it forces handle_mm_fault() > + * return VM_FAULT_OOM and executes pagefault_out_of_memory(). > + * memcg_in_oom is set here to notify pagefault_out_of_memory() > + * that it was a memcg-related failure and not allow to run > + * global OOM. > + */ > + if (current->in_user_fault) > + current->memcg_in_oom = (struct mem_cgroup *)ret; > + } > if (locked) > mem_cgroup_oom_unlock(memcg); > > @@ -1848,6 +1858,15 @@ bool mem_cgroup_oom_synchronize(bool handle) > if (!memcg) > return false; > > + /* OOM is memcg, however out_of_memory() found no victim */ > + if (memcg == (struct mem_cgroup *)OOM_FAILED) { > + /* > + * Should be called from pagefault_out_of_memory() only, > + * where it is used to prevent false global OOM. > + */ > + current->memcg_in_oom = NULL; > + return true; > + } > if (!handle) > goto cleanup; I have to say I am not a great fan of this but this belongs to a separate patch on top of all the previous ones. [...] > diff --git a/mm/oom_kill.c b/mm/oom_kill.c > index 831340e7ad8b..1deef8c7a71b 100644 > --- a/mm/oom_kill.c > +++ b/mm/oom_kill.c > @@ -1137,6 +1137,9 @@ void pagefault_out_of_memory(void) > if (mem_cgroup_oom_synchronize(true)) > return; > > + if (fatal_signal_pending(current)) > + return; > + This belongs to its own patch as well. All that being said I would go with pagefault_out_of_memory as the first patch because it is necessary to handle charge failures. Then go with a patch to remove charge forcing when OOM killer succeeds but the retry still fails and finally go with one that tries to handle oom failures. -- Michal Hocko SUSE Labs