linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Michal Hocko <mhocko@kernel.org>
To: Edward Chron <echron@arista.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	Roman Gushchin <guro@fb.com>,
	Johannes Weiner <hannes@cmpxchg.org>,
	David Rientjes <rientjes@google.com>,
	Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>,
	Shakeel Butt <shakeelb@google.com>,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	colona@arista.com
Subject: Re: [PATCH] mm/oom: Add killed process selection information
Date: Thu, 15 Aug 2019 10:24:33 +0200	[thread overview]
Message-ID: <20190815082433.GC9477@dhcp22.suse.cz> (raw)
In-Reply-To: <20190815060604.3675-1-echron@arista.com>

On Wed 14-08-19 23:06:04, Edward Chron wrote:
> For an OOM event: print oom_score_adj value for the OOM Killed process
> to document what the oom score adjust value was at the time the process
> at the time of the OOM event. The value can be set by the user and it
> effects the resulting oom_score so useful to document this value.

This value is interesting especially for setups which do not print
eligible tasks (sysctl oom_dump_tasks = 0) and helps to notice a
misconfiguration <YOUR UDEV EXAMPLE GOES HERE> or to confirm that
oom_score_adj configuration applies as expected.
 
> Sample message output:
> Aug 14 23:00:02 testserver kernel: Out of memory: Killed process 2692
>  (oomprocs) total-vm:1056800kB, anon-rss:1052760kB, file-rss:4kB,i
>  shmem-rss:0kB oom_score_adj:1000
> 
> Signed-off-by: Edward Chron <echron@arista.com>

With that feel free to add
Acked-by: Michal Hocko <mhocko@suse.com>

and post as a stand alone patch. Btw. the patch could be simplified by
not using a helper variable and using victim->signal->oom_score_adj
right in the pr_err.

Thanks!

> ---
>  mm/oom_kill.c | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/mm/oom_kill.c b/mm/oom_kill.c
> index eda2e2a0bdc6..6b1674cac377 100644
> --- a/mm/oom_kill.c
> +++ b/mm/oom_kill.c
> @@ -858,6 +858,7 @@ static void __oom_kill_process(struct task_struct *victim, const char *message)
>  	struct task_struct *p;
>  	struct mm_struct *mm;
>  	bool can_oom_reap = true;
> +	long adj;
>  
>  	p = find_lock_task_mm(victim);
>  	if (!p) {
> @@ -877,6 +878,8 @@ static void __oom_kill_process(struct task_struct *victim, const char *message)
>  	count_vm_event(OOM_KILL);
>  	memcg_memory_event_mm(mm, MEMCG_OOM_KILL);
>  
> +	adj = (long)victim->signal->oom_score_adj;
> +
>  	/*
>  	 * We should send SIGKILL before granting access to memory reserves
>  	 * in order to prevent the OOM victim from depleting the memory
> @@ -884,12 +887,12 @@ static void __oom_kill_process(struct task_struct *victim, const char *message)
>  	 */
>  	do_send_sig_info(SIGKILL, SEND_SIG_PRIV, victim, PIDTYPE_TGID);
>  	mark_oom_victim(victim);
> -	pr_err("%s: Killed process %d (%s) total-vm:%lukB, anon-rss:%lukB, file-rss:%lukB, shmem-rss:%lukB\n",
> +	pr_err("%s: Killed process %d (%s) total-vm:%lukB, anon-rss:%lukB, file-rss:%lukB, shmem-rss:%lukB oom_score_adj:%ld\n",
>  		message, task_pid_nr(victim), victim->comm,
>  		K(victim->mm->total_vm),
>  		K(get_mm_counter(victim->mm, MM_ANONPAGES)),
>  		K(get_mm_counter(victim->mm, MM_FILEPAGES)),
> -		K(get_mm_counter(victim->mm, MM_SHMEMPAGES)));
> +		K(get_mm_counter(victim->mm, MM_SHMEMPAGES)), adj);
>  	task_unlock(victim);
>  
>  	/*
> -- 
> 2.20.1

-- 
Michal Hocko
SUSE Labs

  reply	other threads:[~2019-08-15  8:24 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-15  6:06 [PATCH] mm/oom: Add killed process selection information Edward Chron
2019-08-15  8:24 ` Michal Hocko [this message]
  -- strict thread matches above, loose matches on Subject: below --
2019-08-08 18:32 Edward Chron
2019-08-08 18:51 ` Michal Hocko
     [not found]   ` <CAM3twVT0_f++p1jkvGuyMYtaYtzgEiaUtb8aYNCmNScirE4=og@mail.gmail.com>
2019-08-08 20:07     ` Michal Hocko
2019-08-08 22:15       ` Edward Chron
2019-08-09  6:40         ` Michal Hocko
2019-08-09 22:15           ` Edward Chron
2019-08-12 11:42             ` Michal Hocko
2019-08-15  6:24               ` Edward Chron
2019-08-15  8:18                 ` 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=20190815082433.GC9477@dhcp22.suse.cz \
    --to=mhocko@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=colona@arista.com \
    --cc=echron@arista.com \
    --cc=guro@fb.com \
    --cc=hannes@cmpxchg.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=penguin-kernel@I-love.SAKURA.ne.jp \
    --cc=rientjes@google.com \
    --cc=shakeelb@google.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).