From patchwork Wed Aug 8 07:13:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Hocko X-Patchwork-Id: 10559577 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 CF82E14E5 for ; Wed, 8 Aug 2018 07:13:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B9092289B8 for ; Wed, 8 Aug 2018 07:13:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AC3FA289F0; Wed, 8 Aug 2018 07:13:20 +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 C6DCB289B8 for ; Wed, 8 Aug 2018 07:13:19 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 61E176B0008; Wed, 8 Aug 2018 03:13:18 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 5AB6F6B000C; Wed, 8 Aug 2018 03:13:18 -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 498066B000D; Wed, 8 Aug 2018 03:13:18 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf1-f200.google.com (mail-pf1-f200.google.com [209.85.210.200]) by kanga.kvack.org (Postfix) with ESMTP id 0A4756B0008 for ; Wed, 8 Aug 2018 03:13:18 -0400 (EDT) Received: by mail-pf1-f200.google.com with SMTP id e15-v6so910349pfi.5 for ; Wed, 08 Aug 2018 00:13:18 -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; bh=W0xqvW0EvL/CI/F/azncXzllRxqrQN6A5K+UrpaDbZ8=; b=GkoMXlr2lZFpR3WP4dKkYoYIX2bQlXULNtuM5IvQn/fjpcK5L1Zf7Z/Kb9c37rKsfD 4mqCxHTWIkYekvTmVl1efdyNx3+W7f7jYbf4Cac5Q4YwNazcq1KrglhkRBzTiqItSWMZ IuJ+6E+90Frktyi0dPA5+WHJw2OidCMByzVLkRs7Zg7XlbUVcDZ2Dh6twAQWvw3+nleH BYTPYOV9Kaumzp8oYLZALfEeWczN9LR64jsyzytUiBBsDYp2/JHAfZn4LV8uauL1ZRqr X+xE+FjHtUihwEudxzDYLpoCui7q0pdUGWAO0qUHanEbqE9htcnxuWHQnViA6P3dIPcA 11Iw== 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: AOUpUlFHfStwaVFKmRtW9buCyfjy9LcVHNQwV4YIWjp42gm0xI+7unT5 hE6MkXxfo9ZTzMfXHRfGU+QkjjE3V6s+Dg3uktAqHcBTATuUsYFh+uKVYQb/n1bbAZKpG5cSc+F Ctl6Fb7oHcwMZltKhi8lvjqiRMPIDbu+mPwFpHafaPCFOq0zSnQB0SUWO3LvvSCriKP6UhdGBf2 pmlpa3lvX2gSN6Mjt8Lz8bA1Z7QRoakln/I7rFswh8GTSyMYJljtim2l5M88nSc2GEy97rFo98/ xoKZ21lf4u+WKeRLHgiiYVVChj1K7UYq8Q2afWVm41DpFMxHPL8uTVhGbJCOSTxzmN0ZGjJFR0r dtDBCsSiB8qfjSZjvxMvyvwFtMm3abq+5HwCQ539xyb8i8u+DRWdSHCCafddbBD2xspvFHxxTA= = X-Received: by 2002:a17:902:7106:: with SMTP id a6-v6mr1485847pll.28.1533712397718; Wed, 08 Aug 2018 00:13:17 -0700 (PDT) X-Received: by 2002:a17:902:7106:: with SMTP id a6-v6mr1485819pll.28.1533712396974; Wed, 08 Aug 2018 00:13:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533712396; cv=none; d=google.com; s=arc-20160816; b=nRbe6uaiu9ftGPbiaFXFKvOPrQnhJ7lwYQxJAsWJdnehFoI/nysO8RpY2lfpwhogZz EouSdl9EMXT/vLQytnC/eJ6pmskVDQJOqdAehnxnMFuNReH+2h67nbUiSQVy1P+oYBaj OQyNXz6wZB9rW9ug4r2pi065UmOWOCMt9JjWWeroUPyYJspmG2ZrXhQVnOD/hM60rghA 1hthK8pvM4kM67k5cOYQFH6E53unqNZPVGmLc2BKajTvgvuON1Og+WJy5hwTjMYZKCQt IEF+c3KlkPAo1tkA9noiT5oHVs9JJrVPCU0JsEqDp9BxHr+uoOMERgemkb13rJVNuhVv I04Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=W0xqvW0EvL/CI/F/azncXzllRxqrQN6A5K+UrpaDbZ8=; b=p5oDyExl0fp4nvbTuU4cBPZjzh1kO/TxXqEeYtGDXT5gZEYGxR/Lk5jW1KGtwKHcA4 4oULElRB9dyuPkJ2p6UDDaTJODnNb17rwl9V/JtWmZZzFdyilksRp1bJDsxVz53+Bf24 HK1QV7UVsVDUHpqbKd4fLB/+Khn6FGvZ4LqytVt2qOjXSTK0Rp13TcoueWWZ6z2n1zQt JK8MxEKhUAi/zLoSEktwves7NiEIOu0WXxOr+TZO4kk6j8bgrprffi/Ej+v2pR9EyZUb DSnr1q2Y6s0P0ZMub0Tn2fL+sVvjFALGqtA/QHZGo/Iiwa9O6hS0mtZ16SHbnBpp98zH yOZA== 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 s11-v6sor914133pgi.138.2018.08.08.00.13.16 for (Google Transport Security); Wed, 08 Aug 2018 00:13:16 -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: AA+uWPzNvkVbrQDhucHPBaw4KOF7FkMgFt2tEuz3QlBtHv2Vfti2bvYMsxNKNLO6tpmFXFdCEDo2Cg== X-Received: by 2002:a63:b705:: with SMTP id t5-v6mr1377740pgf.45.1533712396705; Wed, 08 Aug 2018 00:13:16 -0700 (PDT) Received: from tiehlicka.suse.cz (prg-ext-pat.suse.com. [213.151.95.130]) by smtp.gmail.com with ESMTPSA id n9-v6sm5517945pfg.21.2018.08.08.00.13.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 08 Aug 2018 00:13:16 -0700 (PDT) From: Michal Hocko To: Johannes Weiner Cc: Andrew Morton , Vladimir Davydov , Greg Thelen , Tetsuo Handa , Dmitry Vyukov , , LKML , Michal Hocko Subject: [PATCH 2/2] memcg, oom: emit oom report when there is no eligible task Date: Wed, 8 Aug 2018 09:13:01 +0200 Message-Id: <20180808071301.12478-3-mhocko@kernel.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180808071301.12478-1-mhocko@kernel.org> References: <20180808064414.GA27972@dhcp22.suse.cz> <20180808071301.12478-1-mhocko@kernel.org> 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 Johannes had doubts that the current WARN in the memcg oom path when there is no eligible task is not all that useful because it doesn't really give any useful insight into the memcg state. My original intention was to make this lightweight but it is true that seeing a stack trace will likely be not sufficient when somebody gets back to us and report this warning. Therefore replace the current warning by the full oom report which will give us not only the back trace of the offending path but also the full memcg state - memory counters and existing tasks. Suggested-by: Johannes Weiner Signed-off-by: Michal Hocko Signed-off-by: Johannes Weiner Acked-by: Michal Hocko --- include/linux/oom.h | 2 ++ mm/memcontrol.c | 24 +++++++++++++----------- mm/oom_kill.c | 8 ++++---- 3 files changed, 19 insertions(+), 15 deletions(-) diff --git a/include/linux/oom.h b/include/linux/oom.h index a16a155a0d19..7424f9673cd1 100644 --- a/include/linux/oom.h +++ b/include/linux/oom.h @@ -133,6 +133,8 @@ extern struct task_struct *find_lock_task_mm(struct task_struct *p); extern int oom_evaluate_task(struct task_struct *task, void *arg); +extern void dump_oom_header(struct oom_control *oc, struct task_struct *victim); + /* sysctls */ extern int sysctl_oom_dump_tasks; extern int sysctl_oom_kill_allocating_task; diff --git a/mm/memcontrol.c b/mm/memcontrol.c index c80e5b6a8e9f..3d7c90e6c235 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -1390,6 +1390,19 @@ static bool mem_cgroup_out_of_memory(struct mem_cgroup *memcg, gfp_t gfp_mask, mutex_lock(&oom_lock); ret = out_of_memory(&oc); mutex_unlock(&oom_lock); + + /* + * under rare race the current task might have been selected while + * reaching mem_cgroup_out_of_memory and there is no other oom victim + * left. There is still no reason to warn because this task will + * die and release its bypassed charge eventually. + */ + if (tsk_is_oom_victim(current)) + return ret; + + pr_warn("Memory cgroup charge failed because of no reclaimable memory! " + "This looks like a misconfiguration or a kernel bug."); + dump_oom_header(&oc, NULL); return ret; } @@ -1706,17 +1719,6 @@ static enum oom_status mem_cgroup_oom(struct mem_cgroup *memcg, gfp_t mask, int if (mem_cgroup_out_of_memory(memcg, mask, order)) return OOM_SUCCESS; - /* - * under rare race the current task might have been selected while - * reaching mem_cgroup_out_of_memory and there is no other oom victim - * left. There is still no reason to warn because this task will - * die and release its bypassed charge eventually. - */ - if (tsk_is_oom_victim(current)) - return OOM_SUCCESS; - - WARN(1,"Memory cgroup charge failed because of no reclaimable memory! " - "This looks like a misconfiguration or a kernel bug."); return OOM_FAILED; } diff --git a/mm/oom_kill.c b/mm/oom_kill.c index 104ef4a01a55..8918640fcb85 100644 --- a/mm/oom_kill.c +++ b/mm/oom_kill.c @@ -428,7 +428,7 @@ static void dump_tasks(struct mem_cgroup *memcg, const nodemask_t *nodemask) rcu_read_unlock(); } -static void dump_header(struct oom_control *oc, struct task_struct *p) +void dump_oom_header(struct oom_control *oc, struct task_struct *p) { pr_warn("%s invoked oom-killer: gfp_mask=%#x(%pGg), order=%d, oom_score_adj=%hd\n", current->comm, oc->gfp_mask, &oc->gfp_mask, oc->order, @@ -945,7 +945,7 @@ static void oom_kill_process(struct oom_control *oc, const char *message) task_unlock(p); if (__ratelimit(&oom_rs)) - dump_header(oc, p); + dump_oom_header(oc, p); pr_err("%s: Kill process %d (%s) score %u or sacrifice child\n", message, task_pid_nr(p), p->comm, points); @@ -1039,7 +1039,7 @@ static void check_panic_on_oom(struct oom_control *oc) /* Do not panic for oom kills triggered by sysrq */ if (is_sysrq_oom(oc)) return; - dump_header(oc, NULL); + dump_oom_header(oc, NULL); panic("Out of memory: %s panic_on_oom is enabled\n", sysctl_panic_on_oom == 2 ? "compulsory" : "system-wide"); } @@ -1129,7 +1129,7 @@ bool out_of_memory(struct oom_control *oc) select_bad_process(oc); /* Found nothing?!?! Either we hang forever, or we panic. */ if (!oc->chosen_task && !is_sysrq_oom(oc) && !is_memcg_oom(oc)) { - dump_header(oc, NULL); + dump_oom_header(oc, NULL); panic("Out of memory and no killable processes...\n"); } if (oc->chosen_task && oc->chosen_task != INFLIGHT_VICTIM)