Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 23 Jun 2022 22:23:03 GMT
From:      Mitchell Horne <mhorne@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: 0db22efc9445 - stable/13 - Use KERNEL_PANICKED() in more places
Message-ID:  <202206232223.25NMN3RK055012@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/13 has been updated by mhorne:

URL: https://cgit.FreeBSD.org/src/commit/?id=0db22efc94459609b99d5289c2fecf22bda646fc

commit 0db22efc94459609b99d5289c2fecf22bda646fc
Author:     Mitchell Horne <mhorne@FreeBSD.org>
AuthorDate: 2022-06-02 13:14:41 +0000
Commit:     Mitchell Horne <mhorne@FreeBSD.org>
CommitDate: 2022-06-23 22:19:26 +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
    
    (cherry picked from commit 35eb9b10c265a27ce1f80a6eb74887240c7f4305)
---
 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 +-
 5 files changed, 10 insertions(+), 9 deletions(-)

diff --git a/sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c b/sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c
index ca2a5438f1f1..75129eccc251 100644
--- a/sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c
+++ b/sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c
@@ -7335,7 +7335,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
@@ -7366,7 +7366,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 8764eaa379c9..c5be9c443456 100644
--- a/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c
+++ b/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c
@@ -720,7 +720,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 2357b377f1e5..38fda0a501c5 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 875d5edd2d4e..c635e33e5fb2 100644
--- a/sys/kern/kern_shutdown.c
+++ b/sys/kern/kern_shutdown.c
@@ -780,7 +780,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
@@ -877,7 +877,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;
@@ -961,7 +961,7 @@ kproc_shutdown(void *arg, int howto)
 	struct proc *p;
 	int error;
 
-	if (panicstr)
+	if (KERNEL_PANICKED())
 		return;
 
 	p = (struct proc *)arg;
@@ -981,7 +981,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 825d7d4228c0..cf7c27c9c418 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)) {



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202206232223.25NMN3RK055012>