mirror of
https://github.com/haproxy/haproxy.git
synced 2026-07-05 15:27:44 -04:00
MEDIUM: task: make __tasklet_wakeup_on() only accept non-local threads
The ambiguity in usage for __tasklet_wakeup_on() is now gone. All known callers that used to be able to pass a negative value now call __tasklet_wakeup_here(), and remaining ones always pass an explicit thread number. This means that we can remove the "if (thr<0)" branch, but still leave a BUG_ON_HOT() to catch any possibly missed case. The comment around tasklet_wakeup_on() not supporting remotely waking a tasklet whose tid<0 was also removed since it was addressed long ago.
This commit is contained in:
parent
56f6a049bd
commit
69c799f286
2 changed files with 10 additions and 41 deletions
|
|
@ -474,12 +474,9 @@ static inline void _tasklet_wakeup_here(struct tasklet *tl, uint f, const struct
|
|||
__tasklet_wakeup_here(tl);
|
||||
}
|
||||
|
||||
/* schedules tasklet <tl> to run onto thread <thr> or the current thread if
|
||||
* <thr> is negative. Note that it is illegal to wakeup a foreign tasklet if
|
||||
* its tid is negative and it is illegal to self-assign a tasklet that was
|
||||
* at least once scheduled on a specific thread. With DEBUG_TASK, the
|
||||
* <file>:<line> from the call place are stored into the tasklet for tracing
|
||||
* purposes.
|
||||
/* schedules tasklet <tl> to run onto thread <thr> which must be valid. With
|
||||
* DEBUG_TASK, the <file>:<line> from the call place are stored into the
|
||||
* tasklet for tracing purposes.
|
||||
*
|
||||
* The macro accepts an optional 3rd argument that is passed as a set of flags
|
||||
* to be set on the tasklet, among TASK_WOKEN_*, TASK_F_UEVT* etc to indicate a
|
||||
|
|
|
|||
42
src/task.c
42
src/task.c
|
|
@ -168,46 +168,18 @@ void __tasklet_wakeup_here(struct tasklet *tl)
|
|||
|
||||
/* Do not call this one, please use tasklet_wakeup_on() instead, as this one is
|
||||
* the slow path of tasklet_wakeup_on() which performs some preliminary checks
|
||||
* and sets TASK_QUEUED before calling this one. A negative <thr> designates
|
||||
* the current thread.
|
||||
* and sets TASK_QUEUED before calling this one.
|
||||
*/
|
||||
void __tasklet_wakeup_on(struct tasklet *tl, int thr)
|
||||
{
|
||||
if (likely(thr < 0)) {
|
||||
/* this tasklet runs on the caller thread */
|
||||
if (_HA_ATOMIC_LOAD(&th_ctx->flags) & TH_FL_TASK_PROFILING)
|
||||
tl->wake_date = now_mono_time();
|
||||
BUG_ON_HOT(thr < 0);
|
||||
|
||||
if (tl->state & TASK_HEAVY) {
|
||||
LIST_APPEND(&th_ctx->tasklets[TL_HEAVY], &tl->list);
|
||||
th_ctx->tl_class_mask |= 1 << TL_HEAVY;
|
||||
}
|
||||
else if (tl->state & TASK_SELF_WAKING) {
|
||||
LIST_APPEND(&th_ctx->tasklets[TL_BULK], &tl->list);
|
||||
th_ctx->tl_class_mask |= 1 << TL_BULK;
|
||||
}
|
||||
else if ((struct task *)tl == th_ctx->current && !(tl->state & TASK_WOKEN_ANY)) {
|
||||
LIST_APPEND(&th_ctx->tasklets[TL_BULK], &tl->list);
|
||||
th_ctx->tl_class_mask |= 1 << TL_BULK;
|
||||
}
|
||||
else if (th_ctx->current_queue < 0) {
|
||||
LIST_APPEND(&th_ctx->tasklets[TL_URGENT], &tl->list);
|
||||
th_ctx->tl_class_mask |= 1 << TL_URGENT;
|
||||
}
|
||||
else {
|
||||
LIST_APPEND(&th_ctx->tasklets[TL_NORMAL], &tl->list);
|
||||
th_ctx->tl_class_mask |= 1 << TL_NORMAL;
|
||||
}
|
||||
_HA_ATOMIC_INC(&th_ctx->rq_total);
|
||||
} else {
|
||||
/* this tasklet runs on a specific thread. */
|
||||
if (_HA_ATOMIC_LOAD(&ha_thread_ctx[thr].flags) & TH_FL_TASK_PROFILING)
|
||||
tl->wake_date = now_mono_time();
|
||||
if (_HA_ATOMIC_LOAD(&ha_thread_ctx[thr].flags) & TH_FL_TASK_PROFILING)
|
||||
tl->wake_date = now_mono_time();
|
||||
|
||||
MT_LIST_APPEND(&ha_thread_ctx[thr].shared_tasklet_list, list_to_mt_list(&tl->list));
|
||||
_HA_ATOMIC_INC(&ha_thread_ctx[thr].rq_total);
|
||||
wake_thread(thr);
|
||||
}
|
||||
MT_LIST_APPEND(&ha_thread_ctx[thr].shared_tasklet_list, list_to_mt_list(&tl->list));
|
||||
_HA_ATOMIC_INC(&ha_thread_ctx[thr].rq_total);
|
||||
wake_thread(thr);
|
||||
}
|
||||
|
||||
/* Do not call this one, please use tasklet_wakeup_after_on() instead, as this one is
|
||||
|
|
|
|||
Loading…
Reference in a new issue