mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-08-07 23:56:57 +02:00
MEDIUM: tasks: check the global task mask instead of the thread number
When deciding whether to scan the global run queue or not, we currently check the configured threads number, and if it's 1 we skip the queue since it's not supposed to be used. However when running with a master process and multiple threads in the workers, the master will turn this number back to 1 while some task wakeups might possibly have set bits in the global tasks mask, thus causing active_tasks_mask to have one bit permanently set, preventing the process from sleeping. Instead of checking global.nbthread, let's check for the current thread's bit in global_tasks_mask. First it will make this part of the code more consistent, working like a test and set operation, it will solve the issue with master+nbthread and as a bonus it will save a lock/unlock for each scheduler call when the thread doesn't have a task in the global run queue.
This commit is contained in:
parent
a1214a501f
commit
1ee55fddea
@ -322,7 +322,7 @@ void process_runnable_tasks()
|
|||||||
nb_tasks_cur = nb_tasks;
|
nb_tasks_cur = nb_tasks;
|
||||||
max_processed = global.tune.runqueue_depth;
|
max_processed = global.tune.runqueue_depth;
|
||||||
|
|
||||||
if (likely(global.nbthread > 1)) {
|
if (likely(global_tasks_mask & tid_bit)) {
|
||||||
HA_SPIN_LOCK(TASK_RQ_LOCK, &rq_lock);
|
HA_SPIN_LOCK(TASK_RQ_LOCK, &rq_lock);
|
||||||
if (!(active_tasks_mask & tid_bit)) {
|
if (!(active_tasks_mask & tid_bit)) {
|
||||||
HA_SPIN_UNLOCK(TASK_RQ_LOCK, &rq_lock);
|
HA_SPIN_UNLOCK(TASK_RQ_LOCK, &rq_lock);
|
||||||
|
Loading…
Reference in New Issue
Block a user