From a7841227090327df4739e2f42a74b353b7b0253c Mon Sep 17 00:00:00 2001 From: Changpeng Liu Date: Thu, 5 Aug 2021 17:56:16 +0800 Subject: [PATCH] nvmf/vfio-user: use correct syslog level vsnprintf() is called in the IO processing path if we set LOG_DEBUG by default, which will impact the performance numbers. See below perf record: 13.44% reactor_0 [kernel.kallsyms] [k] do_syscall_64 7.59% reactor_0 [kernel.kallsyms] [k] syscall_return_via_sysret 7.18% reactor_0 libc-2.29.so [.] __vfprintf_internal 5.60% reactor_0 [kernel.kallsyms] [k] entry_SYSCALL_64 4.74% reactor_0 [kernel.kallsyms] [k] vmx_deliver_posted_interrupt 4.36% reactor_0 nvmf_tgt [.] post_completion Change-Id: Icc12345c341d870375a1db729412acb7b3cd0211 Signed-off-by: Changpeng Liu Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/9079 Tested-by: SPDK CI Jenkins Community-CI: Mellanox Build Bot Community-CI: Broadcom CI Reviewed-by: John Levon Reviewed-by: Aleksey Marchuk Reviewed-by: Jim Harris --- lib/nvmf/vfio_user.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/lib/nvmf/vfio_user.c b/lib/nvmf/vfio_user.c index fa84326c6..e21f408bb 100644 --- a/lib/nvmf/vfio_user.c +++ b/lib/nvmf/vfio_user.c @@ -1725,6 +1725,23 @@ vfio_user_log(vfu_ctx_t *vfu_ctx, int level, char const *msg) } } +static int +vfio_user_get_log_level(void) +{ + int level; + + if (SPDK_DEBUGLOG_FLAG_ENABLED("nvmf_vfio")) { + return LOG_DEBUG; + } + + level = spdk_log_to_syslog_level(spdk_log_get_level()); + if (level < 0) { + return LOG_ERR; + } + + return level; +} + static void init_pci_config_space(vfu_pci_config_space_t *p) { @@ -2006,7 +2023,7 @@ nvmf_vfio_user_listen(struct spdk_nvmf_transport *transport, err = -1; goto out; } - vfu_setup_log(endpoint->vfu_ctx, vfio_user_log, LOG_DEBUG); + vfu_setup_log(endpoint->vfu_ctx, vfio_user_log, vfio_user_get_log_level()); err = vfio_user_dev_info_fill(vu_transport, endpoint); if (err < 0) {