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)
Mon, Jan 30, 9:15 AM
Unknown Object (File)
Mon, Jan 30, 9:14 AM
Unknown Object (File)
Dec 30 2022, 8:30 PM
Unknown Object (File)
Dec 27 2022, 7:52 AM
Unknown Object (File)
Dec 21 2022, 2:12 AM
Unknown Object (File)
Dec 19 2022, 5:54 PM
Unknown Object (File)
Dec 19 2022, 5:52 PM
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.