[ovs-dev] [PATCH] Fast path in vlog
William Tu
u9012063 at gmail.com
Tue Apr 21 15:57:04 UTC 2020
On Tue, Apr 21, 2020 at 09:24:38AM +0100, anton.ivanov at cambridgegreys.com wrote:
> From: Anton Ivanov <anton.ivanov at cambridgegreys.com>
>
> Avoid grabbing any mutexes if the log levels specify that
> no logging is to take place.
>
> Signed-off-by: Anton Ivanov <anton.ivanov at cambridgegreys.com>
> ---
Looks good to me, thanks
Acked-by: William Tu <u9012063 at gmail.com>
> lib/vlog.c | 11 +++++++++--
> 1 file changed, 9 insertions(+), 2 deletions(-)
>
> diff --git a/lib/vlog.c b/lib/vlog.c
> index ee6b0d3a6..533f93755 100644
> --- a/lib/vlog.c
> +++ b/lib/vlog.c
> @@ -1103,10 +1103,17 @@ vlog_valist(const struct vlog_module *module, enum vlog_level level,
> {
> bool log_to_console = module->levels[VLF_CONSOLE] >= level;
> bool log_to_syslog = module->levels[VLF_SYSLOG] >= level;
> - bool log_to_file;
> + bool log_to_file = module->levels[VLF_FILE] >= level;
> +
> + if (!(log_to_console || log_to_syslog || log_to_file)) {
> + /* fast path - all logging levels specify no logging, no
> + * need to hog the log mutex
> + */
> + return;
> + }
>
> ovs_mutex_lock(&log_file_mutex);
> - log_to_file = module->levels[VLF_FILE] >= level && log_fd >= 0;
> + log_to_file &= (log_fd >= 0);
> ovs_mutex_unlock(&log_file_mutex);
> if (log_to_console || log_to_syslog || log_to_file) {
> int save_errno = errno;
> --
> 2.20.1
>
> _______________________________________________
> dev mailing list
> dev at openvswitch.org
> https://mail.openvswitch.org/mailman/listinfo/ovs-dev
More information about the dev
mailing list