From patchwork Thu May 20 14:29:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aaron Tomlin X-Patchwork-Id: 12270567 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=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT 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 5A8C4C433ED for ; Thu, 20 May 2021 14:29:08 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id E5E95610A8 for ; Thu, 20 May 2021 14:29:07 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E5E95610A8 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 472828E0016; Thu, 20 May 2021 10:29:07 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3FAB78E0012; Thu, 20 May 2021 10:29:07 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 226EC8E0016; Thu, 20 May 2021 10:29:07 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0089.hostedemail.com [216.40.44.89]) by kanga.kvack.org (Postfix) with ESMTP id E412E8E0012 for ; Thu, 20 May 2021 10:29:06 -0400 (EDT) Received: from smtpin21.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 7E095181522BE for ; Thu, 20 May 2021 14:29:06 +0000 (UTC) X-FDA: 78161841492.21.13CE338 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by imf05.hostedemail.com (Postfix) with ESMTP id D53AFE000114 for ; Thu, 20 May 2021 14:29:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1621520945; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=oYOc57ukgw42N/SN5E1bnm5deoP6acpYVUsf7mHSuH8=; b=U4G2SRio6IdYGakZQLDxVPNLN60aLUxJrAz/V/BkDTRDUhk2/pEHpy7RtCx0zX7LyzwAbn 2S+MkGQkETaRLMjqOqFnu8Ivm49mwn2Yb1+Gq9bEPHRITd+ZBfY/JXadB2IHvNesEnNFQz VE6lTeyOKRnCoqWPAaG4vJnw02sQUl4= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-565-FjwGxa77OzWj0cPw3dHLxA-1; Thu, 20 May 2021 10:29:04 -0400 X-MC-Unique: FjwGxa77OzWj0cPw3dHLxA-1 Received: by mail-wm1-f72.google.com with SMTP id z64-20020a1ce2430000b029016d56f15ac0so2257791wmg.1 for ; Thu, 20 May 2021 07:29:04 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=oYOc57ukgw42N/SN5E1bnm5deoP6acpYVUsf7mHSuH8=; b=jwOYG2MQ+lPrSHvLZN6JTPJwUgvr/ftcB+8pEAlJu3HsAVjIDZXPoVglOpGH1LINrW iRORyWM7jE+DoXqrIyPDv21jSq/uIjHn07zwLQji5F024WPGwmvOB3KvJhg8sO/ocL/P bnVH/4kFbcZ++qKM4aTZ2E8t0BNTejVNdqOEdc0VvLhCbw0+zhL2Sb2NxcB4yNysYmul M7EFOHvwDLujUS/JzylqQZkOL5muWx93QHeHYRteVF3v6npViM/0EA0fLG8kJoBRebzA DgsjF1uTsn726MEIgTgu4L3VJmkPf9ZXnb0uzqHbAyKBESLdffxGRbjzNS6JE1UucUg/ Cs3g== X-Gm-Message-State: AOAM533keB7jz2ba9uXFDEqq4s7NKlLxVpdWc8dKzNe3tQx+zUk7/TAd QgKfEG1JiWXUj5fEm6XgmbS1JjIBP8Tr+wist4/TLETa1aclHG/IoFswZ+f26YdjjyGznXk9E9o aygciJFxJevQBEYRZej5AGGzFmYZ2JJhaaK3JTDmgwCsRpmsaozmgcMqRmTND X-Received: by 2002:a7b:c841:: with SMTP id c1mr3984984wml.123.1621520942761; Thu, 20 May 2021 07:29:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxEbGPnyNZxPxygXLaN6j4fqdxsCTcH6CY0x7XaZ7SRad5T96/CwNYW80Oacd2SE3qX6+15wg== X-Received: by 2002:a7b:c841:: with SMTP id c1mr3984953wml.123.1621520942497; Thu, 20 May 2021 07:29:02 -0700 (PDT) Received: from localhost (cpc111743-lutn13-2-0-cust979.9-3.cable.virginm.net. [82.17.115.212]) by smtp.gmail.com with ESMTPSA id m7sm3338168wrv.35.2021.05.20.07.29.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 May 2021 07:29:02 -0700 (PDT) From: Aaron Tomlin To: linux-mm@kvack.org Cc: akpm@linux-foundation.org, vbabka@suse.cz, mhocko@suse.com, willy@infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v4] mm/page_alloc: bail out on fatal signal during reclaim/compaction retry attempt Date: Thu, 20 May 2021 15:29:01 +0100 Message-Id: <20210520142901.3371299-1-atomlin@redhat.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: References: MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=U4G2SRio; spf=none (imf05.hostedemail.com: domain of atomlin@redhat.com has no SPF policy when checking 216.205.24.124) smtp.mailfrom=atomlin@redhat.com; dmarc=pass (policy=none) header.from=redhat.com X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: D53AFE000114 X-Stat-Signature: tncdd76s1jffunhbs8zpsxuikawdhojj X-HE-Tag: 1621520943-501967 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: A customer experienced a low-memory situation and decided to issue a SIGKILL (i.e. a fatal signal). Instead of promptly terminating as one would expect, the aforementioned task remained unresponsive. Further investigation indicated that the task was "stuck" in the reclaim/compaction retry loop. Now, it does not make sense to retry compaction when a fatal signal is pending. 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). This patch ensures that compaction is not needlessly retried irrespective of the last known compaction result e.g. if it was skipped, in the unlikely case a fatal signal is found pending. So, OOM is at least attempted. Signed-off-by: Aaron Tomlin Reviewed-by: Vlastimil Babka --- mm/page_alloc.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index aaa1655cf682..b317057ac186 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -4252,6 +4252,9 @@ should_compact_retry(struct alloc_context *ac, int order, int alloc_flags, if (!order) return false; + if (fatal_signal_pending(current)) + return false; + if (compaction_made_progress(compact_result)) (*compaction_retries)++;