MINOR: task: don't set TASK_RUNNING on tasklets

We can't clear flags on tasklets because we don't know if they're still
present upon return (they all return NULL, maybe that could change in
the future). As a side effect, once TASK_RUNNING is set, it's never
cleared anymore, which is misleading and resulted in some incorrect
flagging of bulk tasks in the recent scheduler changes. And the only
reason for setting TASK_RUNNING on tasklets was to detect self-wakers,
which is not done using a dedicated flag. So instead of setting this
flags for no opportunity to clear it, let's simply not set it.
This commit is contained in:
Willy Tarreau 2020-01-31 16:39:30 +01:00
parent 1dfc9bbdc6
commit 952c2640b0

View File

@ -329,10 +329,7 @@ static int run_tasks_from_list(struct list *list, int max)
while (done < max && !LIST_ISEMPTY(list)) {
t = (struct task *)LIST_ELEM(list->n, struct tasklet *, list);
state = (t->state & (TASK_SHARED_WQ|TASK_SELF_WAKING)) | TASK_RUNNING;
state = _HA_ATOMIC_XCHG(&t->state, state);
__ha_barrier_atomic_store();
__tasklet_remove_from_tasklet_list((struct tasklet *)t);
state = (t->state & (TASK_SHARED_WQ|TASK_SELF_WAKING));
ti->flags &= ~TI_FL_STUCK; // this thread is still running
activity[tid].ctxsw++;
@ -342,6 +339,9 @@ static int run_tasks_from_list(struct list *list, int max)
sched->current = t;
if (TASK_IS_TASKLET(t)) {
state = _HA_ATOMIC_XCHG(&t->state, state);
__ha_barrier_atomic_store();
__tasklet_remove_from_tasklet_list((struct tasklet *)t);
process(NULL, ctx, state);
done++;
sched->current = NULL;
@ -349,6 +349,10 @@ static int run_tasks_from_list(struct list *list, int max)
continue;
}
state = _HA_ATOMIC_XCHG(&t->state, state | TASK_RUNNING);
__ha_barrier_atomic_store();
__tasklet_remove_from_tasklet_list((struct tasklet *)t);
/* OK then this is a regular task */
task_per_thread[tid].task_list_size--;