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

Function _lockmgr_assert

freebsd/kern/kern_lock.c:1716–1785  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1714#endif
1715
1716void
1717_lockmgr_assert(const struct lock *lk, int what, const char *file, int line)
1718{
1719 int slocked = 0;
1720
1721 if (KERNEL_PANICKED())
1722 return;
1723 switch (what) {
1724 case KA_SLOCKED:
1725 case KA_SLOCKED | KA_NOTRECURSED:
1726 case KA_SLOCKED | KA_RECURSED:
1727 slocked = 1;
1728 case KA_LOCKED:
1729 case KA_LOCKED | KA_NOTRECURSED:
1730 case KA_LOCKED | KA_RECURSED:
1731#ifdef WITNESS
1732
1733 /*
1734 * We cannot trust WITNESS if the lock is held in exclusive
1735 * mode and a call to lockmgr_disown() happened.
1736 * Workaround this skipping the check if the lock is held in
1737 * exclusive mode even for the KA_LOCKED case.
1738 */
1739 if (slocked || (lk->lk_lock & LK_SHARE)) {
1740 witness_assert(&lk->lock_object, what, file, line);
1741 break;
1742 }
1743#endif
1744 if (lk->lk_lock == LK_UNLOCKED ||
1745 ((lk->lk_lock & LK_SHARE) == 0 && (slocked ||
1746 (!lockmgr_xlocked(lk) && !lockmgr_disowned(lk)))))
1747 panic("Lock %s not %slocked @ %s:%d\n",
1748 lk->lock_object.lo_name, slocked ? "share" : "",
1749 file, line);
1750
1751 if ((lk->lk_lock & LK_SHARE) == 0) {
1752 if (lockmgr_recursed(lk)) {
1753 if (what & KA_NOTRECURSED)
1754 panic("Lock %s recursed @ %s:%d\n",
1755 lk->lock_object.lo_name, file,
1756 line);
1757 } else if (what & KA_RECURSED)
1758 panic("Lock %s not recursed @ %s:%d\n",
1759 lk->lock_object.lo_name, file, line);
1760 }
1761 break;
1762 case KA_XLOCKED:
1763 case KA_XLOCKED | KA_NOTRECURSED:
1764 case KA_XLOCKED | KA_RECURSED:
1765 if (!lockmgr_xlocked(lk) && !lockmgr_disowned(lk))
1766 panic("Lock %s not exclusively locked @ %s:%d\n",
1767 lk->lock_object.lo_name, file, line);
1768 if (lockmgr_recursed(lk)) {
1769 if (what & KA_NOTRECURSED)
1770 panic("Lock %s recursed @ %s:%d\n",
1771 lk->lock_object.lo_name, file, line);
1772 } else if (what & KA_RECURSED)
1773 panic("Lock %s not recursed @ %s:%d\n",

Callers 4

lockmgr_upgradeFunction · 0.85
lockmgr_unlockFunction · 0.85
__lockmgr_argsFunction · 0.85
_lockmgr_disownFunction · 0.85

Calls 2

witness_assertFunction · 0.85
panicFunction · 0.70

Tested by

no test coverage detected