From patchwork Mon May 21 02:39:46 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: 10413797 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 B3CB7601F9 for ; Mon, 21 May 2018 02:40:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A27D728756 for ; Mon, 21 May 2018 02:40:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 93E7628767; Mon, 21 May 2018 02:40:03 +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 6D02A28756 for ; Mon, 21 May 2018 02:40:02 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6A3726B0003; Sun, 20 May 2018 22:40:01 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 652586B0005; Sun, 20 May 2018 22:40:01 -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 543136B0006; Sun, 20 May 2018 22:40:01 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf0-f199.google.com (mail-pf0-f199.google.com [209.85.192.199]) by kanga.kvack.org (Postfix) with ESMTP id 120E26B0003 for ; Sun, 20 May 2018 22:40:01 -0400 (EDT) Received: by mail-pf0-f199.google.com with SMTP id s3-v6so8456439pfh.0 for ; Sun, 20 May 2018 19:40:01 -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=ysBFv8joIWdKc1XALHbQhRZpWiUFhWWhmMhAImmYsxU=; b=tbIu3uFf+QP1dBVpYepclLMdrfcDBEP/DED8UJtPtKHEHxAcv5E/jzrUa21BStHgc1 xoR0uAveoITvo0XYiLTrtX/DJmBFb4Ga70SLRJH9lpUb75tOPYZGlG3ndQNFzDVZqHHA GSi1pShZ3Yqhwk5r32DFSMun6WlURulOT2YGwKSQSYkU+1ewiTiDMv8Esdgpw5/hMAwt 8IglXEfBseVjBZ8gsVnWHI7H8K2VyRrvw3QvBZgPCZX6qY+VX0PU/A5gD9gtCJ+f6Apr aVWBDPaU+46UkAPT3/Ufmo5/uO3QG5yZq5I5FiL/krXeCDXIDVKg0H6mkLg65oHMHGLe 3U7A== X-Gm-Message-State: ALKqPwfHd5apjnKPMYurBP+WyXnTLt0cFCLjWpQSIVOgxRuIdb8J/2qS fTvMBxwm65uNGeWlPB/93CyInJehCgeI+6samLlLeeWW266+DjmXJDbxZZ/0WtnANFq4/gtT3pt wXrJug6lZLou82BqYgJRR7am6eesZz9x/rQOTIUTi1AzZYSyNpie2iCM28Ee4hHL3GjSp3mYQjf vPSaBancn8DqNn+AjNZX4QpGogcG52+Zp0Mj37vYT3J/4TZf+7haeQBmOj4AXh46gCmp09CnTT5 ps3+QrygYbyYpIn7BvgNZvYZRLIeESYAsTRcq3nl/e5OKJwyUFiYnY0jHFZTAxmayQWicdwJCqW F91ZdSKoLdJH8isgAVvlbC5AQkESrzVCkco+DO5Rg0F/aWy8wnMQkpPW5U9me2LGYZdN3jdcSLc I X-Received: by 2002:a17:902:7446:: with SMTP id e6-v6mr18370637plt.369.1526870400763; Sun, 20 May 2018 19:40:00 -0700 (PDT) X-Received: by 2002:a17:902:7446:: with SMTP id e6-v6mr18370606plt.369.1526870399976; Sun, 20 May 2018 19:39:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526870399; cv=none; d=google.com; s=arc-20160816; b=BwfL2hpRRYu4+sJpmp+8iLvrSSoO6U2RPOx/pCcKk6V8pHDL/c3Ij71v29LmDRnyK8 1R4RgFdKlUT7cmeVhCaNtRGby8klONLyqIHQWvKDD62fEgfQ/+PQnuubugIvF2H830dx 5QM74VmBEbpEs1v+6AVMhiM0J3EPzsqR3ZFsYRTEvHK3OxTr3wYws4s5+qKmJteRlRn/ XI8wH5YO6rEK901KnW/wtFxf/OOB82ALsUL34pcCpo5/KeKtOfqbw3s/9MOq+CYKTFM/ E/j98r5Qia1qf9UcZ5yEYtsNYcJcKXJagaAVe+43CER3itt1lmyL0+4quq1Ql9/bmh4N 61KA== 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=ysBFv8joIWdKc1XALHbQhRZpWiUFhWWhmMhAImmYsxU=; b=Boxme/TNcislj8gjwhZ9jZnPmjYUYEJ5U1FFC2vPHOnl5WbdcOgNy0r8m8T2WKlwuK prFjzBT+BOZho7SQ02MRuvDytVt0OhoPAYJjPMXZl4qR/J7DhkWfRfNRZ3hlLLeKLhh6 LoBGMPvYXRV1vuW+Rv8Qs8F0NMlG/qThiM4lDlPedT+GbBqrpPSzbff7ycSB78J6v+9Y 6VPz4fsV1N9ejcCIvisjB8l+q6q/SI6IWyND7R0LCEZhYxcpjk/j5P0On1su2yLub/Nl 4qjwboeBwSsdydwsan4SpKzcS03V1qal0hncETlEI/tGBAJeKQm5JNr33fT13zVa48n+ gm3g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=T9hvtQpp; 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 f3-v6sor5402526pld.40.2018.05.20.19.39.59 for (Google Transport Security); Sun, 20 May 2018 19:39:59 -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=T9hvtQpp; 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=ysBFv8joIWdKc1XALHbQhRZpWiUFhWWhmMhAImmYsxU=; b=T9hvtQppMWhaehlVU2h1EeuGaW6VHPAbJUv+R/mUgFoDP4AAzlkNMPyoQ2nFihLU/J Kb0+Dv1BYQ+bUSAipSYEIjZEjIG6v1EoppkZV5nKxWM3h7pC40CkNZDX73gM5Jf3iVhj e42XT2pd/9wlqlJEHAIxxfyp+ogLV1v0zRfLLdL1uEVNGsRjQ3CyDSR2OEnesfvUBxcl 355MBv1seUVhtUsUc/qLjtYpe61s9qEGF6dgktG02VHXFxIj78mXcT8CTiohKh/7GfTr ptC4JBcVnNAo3G5uju6pLY5MmMrs3s/LQGIKCJ2zn2Br40yvK1Qov2baLnhB6bajaEXC ce3A== X-Google-Smtp-Source: AB8JxZrnAx4WpSMGMpw9nR156fqfxVlOgX4XN07B0y7m6TwigQD7ZRCwJHuO+87vrg1KLPKcoW1bWQ== X-Received: by 2002:a17:902:5597:: with SMTP id g23-v6mr18615713pli.347.1526870399656; Sun, 20 May 2018 19:39:59 -0700 (PDT) Received: from node5.localdomain ([52.229.160.192]) by smtp.gmail.com with ESMTPSA id s4-v6sm16781183pgp.35.2018.05.20.19.39.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 20 May 2018 19:39:58 -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 v4] Print the memcg's name when system-wide OOM happened Date: Mon, 21 May 2018 03:39:46 +0100 Message-Id: <1526870386-2439-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 print the memcg's name after this patch, so users can get the memcg's path from the oom report and check the certain container more quickly. Changes since v3: - rename the helper's name to mem_cgroup_print_oom_memcg_name. - add the rcu lock held to the helper. - remove the print info of memcg's name in mem_cgroup_print_oom_info. 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 | 9 +++++++++ mm/memcontrol.c | 27 +++++++++++++++++++-------- mm/oom_kill.c | 1 + 3 files changed, 29 insertions(+), 8 deletions(-) diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h index d99b71bc2c66..5fc58beae368 100644 --- a/include/linux/memcontrol.h +++ b/include/linux/memcontrol.h @@ -464,6 +464,9 @@ void mem_cgroup_handle_over_high(void); unsigned long mem_cgroup_get_limit(struct mem_cgroup *memcg); +void mem_cgroup_print_oom_memcg_name(struct mem_cgroup *memcg, + struct task_struct *p); + void mem_cgroup_print_oom_info(struct mem_cgroup *memcg, struct task_struct *p); @@ -858,6 +861,12 @@ static inline unsigned long mem_cgroup_get_limit(struct mem_cgroup *memcg) return 0; } +static inline void +mem_cgroup_print_oom_memcg_name(struct mem_cgroup *memcg, + 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..138a11edfacb 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -1118,19 +1118,15 @@ static const char *const memcg1_stat_names[] = { }; #define K(x) ((x) << (PAGE_SHIFT-10)) + /** - * mem_cgroup_print_oom_info: Print OOM information relevant to memory controller. + * mem_cgroup_print_oom_memcg_name: Print the memcg's name which contains the + * task that will be killed by the oom-killer. * @memcg: The memory cgroup that went over limit * @p: Task that is going to be killed - * - * NOTE: @memcg and @p's mem_cgroup can be different when hierarchy is - * enabled */ -void mem_cgroup_print_oom_info(struct mem_cgroup *memcg, struct task_struct *p) +void mem_cgroup_print_oom_memcg_name(struct mem_cgroup *memcg, struct task_struct *p) { - struct mem_cgroup *iter; - unsigned int i; - rcu_read_lock(); if (p) { @@ -1145,7 +1141,22 @@ void mem_cgroup_print_oom_info(struct mem_cgroup *memcg, struct task_struct *p) pr_cont("\n"); rcu_read_unlock(); +} + +/** + * mem_cgroup_print_oom_info: Print OOM information relevant to memory controller. + * @memcg: The memory cgroup that went over limit + * @p: Task that is going to be killed + * + * NOTE: @memcg and @p's mem_cgroup can be different when hierarchy is + * enabled + */ +void mem_cgroup_print_oom_info(struct mem_cgroup *memcg, struct task_struct *p) +{ + struct mem_cgroup *iter; + unsigned int i; + mem_cgroup_print_oom_memcg_name(memcg, p); pr_info("memory: usage %llukB, limit %llukB, failcnt %lu\n", K((u64)page_counter_read(&memcg->memory)), K((u64)memcg->memory.limit), memcg->memory.failcnt); diff --git a/mm/oom_kill.c b/mm/oom_kill.c index 8ba6cb88cf58..3e0b725fb877 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_oom_memcg_name(oc->memcg, p); show_mem(SHOW_MEM_FILTER_NODES, oc->nodemask); if (is_dump_unreclaim_slabs()) dump_unreclaimable_slab();