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)
Mon, Nov 25, 1:04 PM
Unknown Object (File)
Oct 12 2024, 8:23 AM
Unknown Object (File)
Oct 2 2024, 2:07 AM
Unknown Object (File)
Sep 22 2024, 5:39 PM
Unknown Object (File)
Sep 22 2024, 3:21 AM
Unknown Object (File)
Sep 21 2024, 2:10 PM
Unknown Object (File)
Sep 20 2024, 10:25 AM
Unknown Object (File)
Aug 19 2024, 12:11 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.