]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
CLEANUP: task: move tid and wake_date into the common part
authorWilly Tarreau <w@1wt.eu>
Wed, 7 Sep 2022 14:43:01 +0000 (16:43 +0200)
committerWilly Tarreau <w@1wt.eu>
Thu, 8 Sep 2022 12:30:38 +0000 (14:30 +0200)
There used to be one tid for tasklets and a thread_mask for tasks. Since
2.7, both tasks and tasklets now use a tid (albeit with a very slight
semantic difference for the negative value), to in order to limit code
duplication and to ease debugging it makes sense to move tid into the
common part. One limitation is that it will leave a hole in the structure,
but we now have the wake_date that is always present and can move there as
well to plug the hole.

This results in something overall pretty clean (and cleaner than before),
with the low-level stuff (state,tid,process,context) appearing first, then
the caller stuff (caller,wake_date,calls,debug) next, and finally the
type-specific stuff (rq/wq/expire/nice).

include/haproxy/task-t.h

index 0c2dcc8ef2714c09034f940ca97ab5ba2d20a1f7..06d7f225cf36cca6782bc72d3832cf2074ff5d4a 100644 (file)
@@ -104,11 +104,12 @@ struct notification {
 #define TASK_COMMON                                                    \
        struct {                                                        \
                unsigned int state; /* task state : bitfield of TASK_   */ \
-               /* 16-bit hole here */ \
-               unsigned int calls; /* number of times process was called */ \
+               int tid;            /* tid of task/tasklet. <0 = local for tasklet, unbound for task */ \
                struct task *(*process)(struct task *t, void *ctx, unsigned int state); /* the function which processes the task */ \
                void *context; /* the task's context */                 \
                const struct ha_caller *caller;  /* call place of last wakeup(); 0 on init, -1 on free */ \
+               uint32_t wake_date;              /* date of the last task wakeup */ \
+               unsigned int calls;              /* number of times process was called */ \
                TASK_DEBUG_STORAGE;                                     \
        }
 
@@ -124,8 +125,7 @@ struct task {
        struct eb32_node wq;            /* ebtree node used to hold the task in the wait queue */
        int expire;                     /* next expiration date for this task, in ticks */
        short nice;                     /* task prio from -1024 to +1024 */
-       short tid;                      /* TID where it's allowed to run, <0 if anywhere */
-       uint32_t wake_date;             /* date of the last task wakeup */
+       /* 16-bit hole here */
 };
 
 /* lightweight tasks, without priority, mainly used for I/Os */
@@ -137,8 +137,6 @@ struct tasklet {
         * list starts and this works because both are exclusive. Never ever
         * reorder these fields without taking this into account!
         */
-       uint32_t wake_date;             /* date of the last tasklet wakeup */
-       int tid;                        /* TID of the tasklet owner, <0 if local */
 };
 
 /*