HomeFreeBSD

smr: Fix synchronization in smr_enter()

Description

smr: Fix synchronization in smr_enter()

smr_enter() must publish its observed read sequence number before
issuing any subsequent memory operations. The ordering provided by
atomic_add_acq_int() is insufficient on some platforms, at least on
arm64, because it permits reordering of subsequent loads with the store
to c_seq.

Thus, use atomic_thread_fence_seq_cst() to issue a store-load barrier
after publishing the read sequence number.

On x86, take advantage of the fact that memory operations are not
reordered with locked instructions to improve code density: we can store
the observed read sequence and provide a store-load barrier with a
single operation.

Based on a patch from Pierre Habouzit <pierre@habouzit.net>.

PR: 265974
Reviewed by: alc

(cherry picked from commit 8694fd333556addb97acfff1feca6a1e389201ce)

Details

Provenance
markjAuthored on Sep 24 2022, 1:18 PM
Parents
rG48f10c94eb15: riscv: Apply 8d7ee2047c5e to the riscv pmap
Branches
Unknown
Tags
Unknown