From: Willy Tarreau Date: Wed, 17 Apr 2019 18:52:51 +0000 (+0200) Subject: MINOR: task/thread: factor out a wake-up condition X-Git-Tag: v2.0-dev3~235 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=8c12e2f785ad47fedd80af745f1c5743efcd35ff;p=thirdparty%2Fhaproxy.git MINOR: task/thread: factor out a wake-up condition The wakeup condition in task_wakeup() is redundant as it is already validated by the CAS. Better move the __task_wakeup() call there, it also has the merit of being easier to audit this way. This also reduces the code size by around 1.8 kB : $ size haproxy-? text data bss dec hex filename 2153806 100208 1307676 3561690 3658da haproxy-1 2152094 100208 1307676 3559978 36522a haproxy-2 --- diff --git a/include/proto/task.h b/include/proto/task.h index 361ea85380..ab1245f825 100644 --- a/include/proto/task.h +++ b/include/proto/task.h @@ -153,11 +153,11 @@ static inline void task_wakeup(struct task *t, unsigned int f) state = _HA_ATOMIC_OR(&t->state, f); while (!(state & (TASK_RUNNING | TASK_QUEUED))) { - if (_HA_ATOMIC_CAS(&t->state, &state, state | TASK_QUEUED)) + if (_HA_ATOMIC_CAS(&t->state, &state, state | TASK_QUEUED)) { + __task_wakeup(t, root); break; + } } - if (!(state & (TASK_QUEUED | TASK_RUNNING))) - __task_wakeup(t, root); } /* change the thread affinity of a task to */