History log of /freebsd-10-stable/sys/sys/rwlock.h
Revision Date Author Comments
# 323870 21-Sep-2017 marius

MFC: r275751

Add _NEW flag to mtx(9), sx(9), rmlock(9) and rwlock(9).
A _NEW flag passed to _init_flags() to avoid check for double-init.


# 320885 11-Jul-2017 mjg

Remove waiters check from the inline rw wunlock routine.

This is a direct commit to stable/10.

r310979 is a merge of depessimisation of locking primitives.
The important part was getting rid of an attempt to grab the lock in the
slow path immediately after the fast path failed. In addition to that
temporary checks were added before all atomic ops. They have no impact on
semantic nor correctness, they only avoid an atomic operation which is
likely to fail.

After the addition of atomic_fcmpset and further changes said checks
became pessimal and got removed. This may get merged to stable/10.

Reports started showing up about a crash in all branches having extra
checks. The codepath is:
.. -> vm_map_delete -> __rw_wunlock_hard -> turnstile_broadcast

The kernel crashed trying to wake up nonexistent waiters. The lock value
as found in the vmcore matches the panicking thread, so in particular
there was no waiters bit set. The bit can only be cleared by the current
owner.

A debug patch was provided, which reportedly had a side effect of getting
rid of the issue.

Also one of the reporters said that reverting the patch which adds the
extra checks makes the crash go away.

It was also reported that head with the fcmpset changes (explicit checks
removed) also stops crashing.

Finally, one user tested crashing stable/10 variant with just the rw
wunlock check removed.

The common case in all but one reports was an Intel Atom cpu. Claiming
a cpu bug at this point is bold and I'm going to refrain from it, but
right now apart from cpu-specific optimisation made by the compiler on
custom kernel compiles I don't see how this can be a software bug.

This will have to be investigated more.

Meanwhile, restore rw wunlock to pre-r310979 state.

PR: 213903


# 310979 31-Dec-2016 mjg

MFC r301157:

Microoptimize locking primitives by avoiding unnecessary atomic ops.

Inline version of primitives do an atomic op and if it fails they fallback to
actual primitives, which immediately retry the atomic op.

The obvious optimisation is to check if the lock is free and only then proceed
to do an atomic op.


# 262192 18-Feb-2014 jhb

MFC 261517,261520:
Convert the license on files where I am the sole copyright holder to
2 clause BSD licenses.


# 262192 18-Feb-2014 jhb

MFC 261517,261520:
Convert the license on files where I am the sole copyright holder to
2 clause BSD licenses.