All of lore.kernel.org
 help / color / mirror / Atom feed
From: Michal Hocko <mhocko@kernel.org>
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 v9] Refactor part of the oom report in dump_header
Date: Fri, 22 Jun 2018 10:39:49 +0200	[thread overview]
Message-ID: <20180622083949.GR10465@dhcp22.suse.cz> (raw)
In-Reply-To: <1529056341-16182-1-git-send-email-ufo19890607@gmail.com>

On Fri 15-06-18 17:52:21, ufo19890607@gmail.com wrote:
> From: yuzhoujian <yuzhoujian@didichuxing.com>
> 
> Some users complains that system-wide oom report does not print memcg's
> name which contains the task killed by the oom-killer. The current system
> wide oom report prints the task's command, gfp_mask, order ,oom_score_adj
> and shows the memory info, but misses some important information, etc. the
> memcg that has reached its limit and the memcg to which the killed process
> is attached.

We do not print the memcg which reached the limit in the global context
because that is irrelevant completely. I do agree that memcg of the
oom victim might be interesting and the changelog should explain why.

So what about the following wording instead:
"
The current system wide oom report prints information about the victim
and the allocation context and restrictions. It, however, doesn't
provide any information about memory cgroup the victim belongs to. This
information can be interesting for container users because they can find
the victim's container much more easily.
"
 
> I follow the advices of David Rientjes and Michal Hocko, and refactor
> part of the oom report. After this patch, users can get the memcg's
> path from the oom report and check the certain container more quickly.
> 
> The oom print info after this patch:
> oom-kill:constraint=<constraint>,nodemask=<nodemask>,origin_memcg=<memcg>,kill_memcg=<memcg>,task=<commm>,pid=<pid>,uid=<uid>
[...]
> diff --git a/include/linux/oom.h b/include/linux/oom.h
> index 6adac113e96d..5bed78d4bfb8 100644
> --- a/include/linux/oom.h
> +++ b/include/linux/oom.h
> @@ -15,6 +15,20 @@ struct notifier_block;
>  struct mem_cgroup;
>  struct task_struct;
>  
> +enum oom_constraint {
> +	CONSTRAINT_NONE,
> +	CONSTRAINT_CPUSET,
> +	CONSTRAINT_MEMORY_POLICY,
> +	CONSTRAINT_MEMCG,
> +};
> +
> +static const char * const oom_constraint_text[] = {
> +	[CONSTRAINT_NONE] = "CONSTRAINT_NONE",
> +	[CONSTRAINT_CPUSET] = "CONSTRAINT_CPUSET",
> +	[CONSTRAINT_MEMORY_POLICY] = "CONSTRAINT_MEMORY_POLICY",
> +	[CONSTRAINT_MEMCG] = "CONSTRAINT_MEMCG",
> +};

I've suggested that this should be a separate patch.

[...]
> -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,
> +		enum oom_constraint constraint, nodemask_t *nodemask)
>  {
> -	struct mem_cgroup *iter;
> -	unsigned int i;
> +	struct cgroup *origin_cgrp, *kill_cgrp;
>  
>  	rcu_read_lock();
>  
> +	pr_info("oom-kill:constraint=%s,nodemask=%*pbl,origin_memcg=",
> +	    oom_constraint_text[constraint], nodemask_pr_args(nodemask));
> +
> +	if (memcg)
> +		pr_cont_cgroup_path(memcg->css.cgroup);
> +	else
> +		pr_cont("(null)");

I do not like this. What does origin_memcg=(null) tell you? You really
have to know the code to see this is a global oom killer actually.
Furthermore I would expect that origin_memcg is tasks' origin memcg
rather than oom's origin. So I think you want the following instead


	pr_info("oom-kill:constraint=%s,nodemask=%*pbl",
		oom_constraint_text[constraint], nodemask_pr_args(nodemask));
	if (memcg) {
		pr_cont(", oom_memcg=");
		pr_cont_cgroup_path(memcg->css.cgroup);
	}
	
	if (p) {
		pr_cont(", task_memcg=");
  		pr_cont_cgroup_path(task_cgroup(p, memory_cgrp_id));
		pr_cont(", task=%s, pid=%5d, uid=%5d", p->comm, p->pid, from_kuid(&init_user_ns, task_uid(p)));
	}
  	pr_cont("\n");
-- 
Michal Hocko
SUSE Labs

  parent reply	other threads:[~2018-06-22  8:39 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-15  9:52 [PATCH v9] Refactor part of the oom report in dump_header ufo19890607
2018-06-22  6:33 ` 禹舟键
2018-06-22  8:39 ` Michal Hocko [this message]
2018-06-22  9:33   ` 禹舟键
2018-06-22 10:42     ` Michal Hocko
2018-06-22 10:42       ` Michal Hocko
2018-06-22 11:40       ` 禹舟键
2018-06-22 12:19         ` Michal Hocko
2018-06-22 12:19           ` Michal Hocko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180622083949.GR10465@dhcp22.suse.cz \
    --to=mhocko@kernel.org \
    --cc=aarcange@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=guro@fb.com \
    --cc=kirill.shutemov@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=penguin-kernel@i-love.sakura.ne.jp \
    --cc=rientjes@google.com \
    --cc=ufo19890607@gmail.com \
    --cc=yang.s@alibaba-inc.com \
    --cc=yuzhoujian@didichuxing.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.