]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: task: make tasklet_wakeup() explicitly call _tasklet_wakeup_here()
authorWilly Tarreau <w@1wt.eu>
Wed, 24 Jun 2026 13:50:47 +0000 (15:50 +0200)
committerWilly Tarreau <w@1wt.eu>
Wed, 24 Jun 2026 17:08:00 +0000 (19:08 +0200)
This patch moves the tid check upper in the chain, in tasklet_wakeup()
so as to branch to _tasklet_wakeup_here() for run-anywhere tasklets, or
_tasklet_wakeup_on() for designated threads. The tid is retrieved via
__task_get_current_owner() so that the call remains compatible with
tasklets that would have a super-negative tid due to being tasks used
as tasklets.

include/haproxy/task.h

index 203abb88256d2ac8cf9e3ace90e1d28e0288d409..aa8718f14f03d56919a8f87741540f9a3c6144a7 100644 (file)
@@ -521,8 +521,15 @@ static inline void _tasklet_wakeup_on(struct tasklet *tl, int thr, uint f, const
  * wakeup cause to the tasklet. When not set, the arg defaults to zero (i.e. no
  * flag is added).
  */
-#define tasklet_wakeup(tl, ...)                                                \
-       _tasklet_wakeup_on(tl, (tl)->tid, DEFVAL(TASK_WOKEN_OTHER, ##__VA_ARGS__), MK_CALLER(WAKEUP_TYPE_TASKLET_WAKEUP, 0, 0))
+#define tasklet_wakeup(tl, ...)        do {                                    \
+       const struct ha_caller *_caller = MK_CALLER(WAKEUP_TYPE_TASKLET_WAKEUP, 0, 0); \
+       uint _flg = DEFVAL(TASK_WOKEN_OTHER, ##__VA_ARGS__);            \
+       int _tl_tid = __task_get_current_owner((tl)->tid);              \
+       if (_tl_tid < 0)                                                \
+               _tasklet_wakeup_here(tl, _flg, _caller);                \
+       else                                                            \
+               _tasklet_wakeup_on(tl, _tl_tid, _flg, _caller);         \
+       } while (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