]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: sched: split tasklet_wakeup() into tasklet_wakeup_on()
authorWilly Tarreau <w@1wt.eu>
Fri, 3 Jul 2020 15:13:05 +0000 (17:13 +0200)
committerWilly Tarreau <w@1wt.eu>
Fri, 3 Jul 2020 15:19:47 +0000 (17:19 +0200)
tasklet_wakeup() only checks tl->tid to know whether the task is
programmed to run on the current thread or on a specific thread. We'll
have to ease this selection in a subsequent patch, preferably without
modifying tl->tid, so let's have a new tasklet_wakeup_on() function
to specify the thread number to run on. That the logic has not changed
at all.

include/haproxy/task.h

index 1f31a76bd90938f4ddda2f79114b7fe9544638fb..db919913b5be70665ecccd61053fbd5a8fefd715 100644 (file)
@@ -322,9 +322,12 @@ static inline struct task *task_unlink_rq(struct task *t)
        return t;
 }
 
-static inline void tasklet_wakeup(struct tasklet *tl)
+/* schedules tasklet <tl> to run onto thread <thr> or the current thread if
+ * <thr> is negative.
+ */
+static inline void tasklet_wakeup_on(struct tasklet *tl, int thr)
 {
-       if (likely(tl->tid < 0)) {
+       if (likely(thr < 0)) {
                /* this tasklet runs on the caller thread */
                if (LIST_ISEMPTY(&tl->list)) {
                        if (tl->state & TASK_SELF_WAKING) {
@@ -349,15 +352,22 @@ static inline void tasklet_wakeup(struct tasklet *tl)
                }
        } else {
                /* this tasklet runs on a specific thread */
-               if (MT_LIST_ADDQ(&task_per_thread[tl->tid].shared_tasklet_list, (struct mt_list *)&tl->list) == 1) {
+               if (MT_LIST_ADDQ(&task_per_thread[thr].shared_tasklet_list, (struct mt_list *)&tl->list) == 1) {
                        _HA_ATOMIC_ADD(&tasks_run_queue, 1);
-                       if (sleeping_thread_mask & (1UL << tl->tid)) {
-                               _HA_ATOMIC_AND(&sleeping_thread_mask, ~(1UL << tl->tid));
-                               wake_thread(tl->tid);
+                       if (sleeping_thread_mask & (1UL << thr)) {
+                               _HA_ATOMIC_AND(&sleeping_thread_mask, ~(1UL << thr));
+                               wake_thread(thr);
                        }
                }
        }
+}
 
+/* schedules tasklet <tl> to run onto the thread designated by tl->tid, which
+ * is either its owner thread if >= 0 or the current thread if < 0.
+ */
+static inline void tasklet_wakeup(struct tasklet *tl)
+{
+       tasklet_wakeup_on(tl, tl->tid);
 }
 
 /* Insert a tasklet into the tasklet list. If used with a plain task instead,