From patchwork Mon Aug 20 10:37:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tetsuo Handa X-Patchwork-Id: 10570365 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 74497112E for ; Mon, 20 Aug 2018 13:15:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5B20D290F1 for ; Mon, 20 Aug 2018 13:15:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 58B2D29385; Mon, 20 Aug 2018 13:15:45 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1A666290F1 for ; Mon, 20 Aug 2018 13:15:44 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2CAC16B193E; Mon, 20 Aug 2018 09:15:43 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 27A7E6B193F; Mon, 20 Aug 2018 09:15:43 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 169D86B1940; Mon, 20 Aug 2018 09:15:43 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-oi0-f71.google.com (mail-oi0-f71.google.com [209.85.218.71]) by kanga.kvack.org (Postfix) with ESMTP id DE4436B193E for ; Mon, 20 Aug 2018 09:15:42 -0400 (EDT) Received: by mail-oi0-f71.google.com with SMTP id u11-v6so14040510oif.22 for ; Mon, 20 Aug 2018 06:15:42 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id; bh=FGJ6OinG2o5MNtzAAIxmLg2x0Sk4C83iFYefcshJ0a8=; b=pd3/oPBJl8eDda69y8LBs9etol5mS7fhpwkN4DISHAC8LrEgQkH9c92dvg7xkwG721 9K+XwxOJKTe9S7bZ0OIgccygnWv2EPFl07VsuufNEcjFGOH+kgEkFGySOlgurmYmm0Ps hkClECysa2Bo94WbgE2eEAJAxR+M0Qw7h/x9cJSLRcw/u2GtdDmdmiy/U7V0/0npPD8L jePbKkGz9tzn55VIgXVs+dork9cmzj+GJUT+yZFFQBtAhcOYe3Rvp/kB3VtkNtnpD1+Y YFyxE5dDbZlxAIq1ZkigGieuYoT5WTiNYjoJJxtlWPFFPM+wD0rH74N+788nWMhEtDZr 9WAw== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of penguin-kernel@i-love.sakura.ne.jp designates 202.181.97.72 as permitted sender) smtp.mailfrom=penguin-kernel@i-love.sakura.ne.jp X-Gm-Message-State: AOUpUlFlehY7YIStbMrAdC9a9VHizkwPPM9STnC2N866yz5q2pr2RGu8 voFZT3nCDWpupEA7OWyeJ/eOrSBY9RO/6oOk2a+xu0naZBuv1oxHNPk/Rbr1iXgDrHX++76d8+/ shJTxvo9wZJqmuhOqkkuMBE1sp38ej22h3xPWdXHbSSufqUOqDKcdGAP//bExaLMbmA== X-Received: by 2002:aca:36c1:: with SMTP id d184-v6mr14749456oia.36.1534770942561; Mon, 20 Aug 2018 06:15:42 -0700 (PDT) X-Google-Smtp-Source: AA+uWPwBni4BWLZd7aU4N6thpCF1i8LqhU+r27vYgEgQvOHYe/73SccVZqtggcXTO+JZd5ijoaWv X-Received: by 2002:aca:36c1:: with SMTP id d184-v6mr14749413oia.36.1534770941797; Mon, 20 Aug 2018 06:15:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534770941; cv=none; d=google.com; s=arc-20160816; b=ens0Qv21bZYpm0+cJgTIXOKVSRivfggwCc15jJz0Hw8xh86lzJ4irKkmNwlbHme/iu aLfZrbCuAHx/aqilsf9SELk2u6UD6AjwfOi/1NH/jyXB1lK9wdKlFStjPez0fNSAWF7I 5stsodFr+tjoAz7dXYq+YrY0nUc1mUIabALhZvgOi3/Z/auFRm+i9zMFIIHLYaadaT0B xjL6hmQ4D3t8uOOMirJrjLZvuuHAEfCPBqmvua1Z1pV5xVEX2JxuksYBg0cdMjxtRWn4 2TulY+BgFusxMD0OcK4RGPiJgdP6rIREZ7ZfTXazZ0eHbQPLHksEG7nbD2zPz0VHbnTA m4xQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:date:subject:cc:to:from:arc-authentication-results; bh=FGJ6OinG2o5MNtzAAIxmLg2x0Sk4C83iFYefcshJ0a8=; b=dECBcSsckPZd7EbkUd6QrVssRAM8STRmtIG/aXW30x36OwIuAm1p73nxKJHXPpYrHn 5s11x7IUENDzd5oBxnPp161ErWuijP8eaie8VLSZV9+iz3RPXxJyFHaHD/bMmAU760xz j8vmfDSVdpUISa8kbWFWZyeNqpnBI9MfrIl1+Ms9THmx2y/STbnpLRzDyi458Yj6oWRm SvaSWWY9MlLOsCNbeHCqs0Z5EW+dgBgIUM2KWgy8DeSfw7PSqIaQT5A5q1Si0QZg8EDq YdqiL1lFIBg+Cm7gBN8sjtUeVRcp2K3/kJQO7iDvuVVeghHkbyu7kJ43GL/V1IH2a4+Y n91g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of penguin-kernel@i-love.sakura.ne.jp designates 202.181.97.72 as permitted sender) smtp.mailfrom=penguin-kernel@i-love.sakura.ne.jp Received: from www262.sakura.ne.jp (www262.sakura.ne.jp. [202.181.97.72]) by mx.google.com with ESMTPS id t62-v6si7786938oih.223.2018.08.20.06.15.41 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 20 Aug 2018 06:15:41 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of penguin-kernel@i-love.sakura.ne.jp designates 202.181.97.72 as permitted sender) client-ip=202.181.97.72; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of penguin-kernel@i-love.sakura.ne.jp designates 202.181.97.72 as permitted sender) smtp.mailfrom=penguin-kernel@i-love.sakura.ne.jp Received: from fsav403.sakura.ne.jp (fsav403.sakura.ne.jp [133.242.250.102]) by www262.sakura.ne.jp (8.15.2/8.15.2) with ESMTP id w7KAd2T0097811; Mon, 20 Aug 2018 19:39:03 +0900 (JST) (envelope-from penguin-kernel@I-love.SAKURA.ne.jp) Received: from www262.sakura.ne.jp (202.181.97.72) by fsav403.sakura.ne.jp (F-Secure/fsigk_smtp/530/fsav403.sakura.ne.jp); Mon, 20 Aug 2018 19:39:02 +0900 (JST) X-Virus-Status: clean(F-Secure/fsigk_smtp/530/fsav403.sakura.ne.jp) Received: from ccsecurity.localdomain (softbank060157066051.bbtec.net [60.157.66.51]) (authenticated bits=0) by www262.sakura.ne.jp (8.15.2/8.15.2) with ESMTPSA id w7KAcC0H097599 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Mon, 20 Aug 2018 19:39:02 +0900 (JST) (envelope-from penguin-kernel@I-love.SAKURA.ne.jp) From: Tetsuo Handa To: Andrew Morton Cc: Dmitry Vyukov , linux-mm@kvack.org, Michal Hocko , Greg Thelen , David Rientjes , Tetsuo Handa , syzbot Subject: [PATCH] mm, oom: OOM victims do not need to select next OOM victim unless __GFP_NOFAIL. Date: Mon, 20 Aug 2018 19:37:45 +0900 Message-Id: <1534761465-6449-1-git-send-email-penguin-kernel@I-love.SAKURA.ne.jp> X-Mailer: git-send-email 1.8.3.1 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: X-Virus-Scanned: ClamAV using ClamSMTP Commit 696453e66630ad45 ("mm, oom: task_will_free_mem should skip oom_reaped tasks") changed to select next OOM victim as soon as MMF_OOM_SKIP is set. But since OOM victims can try ALLOC_OOM allocation and then give up (if !memcg OOM) or can use forced charge and then retry (if memcg OOM), OOM victims do not need to select next OOM victim unless they are doing __GFP_NOFAIL allocations. This is a quick mitigation because syzbot is hitting WARN(1) caused by this race window [1]. More robust fix (e.g. make it possible to reclaim more memory before MMF_OOM_SKIP is set, wait for some more after MMF_OOM_SKIP is set) is a future work. [1] https://syzkaller.appspot.com/bug?id=ea8c7912757d253537375e981b61749b2da69258 Signed-off-by: Tetsuo Handa Reported-and-tested-by: syzbot --- mm/oom_kill.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mm/oom_kill.c b/mm/oom_kill.c index 412f434..421c0f6 100644 --- a/mm/oom_kill.c +++ b/mm/oom_kill.c @@ -1031,6 +1031,9 @@ bool out_of_memory(struct oom_control *oc) unsigned long freed = 0; enum oom_constraint constraint = CONSTRAINT_NONE; + if (tsk_is_oom_victim(current) && !(oc->gfp_mask & __GFP_NOFAIL)) + return true; + if (oom_killer_disabled) return false;