]> git.dujemihanovic.xyz Git - linux.git/commitdiff
workqueue: Introduce show_freezable_workqueues
authorJungseung Lee <js07.lee@samsung.com>
Mon, 20 Mar 2023 03:29:05 +0000 (12:29 +0900)
committerTejun Heo <tj@kernel.org>
Fri, 24 Mar 2023 01:55:38 +0000 (15:55 -1000)
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>
include/linux/workqueue.h
kernel/power/process.c
kernel/workqueue.c

index ac551b8ee7d9f2f49a90fe3225e51bd41161809e..3992c994787f2df6bb534d9de6d8b52d2899e7cb 100644 (file)
@@ -472,6 +472,7 @@ 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_all_workqueues(void);
+extern void show_freezable_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);
 
index 6c1c7e566d35ece1381bc85186140b3c3fae7e45..cae81a87cc91e3a2f06da590f8db68fb22b4db26 100644 (file)
@@ -93,7 +93,7 @@ static int try_to_freeze_tasks(bool user_only)
                       todo - wq_busy, wq_busy);
 
                if (wq_busy)
-                       show_all_workqueues();
+                       show_freezable_workqueues();
 
                if (!wakeup || pm_debug_messages_on) {
                        read_lock(&tasklist_lock);
index 044b4eee760bb7a60df992c1ef41c7b08e18731c..d78935e4fb5dfc641c3571a4f2dbf347ca67ae9d 100644 (file)
@@ -5065,8 +5065,7 @@ next_pool:
 /**
  * show_all_workqueues - dump workqueue state
  *
- * Called from a sysrq handler or try_to_freeze_tasks() and prints out
- * all busy workqueues and pools.
+ * Called from a sysrq handler and prints out all busy workqueues and pools.
  */
 void show_all_workqueues(void)
 {
@@ -5087,6 +5086,29 @@ void show_all_workqueues(void)
        rcu_read_unlock();
 }
 
+/**
+ * show_freezable_workqueues - dump freezable workqueue state
+ *
+ * Called from try_to_freeze_tasks() and prints out all freezable workqueues
+ * still busy.
+ */
+void show_freezable_workqueues(void)
+{
+       struct workqueue_struct *wq;
+
+       rcu_read_lock();
+
+       pr_info("Showing freezable workqueues that are still busy:\n");
+
+       list_for_each_entry_rcu(wq, &workqueues, list) {
+               if (!(wq->flags & WQ_FREEZABLE))
+                       continue;
+               show_one_workqueue(wq);
+       }
+
+       rcu_read_unlock();
+}
+
 /* used to show worker information through /proc/PID/{comm,stat,status} */
 void wq_worker_comm(char *buf, size_t size, struct task_struct *task)
 {