diff mbox series

[v2] syzbot: Dump all threads upon global OOM.

Message ID 312c642d-559b-92c7-0377-d98ec416e0bd@i-love.sakura.ne.jp (mailing list archive)
State New, archived
Headers show
Series [v2] syzbot: Dump all threads upon global OOM. | expand

Commit Message

Tetsuo Handa Sept. 7, 2018, 1:21 p.m. UTC
On 2018/09/07 21:57, Dmitry Vyukov wrote:
>> @@ -446,6 +447,10 @@ static void dump_header(struct oom_control *oc, struct task_struct *p)
>>                 if (is_dump_unreclaim_slabs())
>>                         dump_unreclaimable_slab();
>>         }
>> +#ifdef CONFIG_DEBUG_AID_FOR_SYZBOT
>> +       show_state();
>> +       panic("Out of memory");
> 
> won't this panic on every oom?
> we have lots of oom's, especially inside of cgroups, but probably global too
> it would be bad if we crash all machines this way
> 
> 

OK. Here is updated patch.

From f3bc8fe25f61d83033472470f950434adc686e20 Mon Sep 17 00:00:00 2001
From: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Date: Fri, 7 Sep 2018 22:18:23 +0900
Subject: [PATCH v2] syzbot: Dump all threads upon global OOM.

syzbot is getting stalls with linux-next kernels because dump_tasks() from
out_of_memory() is printing 5600 tasks. Most of these tasks are syzbot
processes but syzbot is supposed not to create so many processes.
Therefore, let's start from checking what these tasks are doing.
This change will be removed after the bug is fixed.

Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Cc: Dmitry Vyukov <dvyukov@google.com>
Cc: Michal Hocko <mhocko@kernel.org>
---
 mm/oom_kill.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
diff mbox series

Patch

diff --git a/mm/oom_kill.c b/mm/oom_kill.c
index f10aa53..7130285 100644
--- a/mm/oom_kill.c
+++ b/mm/oom_kill.c
@@ -41,6 +41,7 @@ 
 #include <linux/kthread.h>
 #include <linux/init.h>
 #include <linux/mmu_notifier.h>
+#include <linux/sched/debug.h>
 
 #include <asm/tlb.h>
 #include "internal.h"
@@ -446,6 +447,24 @@  static void dump_header(struct oom_control *oc, struct task_struct *p)
 		if (is_dump_unreclaim_slabs())
 			dump_unreclaimable_slab();
 	}
+#ifdef CONFIG_DEBUG_AID_FOR_SYZBOT
+	if (!is_sysrq_oom(oc) && !is_memcg_oom(oc)) {
+		struct task_struct *p;
+		unsigned int tasks = 0;
+
+		rcu_read_lock();
+		for_each_process(p) {
+			if (!(p->flags & PF_KTHREAD))
+				tasks++;
+		}
+		rcu_read_unlock();
+
+		if (tasks >= 1000) {
+			show_state();
+			panic("Out of memory with too many tasks.");
+		}
+	}
+#endif
 	if (sysctl_oom_dump_tasks)
 		dump_tasks(oc->memcg, oc->nodemask);
 }