]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: tasks: Increase the right niced_task counter
authorOlivier Houchard <ohouchard@haproxy.com>
Mon, 1 Jun 2026 16:17:50 +0000 (18:17 +0200)
committerOlivier Houchard <cognet@ci0.org>
Mon, 1 Jun 2026 15:52:13 +0000 (17:52 +0200)
In __task_wakeup(), for a niced task, we don't always want to increase
the niced_task counter of the running thread's thread group, if we are
waking up the task of another thread, who belongs to a different thread
group, then we want to increment that thread group's counter instead, as
that's the one that will get decremented later.
So just increase the counter for the target thread'd thread group,
instead of using tg_ctx.
The impact is probably pretty minor, niced task shared amongst thread
are not very common, and the impact would mostly mean we'd run more/less
tasks in one run of process_runnable_tasks() than expected.
This should be backported as far as 2.8.

src/task.c

index ebce47da03382037e144f18ceacf888ba6992595..8d1bfdff1b0cce56589e10b1cf77bb788cf0e368 100644 (file)
@@ -237,7 +237,7 @@ void __task_wakeup(struct task *t)
        if (likely(t->nice)) {
                int offset;
 
-               _HA_ATOMIC_INC(&tg_ctx->niced_tasks);
+               _HA_ATOMIC_INC(&ha_thread_info[thr].tg_ctx->niced_tasks);
                offset = t->nice * (int)global.tune.runqueue_depth;
                t->rq.key += offset;
        }