From 6dcf45feda7e78378945fe63c1ad2528d5e737f9 Mon Sep 17 00:00:00 2001 From: Mateusz Guzik Date: Wed, 19 Dec 2018 22:30:26 +0000 Subject: [PATCH] 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 --- sys/security/mac/mac_internal.h | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/sys/security/mac/mac_internal.h b/sys/security/mac/mac_internal.h index 2ecffc6715a1..599ef8a75320 100644 --- a/sys/security/mac/mac_internal.h +++ b/sys/security/mac/mac_internal.h @@ -98,12 +98,14 @@ SDT_PROVIDER_DECLARE(mac_framework); /* Entry points to MAC. */ "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 to MAC. */ "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)