From patchwork Mon Oct 22 07:13:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Hocko X-Patchwork-Id: 10651771 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 846461508 for ; Mon, 22 Oct 2018 07:13:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6FC49201A4 for ; Mon, 22 Oct 2018 07:13:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 63A9120499; Mon, 22 Oct 2018 07:13: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 E1E10201A4 for ; Mon, 22 Oct 2018 07:13:45 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 40BF86B0008; Mon, 22 Oct 2018 03:13:44 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 3BA736B000D; Mon, 22 Oct 2018 03:13:44 -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 2D1846B000C; Mon, 22 Oct 2018 03:13:44 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pl1-f200.google.com (mail-pl1-f200.google.com [209.85.214.200]) by kanga.kvack.org (Postfix) with ESMTP id E1C366B0007 for ; Mon, 22 Oct 2018 03:13:43 -0400 (EDT) Received: by mail-pl1-f200.google.com with SMTP id w12-v6so17638894plp.9 for ; Mon, 22 Oct 2018 00:13:43 -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:in-reply-to:references:mime-version :content-transfer-encoding; bh=nh6TfIAAE16IGcEuFepCvkCmMAK/HAXyj6StssKZLCY=; b=ZLyfU27m3hWZM4RvBsH3kuMzW4n4tDpNs7Fn4yRa9RwS4UAvAhMSRkiyYqI5lysLcT mXklZGKNDlBFDTHLRqcaafkM6t++x+t7sZTy4LBI2bqmHKBZZdqGPq3uoXnYr9f5ZnmM 599JmiBYnvnuiOhxUgeQt/A60mlEdAT623eq0XCSgt+KDn4fZRxnjwQ0PKFhARhK83uM ymUO1Cy37P083dnR5FH3y5bxiEAKkAJQoNMfsG0EIyG6lxgnoT4hroV7lHjEbs9vsyYL JV0/aDMtkFyulhBpxgR8Ao99M9TaAMx63FO0/j+AXyR8Oh5HyOFV4yncwrWlIExzsQ9Z zT3g== 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: AGRZ1gLwCxNhqrivD8nt4J+nWpNH6GQHHaQr8DsLQzlbBn1oG1+ShKyN sJyWyW0BeOSklWEK8kTpJqYA8jFPJdijtGjSeo0GST5iIRZ1V2uAwwxEOFJQXi/Xgvv6DXebgrn RSlqqkijVwteozc92wLMk442PXEshajLxRdMUHBv9qaeBU+Ha78tyw7owKXJtMTejb304RpEC/L JT9QkmRaKs8yyhoqW2ojTtEzNzrF/WCdKYnCVu9YFXkS6BsOst5iIYJL/FymbkAznFnq8x0mPkJ A9ZeDS7rJcCrXvMWAjw+cUhJJYuqUe9z1yYcDy5MxyxoCPUOadnw+3KaSX8UcVpAzWHm/3LhfWd s/NfFJlXslT50DfHm4B0Q5+j4S22WM+661CNsjIjTJGo3SzdeWqQUEP+KTnErM0fOSgMyxzNmg= = X-Received: by 2002:a63:2045:: with SMTP id r5-v6mr6668337pgm.328.1540192423533; Mon, 22 Oct 2018 00:13:43 -0700 (PDT) X-Received: by 2002:a63:2045:: with SMTP id r5-v6mr6668309pgm.328.1540192422822; Mon, 22 Oct 2018 00:13:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540192422; cv=none; d=google.com; s=arc-20160816; b=sQjxamK98tFD9RyxpQ3Umou7upK+JsZN+iOTHL0mhJVlP8D5eFE1826d0HqnBdgx3r BKrb2vHwbI9ZqIg/2Yb2xugVZtiwVTUBgCrgy/d22TZW++gDul22CXfsLJ+nFZGZPY8N csFG6pdF5QTyR0kJXHxMdStZnExfUprXnkMZMvNaD5RWz2awbGWT493/gHYJ7/l8hY0l Zj41iVl4AJIxG2a/umlqFSrNJpJHzCjbzkHJOZC0UQBy0pMqktewsOa0+55S9UJ2mNqR +CoGDU0jIX/GnYDMU467Y3kfe927vXsclROujf5WFokUkNCdogDYwAlxUVu0/buWX23g D4rg== 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=nh6TfIAAE16IGcEuFepCvkCmMAK/HAXyj6StssKZLCY=; b=qDjMnaGmZMnpPYHAKvJ0RbPv6iywjUz6NALOq08Gw1rp55VEeyUTTUREWBUqjipdyY xoOaBGnem6/tnacYHi8qL1dClILYIAxbv/1PXq8ThELw9Bow+7aRSnD/QoHBCiD/9mVw fDtmausWgIcmYu5ucxubKmdTpthpOIdrqAT0jqDoAQ3psCfMy6Q1omVCaf1o1Gk//Jvx /s8R+DCjti7YAWyO7vaPxpn9Y5bkf4mkSxa9Jl7jH2XCLDi4vs6B6fH3J3q0LkplcFhL KlnZIQAsTZBRy+zeiavFfkOLagAK3gRg7pJkmUa3C80OUX0lQUKDYrlQ5hOzRERlGYSR v0sA== 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 e2-v6sor20005698pfb.55.2018.10.22.00.13.42 for (Google Transport Security); Mon, 22 Oct 2018 00:13:42 -0700 (PDT) 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: ACcGV61sNTv2hP9X+aRVQzT807Pkr7WqK6I4GYWbREGx1dxf5Pui9ID4vSxD8kgaVDsPxeQBnUwtfw== X-Received: by 2002:a62:ca4d:: with SMTP id n74-v6mr43743422pfg.10.1540192422214; Mon, 22 Oct 2018 00:13:42 -0700 (PDT) Received: from tiehlicka.suse.cz (prg-ext-pat.suse.com. [213.151.95.130]) by smtp.gmail.com with ESMTPSA id c79-v6sm38097542pfc.92.2018.10.22.00.13.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 22 Oct 2018 00:13:41 -0700 (PDT) From: Michal Hocko To: Cc: Johannes Weiner , Tetsuo Handa , David Rientjes , Andrew Morton , LKML , Michal Hocko Subject: [RFC PATCH 1/2] mm, oom: marks all killed tasks as oom victims Date: Mon, 22 Oct 2018 09:13:22 +0200 Message-Id: <20181022071323.9550-2-mhocko@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181022071323.9550-1-mhocko@kernel.org> References: <20181022071323.9550-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). Signed-off-by: Michal Hocko --- mm/oom_kill.c | 1 + 1 file changed, 1 insertion(+) diff --git a/mm/oom_kill.c b/mm/oom_kill.c index f10aa5360616..188ae490cf3e 100644 --- a/mm/oom_kill.c +++ b/mm/oom_kill.c @@ -898,6 +898,7 @@ static void __oom_kill_process(struct task_struct *victim) if (unlikely(p->flags & PF_KTHREAD)) continue; do_send_sig_info(SIGKILL, SEND_SIG_FORCED, p, PIDTYPE_TGID); + mark_oom_victim(p); } rcu_read_unlock(); From patchwork Mon Oct 22 07:13:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Hocko X-Patchwork-Id: 10651773 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 E4C82109C for ; Mon, 22 Oct 2018 07:13:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CECE0201A4 for ; Mon, 22 Oct 2018 07:13:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C2B8C2881A; Mon, 22 Oct 2018 07:13: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 59408201A4 for ; Mon, 22 Oct 2018 07:13:48 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9D9086B000C; Mon, 22 Oct 2018 03:13:46 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 9873C6B000E; Mon, 22 Oct 2018 03:13:46 -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 8A5746B0010; Mon, 22 Oct 2018 03:13:46 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pl1-f197.google.com (mail-pl1-f197.google.com [209.85.214.197]) by kanga.kvack.org (Postfix) with ESMTP id 38A3C6B000C for ; Mon, 22 Oct 2018 03:13:46 -0400 (EDT) Received: by mail-pl1-f197.google.com with SMTP id t18-v6so21565380plo.16 for ; Mon, 22 Oct 2018 00:13:46 -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:in-reply-to:references:mime-version :content-transfer-encoding; bh=FBCBxQHOTmvZgHJl60t6jyJTwJfcDyQfW3eSyeZ8neA=; b=QCyoF/3WtrND+xiQTWxskOqxXN6dNxjVRjpmDqcunTkmHHpO5X/OyHxVrSf9TNKU65 Cu1rQ7k86zi70PnKqCIYerY+xnAHnXEUnkzOHz6rlFPuLVd3m533ysF1McLNooRGZ5vy d6sCdNOnwFZZgGxOr4pxObWPzSe2nnn1sEPtMgPj1+DDHvALFBSZeMtQijfyMm3t4hJt nv8Z9C22IcUsCp3dSyXpYnKXa/CDYGRT4n6aFyftpl2H3aLR6wMknr3uIEHDMYBqxsHI /UoMoOUC61zMOhWFd6Pgqb+rj+sGcQz6d9qZkhkh7LBVhFJsBmQQGZE17+O0F96/ndw2 Y4wA== 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: ABuFfohIJGi1Jgysog1iDS0EdKkSs6QyaaTZRJlk4bhCym4fxDdgPCjE yFqEYqcmHTt9gZN5CZ+58SImPsflYgcPIclU9XC3nUvDtjzt8v9SEOsY9oOlMW3/VaJIzNu/Na/ xNQimJEnbs070vEgnIhlSlf8sH+XWM/m6C3Nx/FU/UiTF44uPJy1lgDD88YYiQOv9ysfv2wQFP8 bgii7Btd9GofQotolDvrXhsZ1qweu0lF5LhDLOAC3RWv3PHMxgW+yvpEcc0F8zeBU4umiYosXOI eyOZBaSOuGEBqpoj2xHg/MOTYOfNk0603J7HGL+1ymskuUEp36Tji3i02oTBV6ucSpOmfvEFDp4 4KZVDNtYcOVvbrcbFzgYaMxk+Pz2M4+E22bV0K2piayaINxBalvMK36dzD/PkUvVD3f0lxOGTw= = X-Received: by 2002:a62:8f0c:: with SMTP id n12-v6mr45039516pfd.172.1540192425911; Mon, 22 Oct 2018 00:13:45 -0700 (PDT) X-Received: by 2002:a62:8f0c:: with SMTP id n12-v6mr45039478pfd.172.1540192425063; Mon, 22 Oct 2018 00:13:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540192425; cv=none; d=google.com; s=arc-20160816; b=QfjeGMSetl3xXivHljwN3sDw4pPXAUD/io9N32c5gWu7uiJvOwUWogJ1n4exMlP42p STzzi8y/Qkllj2JnG5nQUw/ZV2eZTTNoFED9L9Fd4YXD3+eHZqSuKB5JLOqPtQh5YG9S Lg6WUskGUQ9GLWCLMxrY+RPT86pUDcP3TZ66J0Lrhg48PgA+4q4r0jxrQ+46WI3o6ZEj QFiWGOCklEPqzE5Os1/JbHU6Fl2Z1b8RPL8/83Q5RSfRWe8PQPWGyFZ6KBRc8XmwtxyA FvDeoqTiGJsdErzvvctqtVCBXnI5MQvJn7VatAlgjhjWW9SO1ObsMVc961T9m7omKGJY alpg== 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=FBCBxQHOTmvZgHJl60t6jyJTwJfcDyQfW3eSyeZ8neA=; b=XVcQ/wtW47jjWmTcdCWZPdSzCBn6ifJIKENrDq23SL6woKxi4j3S1AJL90oBs4rfxw EQAx64dS+s8MZFxMBVJqxXGAPy2gD8blVQrlQyes1e0nyeSuGNewQp3BdwgVMyn8J9dc alMAC9jCvteDz9j16b2EX1t3FQt08phPM79d6sBuGbrCZVVpTgI6fbarYEEkzmFEff+y wEgSUy369hzNYavkymnqUnwTZtSVWiLfTaQzHPnlqFjX33kr31wZWMCjsLA03xCMhU1L lU/eSRsj+ssS7WfJrDAuE6LPXacGV9/RXMhc8S9pOKLNvB5Fu2CiVA71OqwBYoRI+5l/ H5rw== 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 19-v6sor20803810pft.4.2018.10.22.00.13.44 for (Google Transport Security); Mon, 22 Oct 2018 00:13:45 -0700 (PDT) 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: ACcGV6064Z1dWqa7QMCXfgEb9cpfEDaa6ZH2gbgOOmik96tlPssDIV7b2W3tmlzucX76u01TUKPNKw== X-Received: by 2002:a62:569d:: with SMTP id h29-v6mr16163789pfj.42.1540192424428; Mon, 22 Oct 2018 00:13:44 -0700 (PDT) Received: from tiehlicka.suse.cz (prg-ext-pat.suse.com. [213.151.95.130]) by smtp.gmail.com with ESMTPSA id c79-v6sm38097542pfc.92.2018.10.22.00.13.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 22 Oct 2018 00:13:43 -0700 (PDT) From: Michal Hocko To: Cc: Johannes Weiner , Tetsuo Handa , David Rientjes , Andrew Morton , LKML , Michal Hocko Subject: [RFC PATCH 2/2] memcg: do not report racy no-eligible OOM tasks Date: Mon, 22 Oct 2018 09:13:23 +0200 Message-Id: <20181022071323.9550-3-mhocko@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181022071323.9550-1-mhocko@kernel.org> References: <20181022071323.9550-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 Signed-off-by: Tetsuo Handa Signed-off-by: Tetsuo Handa --- mm/memcontrol.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/mm/memcontrol.c b/mm/memcontrol.c index e79cb59552d9..a9dfed29967b 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -1380,10 +1380,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; }