Page MenuHomeFreeBSD

Fix incorrect assertion in a blocking rm_rlock.
ClosedPublic

Authored by jhb on Aug 6 2015, 6:03 PM.
Tags
None
Referenced Files
Unknown Object (File)
Wed, May 1, 6:28 AM
Unknown Object (File)
Mon, Apr 22, 10:20 PM
Unknown Object (File)
Dec 31 2023, 5:17 PM
Unknown Object (File)
Dec 22 2023, 9:06 PM
Unknown Object (File)
Sep 17 2023, 8:27 AM
Unknown Object (File)
Sep 1 2023, 6:53 PM
Unknown Object (File)
Sep 1 2023, 6:52 PM
Unknown Object (File)
Sep 1 2023, 6:50 PM
Subscribers

Details

Summary

Threads holding a read lock of a sleepable rm lock are not permitted
to sleep. The rmlock implementation enforces this by disabling
sleeping when a read lock is acquired. To simplify the implementation,
sleeping is disabled for most of the duration of rm_rlock. However,
it doesn't need to be disabled until the lock is acquired. If a
sleepable rm lock is contested, then rm_rlock may need to acquire the
backing sx lock. This tripped the overly-broad assertion. Fix by
relaxing the assertion around the call to sx_xlock().

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

jhb retitled this revision from to Fix incorrect assertion in a blocking rm_rlock..
jhb updated this object.
jhb edited the test plan for this revision. (Show Details)
jhb added reviewers: kib, mjg.
mjg edited edge metadata.
This revision is now accepted and ready to land.Aug 6 2015, 11:19 PM
kib edited edge metadata.

This is fine, it seems.

Why the THREAD_NO_SLEEPING() in the _rm_rlock() only done for sleepable rmlocks ?

In D3324#67507, @kib wrote:

This is fine, it seems.

Why the THREAD_NO_SLEEPING() in the _rm_rlock() only done for sleepable rmlocks ?

It is implicit from the lock_class for "regular" rmlocks. However, it would be harmless to do it for those as well and would remove a branch from the fast path for rm read lock operations.

I wrote a test kernel module today (one thread grabs a write lock on a sleepable rm lock and then wakes up another thread that tries to grab a read lock) and verified that this change fixes the panic. I will commit this later today or tomorrow.

This revision was automatically updated to reflect the committed changes.