Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp418080imm; Mon, 9 Jul 2018 04:22:01 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdV1kHzBAPrOmfET2DoD5rkXiZf2gYJQrOxFH5f388bqDzA8lKK2jdGRLVLbWn4JOcZ77Lt X-Received: by 2002:a63:2fc6:: with SMTP id v189-v6mr4909089pgv.61.1531135321032; Mon, 09 Jul 2018 04:22:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531135321; cv=none; d=google.com; s=arc-20160816; b=z267oHfN0o0LEUWzm/P4Z6c2x2DJGpgNuTjUzimjkGtiqym+oAr4+clbUtmJ+aiu2y OaC8nD1JHKs+4daNKuvJ8c0uhngZVd67RW+6fEs0vWUTdPwZ6SIrWTOUCmXRXjU93hLN mPEnZ9h58AfL8uRVa+nxX4r7qnXH/gfRE6+yXgWcLhurnZQTEYIkbO7iuR5V5Ziq0vqN ghSyX8+g3EGZReCJgxL9LxjZbCCJtjPTAva8ImpS5bpovMNT35QxOQzXjrWHfIzz21Ae f2CmRasS3I5FiWZw7kzYnkSNN4TisJBWmAfrduqickduZfm9qJ20fQLleP7ZesKdt4wV D0xQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=hzpUi8KWj7VtnaB4FvrDmOwh4KF4R/Ucjdbs6kZz5UU=; b=GAXXyraf/KcqlSKRbMoMuW51ybd4ikskA3e1nWvIh4uzMwAS77DWn1pwKS0Gd+OxJB o/MnfrIzoAUNyhxqYfRU9aTc8Nvow0jMwW05q7wdGYRXL0FH4BlTsrH56juKG/mpRfAb NRuoz6PVXzNOMmVY2ONSd2oSv3EvEZHqNsOnmO/EDD3XVuTR/Hbtj9jS2SaiTremoCy0 IVk1+dwFf59GCcAeLN4R2EyR0G+un4+voIf2ppH1uF9uqYyW2uoVylRnGWFHJPSUr4M4 CVR+QXhT6MpgXu/sN5OwimxVRLrF1eOSXowKMz2ejS6Jrju6TeDTnOh29UXdddmiATgh gK9Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p129-v6si14922038pfb.145.2018.07.09.04.21.45; Mon, 09 Jul 2018 04:22:00 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933131AbeGILT1 (ORCPT + 99 others); Mon, 9 Jul 2018 07:19:27 -0400 Received: from mx2.suse.de ([195.135.220.15]:34182 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S933111AbeGILTX (ORCPT ); Mon, 9 Jul 2018 07:19:23 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 708C5AD14; Mon, 9 Jul 2018 11:19:22 +0000 (UTC) Date: Mon, 9 Jul 2018 13:19:21 +0200 From: Michal Hocko To: ufo19890607@gmail.com Cc: akpm@linux-foundation.org, 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, linux-mm@kvack.org, linux-kernel@vger.kernel.org, yuzhoujian@didichuxing.com Subject: Re: [PATCH v12 2/2] Add the missing information for the oom report Message-ID: <20180709111921.GI22049@dhcp22.suse.cz> References: <1530796829-4539-1-git-send-email-ufo19890607@gmail.com> <1530796829-4539-2-git-send-email-ufo19890607@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1530796829-4539-2-git-send-email-ufo19890607@gmail.com> User-Agent: Mutt/1.10.0 (2018-05-17) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The subject is not informative. What is the information? Add oom victim's memmcg to the oom context information On Thu 05-07-18 21:20:29, ufo19890607@gmail.com wrote: > From: yuzhoujian > > The current oom report doesn't display victim's memcg context during the > global OOM situation. While this information is not strictly needed, it > can be really helpful for containerized environments to locate which > container has lost a process. Now that we have a single line for the oom > context, we can trivially add both the oom memcg (this can be either > global_oom or a specific memcg which hits its hard limits) and task_memcg > which is the victim's memcg. The is clearly missing. An example of the oom context line would be appropriate. > Signed-off-by: yuzhoujian The patch looks good otherwise. I would suggest switching cpuset and memcg information ordering but that is not crucial AFAICS. So you can add Acked-by: Michal Hocko > --- > include/linux/memcontrol.h | 14 +++++++++++--- > mm/memcontrol.c | 36 ++++++++++++++++++++++-------------- > mm/oom_kill.c | 10 ++++++---- > 3 files changed, 39 insertions(+), 21 deletions(-) > > diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h > index 6c6fb116e925..96a73f989101 100644 > --- a/include/linux/memcontrol.h > +++ b/include/linux/memcontrol.h > @@ -491,8 +491,10 @@ void mem_cgroup_handle_over_high(void); > > unsigned long mem_cgroup_get_max(struct mem_cgroup *memcg); > > -void mem_cgroup_print_oom_info(struct mem_cgroup *memcg, > - struct task_struct *p); > +void mem_cgroup_print_oom_context(struct mem_cgroup *memcg, > + struct task_struct *p); > + > +void mem_cgroup_print_oom_meminfo(struct mem_cgroup *memcg); > > static inline void mem_cgroup_oom_enable(void) > { > @@ -903,7 +905,13 @@ static inline unsigned long mem_cgroup_get_max(struct mem_cgroup *memcg) > } > > static inline void > -mem_cgroup_print_oom_info(struct mem_cgroup *memcg, struct task_struct *p) > +mem_cgroup_print_oom_context(struct mem_cgroup *memcg, > + struct task_struct *p) > +{ > +} > + > +static inline void > +mem_cgroup_print_oom_meminfo(struct mem_cgroup *memcg) > { > } > > diff --git a/mm/memcontrol.c b/mm/memcontrol.c > index e6f0d5ef320a..18deea974cfd 100644 > --- a/mm/memcontrol.c > +++ b/mm/memcontrol.c > @@ -1119,32 +1119,40 @@ 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. > - * @memcg: The memory cgroup that went over limit > + * mem_cgroup_print_oom_context: Print OOM context information relevant to > + * memory controller. > + * @memcg: The origin 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_context(struct mem_cgroup *memcg, struct task_struct *p) > { > - struct mem_cgroup *iter; > - unsigned int i; > + struct cgroup *origin_cgrp, *kill_cgrp; > > rcu_read_lock(); > - > + if (memcg) { > + pr_cont(",oom_memcg="); > + pr_cont_cgroup_path(memcg->css.cgroup); > + } else > + pr_cont(",global_oom"); > if (p) { > - pr_info("Task in "); > + pr_cont(",task_memcg="); > pr_cont_cgroup_path(task_cgroup(p, memory_cgrp_id)); > - pr_cont(" killed as a result of limit of "); > - } else { > - pr_info("Memory limit reached of cgroup "); > } > - > - pr_cont_cgroup_path(memcg->css.cgroup); > - pr_cont("\n"); > - > rcu_read_unlock(); > +} > + > +/** > + * mem_cgroup_print_oom_meminfo: Print OOM memory information relevant to > + * memory controller. > + * @memcg: The memory cgroup that went over limit > + */ > +void mem_cgroup_print_oom_meminfo(struct mem_cgroup *memcg) > +{ > + struct mem_cgroup *iter; > + unsigned int i; > > pr_info("memory: usage %llukB, limit %llukB, failcnt %lu\n", > K((u64)page_counter_read(&memcg->memory)), > diff --git a/mm/oom_kill.c b/mm/oom_kill.c > index c38f224b0d9e..9e80f6c2eb2e 100644 > --- a/mm/oom_kill.c > +++ b/mm/oom_kill.c > @@ -430,13 +430,15 @@ static void dump_header(struct oom_control *oc, struct task_struct *p) > dump_stack(); > > /* one line summary of the oom killer context. */ > - pr_info("oom-kill:constraint=%s,nodemask=%*pbl,task=%s,pid=%5d,uid=%5d", > + pr_info("oom-kill:constraint=%s,nodemask=%*pbl", > oom_constraint_text[oc->constraint], > - nodemask_pr_args(oc->nodemask), > - p->comm, p->pid, from_kuid(&init_user_ns, task_uid(p))); > + nodemask_pr_args(oc->nodemask)); > + mem_cgroup_print_oom_context(oc->memcg, p); > cpuset_print_current_mems_allowed(); > + pr_cont(",task=%s,pid=%5d,uid=%5d\n", p->comm, p->pid, > + from_kuid(&init_user_ns, task_uid(p))); > if (is_memcg_oom(oc)) > - mem_cgroup_print_oom_info(oc->memcg, p); > + mem_cgroup_print_oom_meminfo(oc->memcg); > else { > show_mem(SHOW_MEM_FILTER_NODES, oc->nodemask); > if (is_dump_unreclaim_slabs()) > -- > 2.14.1 > -- Michal Hocko SUSE Labs