linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [RESEND PATCH v2] mm/oom_killer: Add task UID to info message on an oom kill
@ 2019-06-12 17:57 Joel Savitz
  2019-06-12 18:40 ` Rafael Aquini
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Joel Savitz @ 2019-06-12 17:57 UTC (permalink / raw)
  To: linux-kernel
  Cc: Joel Savitz, Rafael Aquini, Andrew Morton, David Rientjes, linux-mm

In the event of an oom kill, useful information about the killed
process is printed to dmesg. Users, especially system administrators,
will find it useful to immediately see the UID of the process.

In the following example, abuse_the_ram is the name of a program
that attempts to iteratively allocate all available memory until it is
stopped by force.

Current message:

Out of memory: Killed process 35389 (abuse_the_ram)
total-vm:133718232kB, anon-rss:129624980kB, file-rss:0kB,
shmem-rss:0kB

Patched message:

Out of memory: Killed process 2739 (abuse_the_ram),
total-vm:133880028kB, anon-rss:129754836kB, file-rss:0kB,
shmem-rss:0kB, UID 0


Suggested-by: David Rientjes <rientjes@google.com>
Signed-off-by: Joel Savitz <jsavitz@redhat.com>
---
 mm/oom_kill.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/mm/oom_kill.c b/mm/oom_kill.c
index 3a2484884cfd..af2e3faa72a0 100644
--- a/mm/oom_kill.c
+++ b/mm/oom_kill.c
@@ -874,12 +874,13 @@ 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, UID %d\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)),
+		from_kuid(&init_user_ns, task_uid(victim)));
 	task_unlock(victim);
 
 	/*
-- 
2.18.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [RESEND PATCH v2] mm/oom_killer: Add task UID to info message on an oom kill
  2019-06-12 17:57 [RESEND PATCH v2] mm/oom_killer: Add task UID to info message on an oom kill Joel Savitz
@ 2019-06-12 18:40 ` Rafael Aquini
  2019-06-13  1:00 ` Andrew Morton
  2019-06-13  8:23 ` Michal Hocko
  2 siblings, 0 replies; 6+ messages in thread
From: Rafael Aquini @ 2019-06-12 18:40 UTC (permalink / raw)
  To: Joel Savitz; +Cc: linux-kernel, Andrew Morton, David Rientjes, linux-mm

On Wed, Jun 12, 2019 at 01:57:53PM -0400, Joel Savitz wrote:
> In the event of an oom kill, useful information about the killed
> process is printed to dmesg. Users, especially system administrators,
> will find it useful to immediately see the UID of the process.
> 
> In the following example, abuse_the_ram is the name of a program
> that attempts to iteratively allocate all available memory until it is
> stopped by force.
> 
> Current message:
> 
> Out of memory: Killed process 35389 (abuse_the_ram)
> total-vm:133718232kB, anon-rss:129624980kB, file-rss:0kB,
> shmem-rss:0kB
> 
> Patched message:
> 
> Out of memory: Killed process 2739 (abuse_the_ram),
> total-vm:133880028kB, anon-rss:129754836kB, file-rss:0kB,
> shmem-rss:0kB, UID 0
> 
> 
> Suggested-by: David Rientjes <rientjes@google.com>
> Signed-off-by: Joel Savitz <jsavitz@redhat.com>
> ---
>  mm/oom_kill.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/mm/oom_kill.c b/mm/oom_kill.c
> index 3a2484884cfd..af2e3faa72a0 100644
> --- a/mm/oom_kill.c
> +++ b/mm/oom_kill.c
> @@ -874,12 +874,13 @@ 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, UID %d\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)),
> +		from_kuid(&init_user_ns, task_uid(victim)));
>  	task_unlock(victim);
>  
>  	/*
> -- 
> 2.18.1
> 
Acked-by: Rafael Aquini <aquini@redhat.com>


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [RESEND PATCH v2] mm/oom_killer: Add task UID to info message on an oom kill
  2019-06-12 17:57 [RESEND PATCH v2] mm/oom_killer: Add task UID to info message on an oom kill Joel Savitz
  2019-06-12 18:40 ` Rafael Aquini
@ 2019-06-13  1:00 ` Andrew Morton
  2019-06-13  8:23 ` Michal Hocko
  2 siblings, 0 replies; 6+ messages in thread
From: Andrew Morton @ 2019-06-13  1:00 UTC (permalink / raw)
  To: Joel Savitz; +Cc: linux-kernel, Rafael Aquini, David Rientjes, linux-mm

On Wed, 12 Jun 2019 13:57:53 -0400 Joel Savitz <jsavitz@redhat.com>
wrote:

> In the event of an oom kill, useful information about the killed
> process is printed to dmesg. Users, especially system administrators,
> will find it useful to immediately see the UID of the process.
> 
> In the following example, abuse_the_ram is the name of a program
> that attempts to iteratively allocate all available memory until it is
> stopped by force.
> 
> Current message:
> 
> Out of memory: Killed process 35389 (abuse_the_ram)
> total-vm:133718232kB, anon-rss:129624980kB, file-rss:0kB,
> shmem-rss:0kB
> 
> Patched message:
> 
> Out of memory: Killed process 2739 (abuse_the_ram),
> total-vm:133880028kB, anon-rss:129754836kB, file-rss:0kB,
> shmem-rss:0kB, UID 0

The other fields are name:value so it seems better to make the UID
field conform.

Also, there's no typesafe way of printing a uid_t (using the printk %p trick)
so yes, we have to assume its type.  But assuming unsigned int is
better than assuming int!

So...



s/UID %d/UID:%u/ in printk

--- a/mm/oom_kill.c~mm-oom_killer-add-task-uid-to-info-message-on-an-oom-kill-fix
+++ a/mm/oom_kill.c
@@ -876,7 +876,7 @@ static void __oom_kill_process(struct ta
 	 */
 	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, UID %d\n",
