qemu-coroutine-lock: add smp_mb__after_rmw()
authorPaolo Bonzini <pbonzini@redhat.com>
Fri, 3 Mar 2023 09:52:59 +0000 (10:52 +0100)
committerPaolo Bonzini <pbonzini@redhat.com>
Tue, 7 Mar 2023 11:39:53 +0000 (12:39 +0100)
commite3a3b6ec8169eab2feb241b4982585001512cd55
tree7c7eb3f3c10ab6ac7d8ddb794f21ecb668c829f8
parentb532526a07ef3b903ead2e055fe6cc87b41057a3
qemu-coroutine-lock: add smp_mb__after_rmw()

mutex->from_push and mutex->handoff in qemu-coroutine-lock implement
the familiar pattern:

   write a                                  write b
   smp_mb()                                 smp_mb()
   read b                                   read a

The memory barrier is required by the C memory model even after a
SEQ_CST read-modify-write operation such as QSLIST_INSERT_HEAD_ATOMIC.
Add it and avoid the unclear qatomic_mb_read() operation.

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: David Hildenbrand <david@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
util/qemu-coroutine-lock.c