MINOR: atomic: make sure to always relax after a failed CAS
authorWilly Tarreau <w@1wt.eu>
Thu, 17 Aug 2023 06:59:15 +0000 (08:59 +0200)
committerWilly Tarreau <w@1wt.eu>
Thu, 17 Aug 2023 07:09:20 +0000 (09:09 +0200)
commit78fa54863dcd6c2f26e467c4cd9dfcc96c0b5f7d
treee8f016ae4346ad7351a7f7572790a2ca0419f3c7
parent071d689a514dac522ac3654f53bc22214b5716d0
MINOR: atomic: make sure to always relax after a failed CAS

There were a few places left where we forgot to call __ha_cpu_relax()
after a failed CAS, in the HA_ATOMIC_UPDATE_{MIN,MAX} macros, and in
a few sync_* API macros (the same as above plus HA_ATOMIC_CAS and
HA_ATOMIC_XCHG). Let's add them now.

This could have been a cause of contention, particularly with
process_stream() calling stream_update_time_stats() which uses 8 of them
in a call (4 for the server, 4 for the proxy). This may be a possible
explanation for the high CPU consumption reported in GH issue #2251.

This should be backported at least to 2.6 as it's harmless.
include/haproxy/atomic.h