Module Name:    src
Committed By:   riastradh
Date:           Sat Oct 29 14:00:12 UTC 2022

Modified Files:
        src/sys/sys: sdt.h

Log Message:
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...


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/sys/sys/sdt.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/sys/sdt.h
diff -u src/sys/sys/sdt.h:1.14 src/sys/sys/sdt.h:1.15
--- src/sys/sys/sdt.h:1.14	Sun Apr 19 03:12:35 2020
+++ src/sys/sys/sdt.h	Sat Oct 29 14:00:12 2022
@@ -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 <j...@freebsd.org>
@@ -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)(		       \

Reply via email to