MINOR: freq_ctr: add cpu_relax in the rotation loop of update_freq_ctr_period()

When counters are rotated, there is contention between the threads which
can slow down the operation of the thread performing the rotation. Let's
apply a cpu_relax there to let the first thread finish faster.
This commit is contained in:
Willy Tarreau 2021-04-11 01:18:39 +02:00
parent fc6323ad82
commit 6339c19cac

View File

@ -50,7 +50,7 @@ static inline unsigned int update_freq_ctr_period(struct freq_ctr *ctr,
/* remove the bit, used for the lock */
curr_tick &= ~1;
} while (!_HA_ATOMIC_CAS(&ctr->curr_tick, &curr_tick, curr_tick | 0x1));
} while (!_HA_ATOMIC_CAS(&ctr->curr_tick, &curr_tick, curr_tick | 0x1) && __ha_cpu_relax());
__ha_barrier_atomic_store();
if (now_ms_tmp - curr_tick >= period) {