mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2024-12-17 17:04:35 +00:00
MINOR: task: stop abusing the nice field to detect a tasklet
It's cleaner to use a flag from the task's state to detect a tasklet and it's even cheaper. One of the best benefits is that this will allow to get the nice field out of the common part since the tasklet doesn't need it anymore. This commit uses the last task bit available but that's temporary as the purpose of the change is to extend this.
This commit is contained in:
parent
1adaddb494
commit
db4e238938
@ -50,6 +50,8 @@
|
||||
#define TASK_WOKEN_RES 0x2000 /* woken up because of available resource */
|
||||
#define TASK_WOKEN_OTHER 0x4000 /* woken up for an unspecified reason */
|
||||
|
||||
#define TASK_F_TASKLET 0x8000 /* nature of this task: 0=task 1=tasklet */
|
||||
|
||||
/* use this to check a task state or to clean it up before queueing */
|
||||
#define TASK_WOKEN_ANY (TASK_WOKEN_OTHER|TASK_WOKEN_INIT|TASK_WOKEN_TIMER| \
|
||||
TASK_WOKEN_IO|TASK_WOKEN_SIGNAL|TASK_WOKEN_MSG| \
|
||||
@ -113,7 +115,7 @@ struct task_per_thread {
|
||||
#define TASK_COMMON \
|
||||
struct { \
|
||||
unsigned short state; /* task state : bitfield of TASK_ */ \
|
||||
short nice; /* task prio from -1024 to +1024, or -32768 for tasklets */ \
|
||||
short nice; /* task prio from -1024 to +1024 */ \
|
||||
unsigned int calls; /* number of times process was called */ \
|
||||
struct task *(*process)(struct task *t, void *ctx, unsigned short state); /* the function which processes the task */ \
|
||||
void *context; /* the task's context */ \
|
||||
|
@ -83,7 +83,7 @@
|
||||
#define TIMER_LOOK_BACK (1U << 31)
|
||||
|
||||
/* tasklets are recognized with nice==-32768 */
|
||||
#define TASK_IS_TASKLET(t) ((t)->nice == -32768)
|
||||
#define TASK_IS_TASKLET(t) ((t)->state & TASK_F_TASKLET)
|
||||
|
||||
|
||||
/* a few exported variables */
|
||||
@ -435,15 +435,15 @@ static inline struct task *task_init(struct task *t, unsigned long thread_mask)
|
||||
return t;
|
||||
}
|
||||
|
||||
/* Initialize a new tasklet. It's identified as a tasklet by ->nice=-32768. It
|
||||
* is expected to run on the calling thread by default, it's up to the caller
|
||||
* to change ->tid if it wants to own it.
|
||||
/* Initialize a new tasklet. It's identified as a tasklet by its flags
|
||||
* TASK_F_TASKLET. It is expected to run on the calling thread by default,
|
||||
* it's up to the caller to change ->tid if it wants to own it.
|
||||
*/
|
||||
static inline void tasklet_init(struct tasklet *t)
|
||||
{
|
||||
t->nice = -32768;
|
||||
t->nice = 0;
|
||||
t->calls = 0;
|
||||
t->state = 0;
|
||||
t->state = TASK_F_TASKLET;
|
||||
t->process = NULL;
|
||||
t->tid = -1;
|
||||
#ifdef DEBUG_TASK
|
||||
|
@ -487,7 +487,7 @@ unsigned int run_tasks_from_lists(unsigned int budgets[])
|
||||
|
||||
budgets[queue]--;
|
||||
t = (struct task *)LIST_ELEM(tl_queues[queue].n, struct tasklet *, list);
|
||||
state = t->state & (TASK_SHARED_WQ|TASK_SELF_WAKING|TASK_HEAVY|TASK_KILLED);
|
||||
state = t->state & (TASK_SHARED_WQ|TASK_SELF_WAKING|TASK_HEAVY|TASK_F_TASKLET|TASK_KILLED);
|
||||
|
||||
ti->flags &= ~TI_FL_STUCK; // this thread is still running
|
||||
activity[tid].ctxsw++;
|
||||
@ -498,7 +498,7 @@ unsigned int run_tasks_from_lists(unsigned int budgets[])
|
||||
|
||||
_HA_ATOMIC_SUB(&sched->rq_total, 1);
|
||||
|
||||
if (TASK_IS_TASKLET(t)) {
|
||||
if (state & TASK_F_TASKLET) {
|
||||
uint64_t before = 0;
|
||||
|
||||
LIST_DEL_INIT(&((struct tasklet *)t)->list);
|
||||
|
Loading…
Reference in New Issue
Block a user