Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F156888988
D6117.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
15 KB
Referenced Files
None
Subscribers
None
D6117.diff
View Options
Index: sys/kern/kern_shutdown.c
===================================================================
--- sys/kern/kern_shutdown.c
+++ sys/kern/kern_shutdown.c
@@ -56,7 +56,6 @@
#include <sys/kernel.h>
#include <sys/kerneldump.h>
#include <sys/kthread.h>
-#include <sys/ktr.h>
#include <sys/malloc.h>
#include <sys/mount.h>
#include <sys/priv.h>
@@ -556,126 +555,6 @@
/* NOTREACHED */ /* assuming reset worked */
}
-#if defined(WITNESS) || defined(INVARIANTS)
-static int kassert_warn_only = 0;
-#ifdef KDB
-static int kassert_do_kdb = 0;
-#endif
-#ifdef KTR
-static int kassert_do_ktr = 0;
-#endif
-static int kassert_do_log = 1;
-static int kassert_log_pps_limit = 4;
-static int kassert_log_mute_at = 0;
-static int kassert_log_panic_at = 0;
-static int kassert_warnings = 0;
-
-SYSCTL_NODE(_debug, OID_AUTO, kassert, CTLFLAG_RW, NULL, "kassert options");
-
-SYSCTL_INT(_debug_kassert, OID_AUTO, warn_only, CTLFLAG_RWTUN,
- &kassert_warn_only, 0,
- "KASSERT triggers a panic (1) or just a warning (0)");
-
-#ifdef KDB
-SYSCTL_INT(_debug_kassert, OID_AUTO, do_kdb, CTLFLAG_RWTUN,
- &kassert_do_kdb, 0, "KASSERT will enter the debugger");
-#endif
-
-#ifdef KTR
-SYSCTL_UINT(_debug_kassert, OID_AUTO, do_ktr, CTLFLAG_RWTUN,
- &kassert_do_ktr, 0,
- "KASSERT does a KTR, set this to the KTRMASK you want");
-#endif
-
-SYSCTL_INT(_debug_kassert, OID_AUTO, do_log, CTLFLAG_RWTUN,
- &kassert_do_log, 0, "KASSERT triggers a panic (1) or just a warning (0)");
-
-SYSCTL_INT(_debug_kassert, OID_AUTO, warnings, CTLFLAG_RWTUN,
- &kassert_warnings, 0, "number of KASSERTs that have been triggered");
-
-SYSCTL_INT(_debug_kassert, OID_AUTO, log_panic_at, CTLFLAG_RWTUN,
- &kassert_log_panic_at, 0, "max number of KASSERTS before we will panic");
-
-SYSCTL_INT(_debug_kassert, OID_AUTO, log_pps_limit, CTLFLAG_RWTUN,
- &kassert_log_pps_limit, 0, "limit number of log messages per second");
-
-SYSCTL_INT(_debug_kassert, OID_AUTO, log_mute_at, CTLFLAG_RWTUN,
- &kassert_log_mute_at, 0, "max number of KASSERTS to log");
-
-static int kassert_sysctl_kassert(SYSCTL_HANDLER_ARGS);
-
-SYSCTL_PROC(_debug_kassert, OID_AUTO, kassert,
- CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_SECURE, NULL, 0,
- kassert_sysctl_kassert, "I", "set to trigger a test kassert");
-
-static int
-kassert_sysctl_kassert(SYSCTL_HANDLER_ARGS)
-{
- int error, i;
-
- error = sysctl_wire_old_buffer(req, sizeof(int));
- if (error == 0) {
- i = 0;
- error = sysctl_handle_int(oidp, &i, 0, req);
- }
- if (error != 0 || req->newptr == NULL)
- return (error);
- KASSERT(0, ("kassert_sysctl_kassert triggered kassert %d", i));
- return (0);
-}
-
-/*
- * Called by KASSERT, this decides if we will panic
- * or if we will log via printf and/or ktr.
- */
-void
-kassert_panic(const char *fmt, ...)
-{
- static char buf[256];
- va_list ap;
-
- va_start(ap, fmt);
- (void)vsnprintf(buf, sizeof(buf), fmt, ap);
- va_end(ap);
-
- /*
- * panic if we're not just warning, or if we've exceeded
- * kassert_log_panic_at warnings.
- */
- if (!kassert_warn_only ||
- (kassert_log_panic_at > 0 &&
- kassert_warnings >= kassert_log_panic_at)) {
- va_start(ap, fmt);
- vpanic(fmt, ap);
- /* NORETURN */
- }
-#ifdef KTR
- if (kassert_do_ktr)
- CTR0(ktr_mask, buf);
-#endif /* KTR */
- /*
- * log if we've not yet met the mute limit.
- */
- if (kassert_do_log &&
- (kassert_log_mute_at == 0 ||
- kassert_warnings < kassert_log_mute_at)) {
- static struct timeval lasterr;
- static int curerr;
-
- if (ppsratecheck(&lasterr, &curerr, kassert_log_pps_limit)) {
- printf("KASSERT failed: %s\n", buf);
- kdb_backtrace();
- }
- }
-#ifdef KDB
- if (kassert_do_kdb) {
- kdb_enter(KDB_WHY_KASSERT, buf);
- }
-#endif
- atomic_add_int(&kassert_warnings, 1);
-}
-#endif
-
/*
* Panic is called on unresolvable fatal errors. It prints "panic: mesg",
* and then reboots. If we are called twice, then we avoid trying to sync
Index: sys/kern/subr_witness.c
===================================================================
--- sys/kern/subr_witness.c
+++ sys/kern/subr_witness.c
@@ -835,15 +835,15 @@
class = LOCK_CLASS(lock);
if ((lock->lo_flags & LO_RECURSABLE) != 0 &&
(class->lc_flags & LC_RECURSABLE) == 0)
- kassert_panic("%s: lock (%s) %s can not be recursable",
+ panic("%s: lock (%s) %s can not be recursable",
__func__, class->lc_name, lock->lo_name);
if ((lock->lo_flags & LO_SLEEPABLE) != 0 &&
(class->lc_flags & LC_SLEEPABLE) == 0)
- kassert_panic("%s: lock (%s) %s can not be sleepable",
+ panic("%s: lock (%s) %s can not be sleepable",
__func__, class->lc_name, lock->lo_name);
if ((lock->lo_flags & LO_UPGRADABLE) != 0 &&
(class->lc_flags & LC_UPGRADABLE) == 0)
- kassert_panic("%s: lock (%s) %s can not be upgradable",
+ panic("%s: lock (%s) %s can not be upgradable",
__func__, class->lc_name, lock->lo_name);
/*
@@ -1087,7 +1087,7 @@
* all spin locks.
*/
if (td->td_critnest != 0 && !kdb_active)
- kassert_panic("acquiring blockable sleep lock with "
+ panic("acquiring blockable sleep lock with "
"spinlock or critical section held (%s) %s @ %s:%d",
class->lc_name, lock->lo_name,
fixup_filename(file), line);
@@ -1132,7 +1132,7 @@
fixup_filename(file), line);
witness_output("while exclusively locked from %s:%d\n",
fixup_filename(lock1->li_file), lock1->li_line);
- kassert_panic("excl->share");
+ panic("excl->share");
}
if ((lock1->li_flags & LI_EXCLUSIVE) == 0 &&
(flags & LOP_EXCLUSIVE) != 0) {
@@ -1141,7 +1141,7 @@
fixup_filename(file), line);
witness_output("while share locked from %s:%d\n",
fixup_filename(lock1->li_file), lock1->li_line);
- kassert_panic("share->excl");
+ panic("share->excl");
}
return;
}
@@ -1151,11 +1151,11 @@
iclass = LOCK_CLASS(interlock);
lock1 = find_instance(lock_list, interlock);
if (lock1 == NULL)
- kassert_panic("interlock (%s) %s not locked @ %s:%d",
+ panic("interlock (%s) %s not locked @ %s:%d",
iclass->lc_name, interlock->lo_name,
fixup_filename(file), line);
else if ((lock1->li_flags & LI_RECURSEMASK) != 0)
- kassert_panic("interlock (%s) %s recursed @ %s:%d",
+ panic("interlock (%s) %s recursed @ %s:%d",
iclass->lc_name, interlock->lo_name,
fixup_filename(file), line);
}
@@ -1478,32 +1478,28 @@
class = LOCK_CLASS(lock);
if (witness_watch) {
if ((lock->lo_flags & LO_UPGRADABLE) == 0)
- kassert_panic(
- "upgrade of non-upgradable lock (%s) %s @ %s:%d",
+ panic("upgrade of non-upgradable lock (%s) %s @ %s:%d",
class->lc_name, lock->lo_name,
fixup_filename(file), line);
if ((class->lc_flags & LC_SLEEPLOCK) == 0)
- kassert_panic(
- "upgrade of non-sleep lock (%s) %s @ %s:%d",
+ panic("upgrade of non-sleep lock (%s) %s @ %s:%d",
class->lc_name, lock->lo_name,
fixup_filename(file), line);
}
instance = find_instance(curthread->td_sleeplocks, lock);
if (instance == NULL) {
- kassert_panic("upgrade of unlocked lock (%s) %s @ %s:%d",
+ panic("upgrade of unlocked lock (%s) %s @ %s:%d",
class->lc_name, lock->lo_name,
fixup_filename(file), line);
return;
}
if (witness_watch) {
if ((instance->li_flags & LI_EXCLUSIVE) != 0)
- kassert_panic(
- "upgrade of exclusive lock (%s) %s @ %s:%d",
+ panic("upgrade of exclusive lock (%s) %s @ %s:%d",
class->lc_name, lock->lo_name,
fixup_filename(file), line);
if ((instance->li_flags & LI_RECURSEMASK) != 0)
- kassert_panic(
- "upgrade of recursed lock (%s) %s r=%d @ %s:%d",
+ panic("upgrade of recursed lock (%s) %s r=%d @ %s:%d",
class->lc_name, lock->lo_name,
instance->li_flags & LI_RECURSEMASK,
fixup_filename(file), line);
@@ -1524,31 +1520,29 @@
class = LOCK_CLASS(lock);
if (witness_watch) {
if ((lock->lo_flags & LO_UPGRADABLE) == 0)
- kassert_panic(
+ panic(
"downgrade of non-upgradable lock (%s) %s @ %s:%d",
class->lc_name, lock->lo_name,
fixup_filename(file), line);
if ((class->lc_flags & LC_SLEEPLOCK) == 0)
- kassert_panic(
- "downgrade of non-sleep lock (%s) %s @ %s:%d",
+ panic("downgrade of non-sleep lock (%s) %s @ %s:%d",
class->lc_name, lock->lo_name,
fixup_filename(file), line);
}
instance = find_instance(curthread->td_sleeplocks, lock);
if (instance == NULL) {
- kassert_panic("downgrade of unlocked lock (%s) %s @ %s:%d",
+ panic("downgrade of unlocked lock (%s) %s @ %s:%d",
class->lc_name, lock->lo_name,
fixup_filename(file), line);
return;
}
if (witness_watch) {
if ((instance->li_flags & LI_EXCLUSIVE) == 0)
- kassert_panic(
- "downgrade of shared lock (%s) %s @ %s:%d",
+ panic("downgrade of shared lock (%s) %s @ %s:%d",
class->lc_name, lock->lo_name,
fixup_filename(file), line);
if ((instance->li_flags & LI_RECURSEMASK) != 0)
- kassert_panic(
+ panic(
"downgrade of recursed lock (%s) %s r=%d @ %s:%d",
class->lc_name, lock->lo_name,
instance->li_flags & LI_RECURSEMASK,
@@ -1592,7 +1586,7 @@
* eventual register locks and remove them.
*/
if (witness_watch > 0) {
- kassert_panic("lock (%s) %s not locked @ %s:%d", class->lc_name,
+ panic("lock (%s) %s not locked @ %s:%d", class->lc_name,
lock->lo_name, fixup_filename(file), line);
return;
} else {
@@ -1607,7 +1601,7 @@
class->lc_name, lock->lo_name, fixup_filename(file), line);
witness_output("while exclusively locked from %s:%d\n",
fixup_filename(instance->li_file), instance->li_line);
- kassert_panic("excl->ushare");
+ panic("excl->ushare");
}
if ((instance->li_flags & LI_EXCLUSIVE) == 0 && witness_watch > 0 &&
(flags & LOP_EXCLUSIVE) != 0) {
@@ -1616,7 +1610,7 @@
witness_output("while share locked from %s:%d\n",
fixup_filename(instance->li_file),
instance->li_line);
- kassert_panic("share->uexcl");
+ panic("share->uexcl");
}
/* If we are recursed, unrecurse. */
if ((instance->li_flags & LI_RECURSEMASK) > 0) {
@@ -1630,7 +1624,7 @@
if ((instance->li_flags & LI_NORELEASE) != 0 && witness_watch > 0) {
witness_output("forbidden unlock of (%s) %s @ %s:%d\n",
class->lc_name, lock->lo_name, fixup_filename(file), line);
- kassert_panic("lock marked norelease");
+ panic("lock marked norelease");
}
/* Otherwise, remove this item from the list. */
@@ -1686,8 +1680,7 @@
witness_output);
}
- kassert_panic(
- "Thread %p cannot exit while holding sleeplocks\n", td);
+ panic("Thread %p cannot exit while holding sleeplocks\n", td);
}
witness_lock_list_free(lle);
}
@@ -1766,7 +1759,7 @@
} else
sched_unpin();
if (flags & WARN_PANIC && n)
- kassert_panic("%s", __func__);
+ panic("%s", __func__);
else
witness_debugger(n, __func__);
return (n);
@@ -1812,7 +1805,7 @@
} else if ((lock_class->lc_flags & LC_SLEEPLOCK)) {
typelist = &w_sleep;
} else {
- kassert_panic("lock class %s is not sleep or spin",
+ panic("lock class %s is not sleep or spin",
lock_class->lc_name);
return (NULL);
}
@@ -1845,10 +1838,8 @@
w->w_refcount++;
mtx_unlock_spin(&w_mtx);
if (lock_class != w->w_class)
- kassert_panic(
- "lock (%s) %s does not match earlier (%s) lock",
- description, lock_class->lc_name,
- w->w_class->lc_name);
+ panic("lock (%s) %s does not match earlier (%s) lock",
+ description, lock_class->lc_name, w->w_class->lc_name);
return (w);
}
@@ -1984,8 +1975,7 @@
} else {
unlocked = 0;
}
- kassert_panic(
- "%s: parent \"%s\" (%s) and child \"%s\" (%s) are not "
+ panic("%s: parent \"%s\" (%s) and child \"%s\" (%s) are not "
"the same lock type", __func__, parent->w_name,
parent->w_class->lc_name, child->w_name,
child->w_class->lc_name);
@@ -2295,8 +2285,8 @@
}
instance = find_instance(lock_list, lock);
if (instance == NULL) {
- kassert_panic("%s: lock (%s) %s not locked", __func__,
- class->lc_name, lock->lo_name);
+ panic("%s: lock (%s) %s not locked", __func__, class->lc_name,
+ lock->lo_name);
return;
}
*filep = instance->li_file;
@@ -2330,8 +2320,8 @@
}
instance = find_instance(lock_list, lock);
if (instance == NULL)
- kassert_panic("%s: lock (%s) %s not locked", __func__,
- class->lc_name, lock->lo_name);
+ panic("%s: lock (%s) %s not locked", __func__, class->lc_name,
+ lock->lo_name);
lock->lo_witness->w_file = file;
lock->lo_witness->w_line = line;
if (instance == NULL)
@@ -2356,16 +2346,15 @@
else if ((class->lc_flags & LC_SPINLOCK) != 0)
instance = find_instance(PCPU_GET(spinlocks), lock);
else {
- kassert_panic("Lock (%s) %s is not sleep or spin!",
- class->lc_name, lock->lo_name);
+ panic("Lock (%s) %s is not sleep or spin!", class->lc_name,
+ lock->lo_name);
return;
}
switch (flags) {
case LA_UNLOCKED:
if (instance != NULL)
- kassert_panic("Lock (%s) %s locked @ %s:%d.",
- class->lc_name, lock->lo_name,
- fixup_filename(file), line);
+ panic("Lock (%s) %s locked @ %s:%d.", class->lc_name,
+ lock->lo_name, fixup_filename(file), line);
break;
case LA_LOCKED:
case LA_LOCKED | LA_RECURSED:
@@ -2377,36 +2366,34 @@
case LA_XLOCKED | LA_RECURSED:
case LA_XLOCKED | LA_NOTRECURSED:
if (instance == NULL) {
- kassert_panic("Lock (%s) %s not locked @ %s:%d.",
+ panic("Lock (%s) %s not locked @ %s:%d.",
class->lc_name, lock->lo_name,
fixup_filename(file), line);
break;
}
if ((flags & LA_XLOCKED) != 0 &&
(instance->li_flags & LI_EXCLUSIVE) == 0)
- kassert_panic(
- "Lock (%s) %s not exclusively locked @ %s:%d.",
+ panic("Lock (%s) %s not exclusively locked @ %s:%d.",
class->lc_name, lock->lo_name,
fixup_filename(file), line);
if ((flags & LA_SLOCKED) != 0 &&
(instance->li_flags & LI_EXCLUSIVE) != 0)
- kassert_panic(
- "Lock (%s) %s exclusively locked @ %s:%d.",
+ panic("Lock (%s) %s exclusively locked @ %s:%d.",
class->lc_name, lock->lo_name,
fixup_filename(file), line);
if ((flags & LA_RECURSED) != 0 &&
(instance->li_flags & LI_RECURSEMASK) == 0)
- kassert_panic("Lock (%s) %s not recursed @ %s:%d.",
+ panic("Lock (%s) %s not recursed @ %s:%d.",
class->lc_name, lock->lo_name,
fixup_filename(file), line);
if ((flags & LA_NOTRECURSED) != 0 &&
(instance->li_flags & LI_RECURSEMASK) != 0)
- kassert_panic("Lock (%s) %s recursed @ %s:%d.",
+ panic("Lock (%s) %s recursed @ %s:%d.",
class->lc_name, lock->lo_name,
fixup_filename(file), line);
break;
default:
- kassert_panic("Invalid lock assertion at %s:%d.",
+ panic("Invalid lock assertion at %s:%d.",
fixup_filename(file), line);
}
@@ -2432,8 +2419,8 @@
}
instance = find_instance(lock_list, lock);
if (instance == NULL) {
- kassert_panic("%s: lock (%s) %s not locked", __func__,
- class->lc_name, lock->lo_name);
+ panic("%s: lock (%s) %s not locked", __func__, class->lc_name,
+ lock->lo_name);
return;
}
Index: sys/sys/systm.h
===================================================================
--- sys/sys/systm.h
+++ sys/sys/systm.h
@@ -76,19 +76,15 @@
enum VM_GUEST { VM_GUEST_NO = 0, VM_GUEST_VM, VM_GUEST_XEN, VM_GUEST_HV,
VM_GUEST_VMWARE, VM_LAST };
-#if defined(WITNESS) || defined(INVARIANTS)
-void kassert_panic(const char *fmt, ...) __printflike(1, 2);
-#endif
-
#ifdef INVARIANTS /* The option is always available */
#define KASSERT(exp,msg) do { \
if (__predict_false(!(exp))) \
- kassert_panic msg; \
+ panic msg; \
} while (0)
#define VNASSERT(exp, vp, msg) do { \
if (__predict_false(!(exp))) { \
vn_printf(vp, "VNASSERT failed\n"); \
- kassert_panic msg; \
+ panic msg; \
} \
} while (0)
#else
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, May 18, 2:46 AM (2 h, 37 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
33230439
Default Alt Text
D6117.diff (15 KB)
Attached To
Mode
D6117: Revert r243980 and r244105
Attached
Detach File
Event Timeline
Log In to Comment