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 <dariusz.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/447639
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
Darek Stojaczyk 2019-03-11 09:12:57 +01:00 committed by Jim Harris
parent 0a6ad9b02e
commit 626ceb20fe

View File

@ -65,6 +65,16 @@ spdk_extern_vhost_pre_msg_handler(int vid, void *_msg)
} }
switch (msg->request) { 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: case VHOST_USER_SET_MEM_TABLE:
/* rte_vhost will unmap previous memory that SPDK may still /* rte_vhost will unmap previous memory that SPDK may still
* have pending DMA operations on. We can't let that happen, * have pending DMA operations on. We can't let that happen,