Skip to contentSkip to conversation

workqueue: avoid hard lockups in show_workqueue_state()

PATCH Applied Sergey Senozhatsky 2 participants 2 messages Jan 11, 2018 – Jan 12, 2018 Workqueue

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 workqueue: avoid hard lockups in show_workqueue_state()

show_workqueue_state() can print out a lot of messages while being in atomic context, e.g. sysrq-t -> show_workqueue_state(). If the console device is slow it may end up triggering NMI hard lockup watchdog.

---
 kernel/workqueue.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)
kernel/workqueue.c +13 -0
index 9960f8842b31..8dd2e66e8383 100644
@@ -48,6 +48,7 @@
 #include <linux/moduleparam.h>
 #include <linux/uaccess.h>
 #include <linux/sched/isolation.h>
+#include <linux/nmi.h>
 
 #include "workqueue_internal.h"
 
@@ -4473,6 +4474,12 @@ void show_workqueue_state(void)
 			if (pwq->nr_active || !list_empty(&pwq->delayed_works))
 				show_pwq(pwq);
 			spin_unlock_irqrestore(&pwq->pool->lock, flags);
+			/*
+			 * We could be printing a lot from atomic context, e.g.
+			 * sysrq-t -> show_workqueue_state(). Avoid triggering
+			 * hard lockup.
+			 */
+			touch_nmi_watchdog();
 		}
 	}
 
@@ -4500,6 +4507,12 @@ void show_workqueue_state(void)
 		pr_cont("\n");
 	next_pool:
 		spin_unlock_irqrestore(&pool->lock, flags);
+		/*
+		 * We could be printing a lot from atomic context, e.g.
+		 * sysrq-t -> show_workqueue_state(). Avoid triggering
+		 * hard lockup.
+		 */
+		touch_nmi_watchdog();
 	}
 
 	rcu_read_unlock_sched();
Signature · 1 line
2.15.1
maintainer Applied
#1 lore raw
Quoted 5 lines · Sergey Senozhatsky

show_workqueue_state() can print out a lot of messages while being in atomic context, e.g. sysrq-t -> show_workqueue_state(). If the console device is slow it may end up triggering NMI hard lockup watchdog.

Applied to wq/for-4.15-fixes.

Thanks.

Signature · 1 line
tejun