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;