Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp1242987imm; Tue, 22 May 2018 00:30:28 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpLC9qSaqXrbWIMpRq/eRdiFDM+1Nr7wO2hWa3nBJQDtPY9wpRmWSsYfrmqwgb3hrsWfkb8 X-Received: by 2002:a65:42c3:: with SMTP id l3-v6mr18488575pgp.210.1526974228888; Tue, 22 May 2018 00:30:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526974228; cv=none; d=google.com; s=arc-20160816; b=WGpP3LxHZbIKzMSXzIusoPQWYrZ27xWlzJCo6wCR1wFCN3B2t+Bdh+qTr27iqZviNB 6XROUCrc8V7CqE+moBWZOnU2DXwGtcjlOIXNhqLWIxqjDbAriHurPFz2TVB1kDXC3mC1 fZpcjZsRd/I/MiFjfafmCWlsMQLlWtMsBiv3FvEmBagaIXqZSktBdA5p1RYuhDnS2LEh WlsqjU3sJH3/ZDykRO3jCKnV9J6i37snz/GXalreKbkwTD2PgIe8TFJGhK3Z277+srJF OhhxkB+W+W6yL9YcDup++jwlSo1fFTcJMAjQct58vYbWn4+5m56PmTkBKGjEQ2K3D5lW njdQ== 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=KIkmj08NCFNxP3sAfn3SQeYJ1kbuT3iv/nY7GJtflDA=; b=aqnwlAtQDrz4H2v03ooOgx9iBxfyTP2MCnsBGxJWyPedDRVXi8oKi8P7C/LHSneetq Tj8Q63k1WAUgEDjURIXBxr0P4V9qibCSZw/HkmX6bOOYYQXJw3NMjrvjDF1o6jJ3gHmx baIJHb+EMgDXYAmV5yenJVeAXqGfU811N0m6a/3U3cHicEGdbe5LlYmiIjb3QxcefDWs mLz3dQkQZGitiawJ/NIMEKVhWEKcMNGqbPzIxK2cehexBYTCx1eoCSEvrp/Q+BSeEPas neAnqV1Ifpp7vCpIHTFCNwLCxVWZn4C0foVNazQKX6B7nm5vkWg6os4a2T141SzbViMW uRLg== 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 h91-v6si15447505pld.132.2018.05.22.00.30.14; Tue, 22 May 2018 00:30:28 -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 S1751454AbeEVH2q (ORCPT + 99 others); Tue, 22 May 2018 03:28:46 -0400 Received: from mx2.suse.de ([195.135.220.15]:57801 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751160AbeEVH2p (ORCPT ); Tue, 22 May 2018 03:28:45 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 96B49AC43; Tue, 22 May 2018 07:28:43 +0000 (UTC) Date: Tue, 22 May 2018 09:28:41 +0200 From: Michal Hocko To: ufo19890607 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 Subject: Re: [PATCH v4] Print the memcg's name when system-wide OOM happened Message-ID: <20180522072841.GG20020@dhcp22.suse.cz> References: <1526870386-2439-1-git-send-email-ufo19890607@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1526870386-2439-1-git-send-email-ufo19890607@gmail.com> User-Agent: Mutt/1.9.5 (2018-04-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon 21-05-18 03:39:46, ufo19890607 wrote: > 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. This has still the part which is misleading in the global oom context. So no, it seems that a helper will not do much good. Unless we can squeeze everything into a single like like David proposed (http://lkml.kernel.org/r/alpine.DEB.2.21.1805211405300.41872@chino.kir.corp.google.com) we should simply open code the relevant part of in the global oom path. > 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(); > -- > 2.14.1 -- Michal Hocko SUSE Labs