mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-09-22 14:21:25 +02:00
BUG/MEDIUM: tasklets: Make sure we're waking the target thread if it sleeps.
Now that we can wake tasklet for other threads, make sure that if the thread is sleeping, we wake it up, or the tasklet won't be executed until it's done sleeping. That also means that, before going to sleep, and after we put our bit in sleeping_thread_mask, we have to check that nobody added a tasklet for us, just checking for global_tasks_mask isn't enough anymore.
This commit is contained in:
parent
c45791aa52
commit
bba1a263c5
@ -38,6 +38,8 @@
|
|||||||
#include <types/global.h>
|
#include <types/global.h>
|
||||||
#include <types/task.h>
|
#include <types/task.h>
|
||||||
|
|
||||||
|
#include <proto/fd.h>
|
||||||
|
|
||||||
/* Principle of the wait queue.
|
/* Principle of the wait queue.
|
||||||
*
|
*
|
||||||
* We want to be able to tell whether an expiration date is before of after the
|
* We want to be able to tell whether an expiration date is before of after the
|
||||||
@ -226,8 +228,13 @@ static inline struct task *task_unlink_rq(struct task *t)
|
|||||||
|
|
||||||
static inline void tasklet_wakeup(struct tasklet *tl)
|
static inline void tasklet_wakeup(struct tasklet *tl)
|
||||||
{
|
{
|
||||||
if (MT_LIST_ADDQ(&task_per_thread[tl->tid].task_list, &tl->list) == 1)
|
if (MT_LIST_ADDQ(&task_per_thread[tl->tid].task_list, &tl->list) == 1) {
|
||||||
_HA_ATOMIC_ADD(&tasks_run_queue, 1);
|
_HA_ATOMIC_ADD(&tasks_run_queue, 1);
|
||||||
|
if (sleeping_thread_mask & (1 << tl->tid)) {
|
||||||
|
_HA_ATOMIC_AND(&sleeping_thread_mask, ~(1 << tl->tid));
|
||||||
|
wake_thread(tl->tid);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2634,7 +2634,7 @@ static void run_poll_loop()
|
|||||||
else {
|
else {
|
||||||
_HA_ATOMIC_OR(&sleeping_thread_mask, tid_bit);
|
_HA_ATOMIC_OR(&sleeping_thread_mask, tid_bit);
|
||||||
__ha_barrier_atomic_store();
|
__ha_barrier_atomic_store();
|
||||||
if (global_tasks_mask & tid_bit) {
|
if ((global_tasks_mask & tid_bit) || thread_has_tasks()) {
|
||||||
activity[tid].wake_tasks++;
|
activity[tid].wake_tasks++;
|
||||||
_HA_ATOMIC_AND(&sleeping_thread_mask, ~tid_bit);
|
_HA_ATOMIC_AND(&sleeping_thread_mask, ~tid_bit);
|
||||||
} else
|
} else
|
||||||
|
Loading…
x
Reference in New Issue
Block a user