Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 19 Dec 2018 22:30:26 +0000 (UTC)
From:      Mateusz Guzik <mjg@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r342247 - head/sys/security/mac
Message-ID:  <201812192230.wBJMUQI7039050@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: mjg
Date: Wed Dec 19 22:30:26 2018
New Revision: 342247
URL: https://svnweb.freebsd.org/changeset/base/342247

Log:
  mac: reduce pessimization of sdt probe handling
  
  Prior to the change the code would branch on return value and then check
  if probes are enabled. Since vast majority of the time they are not, this
  is clearly wasteful. Check probes first.
  
  Sponsored by:	The FreeBSD Foundation

Modified:
  head/sys/security/mac/mac_internal.h

Modified: head/sys/security/mac/mac_internal.h
==============================================================================
--- head/sys/security/mac/mac_internal.h	Wed Dec 19 22:17:24 2018	(r342246)
+++ head/sys/security/mac/mac_internal.h	Wed Dec 19 22:30:26 2018	(r342247)
@@ -98,12 +98,14 @@ SDT_PROVIDER_DECLARE(mac_framework);	/* Entry points t
 	    "int", arg0);
 
 #define	MAC_CHECK_PROBE4(name, error, arg0, arg1, arg2, arg3)	do {	\
-	if (error) {							\
-		SDT_PROBE5(mac_framework, , name, mac__check__err,	\
-		    error, arg0, arg1, arg2, arg3);			\
-	} else {							\
-		SDT_PROBE5(mac_framework, , name, mac__check__ok,	\
-		    0, arg0, arg1, arg2, arg3);				\
+	if (SDT_PROBES_ENABLED()) {					\
+		if (error) {						\
+			SDT_PROBE5(mac_framework, , name, mac__check__err,\
+			    error, arg0, arg1, arg2, arg3);		\
+		} else {						\
+			SDT_PROBE5(mac_framework, , name, mac__check__ok,\
+			    0, arg0, arg1, arg2, arg3);			\
+		}							\
 	}								\
 } while (0)
 
@@ -122,12 +124,14 @@ SDT_PROVIDER_DECLARE(mac_framework);	/* Entry points t
 	    "int", arg0, arg1);
 
 #define	MAC_GRANT_PROBE2(name, error, arg0, arg1)	do {		\
-	if (error) {							\
-		SDT_PROBE3(mac_framework, , name, mac__grant__err,	\
-		    error, arg0, arg1);					\
-	} else {							\
-		SDT_PROBE3(mac_framework, , name, mac__grant__ok,	\
-		    error, arg0, arg1);					\
+	if (SDT_PROBES_ENABLED()) {					\
+		if (error) {						\
+			SDT_PROBE3(mac_framework, , name, mac__grant__err,\
+			    error, arg0, arg1);				\
+		} else {						\
+			SDT_PROBE3(mac_framework, , name, mac__grant__ok,\
+			    error, arg0, arg1);				\
+		}							\
 	}								\
 } while (0)
 



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