All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mm/oom_killer: Add task UID to info message on an oom kill
@ 2019-04-24 18:20 Joel Savitz
  2019-04-25 20:59 ` Rafael Aquini
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Joel Savitz @ 2019-04-24 18:20 UTC (permalink / raw)
  To: linux-kernel; +Cc: Joel Savitz, Rafael Aquini

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), UID 0,
total-vm:133880028kB, anon-rss:129754836kB, file-rss:0kB,
shmem-rss:0kB

Signed-off-by: Joel Savitz <jsavitz@redhat.com>
---
 mm/oom_kill.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/mm/oom_kill.c b/mm/oom_kill.c
index 3a2484884cfd..22972648b758 100644
--- a/mm/oom_kill.c
+++ b/mm/oom_kill.c
@@ -874,9 +874,9 @@ 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), UID %d, total-vm:%lukB, anon-rss:%lukB, file-rss:%lukB, shmem-rss:%lukB\n",
 		message, task_pid_nr(victim), victim->comm,
-		K(victim->mm->total_vm),
+		task_uid(victim).val, 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)));
-- 
2.18.1


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

* Re: [PATCH] mm/oom_killer: Add task UID to info message on an oom kill
  2019-04-24 18:20 [PATCH] mm/oom_killer: Add task UID to info message on an oom kill Joel Savitz
@ 2019-04-25 20:59 ` Rafael Aquini
  2019-04-25 22:45 ` David Rientjes
  2019-04-28 22:49 ` Michal Hocko
  2 siblings, 0 replies; 4+ messages in thread
From: Rafael Aquini @ 2019-04-25 20:59 UTC (permalink / raw)
  To: Joel Savitz; +Cc: linux-kernel

On Wed, Apr 24, 2019 at 02:20:13PM -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), UID 0,
> total-vm:133880028kB, anon-rss:129754836kB, file-rss:0kB,
> shmem-rss:0kB
> 
> Signed-off-by: Joel Savitz <jsavitz@redhat.com>
> ---
>  mm/oom_kill.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/mm/oom_kill.c b/mm/oom_kill.c
> index 3a2484884cfd..22972648b758 100644
> --- a/mm/oom_kill.c
> +++ b/mm/oom_kill.c
> @@ -874,9 +874,9 @@ 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), UID %d, total-vm:%lukB, anon-rss:%lukB, file-rss:%lukB, shmem-rss:%lukB\n",
>  		message, task_pid_nr(victim), victim->comm,
> -		K(victim->mm->total_vm),
> +		task_uid(victim).val, 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)));
> -- 
> 2.18.1
> 
Acked-by: Rafael Aquini <aquini@redhat.com>

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

* Re: [PATCH] mm/oom_killer: Add task UID to info message on an oom kill
  2019-04-24 18:20 [PATCH] mm/oom_killer: Add task UID to info message on an oom kill Joel Savitz
  2019-04-25 20:59 ` Rafael Aquini
@ 2019-04-25 22:45 ` David Rientjes
  2019-04-28 22:49 ` Michal Hocko
  2 siblings, 0 replies; 4+ messages in thread
From: David Rientjes @ 2019-04-25 22:45 UTC (permalink / raw)
  To: Joel Savitz; +Cc: linux-kernel, Rafael Aquini

On Wed, 24 Apr 2019, 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), UID 0,
> total-vm:133880028kB, anon-rss:129754836kB, file-rss:0kB,
> shmem-rss:0kB
> 
> Signed-off-by: Joel Savitz <jsavitz@redhat.com>

Makes sense, could you add it to the end of the message in case anybody is 
parsing the current string and we would now break their regex?

This would also need from_kuid(&init_user_ns, task_uid(task)) instead.

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

* Re: [PATCH] mm/oom_killer: Add task UID to info message on an oom kill
  2019-04-24 18:20 [PATCH] mm/oom_killer: Add task UID to info message on an oom kill Joel Savitz
  2019-04-25 20:59 ` Rafael Aquini
  2019-04-25 22:45 ` David Rientjes
@ 2019-04-28 22:49 ` Michal Hocko
  2 siblings, 0 replies; 4+ messages in thread
From: Michal Hocko @ 2019-04-28 22:49 UTC (permalink / raw)
  To: Joel Savitz; +Cc: linux-kernel, Rafael Aquini

On Wed 24-04-19 14:20:13, 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.

There was a more general rework of this message
http://lkml.kernel.org/r/1542799799-36184-1-git-send-email-ufo19890607@gmail.com
but I do not see it merged into Andrew's tree. Could you have a look and
pursue it, please?

-- 
Michal Hocko
SUSE Labs

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

end of thread, other threads:[~2019-04-28 22:49 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-24 18:20 [PATCH] mm/oom_killer: Add task UID to info message on an oom kill Joel Savitz
2019-04-25 20:59 ` Rafael Aquini
2019-04-25 22:45 ` David Rientjes
2019-04-28 22:49 ` Michal Hocko

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.