+	pr_err("%s: Killed process %d (%s) total-vm:%lukB, anon-rss:%lukB, file-rss:%lukB, shmem-rss:%lukB, UID:%u\n",
 		message, task_pid_nr(victim), victim->comm,
 		K(victim->mm->total_vm),
 		K(get_mm_counter(victim->mm, MM_ANONPAGES)),
_


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [RESEND PATCH v2] mm/oom_killer: Add task UID to info message on an oom kill
  2019-06-12 17:57 [RESEND PATCH v2] mm/oom_killer: Add task UID to info message on an oom kill Joel Savitz
  2019-06-12 18:40 ` Rafael Aquini
  2019-06-13  1:00 ` Andrew Morton
@ 2019-06-13  8:23 ` Michal Hocko
  2019-09-21  0:13   ` Andrew Morton
  2 siblings, 1 reply; 6+ messages in thread
From: Michal Hocko @ 2019-06-13  8:23 UTC (permalink / raw)
  To: Joel Savitz
  Cc: linux-kernel, Rafael Aquini, Andrew Morton, David Rientjes, linux-mm

On Wed 12-06-19 13:57:53, Joel Savitz wrote:
> In the event of an oom kill, useful information about the killed
> process is printed to dmesg. Users, especially system administrators,
> will find it useful to immediately see the UID of the process.

Could you be more specific please? We already print uid when dumping
eligible tasks so it is not overly hard to find that information in the
oom report. Well, except when dumping of eligible tasks is disabled. Is
this what you are after?

Please always be specific about usecases in the changelog. A terse
statement that something is useful doesn't tell much very often.

Thanks!
-- 
Michal Hocko
SUSE Labs


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [RESEND PATCH v2] mm/oom_killer: Add task UID to info message on an oom kill
  2019-06-13  8:23 ` Michal Hocko
@ 2019-09-21  0:13   ` Andrew Morton
  2019-09-21  1:00     ` Rafael Aquini
  0 siblings, 1 reply; 6+ messages in thread
From: Andrew Morton @ 2019-09-21  0:13 UTC (permalink / raw)
  To: Michal Hocko
  Cc: Joel Savitz, linux-kernel, Rafael Aquini, David Rientjes, linux-mm

On Thu, 13 Jun 2019 10:23:18 +0200 Michal Hocko <mhocko@kernel.org> wrote:

> On Wed 12-06-19 13:57:53, Joel Savitz wrote:
> > In the event of an oom kill, useful information about the killed
> > process is printed to dmesg. Users, especially system administrators,
> > will find it useful to immediately see the UID of the process.
> 
> Could you be more specific please? We already print uid when dumping
> eligible tasks so it is not overly hard to find that information in the
> oom report. Well, except when dumping of eligible tasks is disabled. Is
> this what you are after?
> 
> Please always be specific about usecases in the changelog. A terse
> statement that something is useful doesn't tell much very often.
> 

<crickets?>

I'll add this to the chagnelog:

: We already print uid when dumping eligible tasks so it is not overly hard
: to find that information in the oom report.  However this information is
: unavailable then dumping of eligible tasks is disabled.



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [RESEND PATCH v2] mm/oom_killer: Add task UID to info message on an oom kill
  2019-09-21  0:13   ` Andrew Morton
@ 2019-09-21  1:00     ` Rafael Aquini
  0 siblings, 0 replies; 6+ messages in thread
From: Rafael Aquini @ 2019-09-21  1:00 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Michal Hocko, Joel Savitz, linux-kernel, David Rientjes, linux-mm

On Fri, Sep 20, 2019 at 05:13:40PM -0700, Andrew Morton wrote:
> On Thu, 13 Jun 2019 10:23:18 +0200 Michal Hocko <mhocko@kernel.org> wrote:
> 
> > On Wed 12-06-19 13:57:53, Joel Savitz wrote:
> > > In the event of an oom kill, useful information about the killed
> > > process is printed to dmesg. Users, especially system administrators,
> > > will find it useful to immediately see the UID of the process.
> > 
> > Could you be more specific please? We already print uid when dumping
> > eligible tasks so it is not overly hard to find that information in the
> > oom report. Well, except when dumping of eligible tasks is disabled. Is
> > this what you are after?
> > 
> > Please always be specific about usecases in the changelog. A terse
> > statement that something is useful doesn't tell much very often.
> > 
> 
> <crickets?>
> I'll add this to the chagnelog:
> 
> : We already print uid when dumping eligible tasks so it is not overly hard
> : to find that information in the oom report.  However this information is
> : unavailable then dumping of eligible tasks is disabled.
                ^^^^ 

Thanks Andrew! just a minor nit there: 's/then/when/'


Acked-by: Rafael Aquini <aquini@redhat.com>
> 


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2019-09-21  1:00 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-12 17:57 [RESEND PATCH v2] mm/oom_killer: Add task UID to info message on an oom kill Joel Savitz
2019-06-12 18:40 ` Rafael Aquini
2019-06-13  1:00 ` Andrew Morton
2019-06-13  8:23 ` Michal Hocko
2019-09-21  0:13   ` Andrew Morton
2019-09-21  1:00     ` Rafael Aquini

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).