MINOR: task: limit the remote thread wakeup to the global runqueue only
authorWilly Tarreau <w@1wt.eu>
Wed, 24 Feb 2021 15:44:51 +0000 (16:44 +0100)
committerWilly Tarreau <w@1wt.eu>
Wed, 24 Feb 2021 16:42:04 +0000 (17:42 +0100)
The test in __task_wakeup() to figure if the remote threads are sleeping
doesn't make sense outside of the global runqueue test, since there are
only two possibilities here: local runqueue or global runqueue, hence a
sleeping thread is another one and can only happen when sending to the
global run queue. Let's move the test inside the "if" block.

src/task.c

index 1d1e63c..32c17b0 100644 (file)
@@ -153,18 +153,18 @@ void __task_wakeup(struct task *t)
        if (root == &rqueue) {
                _HA_ATOMIC_OR(&t->state, TASK_GLOBAL);
                HA_SPIN_UNLOCK(TASK_RQ_LOCK, &rq_lock);
-       }
 
-       /* If all threads that are supposed to handle this task are sleeping,
-        * wake one.
-        */
-       if ((((t->thread_mask & all_threads_mask) & sleeping_thread_mask) ==
-            (t->thread_mask & all_threads_mask))) {
-               unsigned long m = (t->thread_mask & all_threads_mask) &~ tid_bit;
+               /* If all threads that are supposed to handle this task are sleeping,
+                * wake one.
+                */
+               if ((((t->thread_mask & all_threads_mask) & sleeping_thread_mask) ==
+                    (t->thread_mask & all_threads_mask))) {
+                       unsigned long m = (t->thread_mask & all_threads_mask) &~ tid_bit;
 
-               m = (m & (m - 1)) ^ m; // keep lowest bit set
-               _HA_ATOMIC_AND(&sleeping_thread_mask, ~m);
-               wake_thread(my_ffsl(m) - 1);
+                       m = (m & (m - 1)) ^ m; // keep lowest bit set
+                       _HA_ATOMIC_AND(&sleeping_thread_mask, ~m);
+                       wake_thread(my_ffsl(m) - 1);
+               }
        }
 #endif
        return;