[ofa-general] [PATCH] opensm/OSM_LOG(): wrap osm_log call with log level check

Sasha Khapyorsky sashak at voltaire.com
Wed Jul 9 15:35:34 PDT 2008


Even more speed (2-3 times) up for noisy osm_log debug calls - this
matters when OpenSM runs with lower log level.

Signed-off-by: Sasha Khapyorsky <sashak at voltaire.com>
---

And also this means that we can clean up all stuff like:

	if (osm_log_is_active(sm->p_log, OSM_LOG_DEBUG))
		OSM_LOG(sm->p_log, OSM_LOG_DEBUG, "blah-blah-blah\n");


 opensm/include/opensm/osm_log.h |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/opensm/include/opensm/osm_log.h b/opensm/include/opensm/osm_log.h
index 9f1a17b..741cef4 100644
--- a/opensm/include/opensm/osm_log.h
+++ b/opensm/include/opensm/osm_log.h
@@ -390,7 +390,10 @@ extern void osm_log_msg_box(osm_log_t *log, osm_log_level_t level,
 extern void osm_log_raw(IN osm_log_t * const p_log,
 	    IN const osm_log_level_t verbosity, IN const char *p_buf);
 
-#define OSM_LOG(log, level, fmt, arg...) osm_log(log, level, "%s: " fmt, __func__, ##arg)
+#define OSM_LOG(log, level, fmt, arg...) do { \
+		if (osm_log_is_active(log, (level))) \
+			osm_log(log, level, "%s: " fmt, __func__, ##arg); \
+	} while (0)
 
 #define DBG_CL_LOCK 0
 
-- 
1.5.5.1.178.g1f811




More information about the general mailing list