Skip to contentSkip to conversation

workqueue: Introduce show_one_worker_pool and show_one_workqueue.

RFC PATCH Superseded Imran Khan 2 participants 3 messages Oct 16, 2021 – Oct 20, 2021

Subsystems (4)

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore

Imran Khan

author
#0 lore raw

RFC PATCH v3 1/1 workqueue: Introduce show_one_worker_pool and show_one_workqueue.

Currently show_workqueue_state shows the state of all workqueues and of all worker pools. In certain cases we may need to dump state of only a specific workqueue or worker pool. For example in destroy_workqueue we only need to show state of the workqueue which is getting destroyed.

So rename show_workqueue_state to show_all_workqueues(to signify it dumps state of all busy workqueues) and divide it into more granular functions (show_one_workqueue and show_one_worker_pool), that would show states of individual workqueues and worker pools and can be used in cases such as the one mentioned above.

Also, as mentioned earlier, make destroy_workqueue dump data pertaining to only the workqueue that is being destroyed and make user(s) of earlier interface(show_workqueue_state), use new interface (show_all_workqueues).

---
Changes in v3:
- Address review comments regarding function names
- Change users of show_workqueue_state to use show_all_workqueues

 drivers/tty/sysrq.c       |   2 +-
 include/linux/workqueue.h |   3 +-
 kernel/power/process.c    |   2 +-
 kernel/workqueue.c        | 148 +++++++++++++++++++++-----------------
 4 files changed, 88 insertions(+), 67 deletions(-)
drivers/tty/sysrq.c +1 -1
index c911196ac893..8d0f07509ca7 100644
@@ -296,7 +296,7 @@ static const struct sysrq_key_op sysrq_showregs_op = {
 static void sysrq_handle_showstate(int key)
 {
 	show_state();
-	show_workqueue_state();
+	show_all_workqueues();
 }
 static const struct sysrq_key_op sysrq_showstate_op = {
 	.handler	= sysrq_handle_showstate,
include/linux/workqueue.h +2 -1
index 2ebef6b1a3d6..c48f86e38d89 100644
@@ -470,7 +470,8 @@ extern bool workqueue_congested(int cpu, struct workqueue_struct *wq);
 extern unsigned int work_busy(struct work_struct *work);
 extern __printf(1, 2) void set_worker_desc(const char *fmt, ...);
 extern void print_worker_info(const char *log_lvl, struct task_struct *task);
-extern void show_workqueue_state(void);
+extern void show_all_workqueues(void);
+extern void show_one_workqueue(struct workqueue_struct *wq);
 extern void wq_worker_comm(char *buf, size_t size, struct task_struct *task);
 
 /**
kernel/power/process.c +1 -1
index 37401c99b7d7..b7e7798637b8 100644
@@ -94,7 +94,7 @@ static int try_to_freeze_tasks(bool user_only)
 		       todo - wq_busy, wq_busy);
 
 		if (wq_busy)
-			show_workqueue_state();
+			show_all_workqueues();
 
 		if (!wakeup || pm_debug_messages_on) {
 			read_lock(&tasklist_lock);
kernel/workqueue.c +84 -64

187 lines not on this page · raw message

base-commit: 683f29b781aeaab6bf302eeb2ef08a5e5f9d8a27

Signature · 1 line
2.30.2
maintainer
#1 lore raw
Quoted 11 lines · Imran Khan

Currently show_workqueue_state shows the state of all workqueues and of all worker pools. In certain cases we may need to dump state of only a specific workqueue or worker pool. For example in destroy_workqueue we only need to show state of the workqueue which is getting destroyed.

So rename show_workqueue_state to show_all_workqueues(to signify it dumps state of all busy workqueues) and divide it into more granular functions (show_one_workqueue and show_one_worker_pool), that would show states of individual workqueues and worker pools and can be used in cases such as the one mentioned above.

Quoted 6 lines

Also, as mentioned earlier, make destroy_workqueue dump data pertaining to only the workqueue that is being destroyed and make user(s) of earlier interface(show_workqueue_state), use new interface (show_all_workqueues).

Can you respin the patch on top of the following branch?

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

Thank you.

Signature · 1 line
tejun
author
#2 lore raw

Hi Tejun,

Quoted 17 lines · Tejun Heo
Quoted 16 lines · Imran Khan

Currently show_workqueue_state shows the state of all workqueues and of all worker pools. In certain cases we may need to dump state of only a specific workqueue or worker pool. For example in destroy_workqueue we only need to show state of the workqueue which is getting destroyed.

So rename show_workqueue_state to show_all_workqueues(to signify it dumps state of all busy workqueues) and divide it into more granular functions (show_one_workqueue and show_one_worker_pool), that would show states of individual workqueues and worker pools and can be used in cases such as the one mentioned above.

Also, as mentioned earlier, make destroy_workqueue dump data pertaining to only the workqueue that is being destroyed and make user(s) of earlier interface(show_workqueue_state), use new interface (show_all_workqueues).

Quoted 5 lines
Quoted 1 line

Can you respin the patch on top of the following branch?

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

Sure, I have rebased it upon the suggested branch and have sent v4 [1] of the change.

[1] https://lore.kernel.org/lkml/[email protected]/

Thanks,
--Imran

Quoted 3 lines

Thank you.