From: Ben Pfaff Date: Wed, 17 Dec 2008 00:32:27 +0000 (-0800) Subject: vlog: Optimize logging disabled, rate-limited messages. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f08cf794c81c3a363b940459ff98963e74a44fa4;p=openvswitch vlog: Optimize logging disabled, rate-limited messages. Previously the arguments of rate-limited messages were always evaluated and passed to vlog_rate_limit(). This commit short-circuits the case where the vlog levels would prevent any messages from being logged even without considering rate limiting. --- diff --git a/lib/vlog.h b/lib/vlog.h index 407177d7..a01309bf 100644 --- a/lib/vlog.h +++ b/lib/vlog.h @@ -163,12 +163,9 @@ void vlog_rate_limit(enum vlog_module, enum vlog_level, * #define THIS_MODULE VLM_netlink * Guaranteed to preserve errno. */ -#define VLOG_ERR_RL(RL, ...) \ - vlog_rate_limit(THIS_MODULE, VLL_ERR, RL, __VA_ARGS__) -#define VLOG_WARN_RL(RL, ...) \ - vlog_rate_limit(THIS_MODULE, VLL_WARN, RL, __VA_ARGS__) -#define VLOG_DBG_RL(RL, ...) \ - vlog_rate_limit(THIS_MODULE, VLL_DBG, RL, __VA_ARGS__) +#define VLOG_ERR_RL(RL, ...) VLOG_RL(RL, VLL_ERR, __VA_ARGS__) +#define VLOG_WARN_RL(RL, ...) VLOG_RL(RL, VLL_WARN, __VA_ARGS__) +#define VLOG_DBG_RL(RL, ...) VLOG_RL(RL, VLL_DBG, __VA_ARGS__) /* Command line processing. */ #define VLOG_OPTION_ENUMS OPT_LOG_FILE @@ -191,6 +188,12 @@ void vlog_usage(void); vlog(THIS_MODULE, LEVEL, __VA_ARGS__); \ } \ } while (0) +#define VLOG_RL(RL, LEVEL, ...) \ + do { \ + if (min_vlog_levels[THIS_MODULE] >= LEVEL) { \ + vlog_rate_limit(THIS_MODULE, LEVEL, RL, __VA_ARGS__); \ + } \ + } while (0) extern enum vlog_level min_vlog_levels[VLM_N_MODULES];