Page MenuHomeFreeBSD

rangelock: add rangelock_cookie_assert
ClosedPublic

Authored by kevans on Sep 12 2019, 11:05 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sat, May 25, 4:37 PM
Unknown Object (File)
Thu, May 23, 5:20 AM
Unknown Object (File)
Wed, May 22, 9:33 PM
Unknown Object (File)
Mon, May 20, 9:30 PM
Unknown Object (File)
Sat, May 11, 2:46 AM
Unknown Object (File)
Mon, May 6, 10:30 PM
Unknown Object (File)
Mon, Apr 29, 11:13 AM
Unknown Object (File)
Mon, Apr 29, 7:17 AM
Subscribers

Details

Summary

An approach to D21391 using rangelocks instead of an sx for the shm seal lock would have shm_dotruncate_locked take a cookie and assert that it's been granted a write lock to leave the locking out of the _locked function.

I do not yet know how I like the rangelock approach, but I think this is a good idea if we go that route.

Diff Detail

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

Event Timeline

sys/kern/kern_rangelock.c
316 ↗(On Diff #62012)

I would suggest to use KASSERT() instead of direct panic(9) call.

329 ↗(On Diff #62012)

Why rl_q_flags instead of flags ?

Also I do not think that RCA_UNLOCKED assert could be made safe.

sys/sys/rangelock.h
101 ↗(On Diff #62012)

I suspect it is too far in cargo cult. It is fine to define RCA_XXX as plain constants, I do not see a need in any services from sys/lock.h.

sys/kern/kern_rangelock.c
316 ↗(On Diff #62012)

Hmm... this makes rangelock_cookie_assert useless if kernel is compiled with INVARIANT_SUPPORT but not INVARIANTS and one still wants to do rangelock cookie assertions in a module. Is this intended/desired?

329 ↗(On Diff #62012)

Ah, missed converting that one.

True- I'll drop RCA_UNLOCKED.

sys/kern/kern_rangelock.c
316 ↗(On Diff #62012)

I am not sure that we need support for rangelocking asserts without INVARIANTs, but I understand your point. In any case I do not insist on this.

Drop RCA_UNLOCKED and cookie cutter sys/lock.h dependency. Leaving the direct panic() as _rangelock_cookie_assert cannot be called on !INVARIANTS files anyways.

This revision is now accepted and ready to land.Sep 14 2019, 8:57 AM
This revision was automatically updated to reflect the committed changes.