Re: [dpdk-dev] [PATCH v1 3/4] vhost: improve device ready definition
From: Maxime Coquelin <hidden>
Date: 2020-06-22 08:56:19
On 6/22/20 10:41 AM, Matan Azrad wrote:
quoted
The issue is if you only check ready state only before and after the message affecting the ring is handled, it can be ready at both stages, while the rings have changed and state change callback should have been called.But in this version I checked twice, before message handler and after message handler, so it should catch any update.
No, this is not enough, we have to check also during some handlers, so that the ready state is invalidated because sometimes it will be ready before and after the message handler but with different values. That's what I did in my example patch:
@@ -1847,15 +1892,16 @@ vhost_user_set_vring_kick(struct virtio_net**pdev, struct VhostUserMsg *msg,
...
if (vq->kickfd >= 0)
close(vq->kickfd);
+
+ vq->kickfd = VIRTIO_UNINITIALIZED_EVENTFD;
+
+ vhost_user_update_vring_state(dev, file.index);
+
vq->kickfd = file.fd;
Without that, the ready check will return ready before and after the
kickfd changed and the driver won't be notified.
In any case, as I said, I will move the ready memory to the virtiqueue structure in order to save the check before the message handler.quoted
Please check the example patch I sent on Friday, it takes care of invalidating the ring state and call the state change callback.