From patchwork Thu Jan 6 10:20:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jann Horn X-Patchwork-Id: 12705266 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 4D769C433EF for ; Thu, 6 Jan 2022 10:21:04 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4C2886B0073; Thu, 6 Jan 2022 05:21:03 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 449F96B0074; Thu, 6 Jan 2022 05:21:03 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2EA7A6B0075; Thu, 6 Jan 2022 05:21:03 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0187.hostedemail.com [216.40.44.187]) by kanga.kvack.org (Postfix) with ESMTP id 1A78E6B0073 for ; Thu, 6 Jan 2022 05:21:03 -0500 (EST) Received: from smtpin01.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id BDE058DF7F for ; Thu, 6 Jan 2022 10:21:02 +0000 (UTC) X-FDA: 78999469164.01.A36D93D Received: from mail-wm1-f46.google.com (mail-wm1-f46.google.com [209.85.128.46]) by imf05.hostedemail.com (Postfix) with ESMTP id 5153810000D for ; Thu, 6 Jan 2022 10:21:02 +0000 (UTC) Received: by mail-wm1-f46.google.com with SMTP id az31-20020a05600c601f00b003475c3c3d03so57574wmb.0 for ; Thu, 06 Jan 2022 02:21:02 -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=vofa99wOtjdFhQhezy1E37S1XL2YEBI129eGPWKU4r0=; b=AkSlh8gb7jpmbNYLGFkTRZdIAm6J/JWwiNQFLKrw/yYGhw9wDDFg4Ck8+y9+iip6m5 S3UF7XghBkOX6qnO3UMtnkoxqxPd29oFDkl97gJnmlEWPOmFIKHKcruowRF9uVhDOiwU 8/CkOHy3Q6EfpoF0e4wo9Ljy9ZWkDYGRW6zgd/nL+jCN1/+n0ZFm5EtNx1fb4BG1KcRa jtPUufIOwbvnWZxzF95UCvxU79Y7TWlujBg+K4X5jNSxPD5zFgkd8SsDD/+EwKitwIGi iHkGSwhz6Rbm8kz62cKsv/0c7uTfBwwLyEAnlhoM+9Tz/FSGBWIaWE72dtId4vsOCpDO kxlw== 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=vofa99wOtjdFhQhezy1E37S1XL2YEBI129eGPWKU4r0=; b=AQoAWq8ts5bBU0tnb/c3lsSAwkWHqvVei7sPqY6fIQUJNdj++Jk0rUGmeImqlJc0PD 915dMx3AWbgO7Slnk5rkdMfpQlY/3enFplP70Wcv3HfxYWpBMgU5OWzXhg83wWvF7sFs xaJOmogame61CXdfa1lRrkvz9YEgf0NfrzxMSACjc59uJLZHYz7tGGdHiHro5p+hrxMW HDq7qt3NoH4DHnWmmVToxwr55U3DWb9PuOfOx7DCreavZVp6iUCPeaJVyMmeRm+F9gNN C4JJ2hC2sZY1zKe28xPeEDMj/pletHIP8MV+8R0ov5Rx7KpVU3WTPgY6URInJ3lQfbsf xxtg== X-Gm-Message-State: AOAM5301qHGOaa86rRegGMc/trbJW8oQaK66nZQwCpX6Rz9NwktUEKZv MYAlwkvKRWCSA9NINGKqTf8ikg== X-Google-Smtp-Source: ABdhPJwah5mmg5z0b3I2dVAhlRIO2OW86Atm2uCjEsx8sUJHA2GWVLIkl73EMPgkPGVB2Mig3FpmSA== X-Received: by 2002:a05:600c:3d0f:: with SMTP id bh15mr6517240wmb.27.1641464460943; Thu, 06 Jan 2022 02:21:00 -0800 (PST) Received: from localhost ([2a02:168:96c5:1:55ed:514f:6ad7:5bcc]) by smtp.gmail.com with ESMTPSA id c7sm1852172wri.21.2022.01.06.02.21.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Jan 2022 02:21:00 -0800 (PST) From: Jann Horn To: Andrew Morton , linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org, Jann Horn , Michal Hocko Subject: [PATCH v2] mm, oom: OOM sysrq should always kill a process Date: Thu, 6 Jan 2022 11:20:27 +0100 Message-Id: <20220106102027.634842-1-jannh@google.com> X-Mailer: git-send-email 2.34.1.448.ga2b2bfdf31-goog MIME-Version: 1.0 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 5153810000D X-Stat-Signature: h6ifru6od49xwd1wd3jerqprtgk4web4 Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=AkSlh8gb; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf05.hostedemail.com: domain of jannh@google.com designates 209.85.128.46 as permitted sender) smtp.mailfrom=jannh@google.com X-HE-Tag: 1641464462-716192 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000002, 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. As documented in struct oom_control, order == -1 means the oom kill is required by sysrq. So check for that, and if it's true, don't bail out no matter what the OOM notifiers say. Acked-by: Michal Hocko Signed-off-by: Jann Horn --- 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; }