MINOR: tasks: pass the queue index to run_task_from_list()

Instead of passing it a pointer to the queue, pass it the queue's index
so that it can perform all the work around current_queue and tl_class_mask.
This commit is contained in:
Willy Tarreau 2020-06-24 09:54:24 +02:00
parent 49f90bf148
commit ba48d5c8f9
2 changed files with 21 additions and 14 deletions

View File

@ -116,7 +116,7 @@ struct work_list *work_list_create(int nbthread,
struct task *(*fct)(struct task *, void *, unsigned short), struct task *(*fct)(struct task *, void *, unsigned short),
void *arg); void *arg);
void work_list_destroy(struct work_list *work, int nbthread); void work_list_destroy(struct work_list *work, int nbthread);
int run_tasks_from_list(struct list *list, int max); int run_tasks_from_list(unsigned int queue, int max);
/* /*
* This does 3 things : * This does 3 things :

View File

@ -318,20 +318,31 @@ int next_timer_expiry()
return ret; return ret;
} }
/* Walks over tasklet list <list> and run at most <max> of them. Returns /* Walks over tasklet list sched->tasklets[queue] and run at most <max> of
* the number of entries effectively processed (tasks and tasklets merged). * them. Returns the number of entries effectively processed (tasks and
* The count of tasks in the list for the current thread is adjusted. * tasklets merged). The count of tasks in the list for the current thread
* is adjusted.
*/ */
int run_tasks_from_list(struct list *list, int max) int run_tasks_from_list(unsigned int queue, int max)
{ {
struct task *(*process)(struct task *t, void *ctx, unsigned short state); struct task *(*process)(struct task *t, void *ctx, unsigned short state);
struct list *tl_queues = sched->tasklets;
struct task *t; struct task *t;
unsigned short state; unsigned short state;
void *ctx; void *ctx;
int done = 0; int done = 0;
while (done < max && !LIST_ISEMPTY(list)) { sched->current_queue = queue;
t = (struct task *)LIST_ELEM(list->n, struct tasklet *, list); while (1) {
if (LIST_ISEMPTY(&tl_queues[queue])) {
sched->tl_class_mask &= ~(1 << queue);
break;
}
if (done >= max)
break;
t = (struct task *)LIST_ELEM(tl_queues[queue].n, struct tasklet *, list);
state = (t->state & (TASK_SHARED_WQ|TASK_SELF_WAKING)); state = (t->state & (TASK_SHARED_WQ|TASK_SELF_WAKING));
ti->flags &= ~TI_FL_STUCK; // this thread is still running ti->flags &= ~TI_FL_STUCK; // this thread is still running
@ -400,6 +411,7 @@ int run_tasks_from_list(struct list *list, int max)
} }
done++; done++;
} }
sched->current_queue = -1;
return done; return done;
} }
@ -553,13 +565,8 @@ void process_runnable_tasks()
/* execute tasklets in each queue */ /* execute tasklets in each queue */
for (queue = 0; queue < TL_CLASSES; queue++) { for (queue = 0; queue < TL_CLASSES; queue++) {
if (max[queue] > 0) { if (max[queue] > 0)
tt->current_queue = queue; max_processed -= run_tasks_from_list(queue, max[queue]);
max_processed -= run_tasks_from_list(&tt->tasklets[queue], max[queue]);
tt->current_queue = -1;
if (LIST_ISEMPTY(&tt->tasklets[queue]))
tt->tl_class_mask &= ~(1 << queue);
}
} }
/* some tasks may have woken other ones up */ /* some tasks may have woken other ones up */