From 626ceb20fe3b85ec1ac89388d68b0437cad5e882 Mon Sep 17 00:00:00 2001 From: Darek Stojaczyk Date: Mon, 11 Mar 2019 09:12:57 +0100 Subject: [PATCH] vhost/compat: stop session at each SET_VRING_CALL msg VHOST_USER_SET_VRING_CALL invalidates the previous file descriptor that SPDK may be using on a different thread. The new descriptor is stored inside rte_vhost internals and is queryable with rte_vhost APIs, but those APIs are too expensive to be called every tick or every time we need to use that fd. Hence, we will now stop the entire vhost session before processing SET_VRING_CALL msg and restart it right after. SPDK will query the most recent call descriptor on session start. We do not necessarily have to stop the device - just letting the session know that its callfd has changed would be enough. That's an area for future optimization. Change-Id: Idccf56fccd21ad0d3c2307eefee7bf35e350fec6 Signed-off-by: Darek Stojaczyk Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/447639 Tested-by: SPDK CI Jenkins Reviewed-by: Changpeng Liu Reviewed-by: Jim Harris --- lib/vhost/rte_vhost_compat.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/vhost/rte_vhost_compat.c b/lib/vhost/rte_vhost_compat.c index 7e0adf75c..8f8122b8c 100644 --- a/lib/vhost/rte_vhost_compat.c +++ b/lib/vhost/rte_vhost_compat.c @@ -65,6 +65,16 @@ spdk_extern_vhost_pre_msg_handler(int vid, void *_msg) } switch (msg->request) { + case VHOST_USER_SET_VRING_CALL: + /* rte_vhost will close the previous callfd and won't notify + * us about any change. This will effectively make SPDK fail + * to deliver any subsequent interrupts until a session is + * restarted. We stop the session here before closing the previous + * fd (so that all interrupts must have been delivered by the + * time the descriptor is closed) and start right after (which + * will make SPDK retrieve the latest, up-to-date callfd from + * rte_vhost. + */ case VHOST_USER_SET_MEM_TABLE: /* rte_vhost will unmap previous memory that SPDK may still * have pending DMA operations on. We can't let that happen,