From 1d7f37a2cb395323605e474c1539836e609734b0 Mon Sep 17 00:00:00 2001 From: Olivier Houchard Date: Thu, 14 Mar 2019 16:14:04 +0100 Subject: [PATCH] BUG/MAJOR: tasks: Use the TASK_GLOBAL flag to know if we're in the global rq. 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 | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/include/proto/task.h b/include/proto/task.h index 8ac8cd2c1..0f8017d1b 100644 --- a/include/proto/task.h +++ b/include/proto/task.h @@ -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; }