locks: ensure proper barriers are used with atomic ops when necessary
authormjg <mjg@FreeBSD.org>
Wed, 1 Mar 2017 05:06:21 +0000 (05:06 +0000)
committermjg <mjg@FreeBSD.org>
Wed, 1 Mar 2017 05:06:21 +0000 (05:06 +0000)
commitab50e3ceda48d6934a523f7540e117e6094fc54e
treee019c8c51e85aace451aa42b60040120053c7a54
parentef2acd7183810e840661e4572113af1521caea7b
locks: ensure proper barriers are used with atomic ops when necessary

Unclear how, but the locking routine for mutexes was using the *release*
barrier instead of acquire. This must have been either a copy-pasto or bad
completion.

Going through other uses of atomics shows no barriers in:
- upgrade routines (addressed in this patch)
- sections protected with turnstile locks - this should be fine as necessary
  barriers are in the worst case provided by turnstile unlock

I would like to thank Mark Millard and andreast@ for reporting the problem and
testing previous patches before the issue got identified.

ps.
  .-'---`-.
,'          `.
|             \
|              \
\           _  \
,\  _    ,'-,/-)\
( * \ \,' ,' ,'-)
 `._,)     -',-')
   \/         ''/
    )        / /
   /       ,'-'

Hardware provided by: IBM LTC
sys/kern/kern_rwlock.c
sys/kern/kern_sx.c
sys/sys/mutex.h