mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-11-28 22:31:06 +01:00
MINOR: tasks: make run_tasks_from_lists() scan the queues itself
Now process_runnable_tasks is responsible for calculating the budgets for each queue, dequeuing from the tree, and calling run_tasks_from_lists(). This latter one scans the queues, picking tasks there and respecting budgets. Note that its name was updated with a plural "s" for this reason.
This commit is contained in:
parent
ba48d5c8f9
commit
59153fef86
@ -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(unsigned int queue, int max);
|
unsigned int run_tasks_from_lists(unsigned int budgets[]);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This does 3 things :
|
* This does 3 things :
|
||||||
|
|||||||
@ -142,7 +142,7 @@ void ha_thread_dump(struct buffer *buf, int thr, int calling_tid)
|
|||||||
|
|
||||||
if (dump == 2) {
|
if (dump == 2) {
|
||||||
/* dumping */
|
/* dumping */
|
||||||
if (addr == run_poll_loop || addr == main || addr == run_tasks_from_list) {
|
if (addr == run_poll_loop || addr == main || addr == run_tasks_from_lists) {
|
||||||
dump = 3;
|
dump = 3;
|
||||||
*buf = bak;
|
*buf = bak;
|
||||||
break;
|
break;
|
||||||
|
|||||||
33
src/task.c
33
src/task.c
@ -318,30 +318,36 @@ int next_timer_expiry()
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Walks over tasklet list sched->tasklets[queue] and run at most <max> of
|
/* Walks over tasklet lists sched->tasklets[0..TL_CLASSES-1] and run at most
|
||||||
* them. Returns the number of entries effectively processed (tasks and
|
* budget[TL_*] of them. Returns the number of entries effectively processed
|
||||||
* tasklets merged). The count of tasks in the list for the current thread
|
* (tasks and tasklets merged). The count of tasks in the list for the current
|
||||||
* is adjusted.
|
* thread is adjusted.
|
||||||
*/
|
*/
|
||||||
int run_tasks_from_list(unsigned int queue, int max)
|
unsigned int run_tasks_from_lists(unsigned int budgets[])
|
||||||
{
|
{
|
||||||
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 list *tl_queues = sched->tasklets;
|
||||||
struct task *t;
|
struct task *t;
|
||||||
|
unsigned int done = 0;
|
||||||
|
unsigned int queue;
|
||||||
unsigned short state;
|
unsigned short state;
|
||||||
void *ctx;
|
void *ctx;
|
||||||
int done = 0;
|
|
||||||
|
|
||||||
sched->current_queue = queue;
|
for (queue = 0; queue < TL_CLASSES;) {
|
||||||
while (1) {
|
sched->current_queue = queue;
|
||||||
|
|
||||||
if (LIST_ISEMPTY(&tl_queues[queue])) {
|
if (LIST_ISEMPTY(&tl_queues[queue])) {
|
||||||
sched->tl_class_mask &= ~(1 << queue);
|
sched->tl_class_mask &= ~(1 << queue);
|
||||||
break;
|
queue++;
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (done >= max)
|
if (!budgets[queue]) {
|
||||||
break;
|
queue++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
budgets[queue]--;
|
||||||
t = (struct task *)LIST_ELEM(tl_queues[queue].n, struct tasklet *, list);
|
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));
|
||||||
|
|
||||||
@ -564,10 +570,7 @@ void process_runnable_tasks()
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* execute tasklets in each queue */
|
/* execute tasklets in each queue */
|
||||||
for (queue = 0; queue < TL_CLASSES; queue++) {
|
max_processed -= run_tasks_from_lists(max);
|
||||||
if (max[queue] > 0)
|
|
||||||
max_processed -= run_tasks_from_list(queue, max[queue]);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* some tasks may have woken other ones up */
|
/* some tasks may have woken other ones up */
|
||||||
if (max_processed > 0 && thread_has_tasks())
|
if (max_processed > 0 && thread_has_tasks())
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user