diff mbox series

[v2] mm, oom: show process exiting information in __oom_kill_process()

Message ID 20200721010127.17238-1-laoar.shao@gmail.com (mailing list archive)
State New, archived
Headers show
Series [v2] mm, oom: show process exiting information in __oom_kill_process() | expand

Commit Message

Yafang Shao July 21, 2020, 1:01 a.m. UTC
When the OOM killer finding a victim and trying to kill it, if the victim
is already exiting, the task mm will be NULL and no process will be killed.
But the dump_header() has been already executed, so it will be strange to
dump so many information without killing a process. We'd better show some
helpful information to indicate why this happens.

Suggested-by: David Rientjes <rientjes@google.com>
Signed-off-by: Yafang Shao <laoar.shao@gmail.com>
Cc: Michal Hocko <mhocko@kernel.org>
Cc: Tetsuo Handa <penguin-kernel@i-love.sakura.ne.jp>
Cc: Qian Cai <cai@lca.pw>

---
v1 -> v2:
- improve the output, per Tetsuo and Michal
---
 mm/oom_kill.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Michal Hocko July 21, 2020, 6:06 a.m. UTC | #1
On Mon 20-07-20 21:01:27, Yafang Shao wrote:
> When the OOM killer finding a victim and trying to kill it, if the victim
> is already exiting, the task mm will be NULL and no process will be killed.
> But the dump_header() has been already executed, so it will be strange to
> dump so many information without killing a process. We'd better show some
> helpful information to indicate why this happens.
> 
> Suggested-by: David Rientjes <rientjes@google.com>
> Signed-off-by: Yafang Shao <laoar.shao@gmail.com>
> Cc: Michal Hocko <mhocko@kernel.org>
> Cc: Tetsuo Handa <penguin-kernel@i-love.sakura.ne.jp>
> Cc: Qian Cai <cai@lca.pw>

Acked-by: Michal Hocko <mhocko@suse.com>

Thanks!

> ---
> v1 -> v2:
> - improve the output, per Tetsuo and Michal
> ---
>  mm/oom_kill.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/mm/oom_kill.c b/mm/oom_kill.c
> index 6e94962893ee..c176c988c109 100644
> --- a/mm/oom_kill.c
> +++ b/mm/oom_kill.c
> @@ -863,6 +863,8 @@ static void __oom_kill_process(struct task_struct *victim, const char *message)
>  
>  	p = find_lock_task_mm(victim);
>  	if (!p) {
> +		pr_info("%s: OOM victim %d (%s) is already exiting. Skip killing the task\n",
> +			message, task_pid_nr(victim), victim->comm);
>  		put_task_struct(victim);
>  		return;
>  	} else if (victim != p) {
> -- 
> 2.18.1
diff mbox series

Patch

diff --git a/mm/oom_kill.c b/mm/oom_kill.c
index 6e94962893ee..c176c988c109 100644
--- a/mm/oom_kill.c
+++ b/mm/oom_kill.c
@@ -863,6 +863,8 @@  static void __oom_kill_process(struct task_struct *victim, const char *message)
 
 	p = find_lock_task_mm(victim);
 	if (!p) {
+		pr_info("%s: OOM victim %d (%s) is already exiting. Skip killing the task\n",
+			message, task_pid_nr(victim), victim->comm);
 		put_task_struct(victim);
 		return;
 	} else if (victim != p) {