Skip to contentSkip to conversation

workqueue: Use wake_up_worker() to wake up first idle worker

PATCH Applied linmiaohe 3 participants 3 messages Jul 27, 2020 – Sep 4, 2020 Workqueue

lore
Share & tools
lore

linmiaohe

author
#0 lore raw

PATCH 1/1 workqueue: Use wake_up_worker() to wake up first idle worker

From: Miaohe Lin <[email protected]>

Use wrapper function wake_up_worker() to wake up first idle worker.

---
 kernel/workqueue.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)
kernel/workqueue.c +4 -6
index c41c3c17b86a..5302f227f38f 100644
@@ -864,7 +864,7 @@ void wq_worker_running(struct task_struct *task)
  */
 void wq_worker_sleeping(struct task_struct *task)
 {
-	struct worker *next, *worker = kthread_data(task);
+	struct worker *worker = kthread_data(task);
 	struct worker_pool *pool;
 
 	/*
@@ -896,11 +896,9 @@ void wq_worker_sleeping(struct task_struct *task)
 	 * lock is safe.
 	 */
 	if (atomic_dec_and_test(&pool->nr_running) &&
-	    !list_empty(&pool->worklist)) {
-		next = first_idle_worker(pool);
-		if (next)
-			wake_up_process(next->task);
-	}
+	    !list_empty(&pool->worklist))
+		wake_up_worker(pool);
+
 	raw_spin_unlock_irq(&pool->lock);
 }
 
Signature · 1 line
2.19.1
reviewer Reviewed-by on v1 1/1
#1 lore raw
Quoted 6 lines · linmiaohe

From: Miaohe Lin <[email protected]>

Use wrapper function wake_up_worker() to wake up first idle worker.

Quoted 35 lines
---
 kernel/workqueue.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)
kernel/workqueue.c +4 -7
index c41c3c17b86a..5302f227f38f 100644
@@ -864,7 +864,7 @@ void wq_worker_running(struct task_struct *task)
  */
 void wq_worker_sleeping(struct task_struct *task)
 {
-       struct worker *next, *worker = kthread_data(task);
+       struct worker *worker = kthread_data(task);
        struct worker_pool *pool;
 
        /*
@@ -896,11 +896,9 @@ void wq_worker_sleeping(struct task_struct *task)
         * lock is safe.
         */
        if (atomic_dec_and_test(&pool->nr_running) &&
-           !list_empty(&pool->worklist)) {
-               next = first_idle_worker(pool);
-               if (next)
-                       wake_up_process(next->task);
-       }
+           !list_empty(&pool->worklist))
+               wake_up_worker(pool);
+
        raw_spin_unlock_irq(&pool->lock);
 }
 
--

2.19.1