MCPcopy Create free account
hub / github.com/F-Stack/f-stack / _rm_assert

Function _rm_assert

freebsd/kern/kern_rmlock.c:745–811  ·  view source on GitHub ↗

* Note that this does not need to use witness_assert() for read lock * assertions since an exact count of read locks held by this thread * is computable. */

Source from the content-addressed store, hash-verified

743 * is computable.
744 */
745void
746_rm_assert(const struct rmlock *rm, int what, const char *file, int line)
747{
748 int count;
749
750 if (SCHEDULER_STOPPED())
751 return;
752 switch (what) {
753 case RA_LOCKED:
754 case RA_LOCKED | RA_RECURSED:
755 case RA_LOCKED | RA_NOTRECURSED:
756 case RA_RLOCKED:
757 case RA_RLOCKED | RA_RECURSED:
758 case RA_RLOCKED | RA_NOTRECURSED:
759 /*
760 * Handle the write-locked case. Unlike other
761 * primitives, writers can never recurse.
762 */
763 if (rm_wowned(rm)) {
764 if (what & RA_RLOCKED)
765 panic("Lock %s exclusively locked @ %s:%d\n",
766 rm->lock_object.lo_name, file, line);
767 if (what & RA_RECURSED)
768 panic("Lock %s not recursed @ %s:%d\n",
769 rm->lock_object.lo_name, file, line);
770 break;
771 }
772
773 critical_enter();
774 count = rm_trackers_present(get_pcpu(), rm, curthread);
775 critical_exit();
776
777 if (count == 0)
778 panic("Lock %s not %slocked @ %s:%d\n",
779 rm->lock_object.lo_name, (what & RA_RLOCKED) ?
780 "read " : "", file, line);
781 if (count > 1) {
782 if (what & RA_NOTRECURSED)
783 panic("Lock %s recursed @ %s:%d\n",
784 rm->lock_object.lo_name, file, line);
785 } else if (what & RA_RECURSED)
786 panic("Lock %s not recursed @ %s:%d\n",
787 rm->lock_object.lo_name, file, line);
788 break;
789 case RA_WLOCKED:
790 if (!rm_wowned(rm))
791 panic("Lock %s not exclusively locked @ %s:%d\n",
792 rm->lock_object.lo_name, file, line);
793 break;
794 case RA_UNLOCKED:
795 if (rm_wowned(rm))
796 panic("Lock %s exclusively locked @ %s:%d\n",
797 rm->lock_object.lo_name, file, line);
798
799 critical_enter();
800 count = rm_trackers_present(get_pcpu(), rm, curthread);
801 critical_exit();
802

Callers 3

_rm_wlock_debugFunction · 0.85
_rm_wunlock_debugFunction · 0.85
_rm_runlock_debugFunction · 0.85

Calls 6

rm_trackers_presentFunction · 0.85
get_pcpuFunction · 0.85
rm_wownedFunction · 0.70
panicFunction · 0.70
critical_enterFunction · 0.50
critical_exitFunction · 0.50

Tested by

no test coverage detected