From patchwork Fri May 18 08:40:51 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?56a56Iif6ZSu?= X-Patchwork-Id: 10408743 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 7D2B2602CB for ; Fri, 18 May 2018 08:41:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6C33028846 for ; Fri, 18 May 2018 08:41:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 60D8D288B4; Fri, 18 May 2018 08:41:07 +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=-3.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, 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 3934128846 for ; Fri, 18 May 2018 08:41:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 484C36B059C; Fri, 18 May 2018 04:41:05 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 434F66B059D; Fri, 18 May 2018 04:41:05 -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 2FFA46B059E; Fri, 18 May 2018 04:41:05 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pl0-f71.google.com (mail-pl0-f71.google.com [209.85.160.71]) by kanga.kvack.org (Postfix) with ESMTP id DDE516B059C for ; Fri, 18 May 2018 04:41:04 -0400 (EDT) Received: by mail-pl0-f71.google.com with SMTP id t5-v6so4655481ply.13 for ; Fri, 18 May 2018 01:41:04 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id; bh=ODH7C7irF56rT8QNA6ylMSXTZonfbntxcJZMqPafer0=; b=E6hW/QXQ8pfIe5oMV6QEx54rKXVpxfgG3MS2jgJiQixPlLziIF0vSyMWBBRUDD9r6M OfwN8Po7+JatkcXGw/GXEnGM3wtTG6WyY71lKOiJlEdrdJRiwXKUYsmzDm/HI4fXm8ia zfe5nG2eH4qNnEAyyqYsF6aJ9xaDQZkoT4GnEEQPSDP0EIwvd2W9TF0yk2wrVHrAo7X/ sznXFb7yy3pMcO9EaTz6jyvaZ06CgrZRM8z+hfJCH8I7LS3mMDEwsu1CkbnnFIK3Ziv/ +8rruHA7r9ZNEMpIuwMp3G1VApiuFSJxPYh6nlEYExixN+znequVvxxpR/DCEqLO3wt4 RMFA== X-Gm-Message-State: ALKqPwcn7qVtdne635zXInq/xuvAOlOVFwaWS5ifnp/YbXgytT5UDOMO YQXX14SjuUunozrTuF54SbCLlKf1JJVZlxIeKCoT2xWpwnQyo5+wlQBHYGsOengwzMgXLTQ7WIu 5PKTr2XjyzMfkJn9UPrXkumqLKhAwRKFBB17aOVP/Q+rUr7U78FZM+AgCU4592n3Utf9D355f+u YRgR+5yfOI0h/OGf25qd9Qynoow7m5XSa/VXiLY956GJfHrEMyduxswmWcsqdIKA+kK44Bbxms/ Tze2v8FhB3jtMk084Ud8kfumnV5WOuIEXBfL8xtOhiwMT1KArDDqXEJafpNPR/FG2oMtgNX5D4Q nR/7ca8hZSLMpfbnnZ39HwuvB8SIheOyfTmWukBlurR3c6o6jAao8zJF7Dla0PM5bn2ygzmo+q2 R X-Received: by 2002:a65:4443:: with SMTP id e3-v6mr6863436pgq.348.1526632864578; Fri, 18 May 2018 01:41:04 -0700 (PDT) X-Received: by 2002:a65:4443:: with SMTP id e3-v6mr6863407pgq.348.1526632863837; Fri, 18 May 2018 01:41:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526632863; cv=none; d=google.com; s=arc-20160816; b=ZhG9wtpXfd8EbMCwO30G5znQiz6RGyp+uh834YgiDFNznE+0V6XKPr0gqNxely84Ai lR8uU0bod+xzT8GvxLz/d41UJjt6wz3/69ynC1VLPP03Y+O/BmI2mKyhniBqzYJJ94zi ZqQpqVA4H+UCC0vHKNjwY7vMPmp1FcCUFbDqXAYosC8GeW6V4XZPqUOifryCC82sjhAP FXxWlbWTFxl+vYwdGZ+5SZabstls4kF/+ufDrByA6UtykDALB2vGOSHk5j+NfCMH48vt WC9GvzJwJesTEQsQ8Pty4Fqj9Nx7/WR4MfGeEcJ4sme1FuUE/RbkQHrX5IwcK76ayQUM ZRAg== 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:dkim-signature :arc-authentication-results; bh=ODH7C7irF56rT8QNA6ylMSXTZonfbntxcJZMqPafer0=; b=RRpxXmAuP5KG/cvr1RBX73JA1DGoHGAO3oukMLdFIwiak5e2RTLxPKrmhBooaPijr5 Ph+nyMs6agVLB6cMJqiPbIR/0eP5V8xrA1IQ9/DeT43v3Esi+BIQr+WrQ2USho0lL3vq pUemTMgAxLCI6AjX3ZpwRlOvi2wnxfm4n5IwmLeAR5E/lvmndBwV5q8SL19rL2wckyD/ S9yYBGJoXQ4axfo1j5rGX6h1Xt/viVZI3GOgRglG0tYyyLybh2mZbDD8S/pUp1Oplqrx v0Q0XdWY/UNM+px1ir/+g1SJmdn1i1fXi4SqECqNas9draga4xqRUsvUKJ1n4DMrY3Mz szfg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Qx3PW6vF; spf=pass (google.com: domain of ufo19890607@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=ufo19890607@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id bd7-v6sor3903971plb.45.2018.05.18.01.41.03 for (Google Transport Security); Fri, 18 May 2018 01:41:03 -0700 (PDT) Received-SPF: pass (google.com: domain of ufo19890607@gmail.com designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Qx3PW6vF; spf=pass (google.com: domain of ufo19890607@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=ufo19890607@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=ODH7C7irF56rT8QNA6ylMSXTZonfbntxcJZMqPafer0=; b=Qx3PW6vF4Bw9IStJVYVqrW/uEm6N6bXxJrVN8HJipIca6M3CHe+UdUQXOoAYmTCFwH B/VE7yDi/MgTbGiteI9kXOp89EMK1CzCcoA8XKI2RyFpQ9Qz58OfjREaFjkxEJf8F6q9 T3I2SnG2fNUdmkEYi/3iVFhkAzntU2Re1l4lk2XCSjkamlHQ92nq1aO2oTplz48g6Vww 6aNXaC06443FMtjMDMBOKc/PdK01vStqgF4A8I2UD9lIOedKPM3WxsYYnJ1xEAtMeKNO jDoMG6m6raEkhLBAIear0+99KYahohjnCdhHq+uDNuvrn+MQnHxSBksjk4QYhMmI4YH1 cGUg== X-Google-Smtp-Source: AB8JxZoBn2+sf4RP2E0zcgpwahRzFYciS939X07zZrM7bTVkYHBQ2xb84+lJhUfN3OexSPEGXf/Erg== X-Received: by 2002:a17:902:bb92:: with SMTP id m18-v6mr8672104pls.46.1526632863475; Fri, 18 May 2018 01:41:03 -0700 (PDT) Received: from node5.localdomain ([13.94.31.177]) by smtp.gmail.com with ESMTPSA id k193-v6sm8798106pgc.39.2018.05.18.01.40.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 18 May 2018 01:41:02 -0700 (PDT) From: ufo19890607 To: akpm@linux-foundation.org, mhocko@suse.com, rientjes@google.com, kirill.shutemov@linux.intel.com, aarcange@redhat.com, penguin-kernel@I-love.SAKURA.ne.jp, guro@fb.com, yang.s@alibaba-inc.com Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, yuzhoujian Subject: [PATCH v3] Print the memcg's name when system-wide OOM happened Date: Fri, 18 May 2018 09:40:51 +0100 Message-Id: <1526632851-25613-1-git-send-email-ufo19890607@gmail.com> 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 From: yuzhoujian The dump_header does not print the memcg's name when the system oom happened. So users cannot locate the certain container which contains the task that has been killed by the oom killer. System oom report will contain the memcg's name after this patch, so users can get the memcg's path from the oom report and check that container more quickly. Changes since v2: - add the mem_cgroup_print_memcg_name helper to print the memcg's name which contains the task that will be killed by the oom-killer. Changes since v1: - replace adding mem_cgroup_print_oom_info with printing the memcg's name only. Signed-off-by: yuzhoujian --- include/linux/memcontrol.h | 7 +++++++ mm/memcontrol.c | 13 +++++++++++++ mm/oom_kill.c | 1 + 3 files changed, 21 insertions(+) diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h index d99b71bc2c66..12ffe4d0a4f8 100644 --- a/include/linux/memcontrol.h +++ b/include/linux/memcontrol.h @@ -464,6 +464,8 @@ void mem_cgroup_handle_over_high(void); unsigned long mem_cgroup_get_limit(struct mem_cgroup *memcg); +void mem_cgroup_print_memcg_name(struct task_struct *p); + void mem_cgroup_print_oom_info(struct mem_cgroup *memcg, struct task_struct *p); @@ -858,6 +860,11 @@ static inline unsigned long mem_cgroup_get_limit(struct mem_cgroup *memcg) return 0; } +static inline void +mem_cgroup_print_memcg_name(struct task_struct *p) +{ +} + static inline void mem_cgroup_print_oom_info(struct mem_cgroup *memcg, struct task_struct *p) { diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 2bd3df3d101a..15fb5ea9ddc9 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -1118,6 +1118,19 @@ static const char *const memcg1_stat_names[] = { }; #define K(x) ((x) << (PAGE_SHIFT-10)) + +/** + * mem_cgroup_print_memcg_name: Print the memcg's name which contains the task + * that will be killed by the oom-killer. + * @p: Task that is going to be killed + */ +void mem_cgroup_print_memcg_name(struct task_struct *p) +{ + pr_info("Task in "); + pr_cont_cgroup_path(task_cgroup(p, memory_cgrp_id)); + pr_cont(" killed as a result of limit of "); +} + /** * mem_cgroup_print_oom_info: Print OOM information relevant to memory controller. * @memcg: The memory cgroup that went over limit diff --git a/mm/oom_kill.c b/mm/oom_kill.c index 8ba6cb88cf58..73fdfa2311d5 100644 --- a/mm/oom_kill.c +++ b/mm/oom_kill.c @@ -433,6 +433,7 @@ static void dump_header(struct oom_control *oc, struct task_struct *p) if (is_memcg_oom(oc)) mem_cgroup_print_oom_info(oc->memcg, p); else { + mem_cgroup_print_memcg_name(p); show_mem(SHOW_MEM_FILTER_NODES, oc->nodemask); if (is_dump_unreclaim_slabs()) dump_unreclaimable_slab();