mirror of
https://github.com/freebsd/freebsd-src.git
synced 2024-12-03 19:08:58 +00:00
Make SPLASSERT sysctl and boot time tunable with kern.splassertmode.
The following values are understood: 0 (ignore), 1 (log), and 2 (panic). The default value is 1. Reviewed by: peter
This commit is contained in:
parent
0a8c1cdc73
commit
891c64630d
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=58295
@ -28,6 +28,8 @@
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/sysctl.h>
|
||||
#include <sys/interrupt.h>
|
||||
#include <machine/ipl.h>
|
||||
#include <machine/cpu.h>
|
||||
@ -166,6 +168,38 @@ GENSET(schedsoftvm, &idelayed, 1 << SWI_VM)
|
||||
GENSET(schedsoftclock, &idelayed, 1 << SWI_CLOCK)
|
||||
|
||||
#ifdef INVARIANT_SUPPORT
|
||||
|
||||
#define SPLASSERT_IGNORE 0
|
||||
#define SPLASSERT_LOG 1
|
||||
#define SPLASSERT_PANIC 2
|
||||
|
||||
static int splassertmode = SPLASSERT_LOG;
|
||||
SYSCTL_INT(_kern, OID_AUTO, splassertmode, CTLFLAG_RW,
|
||||
&splassertmode, 0, "Set the mode of SPLASSERT");
|
||||
|
||||
static void
|
||||
init_splassertmode(void *ignored)
|
||||
{
|
||||
TUNABLE_INT_FETCH("kern.splassertmode", 0, splassertmode);
|
||||
}
|
||||
SYSINIT(param, SI_SUB_TUNABLES, SI_ORDER_ANY, init_splassertmode, NULL);
|
||||
|
||||
static void
|
||||
splassertfail(char *str, const char *msg, char *name, int level)
|
||||
{
|
||||
switch (splassertmode) {
|
||||
case SPLASSERT_IGNORE:
|
||||
break;
|
||||
case SPLASSERT_LOG:
|
||||
printf(str, msg, name, level);
|
||||
printf("\n");
|
||||
break;
|
||||
case SPLASSERT_PANIC:
|
||||
panic(str, msg, name, level);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#define GENSPLASSERT(name, pri) \
|
||||
void \
|
||||
name##assert(const char *msg) \
|
||||
@ -174,7 +208,7 @@ name##assert(const char *msg) \
|
||||
\
|
||||
cpl = getcpl(); \
|
||||
if (cpl < ALPHA_PSL_IPL_##pri); \
|
||||
panic("%s: not %s, cpl == %#x", \
|
||||
splassertfail("%s: not %s, cpl == %#x", \
|
||||
msg, __XSTRING(name) + 3, cpl); \
|
||||
}
|
||||
#else
|
||||
|
@ -28,6 +28,8 @@
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/sysctl.h>
|
||||
#include <machine/ipl.h>
|
||||
#include <machine/globals.h>
|
||||
#include <i386/isa/intr_machdep.h>
|
||||
@ -66,12 +68,44 @@ softclockpending(void)
|
||||
}
|
||||
|
||||
#ifdef INVARIANT_SUPPORT
|
||||
|
||||
#define SPLASSERT_IGNORE 0
|
||||
#define SPLASSERT_LOG 1
|
||||
#define SPLASSERT_PANIC 2
|
||||
|
||||
static int splassertmode = SPLASSERT_LOG;
|
||||
SYSCTL_INT(_kern, OID_AUTO, splassertmode, CTLFLAG_RW,
|
||||
&splassertmode, 0, "Set the mode of SPLASSERT");
|
||||
|
||||
static void
|
||||
init_splassertmode(void *ignored)
|
||||
{
|
||||
TUNABLE_INT_FETCH("kern.splassertmode", 0, splassertmode);
|
||||
}
|
||||
SYSINIT(param, SI_SUB_TUNABLES, SI_ORDER_ANY, init_splassertmode, NULL);
|
||||
|
||||
static void
|
||||
splassertfail(char *str, const char *msg, char *name, int level)
|
||||
{
|
||||
switch (splassertmode) {
|
||||
case SPLASSERT_IGNORE:
|
||||
break;
|
||||
case SPLASSERT_LOG:
|
||||
printf(str, msg, name, level);
|
||||
printf("\n");
|
||||
break;
|
||||
case SPLASSERT_PANIC:
|
||||
panic(str, msg, name, level);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#define GENSPLASSERT(NAME, MODIFIER) \
|
||||
void \
|
||||
NAME##assert(const char *msg) \
|
||||
{ \
|
||||
if ((cpl & (MODIFIER)) != (MODIFIER)) \
|
||||
panic("%s: not %s, cpl == %#x", \
|
||||
splassertfail("%s: not %s, cpl == %#x", \
|
||||
msg, __XSTRING(NAME) + 3, cpl); \
|
||||
}
|
||||
#else
|
||||
|
Loading…
Reference in New Issue
Block a user