Add a "show workqueues" SYSRQ knob.
Subsystems (3)
PATCH 1/1 Add a "show workqueues" SYSRQ knob.
Per Randy, I've added an update to Documentation/sysrq.txt and am resubmitting the patch in the proper style.
This patch adds a convenient function to show all workqueues using the magic SYSRQ handling. It uses the 'z' key to invoke the function as the 'w' key was already gone.
I've found this very useful in debugging; hopefully others will find it as useful.
diffstat wq.patch
drivers/char/sysrq.c | 14 +++++++++++++- include/linux/workqueue.h | 1 + kernel/workqueue.c | 26 ++++++++++++++++++++++++++ 3 files changed, 40 insertions(+), 1 deletion(-)
Signed-off-by Frank Mayhar <[email protected]>
Documentation/sysrq.txt +2 -0
@@ -110,6 +110,8 @@ On all - write a character to /proc/sysrq-trigger. e.g.: 'x' - Used by xmon interface on ppc/powerpc platforms. +'z' - Will dump the contents of the workqueues by workqueue and CPU. + '0'-'9' - Sets the console log level, controlling which kernel messages will be printed to your console. ('0', for example would make it so that only emergency messages like PANICs or OOPSes would
drivers/char/sysrq.c +13 -1
@@ -243,6 +243,18 @@ static struct sysrq_key_op sysrq_showmem_op = { .enable_mask = SYSRQ_ENABLE_DUMP, }; +static void sysrq_handle_showwq (int key,struct pt_regs *pt_regs, +struct tty_struct *tty) +{ +show_workqueues (); +} +static struct sysrq_key_op sysrq_showwq_op = { + .handler = sysrq_handle_showwq, + .help_msg ="showworkqueueZ" , + .action_msg ="Show Workqueues" , + .enable_mask =SYSRQ_ENABLE_DUMP , +}; +/* * Signal sysrq helper function. Sends a signal to all user processes. */
@@ -358,7 +370,7 @@ static struct sysrq_key_op *sysrq_key_table[36] = {/* x: May be registered on ppc/powerpc for xmon */ NULL ,/* x */ NULL ,/* y */ - NULL /* z */ + &sysrq_showwq_op /* z */ };/* key2index calculation, -1 on invalid index */
include/linux/workqueue.h +1 -0
@@ -195,6 +195,7 @@ extern int schedule_on_each_cpu(work_func_t func);extern int current_is_keventd (void );extern int keventd_up (void ); +extern void show_workqueues (void );extern void init_workqueues (void );int execute_in_process_context (work_func_t fn,struct execute_work *);
kernel/workqueue.c +26 -0
@@ -33,6 +33,7 @@#include <linux/kallsyms.h> #include <linux/debug_locks.h> #include <linux/lockdep.h> +#include <linux/kallsyms.h> /* * The per-CPU workqueue (if single thread, we always use the first
@@ -867,6 +868,31 @@ static int __devinit workqueue_cpu_callback(struct notifier_block *nfb,return NOTIFY_OK ; } +void show_workqueues (void ) +{ +struct workqueue_struct *wq; +int cpu; + +spin_lock (&workqueue_lock); +list_for_each_entry (wq, &workqueues, list) { +printk ("\n" ); +printk ("Workqueue %s:\n" , wq->name); +for_each_online_cpu (cpu) { +struct cpu_workqueue_struct *cwq =per_cpu_ptr (wq->cpu_wq, cpu); +struct work_struct *work; + +printk ("\tCPU %d " , cpu); +list_for_each_entry (work, &(cwq->worklist), entry) { +print_symbol ("function %s" , (unsigned long )work->func); + } +printk ("\n" ); + } + } +spin_unlock (&workqueue_lock); + +} +EXPORT_SYMBOL (show_workqueues); +void __init init_workqueues (void ) { cpu_populated_map = cpu_online_map;
Signature · 2 lines
Frank Mayhar <[email protected]> Google, Inc.