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 <changpeng.liu@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/9079
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Mellanox Build Bot
Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com>
Reviewed-by: John Levon <levon@movementarian.org>
Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
Changpeng Liu 2021-08-05 17:56:16 +08:00 committed by Tomasz Zawadzki
parent 01936d2ed8
commit a784122709

View File

@ -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) {