From: anton Date: Sun, 19 Dec 2021 07:45:59 +0000 (+0000) Subject: Reduce the overhead of all trace routines by returning as early as X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=191a76268fcd805662413672d7fdc30e04d405d0;p=openbsd Reduce the overhead of all trace routines by returning as early as possible in kd_curproc(). --- diff --git a/sys/dev/kcov.c b/sys/dev/kcov.c index b49c6d03a7e..d0f75ed995f 100644 --- a/sys/dev/kcov.c +++ b/sys/dev/kcov.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kcov.c,v 1.39 2021/12/18 08:24:31 anton Exp $ */ +/* $OpenBSD: kcov.c,v 1.40 2021/12/19 07:45:59 anton Exp $ */ /* * Copyright (c) 2018 Anton Lindqvist @@ -553,13 +553,6 @@ kd_curproc(int mode) { struct kcov_dev *kd; - /* - * Do not trace if the kernel has panicked. This could happen if curproc - * had kcov enabled while panicking. - */ - if (__predict_false(panicstr || db_active)) - return (NULL); - /* * Do not trace before kcovopen() has been called at least once. * At this point, all secondary CPUs have booted and accessing curcpu() @@ -571,8 +564,18 @@ kd_curproc(int mode) kd = curproc->p_kd; if (__predict_true(kd == NULL) || kd->kd_mode != mode) return (NULL); + + /* + * Do not trace if the kernel has panicked. This could happen if curproc + * had kcov enabled while panicking. + */ + if (__predict_false(panicstr || db_active)) + return (NULL); + + /* Do not trace in interrupt context unless this is a remote section. */ if (inintr() && kd->kd_intr == 0) return (NULL); + return (kd); }