diff --git a/include/proto/task.h b/include/proto/task.h index 41227b8d8..424e8ba66 100644 --- a/include/proto/task.h +++ b/include/proto/task.h @@ -104,8 +104,6 @@ __decl_hathreads(extern HA_SPINLOCK_T rq_lock); /* spin lock related to run que __decl_hathreads(extern HA_RWLOCK_T wq_lock); /* RW lock related to the wait queue */ -static inline void task_insert_into_tasklet_list(struct task *t); - /* return 0 if task is in run queue, otherwise non-zero */ static inline int task_in_rq(struct task *t) { @@ -235,19 +233,18 @@ static inline void tasklet_wakeup(struct tasklet *tl) } -/* may only be used for real tasks */ -static inline void task_insert_into_tasklet_list(struct task *t) +/* Insert a tasklet into the tasklet list. If used with a plain task instead, + * the caller must update the task_list_size. + */ +static inline void tasklet_insert_into_tasklet_list(struct tasklet *tl) { - struct tasklet *tl; - _HA_ATOMIC_ADD(&tasks_run_queue, 1); - task_per_thread[tid].task_list_size++; - tl = (struct tasklet *)t; LIST_ADDQ(&task_per_thread[tid].task_list, &tl->list); } -/* remove the task from the tasklet list. The tasklet MUST already be there. If - * unsure, use tasklet_remove_from_tasklet_list() instead. +/* Remove the tasklet from the tasklet list. The tasklet MUST already be there. + * If unsure, use tasklet_remove_from_tasklet_list() instead. If used with a + * plain task, the caller must update the task_list_size. */ static inline void __tasklet_remove_from_tasklet_list(struct tasklet *t) { diff --git a/src/task.c b/src/task.c index 168320800..2176a9190 100644 --- a/src/task.c +++ b/src/task.c @@ -369,7 +369,8 @@ void process_runnable_tasks() #endif /* And add it to the local task list */ - task_insert_into_tasklet_list(t); + tasklet_insert_into_tasklet_list((struct tasklet *)t); + task_per_thread[tid].task_list_size++; activity[tid].tasksw++; } @@ -389,6 +390,8 @@ void process_runnable_tasks() state = _HA_ATOMIC_XCHG(&t->state, TASK_RUNNING); __ha_barrier_atomic_store(); __tasklet_remove_from_tasklet_list((struct tasklet *)t); + if (!TASK_IS_TASKLET(t)) + task_per_thread[tid].task_list_size--; ti->flags &= ~TI_FL_STUCK; // this thread is still running activity[tid].ctxsw++;