Le 06/12/2019 à 20:37, Mindaugas Rasiukevicius a écrit :
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.
Alright.
The patch needs to be completed though; ie, 'spc_mcount++' too should use
relaxed atomics, UVM style ([1]).
[1]
https://nxr.netbsd.org/diff/src/sys/uvm/uvm_fault.c?r2=%2Fsrc%2Fsys%2Fuvm%2Fuvm_fault.c%401.209&r1=%2Fsrc%2Fsys%2Fuvm%2Fuvm_fault.c%401.208