Maxime Villard <m...@m00nbsd.net> wrote: > Le 06/12/2019 à 17:53, Andrew Doran a écrit : > > On Fri, Dec 06, 2019 at 05:22:39PM +0900, Kengo NAKAHARA wrote: > > > >> /* Update the worker */ > >> - worker_ci = hci; > >> + atomic_swap_ptr(&worker_ci, hci); > > > > Why atomic_swap_ptr() not atomic_store_relaxed()? I don't see any bug > > that it fixes. Other than that it look OK to me. > > Because I suggested it; my concern was that if not explicitly atomic, the > cpu could make two writes internally (even though the compiler produces > only one instruction), and in that case a page fault would have been > possible because of garbage dereference.
No, atomic_store_relaxed() is sufficient; that is what it is for. -- Mindaugas