git: 35eb9b10c265 - main - Use KERNEL_PANICKED() in more places
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Thu, 02 Jun 2022 13:16:20 UTC
The branch main has been updated by mhorne: URL: https://cgit.FreeBSD.org/src/commit/?id=35eb9b10c265a27ce1f80a6eb74887240c7f4305 commit 35eb9b10c265a27ce1f80a6eb74887240c7f4305 Author: Mitchell Horne <mhorne@FreeBSD.org> AuthorDate: 2022-06-02 13:14:41 +0000 Commit: Mitchell Horne <mhorne@FreeBSD.org> CommitDate: 2022-06-02 13:15:43 +0000 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 --- sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c | 4 ++-- sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c | 2 +- sys/dev/vt/vt_core.c | 3 ++- sys/kern/kern_shutdown.c | 8 ++++---- sys/kern/subr_asan.c | 2 +- sys/kern/subr_msan.c | 4 ++-- 6 files changed, 12 insertions(+), 11 deletions(-) diff --git a/sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c b/sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c index b2e7b01b125c..76aaa0920f8a 100644 --- a/sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c +++ b/sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c @@ -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. diff --git a/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c b/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c index 5a8f992ce367..2e2ecf3dd228 100644 --- a/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c +++ b/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c @@ -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]; diff --git a/sys/dev/vt/vt_core.c b/sys/dev/vt/vt_core.c index 860cc0b00781..a623f50c9c06 100644 --- a/sys/dev/vt/vt_core.c +++ b/sys/dev/vt/vt_core.c @@ -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); diff --git a/sys/kern/kern_shutdown.c b/sys/kern/kern_shutdown.c index c78b19ca454a..8c2ec0e42d5d 100644 --- a/sys/kern/kern_shutdown.c +++ b/sys/kern/kern_shutdown.c @@ -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; diff --git a/sys/kern/subr_asan.c b/sys/kern/subr_asan.c index 19496346ce7e..003b89f888e9 100644 --- a/sys/kern/subr_asan.c +++ b/sys/kern/subr_asan.c @@ -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)) { diff --git a/sys/kern/subr_msan.c b/sys/kern/subr_msan.c index 10ccc842012a..816f38fc74cb 100644 --- a/sys/kern/subr_msan.c +++ b/sys/kern/subr_msan.c @@ -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;