]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: tasklet: make the low-level tasklet API take a flag
authorWilly Tarreau <w@1wt.eu>
Tue, 19 Nov 2024 14:33:39 +0000 (15:33 +0100)
committerWilly Tarreau <w@1wt.eu>
Tue, 19 Nov 2024 19:13:41 +0000 (20:13 +0100)
Everything in the tasklet layer supports flags, except that they are
just not implemented in the wakeup functions, while they are in the
task_wakeup functions. Initially it was not considered useful to pass
wakeup causes because these were essentially I/O, but with the growing
number of I/O handlers having to deal with various types of operations
(typically cheap I/O notifications on subscribe vs heavy parsing on
application-level wakeups), it would be nice to start to make this
distinction possible.

This commit extends _tasklet_wakeup_on() and _tasklet_wakeup_after()
to pass a set of flags that continues to be set as zero. For now this
changes nothing, but new functions will come.

include/haproxy/task.h

index dbbb0a8b517f23319f8c6a8f2da9594f8ce43419..3c4163b2795b1d0e4f487508a30971049d397e26 100644 (file)
@@ -375,11 +375,11 @@ static inline void task_set_thread(struct task *t, int thr)
  * purposes.
  */
 #define tasklet_wakeup_on(tl, thr) \
-       _tasklet_wakeup_on(tl, thr, MK_CALLER(WAKEUP_TYPE_TASKLET_WAKEUP, 0, 0))
+       _tasklet_wakeup_on(tl, thr, 0, MK_CALLER(WAKEUP_TYPE_TASKLET_WAKEUP, 0, 0))
 
-static inline void _tasklet_wakeup_on(struct tasklet *tl, int thr, const struct ha_caller *caller)
+static inline void _tasklet_wakeup_on(struct tasklet *tl, int thr, uint f, const struct ha_caller *caller)
 {
-       unsigned int state = tl->state;
+       unsigned int state = _HA_ATOMIC_OR_FETCH(&tl->state, f);
 
        do {
                /* do nothing if someone else already added it */
@@ -407,7 +407,7 @@ static inline void _tasklet_wakeup_on(struct tasklet *tl, int thr, const struct
  * task for tracing purposes.
  */
 #define tasklet_wakeup(tl) \
-       _tasklet_wakeup_on(tl, (tl)->tid, MK_CALLER(WAKEUP_TYPE_TASKLET_WAKEUP, 0, 0))
+       _tasklet_wakeup_on(tl, (tl)->tid, 0, MK_CALLER(WAKEUP_TYPE_TASKLET_WAKEUP, 0, 0))
 
 /* instantly wakes up task <t> on its owner thread even if it's not the current
  * one, bypassing the run queue. The purpose is to be able to avoid contention
@@ -468,12 +468,12 @@ static inline void _task_instant_wakeup(struct task *t, unsigned int f, const st
  * for tracing purposes.
  */
 #define tasklet_wakeup_after(head, tl) \
-       _tasklet_wakeup_after(head, tl, MK_CALLER(WAKEUP_TYPE_TASKLET_WAKEUP_AFTER, 0, 0))
+       _tasklet_wakeup_after(head, tl, 0, MK_CALLER(WAKEUP_TYPE_TASKLET_WAKEUP_AFTER, 0, 0))
 
 static inline struct list *_tasklet_wakeup_after(struct list *head, struct tasklet *tl,
-                                                 const struct ha_caller *caller)
+                                                 uint f, const struct ha_caller *caller)
 {
-       unsigned int state = tl->state;
+       unsigned int state = _HA_ATOMIC_OR_FETCH(&tl->state, f);
 
        do {
                /* do nothing if someone else already added it */