Skip to content

Commit 704bc66

Browse files
Jungseung-Leehtejun
authored andcommitted
workqueue: Introduce show_freezable_workqueues
Currently show_all_workqueue is called if freeze fails at the time of freeze the workqueues, which shows the status of all workqueues and of all worker pools. In this cases we may only need to dump state of only workqueues that are freezable and busy. This patch defines show_freezable_workqueues, which uses show_one_workqueue, a granular function that shows the state of individual workqueues, so that dump only the state of freezable workqueues at that time. tj: Minor message adjustment. Signed-off-by: Jungseung Lee <js07.lee@samsung.com> Signed-off-by: Tejun Heo <tj@kernel.org>
1 parent cd2440d commit 704bc66

3 files changed

Lines changed: 26 additions & 3 deletions

File tree

include/linux/workqueue.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -472,6 +472,7 @@ extern unsigned int work_busy(struct work_struct *work);
472472
extern __printf(1, 2) void set_worker_desc(const char *fmt, ...);
473473
extern void print_worker_info(const char *log_lvl, struct task_struct *task);
474474
extern void show_all_workqueues(void);
475+
extern void show_freezable_workqueues(void);
475476
extern void show_one_workqueue(struct workqueue_struct *wq);
476477
extern void wq_worker_comm(char *buf, size_t size, struct task_struct *task);
477478

kernel/power/process.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ static int try_to_freeze_tasks(bool user_only)
9393
todo - wq_busy, wq_busy);
9494

9595
if (wq_busy)
96-
show_all_workqueues();
96+
show_freezable_workqueues();
9797

9898
if (!wakeup || pm_debug_messages_on) {
9999
read_lock(&tasklist_lock);

kernel/workqueue.c

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5065,8 +5065,7 @@ static void show_one_worker_pool(struct worker_pool *pool)
50655065
/**
50665066
* show_all_workqueues - dump workqueue state
50675067
*
5068-
* Called from a sysrq handler or try_to_freeze_tasks() and prints out
5069-
* all busy workqueues and pools.
5068+
* Called from a sysrq handler and prints out all busy workqueues and pools.
50705069
*/
50715070
void show_all_workqueues(void)
50725071
{
@@ -5087,6 +5086,29 @@ void show_all_workqueues(void)
50875086
rcu_read_unlock();
50885087
}
50895088

5089+
/**
5090+
* show_freezable_workqueues - dump freezable workqueue state
5091+
*
5092+
* Called from try_to_freeze_tasks() and prints out all freezable workqueues
5093+
* still busy.
5094+
*/
5095+
void show_freezable_workqueues(void)
5096+
{
5097+
struct workqueue_struct *wq;
5098+
5099+
rcu_read_lock();
5100+
5101+
pr_info("Showing freezable workqueues that are still busy:\n");
5102+
5103+
list_for_each_entry_rcu(wq, &workqueues, list) {
5104+
if (!(wq->flags & WQ_FREEZABLE))
5105+
continue;
5106+
show_one_workqueue(wq);
5107+
}
5108+
5109+
rcu_read_unlock();
5110+
}
5111+
50905112
/* used to show worker information through /proc/PID/{comm,stat,status} */
50915113
void wq_worker_comm(char *buf, size_t size, struct task_struct *task)
50925114
{

0 commit comments

Comments
 (0)