mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-09-23 06:41:32 +02:00
MINOR: tasks: make current_queue an index instead of a pointer
It will be convenient to have the tasklet queue number soon, better make current_queue an index rather than a pointer to the queue. When not currently running (e.g. from I/O), the index is -1.
This commit is contained in:
parent
3ef7a190b0
commit
c0a08ba2df
@ -77,7 +77,7 @@ struct task_per_thread {
|
|||||||
int task_list_size; /* Number of tasks among the tasklets */
|
int task_list_size; /* Number of tasks among the tasklets */
|
||||||
int rqueue_size; /* Number of elements in the per-thread run queue */
|
int rqueue_size; /* Number of elements in the per-thread run queue */
|
||||||
struct task *current; /* current task (not tasklet) */
|
struct task *current; /* current task (not tasklet) */
|
||||||
struct list *current_queue; /* points to current tasklet list being run */
|
int current_queue; /* points to current tasklet list being run, -1 if none */
|
||||||
__attribute__((aligned(64))) char end[0];
|
__attribute__((aligned(64))) char end[0];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -329,17 +329,17 @@ static inline void tasklet_wakeup(struct tasklet *tl)
|
|||||||
/* this tasklet runs on the caller thread */
|
/* this tasklet runs on the caller thread */
|
||||||
if (LIST_ISEMPTY(&tl->list)) {
|
if (LIST_ISEMPTY(&tl->list)) {
|
||||||
if (tl->state & TASK_SELF_WAKING) {
|
if (tl->state & TASK_SELF_WAKING) {
|
||||||
LIST_ADDQ(&task_per_thread[tid].tasklets[TL_BULK], &tl->list);
|
LIST_ADDQ(&sched->tasklets[TL_BULK], &tl->list);
|
||||||
}
|
}
|
||||||
else if ((struct task *)tl == sched->current) {
|
else if ((struct task *)tl == sched->current) {
|
||||||
_HA_ATOMIC_OR(&tl->state, TASK_SELF_WAKING);
|
_HA_ATOMIC_OR(&tl->state, TASK_SELF_WAKING);
|
||||||
LIST_ADDQ(&task_per_thread[tid].tasklets[TL_BULK], &tl->list);
|
LIST_ADDQ(&sched->tasklets[TL_BULK], &tl->list);
|
||||||
}
|
}
|
||||||
else if (!sched->current) {
|
else if (sched->current_queue < 0) {
|
||||||
LIST_ADDQ(&task_per_thread[tid].tasklets[TL_URGENT], &tl->list);
|
LIST_ADDQ(&sched->tasklets[TL_URGENT], &tl->list);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
LIST_ADDQ(sched->current_queue, &tl->list);
|
LIST_ADDQ(&sched->tasklets[sched->current_queue], &tl->list);
|
||||||
}
|
}
|
||||||
|
|
||||||
_HA_ATOMIC_ADD(&tasks_run_queue, 1);
|
_HA_ATOMIC_ADD(&tasks_run_queue, 1);
|
||||||
|
@ -330,7 +330,6 @@ int run_tasks_from_list(struct list *list, int max)
|
|||||||
void *ctx;
|
void *ctx;
|
||||||
int done = 0;
|
int done = 0;
|
||||||
|
|
||||||
sched->current_queue = list;
|
|
||||||
while (done < max && !LIST_ISEMPTY(list)) {
|
while (done < max && !LIST_ISEMPTY(list)) {
|
||||||
t = (struct task *)LIST_ELEM(list->n, struct tasklet *, list);
|
t = (struct task *)LIST_ELEM(list->n, struct tasklet *, list);
|
||||||
state = (t->state & (TASK_SHARED_WQ|TASK_SELF_WAKING));
|
state = (t->state & (TASK_SHARED_WQ|TASK_SELF_WAKING));
|
||||||
@ -402,7 +401,6 @@ int run_tasks_from_list(struct list *list, int max)
|
|||||||
done++;
|
done++;
|
||||||
}
|
}
|
||||||
|
|
||||||
sched->current_queue = NULL;
|
|
||||||
return done;
|
return done;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -551,8 +549,11 @@ 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(&tt->tasklets[queue], max[queue]);
|
max_processed -= run_tasks_from_list(&tt->tasklets[queue], max[queue]);
|
||||||
|
tt->current_queue = -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* some tasks may have woken other ones up */
|
/* some tasks may have woken other ones up */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user