From: Willy Tarreau Date: Fri, 3 Jul 2020 15:13:05 +0000 (+0200) Subject: MINOR: sched: split tasklet_wakeup() into tasklet_wakeup_on() X-Git-Tag: v2.2-dev12~7 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=43079e07316638c98acd04977fe156b338528d51;p=thirdparty%2Fhaproxy.git MINOR: sched: split tasklet_wakeup() into tasklet_wakeup_on() 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. --- diff --git a/include/haproxy/task.h b/include/haproxy/task.h index 1f31a76bd9..db919913b5 100644 --- a/include/haproxy/task.h +++ b/include/haproxy/task.h @@ -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 to run onto thread or the current thread if + * 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 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,