Page MenuHomeFreeBSD

rangelock: add rangelock_cookie_assert
ClosedPublic

Authored by kevans on Sep 12 2019, 11:05 PM.
Tags
None
Referenced Files
F81987434: D21628.id62069.diff
Wed, Apr 24, 4:45 AM
Unknown Object (File)
Fri, Apr 19, 12:49 AM
Unknown Object (File)
Sat, Apr 6, 5:20 PM
Unknown Object (File)
Sat, Apr 6, 10:51 AM
Unknown Object (File)
Mar 6 2024, 8:22 AM
Unknown Object (File)
Mar 6 2024, 8:21 AM
Unknown Object (File)
Mar 6 2024, 8:21 AM
Unknown Object (File)
Mar 6 2024, 8:21 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.