vhost: fix wait for valid descriptor
PATCH 1/1 vhost: fix wait for valid descriptor
For each virt queue's kickfd and callfd, there are 2 invalid
status: VIRTIO_UNINITIALIZED_EVENTFD and VIRTIO_INVALID_EVENTFD. Don't set the virt queue to ready status until got the valid descriptor.
This is safe for polling mode drivers in Guest OS, the backend vhost process will not post notification to interrupt vector for PMD mode in guest, but the interrupt vector still valid.
--- lib/librte_vhost/vhost_user.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
lib/librte_vhost/vhost_user.c +3 -1
@@ -766,7 +766,9 @@ vq_is_ready(struct vhost_virtqueue *vq) {return vq && vq->desc && vq->avail && vq->used && vq->kickfd !=VIRTIO_UNINITIALIZED_EVENTFD && - vq->callfd !=VIRTIO_UNINITIALIZED_EVENTFD ; + vq->callfd !=VIRTIO_UNINITIALIZED_EVENTFD && + vq->kickfd !=VIRTIO_INVALID_EVENTFD && + vq->callfd !=VIRTIO_INVALID_EVENTFD ; } static int
Signature · 1 line
2.14.1
Quoted 10 lines
-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Tomasz Kulasek
Sent: Saturday, February 10, 2018 1:35 AM
To: [email protected]
Cc: [email protected]; [email protected]; [email protected]; Liu, Changpeng
Subject: [dpdk-dev] [PATCH] vhost: fix wait for valid descriptor
Quoted 4 lines
For each virt queue's kickfd and callfd, there are 2 invalid
status:VIRTIO_UNINITIALIZED_EVENTFDandVIRTIO_INVALID_EVENTFD. Don't set the virt queue to ready status until got the valid descriptor.
Cannot remember why we introduce two invalid status.
If we treat "VIRTIO_INVALID_EVENTFD" as an indicator to judge if device is ready, then defining one status (invalid) is enough.
Thanks,
Jianfeng
Quoted 32 lines
This is safe for polling mode drivers in Guest OS, the backend vhost process will not post notification to interrupt vector for PMD mode in guest, but the interrupt vector still valid.
Fixes e049ca6d10e0 ("vhost-user: prepare multiple queue setup")Signed-off-by Changpeng Liu <[email protected]>Signed-off-by Tomasz Kulasek <[email protected]>--- lib/librte_vhost/vhost_user.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)lib/librte_vhost/vhost_user.c +3
-2@@ -766,7 +766,9 @@ vq_is_ready(struct vhost_virtqueue *vq) {return vq && vq->desc && vq->avail && vq->used && vq->kickfd !=VIRTIO_UNINITIALIZED_EVENTFD && - vq->callfd !=VIRTIO_UNINITIALIZED_EVENTFD ; + vq->callfd !=VIRTIO_UNINITIALIZED_EVENTFD && + vq->kickfd !=VIRTIO_INVALID_EVENTFD && + vq->callfd !=VIRTIO_INVALID_EVENTFD ; } static int --2.14.1
What is the status of this patch?
11/02/2018 05:21, Tan, Jianfeng:
Quoted 54 lines
Quoted 9 lines
-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Tomasz Kulasek
Sent: Saturday, February 10, 2018 1:35 AM
To: [email protected]
Cc: [email protected]; [email protected]; [email protected]; Liu, Changpeng
Subject: [dpdk-dev] [PATCH] vhost: fix wait for valid descriptorQuoted 4 lines
For each virt queue's kickfd and callfd, there are 2 invalid
status:VIRTIO_UNINITIALIZED_EVENTFDandVIRTIO_INVALID_EVENTFD. Don't set the virt queue to ready status until got the valid descriptor.Cannot remember why we introduce two invalid status.
If we treat "
VIRTIO_INVALID_EVENTFD" as an indicator to judge if device is ready, then defining one status (invalid) is enough.Thanks,
JianfengQuoted 32 lines
This is safe for polling mode drivers in Guest OS, the backend vhost process will not post notification to interrupt vector for PMD mode in guest, but the interrupt vector still valid.
Fixes e049ca6d10e0 ("vhost-user: prepare multiple queue setup")Signed-off-by Changpeng Liu <[email protected]>Signed-off-by Tomasz Kulasek <[email protected]>--- lib/librte_vhost/vhost_user.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)lib/librte_vhost/vhost_user.c +3
-2@@ -766,7 +766,9 @@ vq_is_ready(struct vhost_virtqueue *vq) {return vq && vq->desc && vq->avail && vq->used && vq->kickfd !=VIRTIO_UNINITIALIZED_EVENTFD && - vq->callfd !=VIRTIO_UNINITIALIZED_EVENTFD ; + vq->callfd !=VIRTIO_UNINITIALIZED_EVENTFD && + vq->kickfd !=VIRTIO_INVALID_EVENTFD && + vq->callfd !=VIRTIO_INVALID_EVENTFD ; } static int --2.14.1
Tiwei Bie
Acked-by Yuanhan LiuQuoted 31 lines · Thomas Monjalon
What is the status of this patch?
11/02/2018 05:21, Tan, Jianfeng:
Quoted 27 lines
Quoted 9 lines
-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Tomasz Kulasek
Sent: Saturday, February 10, 2018 1:35 AM
To: [email protected]
Cc: [email protected]; [email protected]; [email protected]; Liu, Changpeng
Subject: [dpdk-dev] [PATCH] vhost: fix wait for valid descriptorQuoted 4 lines
For each virt queue's kickfd and callfd, there are 2 invalid
status:VIRTIO_UNINITIALIZED_EVENTFDandVIRTIO_INVALID_EVENTFD. Don't set the virt queue to ready status until got the valid descriptor.Cannot remember why we introduce two invalid status.
If we treat "
VIRTIO_INVALID_EVENTFD" as an indicator to judge if device is ready, then defining one status (invalid) is enough.Thanks,
JianfengQuoted 6 lines
This is safe for polling mode drivers in Guest OS, the backend vhost process will not post notification to interrupt vector for PMD mode in guest, but the interrupt vector still valid.
Fixes e049ca6d10e0 ("vhost-user: prepare multiple queue setup")
This fixes line isn't right. It's the below commit [1] that introduced the code changed by this patch. The code was written in this way intentionally by that commit. With a quick glance at that commit, it seems that this patch isn't valid.
[1] https://git.dpdk.org/dpdk/commit/?id=fb871d0a4dc1c038a381c524cdb86fe83d21d842
commit fb871d0a4dc1c038a381c524cdb86fe83d21d842
Author: Tetsuya Mukawa <[email protected]> Date: Mon Mar 14 17:53:32 2016 +0900
vhost: fix default value of kickfd and callfd
Currently, default values of kickfd and callfd are -1.
If the values are -1, current code guesses kickfd and callfd haven't been initialized yet. Then vhost library will guess the virtqueue isn't ready for processing.
But callfd and kickfd will be set as -1 when "--enable-kvm" isn't specified in QEMU command line. It means we cannot treat -1 as uninitialized state.
The patch defines -1 and -2 as VIRTIO_INVALID_EVENTFD and VIRTIO_UNINITIALIZED_EVENTFD, and uses VIRTIO_UNINITIALIZED_EVENTFD for the default values of kickfd and callfd.
Quoted 28 lines
Quoted 27 lines
Quoted 26 lines
Signed-off-by Changpeng Liu <[email protected]>Signed-off-by Tomasz Kulasek <[email protected]>--- lib/librte_vhost/vhost_user.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)lib/librte_vhost/vhost_user.c +3
-2@@ -766,7 +766,9 @@ vq_is_ready(struct vhost_virtqueue *vq) {return vq && vq->desc && vq->avail && vq->used && vq->kickfd !=VIRTIO_UNINITIALIZED_EVENTFD && - vq->callfd !=VIRTIO_UNINITIALIZED_EVENTFD ; + vq->callfd !=VIRTIO_UNINITIALIZED_EVENTFD && + vq->kickfd !=VIRTIO_INVALID_EVENTFD && + vq->callfd !=VIRTIO_INVALID_EVENTFD ; } static int --2.14.1