]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MEDIUM: tasks: Don't forget to increase/decrease tasks_run_queue.
authorOlivier Houchard <ohouchard@haproxy.com>
Mon, 28 May 2018 11:51:06 +0000 (13:51 +0200)
committerWilly Tarreau <w@1wt.eu>
Mon, 28 May 2018 13:20:55 +0000 (15:20 +0200)
Don't forget to increase tasks_run_queue when we're adding a task to the
tasklet list, and to decrease it when we remove a task from a runqueue,
or its value won't be accurate, and could lead to tasks not being executed
when put in the global run queue.

1.9-dev only, no backport is needed.

include/proto/task.h

index c8004143bb132b4645a587d0e3328f62b60cadac..ef296f6e97a39b4362bdcf4fa0d23718636486ec 100644 (file)
@@ -177,6 +177,7 @@ static inline struct task *task_unlink_wq(struct task *t)
  */
 static inline struct task *__task_unlink_rq(struct task *t)
 {
+       HA_ATOMIC_SUB(&tasks_run_queue, 1);
        eb32sc_delete(&t->rq);
        if (likely(t->nice))
                HA_ATOMIC_SUB(&niced_tasks, 1);
@@ -219,6 +220,7 @@ static inline void task_insert_into_tasklet_list(struct task *t)
         */
        if (unlikely(!HA_ATOMIC_CAS(&t->rq.node.leaf_p, &expected, 0x1)))
                return;
+       HA_ATOMIC_ADD(&tasks_run_queue, 1);
        task_list_size[tid]++;
        tl = (struct tasklet *)t;
        LIST_ADDQ(&task_list[tid], &tl->list);