MINOR: task: make rqueue_ticks atomic
The runqueue ticks counter is per-thread and wasn't initially meant to
be shared. We'll soon have to share it so let's make it atomic. It's
only updated when waking up a task, and no performance difference was
observed. It was moved in the thread_ctx struct so that it doesn't
pollute the local cache line when it's later updated by other threads.
diff --git a/src/task.c b/src/task.c
index b371b89..247ed80 100644
--- a/src/task.c
+++ b/src/task.c
@@ -249,7 +249,7 @@
#endif
{
_HA_ATOMIC_INC(&th_ctx->rq_total);
- t->rq.key = ++th_ctx->rqueue_ticks;
+ t->rq.key = _HA_ATOMIC_ADD_FETCH(&th_ctx->rqueue_ticks, 1);
}
if (likely(t->nice)) {
@@ -854,7 +854,7 @@
*/
if (!lrq) {
- lrq = eb32sc_lookup_ge(&tt->rqueue, tt->rqueue_ticks - TIMER_LOOK_BACK, tid_bit);
+ lrq = eb32sc_lookup_ge(&tt->rqueue, _HA_ATOMIC_LOAD(&tt->rqueue_ticks) - TIMER_LOOK_BACK, tid_bit);
if (unlikely(!lrq))
lrq = eb32sc_first(&tt->rqueue, tid_bit);
}