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=-15.3 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,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 0FF56C433B4 for ; Wed, 19 May 2021 15:22:33 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id A36C7613B9 for ; Wed, 19 May 2021 15:22:32 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A36C7613B9 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id E5A026B0036; Wed, 19 May 2021 11:22:31 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E0A336B006E; Wed, 19 May 2021 11:22:31 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CF98F6B0070; Wed, 19 May 2021 11:22:31 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0095.hostedemail.com [216.40.44.95]) by kanga.kvack.org (Postfix) with ESMTP id 9F32C6B0036 for ; Wed, 19 May 2021 11:22:31 -0400 (EDT) Received: from smtpin12.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 30C74689B for ; Wed, 19 May 2021 15:22:31 +0000 (UTC) X-FDA: 78158347302.12.E568D76 Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by imf25.hostedemail.com (Postfix) with ESMTP id 9C1EB6000244 for ; Wed, 19 May 2021 15:22:29 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 78F4FB18F; Wed, 19 May 2021 15:22:29 +0000 (UTC) To: Aaron Tomlin , linux-mm@kvack.org Cc: akpm@linux-foundation.org, mhocko@suse.com, linux-kernel@vger.kernel.org References: <20210519130609.r3ml6ohb2qsrfq2t@ava.usersys.com> <20210519145014.3220164-1-atomlin@redhat.com> From: Vlastimil Babka Subject: Re: [PATCH] mm/page_alloc: bail out on fatal signal during reclaim/compaction retry attempt Message-ID: <076e1c68-b4a2-26ea-9538-d88e6da800cc@suse.cz> Date: Wed, 19 May 2021 17:22:29 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.10.1 MIME-Version: 1.0 In-Reply-To: <20210519145014.3220164-1-atomlin@redhat.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Authentication-Results: imf25.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf25.hostedemail.com: domain of vbabka@suse.cz designates 195.135.220.15 as permitted sender) smtp.mailfrom=vbabka@suse.cz X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 9C1EB6000244 X-Stat-Signature: d4w1mnqpikf1fwr9rw9ad15bf8etrkxw X-HE-Tag: 1621437749-298132 Content-Transfer-Encoding: quoted-printable 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 5/19/21 4:50 PM, Aaron Tomlin wrote: > It does not make sense to retry compaction when the last known compact > result was skipped and a fatal signal is pending. >=20 > In the context of try_to_compact_pages(), indeed COMPACT_SKIPPED can be > returned; albeit, not every zone, on the zone list, would be considered > in the case a fatal signal is found to be pending. > Yet, in should_compact_retry(), given the last known compaction result, > each zone, on the zone list, can be considered/or checked > (see compaction_zonelist_suitable()). For example, if a zone was found > to succeed, then reclaim/compaction would be tried again > (notwithstanding the above). >=20 > This patch ensures that compaction is not needlessly retried when the > last known compaction result was skipped and in the unlikely case a > fatal signal is found pending. So, OOM is at least attempted. >=20 > Signed-off-by: Aaron Tomlin Hm, indeed, if fatal_signal_pending() is true then try_to_compact_pages()= will bail out in the for-each-zone loop after trying a single zone and if that= zone keeps returning COMPACT_SKIPPED, things can get stuck. And direct reclaim might see compaction_ready() for another zone and retu= rn 1, faking the progress. So your patch seems to be solving the issue. But maybe we should just do = the test at the beginning of should_compact_retry() and not specific to compaction_needs_reclaim() - if there's a fatal signal, there will be no compaction happening, so we should just say not to retry. I suppose if the patch fixes your situation where fatal_signal_pending() = was true, there's hopefully not a more general problem with the retry logic? > --- > mm/page_alloc.c | 2 ++ > 1 file changed, 2 insertions(+) >=20 > diff --git a/mm/page_alloc.c b/mm/page_alloc.c > index aaa1655cf682..5f9aac27a1b5 100644 > --- a/mm/page_alloc.c > +++ b/mm/page_alloc.c > @@ -4268,6 +4268,8 @@ should_compact_retry(struct alloc_context *ac, in= t order, int alloc_flags, > * to work with, so we retry only if it looks like reclaim can help. > */ > if (compaction_needs_reclaim(compact_result)) { > + if (fatal_signal_pending(current)) > + goto out; > ret =3D compaction_zonelist_suitable(ac, order, alloc_flags); > goto out; > } >=20