MINOR: task: replace task_set_affinity() with task_set_thread()
The latter passes a thread ID instead of a mask, making the code simpler.
This commit is contained in:
parent
159e3acf5d
commit
eed3911a54
@ -91,10 +91,12 @@ void task_queue(t)
|
|||||||
function for local tasks or for shared tasks who have the calling
|
function for local tasks or for shared tasks who have the calling
|
||||||
thread in their thread mask.
|
thread in their thread mask.
|
||||||
|
|
||||||
void task_set_affinity(t, m)
|
void task_set_thread(t, id)
|
||||||
Change task <t>'s thread_mask to new value <m>. This may only be
|
Change task <t>'s thread ID to new value <id>. This may only be
|
||||||
performed by the task itself while running. This is only used to let a
|
performed by the task itself while running. This is only used to let a
|
||||||
task voluntarily migrate to another thread.
|
task voluntarily migrate to another thread. Thread id -1 is used to
|
||||||
|
indicate "any thread". It's ignored and replaced by zero when threads
|
||||||
|
are disabled.
|
||||||
|
|
||||||
void tasklet_wakeup(tl)
|
void tasklet_wakeup(tl)
|
||||||
Make sure that tasklet <tl> will wake up, that is, will execute at
|
Make sure that tasklet <tl> will wake up, that is, will execute at
|
||||||
|
@ -66,7 +66,7 @@ static inline int appctx_init(struct appctx *appctx)
|
|||||||
* eventually be created. The affinity must be set now !
|
* eventually be created. The affinity must be set now !
|
||||||
*/
|
*/
|
||||||
BUG_ON(appctx->t->tid != tid);
|
BUG_ON(appctx->t->tid != tid);
|
||||||
task_set_affinity(appctx->t, tid_bit);
|
task_set_thread(appctx->t, tid);
|
||||||
|
|
||||||
if (appctx->applet->init)
|
if (appctx->applet->init)
|
||||||
return appctx->applet->init(appctx);
|
return appctx->applet->init(appctx);
|
||||||
|
@ -324,22 +324,22 @@ static inline void task_queue(struct task *task)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* change the thread affinity of a task to <thread_mask>.
|
/* Change the thread affinity of a task to <thr>, which may either be a valid
|
||||||
|
* thread number from 0 to nbthread-1, or a negative value to allow the task
|
||||||
|
* to run on any thread.
|
||||||
|
*
|
||||||
* This may only be done from within the running task itself or during its
|
* This may only be done from within the running task itself or during its
|
||||||
* initialization. It will unqueue and requeue the task from the wait queue
|
* initialization. It will unqueue and requeue the task from the wait queue
|
||||||
* if it was in it. This is safe against a concurrent task_queue() call because
|
* if it was in it. This is safe against a concurrent task_queue() call because
|
||||||
* task_queue() itself will unlink again if needed after taking into account
|
* task_queue() itself will unlink again if needed after taking into account
|
||||||
* the new thread_mask.
|
* the new thread_mask.
|
||||||
*/
|
*/
|
||||||
static inline void task_set_affinity(struct task *t, unsigned long thread_mask)
|
static inline void task_set_thread(struct task *t, int thr)
|
||||||
{
|
{
|
||||||
int thr;
|
#ifndef USE_THREAD
|
||||||
|
/* no shared queue without threads */
|
||||||
if (atleast2(thread_mask))
|
thr = 0;
|
||||||
thr = -1;
|
#endif
|
||||||
else
|
|
||||||
thr = my_ffsl(thread_mask) - 1;
|
|
||||||
|
|
||||||
if (unlikely(task_in_wq(t))) {
|
if (unlikely(task_in_wq(t))) {
|
||||||
task_unlink_wq(t);
|
task_unlink_wq(t);
|
||||||
t->tid = thr;
|
t->tid = thr;
|
||||||
|
@ -1118,7 +1118,7 @@ struct task *process_chk_conn(struct task *t, void *context, unsigned int state)
|
|||||||
check->state |= CHK_ST_INPROGRESS;
|
check->state |= CHK_ST_INPROGRESS;
|
||||||
TRACE_STATE("init new health-check", CHK_EV_TASK_WAKE|CHK_EV_HCHK_START, check);
|
TRACE_STATE("init new health-check", CHK_EV_TASK_WAKE|CHK_EV_HCHK_START, check);
|
||||||
|
|
||||||
task_set_affinity(t, tid_bit);
|
task_set_thread(t, tid);
|
||||||
|
|
||||||
check->current_step = NULL;
|
check->current_step = NULL;
|
||||||
|
|
||||||
@ -1217,7 +1217,7 @@ struct task *process_chk_conn(struct task *t, void *context, unsigned int state)
|
|||||||
if (LIST_INLIST(&check->buf_wait.list))
|
if (LIST_INLIST(&check->buf_wait.list))
|
||||||
LIST_DEL_INIT(&check->buf_wait.list);
|
LIST_DEL_INIT(&check->buf_wait.list);
|
||||||
|
|
||||||
task_set_affinity(t, all_threads_mask);
|
task_set_thread(t, -1);
|
||||||
check_release_buf(check, &check->bi);
|
check_release_buf(check, &check->bi);
|
||||||
check_release_buf(check, &check->bo);
|
check_release_buf(check, &check->bo);
|
||||||
check->state &= ~(CHK_ST_INPROGRESS|CHK_ST_IN_ALLOC|CHK_ST_OUT_ALLOC);
|
check->state &= ~(CHK_ST_INPROGRESS|CHK_ST_IN_ALLOC|CHK_ST_OUT_ALLOC);
|
||||||
|
@ -525,7 +525,7 @@ struct task *process_chk_proc(struct task *t, void *context, unsigned int state)
|
|||||||
int t_con = tick_add(now_ms, s->proxy->timeout.connect);
|
int t_con = tick_add(now_ms, s->proxy->timeout.connect);
|
||||||
t->expire = tick_first(t->expire, t_con);
|
t->expire = tick_first(t->expire, t_con);
|
||||||
}
|
}
|
||||||
task_set_affinity(t, tid_bit);
|
task_set_thread(t, tid);
|
||||||
goto reschedule;
|
goto reschedule;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -588,7 +588,7 @@ struct task *process_chk_proc(struct task *t, void *context, unsigned int state)
|
|||||||
/* a success was detected */
|
/* a success was detected */
|
||||||
check_notify_success(check);
|
check_notify_success(check);
|
||||||
}
|
}
|
||||||
task_set_affinity(t, 1);
|
task_set_thread(t, 0);
|
||||||
check->state &= ~CHK_ST_INPROGRESS;
|
check->state &= ~CHK_ST_INPROGRESS;
|
||||||
|
|
||||||
pid_list_del(check->curpid);
|
pid_list_del(check->curpid);
|
||||||
|
Loading…
Reference in New Issue
Block a user