From patchwork Mon Jan 7 14:38:01 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Hocko X-Patchwork-Id: 10750665 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 11EB091E for ; Mon, 7 Jan 2019 14:39:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F180D28A3B for ; Mon, 7 Jan 2019 14:39:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E57A028A41; Mon, 7 Jan 2019 14:39:46 +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 D938A28A3B for ; Mon, 7 Jan 2019 14:39:45 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 119F08E002E; Mon, 7 Jan 2019 09:39:44 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 0CC2F8E0001; Mon, 7 Jan 2019 09:39:44 -0500 (EST) 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 E8A7D8E002E; Mon, 7 Jan 2019 09:39:43 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) by kanga.kvack.org (Postfix) with ESMTP id 8B99E8E0001 for ; Mon, 7 Jan 2019 09:39:43 -0500 (EST) Received: by mail-ed1-f70.google.com with SMTP id e12so376858edd.16 for ; Mon, 07 Jan 2019 06:39:43 -0800 (PST) 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:in-reply-to:references:mime-version :content-transfer-encoding; bh=LFZQrU8fTXYe+4yKyznILHyyYdOjuztNdiLALRdIzAY=; b=W/ot4HpxKJvhvMpRDTDZBLj3xrEQ/T+HWLa/jPrYU9TcnbnipBjs+/N9SEQpdbx6Dt qWqwLcZzIkoRMpj2FI0qFs22Ncf6hZiPKXdRuSWAJNH3n4vb8ILjFhrQLSbHAEcv0r2V SU8AHjVJzWZZjJAGwa/oMaSgW4IuEV9k1dQ6DHGlpbn2Idxna1rdxGoEzmymCoUbB3kb CjMTVXuzftP3z3iI2iuxKMp+f8+COy4LKIc47SVNGKWL4OJAn48rR4uXRhK76+y8mFRw cp3AttnlgIgBqsX1VR2ApDHi0KiyIIw8acoyK+MSUcg6HoC7hPd8UY3Dzr9C2YjSa5Lc fKAw== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of mstsxfx@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=mstsxfx@gmail.com; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Gm-Message-State: AA+aEWakuEzTEiQrC2gwokRHZgRXYgKSY88DPYbAVo+07FbhUo7GZ56E Zn5HmV6FeGOikbI6qpOJUFpLzNtZaDt1SdX5JvsUHTzjYYQToZ3DSTaD6EluyOPJDcuA9npZCi9 jmRUUYie5oDuaGl1BTlLlRX/39Y7384vfcQlOUeju7ioKzQKCKhDGCI7EADmxiGSVzUHDalaIUX hoornkkZ6z6U3PGbX2xCOKYrdegHnzR09b7hiAGEa8mKltUOzaByT40aXaLHZxgt5XQuTNBbwNS d4huGk3J1rEWValqsv7m5D9QY02ffbiX8jbwbqxBUU1V4kVfxJ+xhPeqOdWN+7p7BdlacMPNwzx su6g3ua2gYI2AwFK8659Mnat0e/DySjqu8W3yIR0RWCQfWDDHNqOhIJ3/ReLT3zyMkh3+DVqHw= = X-Received: by 2002:a50:8d8c:: with SMTP id r12mr55243304edh.105.1546871983057; Mon, 07 Jan 2019 06:39:43 -0800 (PST) X-Received: by 2002:a50:8d8c:: with SMTP id r12mr55243251edh.105.1546871982175; Mon, 07 Jan 2019 06:39:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546871982; cv=none; d=google.com; s=arc-20160816; b=NKe500z5fDDWEuOUh4/5wB8r1xa076SvuWXrfqZo3El3iJukubRoy7kVVThoKP7m+G cYFqDb0M/N6ZAGVkRXQZpf52sCGS3FUAnGH+EuUcnfROfe/u5n9+ZUgn0x9zmONvc99z DugQrnhNImK77F/4nW9fU7AfGV6jkzCDd9IcACwD5qwmYB4sONxP4bUN/3WtEtNAIEoX ZSRJnT1Hc0XI+iEQwBEl3yg8EgPuzRzdd7v7PlyRw9f7n2tqVkDXF1euLXxhSu12L4sP AZvGlngWUGkZKJ0cQaDpYQHBX7TgpLzD0ffhTI0ax8vG9hiZduW8xrA5SLwN9dWmY/Fq aOGQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=LFZQrU8fTXYe+4yKyznILHyyYdOjuztNdiLALRdIzAY=; b=nUz0XKxiuwFTORTl/Fw+pehkDNNPvpdZIPYE9Rd5z6oJ2/iTMvbpT9MZKql8U8wgCt H+U2oS4N2sXV8viRXWhJZJBUInMl3tg3eu/o+76PG5TdyRkHHgi/L2hs3gqe26Nt8o3O nqLTFgxfh620e98irNwzrrFmVk4Kd0FCUFpUB1/NJhN4vL6L3PMnJQZaVlRDW4ZvQ2Zm rxkedA7vhokeZvtVTbNyM/STjf9VeApuIYq0vhgOvoSF47RhL4QkMZp2+38kkpjsXdjd 0kpIa5VvmEzFlrGX1SPkJwRBcWPpTVfOmxpcLKGwe10zbSR5DLunME60ojbcvyjjIZ97 rtGA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of mstsxfx@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=mstsxfx@gmail.com; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id bz3-v6sor18549802ejb.17.2019.01.07.06.39.42 for (Google Transport Security); Mon, 07 Jan 2019 06:39:42 -0800 (PST) Received-SPF: pass (google.com: domain of mstsxfx@gmail.com designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; spf=pass (google.com: domain of mstsxfx@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=mstsxfx@gmail.com; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Google-Smtp-Source: AFSGD/XDwJtPft+7e+YBwwRMOEFJiiNj0lmF71HskZs7fiZ6HzWFIE7LfZHsN6DrG9+SFqQ6YZXLew== X-Received: by 2002:a17:906:d191:: with SMTP id c17-v6mr47364442ejz.27.1546871981554; Mon, 07 Jan 2019 06:39:41 -0800 (PST) Received: from tiehlicka.suse.cz (prg-ext-pat.suse.com. [213.151.95.130]) by smtp.gmail.com with ESMTPSA id l18sm29285813edq.87.2019.01.07.06.39.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 07 Jan 2019 06:39:40 -0800 (PST) From: Michal Hocko To: Cc: Tetsuo Handa , Johannes Weiner , Andrew Morton , LKML , Michal Hocko Subject: [PATCH 1/2] mm, oom: marks all killed tasks as oom victims Date: Mon, 7 Jan 2019 15:38:01 +0100 Message-Id: <20190107143802.16847-2-mhocko@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190107143802.16847-1-mhocko@kernel.org> References: <20190107143802.16847-1-mhocko@kernel.org> MIME-Version: 1.0 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 From: Michal Hocko Historically we have called mark_oom_victim only to the main task selected as the oom victim because oom victims have access to memory reserves and granting the access to all killed tasks could deplete memory reserves very quickly and cause even larger problems. Since only a partial access to memory reserves is allowed there is no longer this risk and so all tasks killed along with the oom victim can be considered as well. The primary motivation for that is that process groups which do not shared signals would behave more like standard thread groups wrt oom handling (aka tsk_is_oom_victim will work the same way for them). - Use find_lock_task_mm to stabilize mm as suggested by Tetsuo Signed-off-by: Michal Hocko --- mm/oom_kill.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/mm/oom_kill.c b/mm/oom_kill.c index f0e8cd9edb1a..0246c7a4e44e 100644 --- a/mm/oom_kill.c +++ b/mm/oom_kill.c @@ -892,6 +892,7 @@ static void __oom_kill_process(struct task_struct *victim) */ rcu_read_lock(); for_each_process(p) { + struct task_struct *t; if (!process_shares_mm(p, mm)) continue; if (same_thread_group(p, victim)) @@ -911,6 +912,11 @@ static void __oom_kill_process(struct task_struct *victim) if (unlikely(p->flags & PF_KTHREAD)) continue; do_send_sig_info(SIGKILL, SEND_SIG_PRIV, p, PIDTYPE_TGID); + t = find_lock_task_mm(p); + if (!t) + continue; + mark_oom_victim(t); + task_unlock(t); } rcu_read_unlock(); From patchwork Mon Jan 7 14:38:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Hocko X-Patchwork-Id: 10750667 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 E4C7091E for ; Mon, 7 Jan 2019 14:39:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D3EC828A3B for ; Mon, 7 Jan 2019 14:39:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C877928A41; Mon, 7 Jan 2019 14:39:48 +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 669CC28A3B for ; Mon, 7 Jan 2019 14:39:48 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6BC4C8E002F; Mon, 7 Jan 2019 09:39:45 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 671628E0001; Mon, 7 Jan 2019 09:39:45 -0500 (EST) 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 47FA28E002F; Mon, 7 Jan 2019 09:39:45 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-ed1-f69.google.com (mail-ed1-f69.google.com [209.85.208.69]) by kanga.kvack.org (Postfix) with ESMTP id D863A8E0001 for ; Mon, 7 Jan 2019 09:39:44 -0500 (EST) Received: by mail-ed1-f69.google.com with SMTP id e17so382088edr.7 for ; Mon, 07 Jan 2019 06:39:44 -0800 (PST) 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:in-reply-to:references:mime-version :content-transfer-encoding; bh=czsf4vL5FOcnDURNZogytxKTVT3D/fN437qEHjVuQNY=; b=USo/h3ljzJbudQR5TJDcXtmqqPB0DYsARtocgBZj6DyOwg85tCpJVcxw7vHNvyUSlP GP6/umpaFqjFWRb48c4bohAllvVijBTds6hKRpCLZOftlxr0MBd7itzRzVgrn9HSn1lm gZX03dNr8rtCjaJefYdy1pmT4uQfe/dHwlNwy2s0/zbP5meSDonfr5ZwDrNviX3zEHiC XLSLp55Ys3xKlJARk+Qs7rJS8+2vBCvNqJ/cobbtBT58ecxqwXNyMOMc9Sf7rxz2LpMG LNsz6Vil3vQgr5UJfA/vlVusR9LowaGDPXuLcQEXV38oNSCuiiNuYEdm72GSO2d4W+mt wzog== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of mstsxfx@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=mstsxfx@gmail.com; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Gm-Message-State: AA+aEWa27b7GHP9SyaEAlEWaCZeaJd9c6TOOpr3kuyCZ+fEogzA+60eV Q4iVU/FgpN+l+b1CyiJxGOyk7WuY0mJLVZXW5dWwSU7TsWLBAC5RTkj/LVdGrB+x/XqL+oY8Wwe MPKBEx/8C22ssT/ciN815fNeouj2deQsRlq+xj8Dz5pZiKDQpe5iT2YWKa3vzkqp0ADELX1w2Dw x4qlgckjcYYJh1zDgT4KV9WiT4q8W7N09CoWUHut7Ttdl8MPYsRINGUBBBjpHM3u/x1z8Ih6njI gNOEsb3MKL0Vnb2HR51qzbW2yBO6I8wh9zhfmLEZUg4/DqvpflCIr0oXoO45JLI+aE4ELCBDzsw yAU2qZOGicF+5CzkG22WmX5+VXlnQhn2SotjCxJAso5dD+cbvKeJwrc57Su5F4g8ANzf7Vfzsw= = X-Received: by 2002:a50:af21:: with SMTP id g30mr52882454edd.234.1546871984394; Mon, 07 Jan 2019 06:39:44 -0800 (PST) X-Received: by 2002:a50:af21:: with SMTP id g30mr52882407edd.234.1546871983534; Mon, 07 Jan 2019 06:39:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546871983; cv=none; d=google.com; s=arc-20160816; b=ctWSqK5wSw3VeNswPm39qsQbdIYvXNykYeoKtMbMdCWGNZSP7U7ROAHNvCRizMltsb YYe6VhLiRQ0KN93SC8+gj2nna1+lNtX6zwXZpc4+VNk3PXb6vmMqPhWxO+fTiAdGD603 Xr2udajZ/AEcW7U6ui7rJdG0kU+lDxh/b22ItrCHjX6qNken+tmvJZS1ArJntLvMGrgR /+reBphOu7W8JWr9zbxPKk5yeCMZRqrQCSHuyiiaTaA37IIcfBWj684eIYbUa+wphqcl AsYMtW7U2gazHdIt7SlLgq/7eBYT7ybgT0g/rOnKRFpArk8hSMjaNYBjbWrboeE6zVff DpTQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=czsf4vL5FOcnDURNZogytxKTVT3D/fN437qEHjVuQNY=; b=YtxeCmK05FIAeONnPDBY2HKOPe+YzneQuB5Ip0wT9Lh090fibY7PUCWBGlV/3dWvg7 d/U3JWr4KTtY5qg2HQXWox64k5fxbF8GuupjfhnjucZ7QpzoJcC9j8E3qYpUGQLfRntP yYICqGt5IcwbC4F4GTVnA8u7mFXbR5++DjEsyX+FMB+cJCcwwr1YOjkSYMPVpNCkHkkw V32xxFrAJbyOR2YvlorJB1QiGk+m1cPgPVughj2W4INXsJPflVmSPDGjxjFphRK5Vfk3 ZkOvp8fTs7u9Jn/kXcMteBeGaqLlGX6iyXT16uZBmlOGH2Yxj5+4E2XkuVzw3NXvvTYV U6gA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of mstsxfx@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=mstsxfx@gmail.com; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id a37sor36264614edd.23.2019.01.07.06.39.43 for (Google Transport Security); Mon, 07 Jan 2019 06:39:43 -0800 (PST) Received-SPF: pass (google.com: domain of mstsxfx@gmail.com designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; spf=pass (google.com: domain of mstsxfx@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=mstsxfx@gmail.com; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Google-Smtp-Source: AFSGD/Uhw9JeGaHha/JfMcZjkBf21wzOw/01k7ipnizHZJkKEM6lzU1I0tG3yeYB8iVCpINRJsmKrg== X-Received: by 2002:a50:d311:: with SMTP id g17mr55094523edh.187.1546871982911; Mon, 07 Jan 2019 06:39:42 -0800 (PST) Received: from tiehlicka.suse.cz (prg-ext-pat.suse.com. [213.151.95.130]) by smtp.gmail.com with ESMTPSA id l18sm29285813edq.87.2019.01.07.06.39.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 07 Jan 2019 06:39:41 -0800 (PST) From: Michal Hocko To: Cc: Tetsuo Handa , Johannes Weiner , Andrew Morton , LKML , Michal Hocko Subject: [PATCH 2/2] memcg: do not report racy no-eligible OOM tasks Date: Mon, 7 Jan 2019 15:38:02 +0100 Message-Id: <20190107143802.16847-3-mhocko@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190107143802.16847-1-mhocko@kernel.org> References: <20190107143802.16847-1-mhocko@kernel.org> MIME-Version: 1.0 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 From: Michal Hocko Tetsuo has reported [1] that a single process group memcg might easily swamp the log with no-eligible oom victim reports due to race between the memcg charge and oom_reaper Thread 1 Thread2 oom_reaper try_charge try_charge mem_cgroup_out_of_memory mutex_lock(oom_lock) mem_cgroup_out_of_memory mutex_lock(oom_lock) out_of_memory select_bad_process oom_kill_process(current) wake_oom_reaper oom_reap_task MMF_OOM_SKIP->victim mutex_unlock(oom_lock) out_of_memory select_bad_process # no task If Thread1 didn't race it would bail out from try_charge and force the charge. We can achieve the same by checking tsk_is_oom_victim inside the oom_lock and therefore close the race. [1] http://lkml.kernel.org/r/bb2074c0-34fe-8c2c-1c7d-db71338f1e7f@i-love.sakura.ne.jp Signed-off-by: Michal Hocko --- mm/memcontrol.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/mm/memcontrol.c b/mm/memcontrol.c index af7f18b32389..90eb2e2093e7 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -1387,10 +1387,22 @@ static bool mem_cgroup_out_of_memory(struct mem_cgroup *memcg, gfp_t gfp_mask, .gfp_mask = gfp_mask, .order = order, }; - bool ret; + bool ret = true; mutex_lock(&oom_lock); + + /* + * multi-threaded tasks might race with oom_reaper and gain + * MMF_OOM_SKIP before reaching out_of_memory which can lead + * to out_of_memory failure if the task is the last one in + * memcg which would be a false possitive failure reported + */ + if (tsk_is_oom_victim(current)) + goto unlock; + ret = out_of_memory(&oc); + +unlock: mutex_unlock(&oom_lock); return ret; } From patchwork Tue Jan 8 14:21:23 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tetsuo Handa X-Patchwork-Id: 10752121 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 D9D8713B5 for ; Tue, 8 Jan 2019 14:21:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C6C3A28D23 for ; Tue, 8 Jan 2019 14:21:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BB73828D3E; Tue, 8 Jan 2019 14:21:42 +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 8DF2528D1E for ; Tue, 8 Jan 2019 14:21:41 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 43C078E007C; Tue, 8 Jan 2019 09:21:40 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 3EC5F8E0038; Tue, 8 Jan 2019 09:21:40 -0500 (EST) 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 303608E007C; Tue, 8 Jan 2019 09:21:40 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-io1-f71.google.com (mail-io1-f71.google.com [209.85.166.71]) by kanga.kvack.org (Postfix) with ESMTP id 078EA8E0038 for ; Tue, 8 Jan 2019 09:21:40 -0500 (EST) Received: by mail-io1-f71.google.com with SMTP id k4so3350271ioc.10 for ; Tue, 08 Jan 2019 06:21:40 -0800 (PST) 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:subject:to:cc :references:from:message-id:date:user-agent:mime-version:in-reply-to :content-language:content-transfer-encoding; bh=GeYx/cHE3aToofbz8o04sW6xFi+UIWE+eS1U30rsmFw=; b=UVXxb1oi6QoqGe1uhZpieLHyS8NRAHVh6xsbu1vHXh6OeJApQ43CbUNVJQZp9DY8N1 l2hZOWeYSSmYq3XVJw2YcT/SBaG4rNYiMFmZUzbVasKK9a+OVXkL5HcXa7Q7B4736z7o 1bUipBEB9NVWM2Qd6yPEOQHIiolB5R2LMuyAB82mCA0c6vQuau5gRPzRap+AgIK78GnD 0XvdEHnYh+igTZ4XpbU9UXXAL+7vgEeaJnwEdgjjSPDq2YSvt2tDIThwfZkNvZ9YKkdP J9bnTj/l3/Ck2Qh5jr2pBtG7a9rY4sfoiAGzFqiHxtWTBY0rYgzPvuGN981ylo6jAyR9 KiPw== 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: AJcUukfFuUMYgqbdus9CBYYnn7/Qh+2Z7fIMHGFTli1Q/nJ4TveYIueM UC3AK3UkWssluXgS3GnKRLagIBQZIGpBvvp8wvGzjBgUMMDgo/Hzdge8bR9IF/TD9gy5Aj41D6Q 3H6Bsh7My3qyZ9k/lcaJps+E3wHiLNfc3su8PkVAj1EeMKCUnQRp3JyEwNalgk/DLEA== X-Received: by 2002:a5e:9e4a:: with SMTP id j10mr1304282ioq.165.1546957299699; Tue, 08 Jan 2019 06:21:39 -0800 (PST) X-Google-Smtp-Source: ALg8bN4SLa62XadwugQQXGqaAxpT7SmlZL+mwpkhsb3twBb4vWhrn12zIcNmvCq0XV5F4gKZmqNq X-Received: by 2002:a5e:9e4a:: with SMTP id j10mr1304212ioq.165.1546957298431; Tue, 08 Jan 2019 06:21:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546957298; cv=none; d=google.com; s=arc-20160816; b=mv/Ns766JDdh93LGDASLMj4koqma+lOiv+zrhKfb8Q0pIhyQV4w7ACOT0sygJj4zHV B3ZiTgjd5tilansyK3C+gJwtIBTX26l+KbMM49YZh3HtGR8oufsaI834J7Phh6+hzXD3 ptMscuPHCnUaD2IY27MzT4KwstKlTY7zN2ZhdfkOd0EDleuxWCOifFIXooY73aPk3c9r L5Y9ZOS3MWfVU8TzVOAFFGAZsE19dMipcTVgXBdrLYNE1v4XaMtc45v6iaH45g+Is4fo lgrOTx0CtbrpISiE4ggPRQQTNE2YN4SkOr9Le/wixFus7zX84WJHGN02MVsH6lEPY50C 4bLQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:content-language:in-reply-to:mime-version :user-agent:date:message-id:from:references:cc:to:subject; bh=GeYx/cHE3aToofbz8o04sW6xFi+UIWE+eS1U30rsmFw=; b=aSfkhASj57sW6tZwUJbWsEEUKMc3DJEKZqJ5JLqlDwU8x++KHWI1F/ugjf8wYVdL7A ny7/EI6MsNME58p5tgGeV7tejvWUa0h/ku0/sLk3VnJ33uTV1VZW7NRpxjx2e9O/pVVR B/dpUk4jLcJs54t7+O8NxN6EsIGPbLkL+1/w9jTEgQW9l/F1zp2eUDoyQpbpYPszATYK S7ShoB88kRWsr+dTAnUlRev6mlg8gUh4YPT7rKicMBqD+wkbQ5BVLMY8yZdnVWWEgpua a0164QT0IiMHJOORzE2H0UBwS8Y058k+HcwEjuoNKrx5vUI/oad3EkbelcDg5WiwsKyn T5kw== 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 n128si6999665itc.40.2019.01.08.06.21.37 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 08 Jan 2019 06:21:38 -0800 (PST) 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 fsav303.sakura.ne.jp (fsav303.sakura.ne.jp [153.120.85.134]) by www262.sakura.ne.jp (8.15.2/8.15.2) with ESMTP id x08ELVPf097884; Tue, 8 Jan 2019 23:21:31 +0900 (JST) (envelope-from penguin-kernel@i-love.sakura.ne.jp) Received: from www262.sakura.ne.jp (202.181.97.72) by fsav303.sakura.ne.jp (F-Secure/fsigk_smtp/530/fsav303.sakura.ne.jp); Tue, 08 Jan 2019 23:21:31 +0900 (JST) X-Virus-Status: clean(F-Secure/fsigk_smtp/530/fsav303.sakura.ne.jp) Received: from [192.168.1.8] (softbank126126163036.bbtec.net [126.126.163.36]) (authenticated bits=0) by www262.sakura.ne.jp (8.15.2/8.15.2) with ESMTPSA id x08ELPLx097838 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NO); Tue, 8 Jan 2019 23:21:31 +0900 (JST) (envelope-from penguin-kernel@i-love.sakura.ne.jp) Subject: [PATCH 3/2] memcg: Facilitate termination of memcg OOM victims. To: Michal Hocko , linux-mm@kvack.org Cc: Johannes Weiner , Andrew Morton , LKML References: <20190107143802.16847-1-mhocko@kernel.org> From: Tetsuo Handa Message-ID: Date: Tue, 8 Jan 2019 23:21:23 +0900 User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.4.0 MIME-Version: 1.0 In-Reply-To: <20190107143802.16847-1-mhocko@kernel.org> Content-Language: en-US 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 From: Tetsuo Handa If memcg OOM events in different domains are pending, already OOM-killed threads needlessly wait for pending memcg OOM events in different domains. An out_of_memory() call is slow because it involves printk(). With slow serial consoles, out_of_memory() might take more than a second. Therefore, allowing killed processes to quickly call mmput() from exit_mm() from do_exit() will help calling __mmput() (which can reclaim more memory than the OOM reaper can reclaim) quickly. Signed-off-by: Tetsuo Handa --- mm/memcontrol.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 90eb2e2..a7d3ba9 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -1389,14 +1389,19 @@ static bool mem_cgroup_out_of_memory(struct mem_cgroup *memcg, gfp_t gfp_mask, }; bool ret = true; - mutex_lock(&oom_lock); - /* - * multi-threaded tasks might race with oom_reaper and gain - * MMF_OOM_SKIP before reaching out_of_memory which can lead - * to out_of_memory failure if the task is the last one in - * memcg which would be a false possitive failure reported + * Multi-threaded tasks might race with oom_reaper() and gain + * MMF_OOM_SKIP before reaching out_of_memory(). But if current + * thread was already killed or is ready to terminate, there is + * no need to call out_of_memory() nor wait for oom_reaoer() to + * set MMF_OOM_SKIP. These three checks minimize possibility of + * needlessly calling out_of_memory() and try to call exit_mm() + * as soon as possible. */ + if (mutex_lock_killable(&oom_lock)) + return true; + if (fatal_signal_pending(current)) + goto unlock; if (tsk_is_oom_victim(current)) goto unlock;