From patchwork Thu Jan 6 10:26:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jann Horn X-Patchwork-Id: 12705269 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 98673C433F5 for ; Thu, 6 Jan 2022 10:26:12 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id EF4636B0073; Thu, 6 Jan 2022 05:26:11 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id EA4686B0074; Thu, 6 Jan 2022 05:26:11 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D94336B0075; Thu, 6 Jan 2022 05:26:11 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0137.hostedemail.com [216.40.44.137]) by kanga.kvack.org (Postfix) with ESMTP id CA4AB6B0073 for ; Thu, 6 Jan 2022 05:26:11 -0500 (EST) Received: from smtpin29.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 8AFA39676F for ; Thu, 6 Jan 2022 10:26:11 +0000 (UTC) X-FDA: 78999482142.29.9FBC8EE Received: from mail-wr1-f52.google.com (mail-wr1-f52.google.com [209.85.221.52]) by imf30.hostedemail.com (Postfix) with ESMTP id 396ED80009 for ; Thu, 6 Jan 2022 10:26:11 +0000 (UTC) Received: by mail-wr1-f52.google.com with SMTP id l10so3821476wrh.7 for ; Thu, 06 Jan 2022 02:26:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=LXEy2JWqJ3SIAUYkh8ZNaC8ZweH0TNacKsusb8Rd4Cc=; b=cpTHs1MmcQ4aVFKUDrCc10ZLWTqvE6Zz0AMAvgNV6st8WB8je6nDeju74emJLV4vq7 w+cLYv46RHMRlnSeZzaCZebd9gWYLDVMXMXK/Z6d5Iehi+CvAup11AIbHy0J3f6R+NX3 BlUxM1uzlwnomEvRu4fqFN0UaWRnfD8NL96RMpmt7gGvEJkfta30ThbJ0626pUvdETa2 93fZ2PbW4GyopCmg60w6JdcfRHCKj5Uxl38GJZmgzUN5DCpl99ni3SZkJTs3fulQ63ej 5nQw1biCp00wIrfQlQyzaADnMyp3iSI/bS+7dGwl4/CfmZRWF02ODZ4grwmDTqULTgHa yJrA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=LXEy2JWqJ3SIAUYkh8ZNaC8ZweH0TNacKsusb8Rd4Cc=; b=3YOik7XmYyH7buxMuCH0+Jtt05dtS53as/4HdXEwk5HCxhclRXtDzKJVNYBN0V7qS8 CfykKNnmk6jMV8aZubh1TGUrDDsbLJlE2gVMO7YKhtZoRnIOpnCUtrQ/iDvfVX9Wu1Nc GdQerXI0fFxTAj8wTOGq+wwWOtcvDAlIZ8ahQVybGyFmgSEqUlJYvKj4h8lakxFSiifG s6fLXOxdHTyFwPBF1xVBGm6RaL23EedP77pasARkFrvc+K3udrKItJ2bqz/FXJFx3xHp N/aZo9Z73fPl3iPNsFfL1v0TSc0PEpoVSFoj1bb+VZ4Vzoq8ISBZW2wiYtcffdYIQNH4 vb3A== X-Gm-Message-State: AOAM530/iH7UMFiIj1TeXkaBvS8I3I79BZ2A7XCjfykD0DXQmTdqzjU7 ryov2MVOlQ819ULUZz+dPpKlRg== X-Google-Smtp-Source: ABdhPJzyMbHwEPoud6lmHP1xhl6IJo5bRI1Oil2SZ8cbIoUzjb6ksEX69Lkr8fG0rS/zqB64CgO85w== X-Received: by 2002:a05:6000:2c9:: with SMTP id o9mr50414363wry.377.1641464769966; Thu, 06 Jan 2022 02:26:09 -0800 (PST) Received: from localhost ([2a02:168:96c5:1:55ed:514f:6ad7:5bcc]) by smtp.gmail.com with ESMTPSA id h204sm1363792wmh.33.2022.01.06.02.26.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Jan 2022 02:26:09 -0800 (PST) From: Jann Horn To: Andrew Morton , linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org, Jann Horn , Michal Hocko Subject: [PATCH v3] mm, oom: OOM sysrq should always kill a process Date: Thu, 6 Jan 2022 11:26:05 +0100 Message-Id: <20220106102605.635656-1-jannh@google.com> X-Mailer: git-send-email 2.34.1.448.ga2b2bfdf31-goog MIME-Version: 1.0 X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 396ED80009 X-Stat-Signature: 53p6p4kyx1d3bbihrfgjhwug66gtpit4 Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=cpTHs1Mm; spf=pass (imf30.hostedemail.com: domain of jannh@google.com designates 209.85.221.52 as permitted sender) smtp.mailfrom=jannh@google.com; dmarc=pass (policy=reject) header.from=google.com X-HE-Tag: 1641464771-303326 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: The OOM kill sysrq (alt+sysrq+F) should allow the user to kill the process with the highest OOM badness with a single execution. However, at the moment, the OOM kill can bail out if an OOM notifier (e.g. the i915 one) says that it reclaimed a tiny amount of memory from somewhere. That's probably not what the user wants, so skip the bailout if the OOM was triggered via sysrq. Acked-by: Michal Hocko Signed-off-by: Jann Horn Acked-by: David Rientjes --- mm/oom_kill.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) base-commit: c9e6606c7fe92b50a02ce51dda82586ebdf99b48 diff --git a/mm/oom_kill.c b/mm/oom_kill.c index 1ddabefcfb5a..3c480b24a93c 100644 --- a/mm/oom_kill.c +++ b/mm/oom_kill.c @@ -1057,7 +1057,7 @@ bool out_of_memory(struct oom_control *oc) if (!is_memcg_oom(oc)) { blocking_notifier_call_chain(&oom_notify_list, 0, &freed); - if (freed > 0) + if (freed > 0 && !is_sysrq_oom(oc)) /* Got some memory back in the last second. */ return true; }