Use KERNEL_PANICKED() in more places

This is slightly more optimized than checking panicstr directly. For
most of these instances performance doesn't matter, but let's make
KERNEL_PANICKED() the common idiom.

Reviewed by:	mjg
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D35373
This commit is contained in:
Mitchell Horne 2022-06-02 10:14:41 -03:00
parent 592e876a42
commit 35eb9b10c2
6 changed files with 12 additions and 11 deletions

View File

@ -7338,7 +7338,7 @@ dtrace_probe(dtrace_id_t id, uintptr_t arg0, uintptr_t arg1,
volatile uint16_t *flags;
hrtime_t now;
if (panicstr != NULL)
if (KERNEL_PANICKED())
return;
#ifdef illumos
@ -7369,7 +7369,7 @@ dtrace_probe(dtrace_id_t id, uintptr_t arg0, uintptr_t arg1,
#ifdef illumos
if (panic_quiesce) {
#else
if (panicstr != NULL) {
if (KERNEL_PANICKED()) {
#endif
/*
* We don't trace anything if we're panicking.

View File

@ -718,7 +718,7 @@ hv_storvsc_io_request(struct storvsc_softc *sc,
* always uses sc->hs_chan, then we must send to that channel or a poll
* timeout will occur.
*/
if (panicstr) {
if (KERNEL_PANICKED()) {
outgoing_channel = sc->hs_chan;
} else {
outgoing_channel = sc->hs_sel_chan[ch_sel];

View File

@ -593,7 +593,8 @@ vt_window_switch(struct vt_window *vw)
* switch to console mode when panicking, making sure the panic
* is readable (even when a GUI was using ttyv0).
*/
if ((kdb_active || panicstr) && vd->vd_driver->vd_postswitch)
if ((kdb_active || KERNEL_PANICKED()) &&
vd->vd_driver->vd_postswitch)
vd->vd_driver->vd_postswitch(vd);
VT_UNLOCK(vd);
return (0);

View File

@ -835,7 +835,7 @@ kassert_panic(const char *fmt, ...)
* If we are suppressing secondary panics, log the warning but do not
* re-enter panic/kdb.
*/
if (panicstr != NULL && kassert_suppress_in_panic) {
if (KERNEL_PANICKED() && kassert_suppress_in_panic) {
if (kassert_do_log) {
printf("KASSERT failed: %s\n", buf);
#ifdef KDB
@ -932,7 +932,7 @@ vpanic(const char *fmt, va_list ap)
bootopt = RB_AUTOBOOT;
newpanic = 0;
if (panicstr)
if (KERNEL_PANICKED())
bootopt |= RB_NOSYNC;
else {
bootopt |= RB_DUMP;
@ -1016,7 +1016,7 @@ kproc_shutdown(void *arg, int howto)
struct proc *p;
int error;
if (panicstr)
if (KERNEL_PANICKED())
return;
p = (struct proc *)arg;
@ -1036,7 +1036,7 @@ kthread_shutdown(void *arg, int howto)
struct thread *td;
int error;
if (panicstr)
if (KERNEL_PANICKED())
return;
td = (struct thread *)arg;

View File

@ -387,7 +387,7 @@ kasan_shadow_check(unsigned long addr, size_t size, bool write,
return;
if (__predict_false(kasan_md_unsupported(addr)))
return;
if (__predict_false(panicstr != NULL))
if (KERNEL_PANICKED())
return;
if (__builtin_constant_p(size)) {

View File

@ -178,7 +178,7 @@ kmsan_report_hook(const void *addr, size_t size, size_t off, const char *hook)
char buf[128];
int type;
if (__predict_false(panicstr != NULL || kdb_active || kmsan_reporting))
if (__predict_false(KERNEL_PANICKED() || kdb_active || kmsan_reporting))
return;
kmsan_reporting = true;
@ -234,7 +234,7 @@ kmsan_report_inline(msan_orig_t orig, unsigned long pc)
long foff;
int type;
if (__predict_false(panicstr != NULL || kdb_active || kmsan_reporting))
if (__predict_false(KERNEL_PANICKED() || kdb_active || kmsan_reporting))
return;
kmsan_reporting = true;