REORG: atomic: reimplement pl_cpu_relax() from atomic-ops.h
authorWilly Tarreau <w@1wt.eu>
Tue, 2 Mar 2021 06:08:34 +0000 (07:08 +0100)
committerWilly Tarreau <w@1wt.eu>
Fri, 5 Mar 2021 07:30:08 +0000 (08:30 +0100)
commit958ae26c3558f0a5cdcb7a92cc535f1cd1ac9a64
treec497f4aadff1e44dc9a67a397e1179651046c29b
parent1568355afdde5a861550292d6d85888d5cc1a7af
REORG: atomic: reimplement pl_cpu_relax() from atomic-ops.h

There is some confusion here as we need to place some cpu_relax statements
in some loops where it's not easily possible to condition them on the use
of threads. That's what atomic.h already does. So let's take the various
pl_cpu_relax() implementations from there and place them in atomic.h under
the name __ha_cpu_relax() and let them adapt to the presence or absence of
threads and to the architecture (currently only x86 and aarch64 use a barrier
instruction), though it's very likely that arm would work well with a cache
flushing ISB instruction as well).

This time they were implemented as expressions returning 1 rather than
statements, in order to ease their placement as the loop condition or the
continuation expression inside "for" loops. We should probably do the same
with barriers and a few such other ones.
include/haproxy/atomic.h