From 1535e9dbb6d66647f3f64d307b07abd41c8973c5 Mon Sep 17 00:00:00 2001 From: Thanos Makatos Date: Wed, 4 May 2022 11:50:07 +0000 Subject: [PATCH] nvmf/vfio-user: reduce libvfio-user socket poll frequency Constantly polling the socket degrades performance significantly. Polling the socket at a much lower frequency, every 1ms, is good enough for now. fixes #2494 Signed-off-by: Thanos Makatos Co-authored-by: John Levon Change-Id: I4a7d35c45ece863b9df756324c23f41736df49f8 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/12494 Community-CI: Broadcom CI Tested-by: SPDK CI Jenkins Reviewed-by: Changpeng Liu Reviewed-by: Jim Harris --- lib/nvmf/vfio_user.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/nvmf/vfio_user.c b/lib/nvmf/vfio_user.c index cdca3e6a0..a20ec108a 100644 --- a/lib/nvmf/vfio_user.c +++ b/lib/nvmf/vfio_user.c @@ -4597,11 +4597,13 @@ handle_queue_connect_rsp(struct nvmf_vfio_user_req *req, void *cb_arg) vu_ctrlr->thread = spdk_get_thread(); vu_ctrlr->ctrlr = sq->qpair.ctrlr; vu_ctrlr->state = VFIO_USER_CTRLR_RUNNING; - vu_ctrlr->vfu_ctx_poller = SPDK_POLLER_REGISTER(vfio_user_poll_vfu_ctx, vu_ctrlr, 0); cq->thread = spdk_get_thread(); if (in_interrupt_mode(endpoint->transport)) { + vu_ctrlr->vfu_ctx_poller = SPDK_POLLER_REGISTER(vfio_user_poll_vfu_ctx, + vu_ctrlr, 0); + vu_ctrlr->intr_fd = vfu_get_poll_fd(vu_ctrlr->endpoint->vfu_ctx); assert(vu_ctrlr->intr_fd != -1); @@ -4614,6 +4616,9 @@ handle_queue_connect_rsp(struct nvmf_vfio_user_req *req, void *cb_arg) spdk_poller_register_interrupt(vu_ctrlr->vfu_ctx_poller, vfio_user_set_intr_mode, vu_ctrlr); + } else { + vu_ctrlr->vfu_ctx_poller = SPDK_POLLER_REGISTER(vfio_user_poll_vfu_ctx, + vu_ctrlr, 1000); } } else { /* For I/O queues this command was generated in response to an