Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/sys sys/sdt.h: Predict dtrace probe branches not taken i...



details:   https://anonhg.NetBSD.org/src/rev/c7e2938231e9
branches:  trunk
changeset: 372181:c7e2938231e9
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Sat Oct 29 14:00:12 2022 +0000

description:
sys/sdt.h: Predict dtrace probe branches not taken in SDT_PROBE*.

This should help reduce the overhead of KDRACE_HOOKS while you're not
actually tracing anything!  Shoulda done this ages ago...

diffstat:

 sys/sys/sdt.h |  8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diffs (36 lines):

diff -r 476611d6dd40 -r c7e2938231e9 sys/sys/sdt.h
--- a/sys/sys/sdt.h     Sat Oct 29 13:59:57 2022 +0000
+++ b/sys/sys/sdt.h     Sat Oct 29 14:00:12 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: sdt.h,v 1.14 2020/04/19 03:12:35 riastradh Exp $       */
+/*     $NetBSD: sdt.h,v 1.15 2022/10/29 14:00:12 riastradh Exp $       */
 
 /*-
  * Copyright 2006-2008 John Birrell <jb%FreeBSD.org@localhost>
@@ -172,7 +172,7 @@
        extern struct sdt_probe sdt_##prov##_##mod##_##func##_##name[1]
 
 #define SDT_PROBE(prov, mod, func, name, arg0, arg1, arg2, arg3, arg4) do {    \
-       if (sdt_##prov##_##mod##_##func##_##name->id)                           \
+       if (__predict_false(sdt_##prov##_##mod##_##func##_##name->id))          \
                (*sdt_probe_func)(sdt_##prov##_##mod##_##func##_##name->id,     \
                    (uintptr_t) (arg0), (uintptr_t) (arg1), (uintptr_t) (arg2), \
                    (uintptr_t) (arg3), (uintptr_t) (arg4));                    \
@@ -313,7 +313,7 @@
 /* XXX: void * function casts */
 #define        SDT_PROBE6(prov, mod, func, name, arg0, arg1, arg2, arg3, arg4, arg5)  \
        do {                                                                   \
-               if (sdt_##prov##_##mod##_##func##_##name->id)                  \
+               if (__predict_false(sdt_##prov##_##mod##_##func##_##name->id)) \
                        __FPTRCAST(void (*)(uint32_t, uintptr_t, uintptr_t,    \
                            uintptr_t, uintptr_t, uintptr_t, uintptr_t),       \
                            sdt_probe_func)(                                   \
@@ -324,7 +324,7 @@
 #define        SDT_PROBE7(prov, mod, func, name, arg0, arg1, arg2, arg3, arg4, arg5,  \
     arg6)                                                                     \
        do {                                                                   \
-               if (sdt_##prov##_##mod##_##func##_##name->id)                  \
+               if (__predict_false(sdt_##prov##_##mod##_##func##_##name->id)) \
                        __FPTRCAST(void (*)(uint32_t, uintptr_t, uintptr_t,    \
                            uintptr_t, uintptr_t, uintptr_t, uintptr_t,        \
                            uintptr_t), sdt_probe_func)(                       \



Home | Main Index | Thread Index | Old Index