]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MAJOR: tasks: Use the TASK_GLOBAL flag to know if we're in the global rq.
authorOlivier Houchard <ohouchard@haproxy.com>
Thu, 14 Mar 2019 15:14:04 +0000 (16:14 +0100)
committerOlivier Houchard <cognet@ci0.org>
Thu, 14 Mar 2019 15:19:11 +0000 (16:19 +0100)
In task_unlink_rq, to decide if we should logk the global runqueue lock,
use the TASK_GLOBAL flag instead of relying on t->thread_mask being tid_bit,
as it could be so while still being in the global runqueue if another thread
woke that task for us.

This should be backported to 1.9.

include/proto/task.h

index 8ac8cd2c1f1e010e35852d4f6f5c93e0b5078bb8..0f8017d1b14d909ca1151207b6c8c1608dd14879 100644 (file)
@@ -225,14 +225,16 @@ static inline struct task *__task_unlink_rq(struct task *t)
  */
 static inline struct task *task_unlink_rq(struct task *t)
 {
-       if (t->thread_mask != tid_bit)
+       int is_global = t->state & TASK_GLOBAL;
+
+       if (is_global)
                HA_SPIN_LOCK(TASK_RQ_LOCK, &rq_lock);
        if (likely(task_in_rq(t))) {
                if (&t->rq == rq_next)
                        rq_next = eb32sc_next(rq_next, tid_bit);
                __task_unlink_rq(t);
        }
-       if (t->thread_mask != tid_bit)
+       if (is_global)
                HA_SPIN_UNLOCK(TASK_RQ_LOCK, &rq_lock);
        return t;
 }