All of lore.kernel.org
 help / color / mirror / Atom feed
* [GIT PULL] workqueue fixes for v5.15-rc6
@ 2021-10-11 21:59 Tejun Heo
  2021-10-12  0:30 ` pr-tracker-bot
  0 siblings, 1 reply; 2+ messages in thread
From: Tejun Heo @ 2021-10-11 21:59 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: Lai Jiangshan, linux-kernel

Hello, Linus.

One patch to add a missing __printf and the other to enable deferred
printing for debug dumps to avoid deadlocks when triggered from some
contexts (e.g. console drivers).

Thanks.

The following changes since commit 6880fa6c56601bb8ed59df6c30fd390cc5f6dd8f:

  Linux 5.15-rc1 (2021-09-12 16:28:37 -0700)

are available in the Git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/tj/wq.git for-5.15-fixes

for you to fetch changes up to 57116ce17b04fde2fe30f0859df69d8dbe5809f6:

  workqueue: fix state-dump console deadlock (2021-10-11 06:50:28 -1000)

----------------------------------------------------------------
Johan Hovold (1):
      workqueue: fix state-dump console deadlock

Rolf Eike Beer (1):
      workqueue: annotate alloc_workqueue() as printf

 include/linux/workqueue.h |  5 ++---
 kernel/workqueue.c        | 18 ++++++++++++++++--
 2 files changed, 18 insertions(+), 5 deletions(-)

diff --git a/include/linux/workqueue.h b/include/linux/workqueue.h
index 2ebef6b1a3d6..74d3c1efd9bb 100644
--- a/include/linux/workqueue.h
+++ b/include/linux/workqueue.h
@@ -399,9 +399,8 @@ extern struct workqueue_struct *system_freezable_power_efficient_wq;
  * RETURNS:
  * Pointer to the allocated workqueue on success, %NULL on failure.
  */
-struct workqueue_struct *alloc_workqueue(const char *fmt,
-					 unsigned int flags,
-					 int max_active, ...);
+__printf(1, 4) struct workqueue_struct *
+alloc_workqueue(const char *fmt, unsigned int flags, int max_active, ...);
 
 /**
  * alloc_ordered_workqueue - allocate an ordered workqueue
diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index 33a6b4a2443d..1b3eb1e9531f 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -4830,8 +4830,16 @@ void show_workqueue_state(void)
 
 		for_each_pwq(pwq, wq) {
 			raw_spin_lock_irqsave(&pwq->pool->lock, flags);
-			if (pwq->nr_active || !list_empty(&pwq->inactive_works))
+			if (pwq->nr_active || !list_empty(&pwq->inactive_works)) {
+				/*
+				 * Defer printing to avoid deadlocks in console
+				 * drivers that queue work while holding locks
+				 * also taken in their write paths.
+				 */
+				printk_deferred_enter();
 				show_pwq(pwq);
+				printk_deferred_exit();
+			}
 			raw_spin_unlock_irqrestore(&pwq->pool->lock, flags);
 			/*
 			 * We could be printing a lot from atomic context, e.g.
@@ -4849,7 +4857,12 @@ void show_workqueue_state(void)
 		raw_spin_lock_irqsave(&pool->lock, flags);
 		if (pool->nr_workers == pool->nr_idle)
 			goto next_pool;
-
+		/*
+		 * Defer printing to avoid deadlocks in console drivers that
+		 * queue work while holding locks also taken in their write
+		 * paths.
+		 */
+		printk_deferred_enter();
 		pr_info("pool %d:", pool->id);
 		pr_cont_pool_info(pool);
 		pr_cont(" hung=%us workers=%d",
@@ -4864,6 +4877,7 @@ void show_workqueue_state(void)
 			first = false;
 		}
 		pr_cont("\n");
+		printk_deferred_exit();
 	next_pool:
 		raw_spin_unlock_irqrestore(&pool->lock, flags);
 		/*

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

* Re: [GIT PULL] workqueue fixes for v5.15-rc6
  2021-10-11 21:59 [GIT PULL] workqueue fixes for v5.15-rc6 Tejun Heo
@ 2021-10-12  0:30 ` pr-tracker-bot
  0 siblings, 0 replies; 2+ messages in thread
From: pr-tracker-bot @ 2021-10-12  0:30 UTC (permalink / raw)
  To: Tejun Heo; +Cc: Linus Torvalds, Lai Jiangshan, linux-kernel

The pull request you sent on Mon, 11 Oct 2021 11:59:57 -1000:

> git://git.kernel.org/pub/scm/linux/kernel/git/tj/wq.git for-5.15-fixes

has been merged into torvalds/linux.git:
https://git.kernel.org/torvalds/c/0a5d6c641b671370f019cbe20fe51ee3ef00264c

Thank you!

-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/prtracker.html

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

end of thread, other threads:[~2021-10-12  0:30 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-11 21:59 [GIT PULL] workqueue fixes for v5.15-rc6 Tejun Heo
2021-10-12  0:30 ` pr-tracker-bot

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.