vhost: add device op to offload the interrupt kick
v3 cover vhost: add device op to offload the interrupt kick
This series adds an operation callback which gets called every time the library wants to call eventfd_write(). This eventfd_write() call could result in a system call, which could potentially block the PMD thread.
The callback function can decide whether it's ok to handle the eventfd_write() now or have the newly introduced function, rte_vhost_notify_guest(), called at a later time.
This can be used by 3rd party applications, like OVS, to avoid system calls being called as part of the PMD threads.
v3:
- Changed ABI compatibility code to no longer use a boolean to avoid having to disable specific GCC warnings.
- Moved the fd check fix to a separate patch (patch 3/4).
- Fixed some coding style issues.
v2: - Used vhost_virtqueue->index to find index for operation.
- Aligned function name to VDUSE RFC patchset.
- Added error and offload statistics counter.
- Mark new API as experimental.
- Change the virtual queue spin lock to read/write spin lock.
- Made shared counters atomic.
- Add versioned rte_vhost_driver_callback_register() for ABI compliance.
Eelco Chaudron (4):
vhost: change vhost_virtqueue access lock to a read/write one
vhost: make the guest_notifications statistic counter atomic
vhost: fix invalid call FD handling
vhost: add device op to offload the interrupt kick
lib/eal/include/generic/rte_rwlock.h | 17 +++++ lib/vhost/meson.build | 2 + lib/vhost/rte_vhost.h | 23 ++++++- lib/vhost/socket.c | 63 +++++++++++++++++-- lib/vhost/version.map | 9 +++ lib/vhost/vhost.c | 92 +++++++++++++++++++++------- lib/vhost/vhost.h | 69 ++++++++++++++------- lib/vhost/vhost_user.c | 14 ++--- lib/vhost/virtio_net.c | 90 +++++++++++++-------------- 9 files changed, 278 insertions(+), 101 deletions(-)
PATCH v3 1/4 vhost: change vhost_virtqueue access lock to a read/write one
This change will allow the vhost interrupt datapath handling to be split between two processed without one of them holding an explicit lock.
--- lib/eal/include/generic/rte_rwlock.h | 17 ++++++ lib/vhost/vhost.c | 46 +++++++++-------- lib/vhost/vhost.h | 4 +- lib/vhost/vhost_user.c | 14 +++-- lib/vhost/virtio_net.c | 90 +++++++++++++++++----------------- 5 files changed, 94 insertions(+), 77 deletions(-)
lib/eal/include/generic/rte_rwlock.h +17 -0
@@ -236,6 +236,23 @@ rte_rwlock_write_unlock(rte_rwlock_t *rwl)__atomic_fetch_sub (&rwl->cnt,RTE_RWLOCK_WRITE , __ATOMIC_RELEASE); } +/** +* Test if the write lock is taken. +* +* @param rwl +* A pointer to a rwlock structure. +* @return +* 1 if the write lock is currently taken; 0 otherwise. +*/ +static inline int +rte_rwlock_write_is_locked (rte_rwlock_t *rwl) +{ +if (__atomic_load_n (&rwl->cnt, __ATOMIC_RELAXED) &RTE_RWLOCK_WRITE ) +return 1 ; + +return 0 ; +} +/** * Try to execute critical section in a hardware memory transaction, if it * fails or not available take a read lock
lib/vhost/vhost.c +23 -23
166 lines not on this page · raw message
lib/vhost/vhost.h +2 -2
@@ -277,7 +277,7 @@ struct vhost_virtqueue {bool access_ok;bool ready; -rte_spinlock_t access_lock; +rte_rwlock_t access_lock;union {
@@ -517,7 +517,7 @@ static inline void vq_assert_lock__(struct virtio_net *dev, struct vhost_virtqueue *vq, const char *func) __rte_assert_exclusive_lock(&vq->access_lock) { - if (unlikely(!rte_spinlock_is_locked(&vq->access_lock))) + if (unlikely(!rte_rwlock_write_is_locked(&vq->access_lock))) rte_panic("VHOST_CONFIG: (%s) %s() called without access lock taken.\n", dev->ifname, func); }
lib/vhost/vhost_user.c +7 -7
@@ -399,7 +399,7 @@ vhost_user_set_features(struct virtio_net **pdev,cleanup_vq_inflight (dev, vq);/* vhost_user_lock_all_queue_pairs locked all qps */ vq_assert_lock (dev, vq); -rte_spinlock_unlock (&vq->access_lock); +rte_rwlock_write_unlock (&vq->access_lock);free_vq (dev, vq); } }
@@ -2649,10 +2649,10 @@ vhost_user_iotlb_msg(struct virtio_net **pdev, len, imsg->perm);if (is_vring_iotlb (dev, vq, imsg)) { -rte_spinlock_lock (&vq->access_lock); +rte_rwlock_write_lock (&vq->access_lock);translate_ring_addresses (&dev, &vq); *pdev = dev; -rte_spinlock_unlock (&vq->access_lock); +rte_rwlock_write_unlock (&vq->access_lock); } }break ;
@@ -2667,9 +2667,9 @@ vhost_user_iotlb_msg(struct virtio_net **pdev, imsg->size);if (is_vring_iotlb (dev, vq, imsg)) { -rte_spinlock_lock (&vq->access_lock); +rte_rwlock_write_lock (&vq->access_lock);vring_invalidate (dev, vq); -rte_spinlock_unlock (&vq->access_lock); +rte_rwlock_write_unlock (&vq->access_lock); } }break ;
@@ -3030,7 +3030,7 @@ vhost_user_lock_all_queue_pairs(struct virtio_net *dev)struct vhost_virtqueue *vq = dev->virtqueue[i];if (vq) { -rte_spinlock_lock (&vq->access_lock); +rte_rwlock_write_lock (&vq->access_lock); vq_num++; } i++;
@@ -3048,7 +3048,7 @@ vhost_user_unlock_all_queue_pairs(struct virtio_net *dev)struct vhost_virtqueue *vq = dev->virtqueue[i];if (vq) { -rte_spinlock_unlock (&vq->access_lock); +rte_rwlock_write_unlock (&vq->access_lock); vq_num++; } i++;
lib/vhost/virtio_net.c +45 -45
360 lines not on this page · raw message
Re: [PATCH v3 1/4] vhost: change vhost_virtqueue access lock to a read/write one
Hi Eelco,
Quoted 3 lines · Eelco Chaudron
This change will allow the vhost interrupt datapath handling to be split between two processed without one of them holding an explicit lock.
As I had a tuned PVP benchmarking setup at hand, I ran a 0.02% loss RFC2544 test with and without this patch to ensure moving to RX locks would not introduce performance regression.
I can confirm there are no performance regression introduced with this patch applied:
And the patch looks good to me:
Thanks,
Maxime
Quoted 9 lines
Signed-off-by Eelco Chaudron <[email protected]>--- lib/eal/include/generic/rte_rwlock.h | 17 ++++++ lib/vhost/vhost.c | 46 +++++++++-------- lib/vhost/vhost.h | 4 +- lib/vhost/vhost_user.c | 14 +++-- lib/vhost/virtio_net.c | 90 +++++++++++++++++----------------- 5 files changed, 94 insertions(+), 77 deletions(-)
Re: [PATCH v3 1/4] vhost: change vhost_virtqueue access lock to a read/write one
Quoted 11 lines · Maxime Coquelin
Hi Eelco,
Quoted 3 lines · Eelco Chaudron
This change will allow the vhost interrupt datapath handling to be split between two processed without one of them holding an explicit lock.
As I had a tuned PVP benchmarking setup at hand, I ran a 0.02% loss RFC2544 test with and without this patch to ensure moving to RX locks would not introduce performance regression.
Quoted 6 lines
I can confirm there are no performance regression introduced with this patch applied:
Tested-by Maxime Coquelin <[email protected]>And the patch looks good to me:
Reviewed-by Maxime Coquelin <[email protected]>
Thanks for running the test and doing the review!
//Eelco
Quoted 9 lines
Quoted 9 lines
Signed-off-by Eelco Chaudron <[email protected]>--- lib/eal/include/generic/rte_rwlock.h | 17 ++++++ lib/vhost/vhost.c | 46 +++++++++-------- lib/vhost/vhost.h | 4 +- lib/vhost/vhost_user.c | 14 +++-- lib/vhost/virtio_net.c | 90 +++++++++++++++++----------------- 5 files changed, 94 insertions(+), 77 deletions(-)
RE: [PATCH v3 1/4] vhost: change vhost_virtqueue access lock to a read/write one
In reply to Eelco ChaudronHi Eelco,
Quoted 38 lines
-----Original Message-----
From: Eelco Chaudron <[email protected]>
Sent: Wednesday, May 17, 2023 5:09 PM
To: [email protected]; Xia, Chenbo <[email protected]>; [email protected]
Cc: [email protected]
Subject: [PATCH v3 1/4] vhost: changevhost_virtqueueaccess lock to a read/write oneThis change will allow the vhost interrupt datapath handling to be split between two processed without one of them holding an explicit lock.
Signed-off-by Eelco Chaudron <[email protected]>--- lib/eal/include/generic/rte_rwlock.h | 17 ++++++ lib/vhost/vhost.c | 46 +++++++++-------- lib/vhost/vhost.h | 4 +- lib/vhost/vhost_user.c | 14 +++-- lib/vhost/virtio_net.c | 90 +++++++++++++++++------------ ----- 5 files changed, 94 insertions(+), 77 deletions(-)lib/eal/include/generic/rte_rwlock.h +7
-0@@ -236,6 +236,23 @@ rte_rwlock_write_unlock(rte_rwlock_t *rwl)__atomic_fetch_sub (&rwl->cnt,RTE_RWLOCK_WRITE , __ATOMIC_RELEASE); } +/** +* Test if the write lock is taken. +* +* @param rwl +* A pointer to a rwlock structure. +* @return +* 1 if the write lock is currently taken; 0 otherwise.
lib/eal/include/generic/rte_rwlock.h rte_rwlock_write_unlock(rte_rwlock_t *rwl) · line 255
Quoted 10 lines
lib/eal/include/generic/rte_rwlock.h +10
-0+*/ +static inline int +rte_rwlock_write_is_locked (rte_rwlock_t *rwl) +{ +if (__atomic_load_n (&rwl->cnt, __ATOMIC_RELAXED) &RTE_RWLOCK_WRITE ) +return 1 ; + +return 0 ; +} +
Again we need to update release note as it's a new EAL API.
Quoted 35 lines
lib/eal/include/generic/rte_rwlock.h +0
-0/** * Try to execute critical section in a hardware memory transaction, if it
* fails or not available take a read locklib/vhost/vhost.c +2
-2@@ -393,9 +393,9 @@ free_vq(struct virtio_net *dev, struct vhost_virtqueue *vq) elserte_free (vq->shadow_used_split); -rte_spinlock_lock (&vq->access_lock); +rte_rwlock_write_lock (&vq->access_lock);vhost_free_async_mem (vq); -rte_spinlock_unlock (&vq->access_lock); +rte_rwlock_write_unlock (&vq->access_lock);rte_free (vq->batch_copy_elems);vhost_user_iotlb_destroy (vq);lib/vhost/vhost.c +1
-1rte_free (vq->log_cache);@@ -630,7 +630,7 @@ alloc_vring_queue(struct virtio_net *dev, uint32_t vring_idx) dev->virtqueue[i] = vq;init_vring_queue (dev, vq, i); -rte_spinlock_init (&vq->access_lock); +rte_rwlock_init (&vq->access_lock); vq->avail_wrap_counter =1 ; vq->used_wrap_counter =1 ;lib/vhost/vhost.c +0
-0vq->signalled_used_valid = false;@@ -1305,14 +1305,14 @@ rte_vhost_vring_call(int vid, uint16_t vring_idx)if (!vq)return -1 ;
lib/vhost/vhost.c rte_vhost_vring_call(int vid, uint16_t vring_idx) · line 1315
Quoted 10 lines
lib/vhost/vhost.c +2
-2-rte_spinlock_lock (&vq->access_lock); +rte_rwlock_read_lock (&vq->access_lock);if (vq_is_packed (dev))vhost_vring_call_packed (dev, vq);else vhost_vring_call_split (dev, vq); -rte_spinlock_unlock (&vq->access_lock); +rte_rwlock_read_unlock (&vq->access_lock);
Not sure about this. vhost_ring_call_packed/split is changing some field in Vq. Should we use write lock here?
Thanks,
Chenbo
Re: [PATCH v3 1/4] vhost: change vhost_virtqueue access lock to a read/write one
Quoted 96 lines · Chenbo
Hi Eelco,
Quoted 38 lines
-----Original Message-----
From: Eelco Chaudron <[email protected]>
Sent: Wednesday, May 17, 2023 5:09 PM
To: [email protected]; Xia, Chenbo <[email protected]>; [email protected]
Cc: [email protected]
Subject: [PATCH v3 1/4] vhost: changevhost_virtqueueaccess lock to a read/write oneThis change will allow the vhost interrupt datapath handling to be split between two processed without one of them holding an explicit lock.
Signed-off-by Eelco Chaudron <[email protected]>--- lib/eal/include/generic/rte_rwlock.h | 17 ++++++ lib/vhost/vhost.c | 46 +++++++++-------- lib/vhost/vhost.h | 4 +- lib/vhost/vhost_user.c | 14 +++-- lib/vhost/virtio_net.c | 90 +++++++++++++++++------------ ----- 5 files changed, 94 insertions(+), 77 deletions(-)lib/eal/include/generic/rte_rwlock.h +7
-0@@ -236,6 +236,23 @@ rte_rwlock_write_unlock(rte_rwlock_t *rwl)__atomic_fetch_sub (&rwl->cnt,RTE_RWLOCK_WRITE , __ATOMIC_RELEASE); } +/** +* Test if the write lock is taken. +* +* @param rwl +* A pointer to a rwlock structure. +* @return +* 1 if the write lock is currently taken; 0 otherwise. lib/eal/include/generic/rte_rwlock.h rte_rwlock_write_unlock(rte_rwlock_t *rwl) · line 255
Quoted 10 lines
lib/eal/include/generic/rte_rwlock.h +10
-0+*/ +static inline int +rte_rwlock_write_is_locked (rte_rwlock_t *rwl) +{ +if (__atomic_load_n (&rwl->cnt, __ATOMIC_RELAXED) &RTE_RWLOCK_WRITE ) +return 1 ; + +return 0 ; +} +Again we need to update release note as it's a new EAL API.
Quoted 43 lines
lib/eal/include/generic/rte_rwlock.h +0
-0/** * Try to execute critical section in a hardware memory transaction, if it
* fails or not available take a read locklib/vhost/vhost.c +2
-2@@ -393,9 +393,9 @@ free_vq(struct virtio_net *dev, struct vhost_virtqueue *vq) elserte_free (vq->shadow_used_split); -rte_spinlock_lock (&vq->access_lock); +rte_rwlock_write_lock (&vq->access_lock);vhost_free_async_mem (vq); -rte_spinlock_unlock (&vq->access_lock); +rte_rwlock_write_unlock (&vq->access_lock);rte_free (vq->batch_copy_elems);vhost_user_iotlb_destroy (vq);rte_free(vq->log_cache);lib/vhost/vhost.c +1
-1@@ -630,7 +630,7 @@ alloc_vring_queue(struct virtio_net *dev, uint32_t vring_idx) dev->virtqueue[i] = vq;init_vring_queue (dev, vq, i); -rte_spinlock_init (&vq->access_lock); +rte_rwlock_init (&vq->access_lock); vq->avail_wrap_counter =1 ; vq->used_wrap_counter =1 ;vq->signalled_used_valid = false;lib/vhost/vhost.c +1
-1@@ -1305,14 +1305,14 @@ rte_vhost_vring_call(int vid, uint16_t vring_idx)if (!vq)return -1 ; -rte_spinlock_lock (&vq->access_lock); +rte_rwlock_read_lock (&vq->access_lock);if (vq_is_packed (dev))vhost_vring_call_packed (dev, vq);else vhost_vring_call_split (dev, vq);
Quoted 5 lines
lib/vhost/vhost.c rte_vhost_vring_call(int vid, uint16_t vring_idx) · line 1315
Quoted 2 lines
lib/vhost/vhost.c +1
-1-rte_spinlock_unlock (&vq->access_lock); +rte_rwlock_read_unlock (&vq->access_lock);Not sure about this. vhost_ring_call_packed/split is changing some field in Vq. Should we use write lock here?
I don't think so, the purpose of the access_lock is not to make the datapath threads-safe, but to protect the datapath from metadata changes by the control path.
Thanks,
Maxime
Quoted 4 lines
Thanks,
Chenbo
Re: [PATCH v3 1/4] vhost: change vhost_virtqueue access lock to a read/write one
Quoted 103 lines · Maxime Coquelin
Quoted 96 lines · Chenbo
Hi Eelco,
Quoted 38 lines
-----Original Message-----
From: Eelco Chaudron <[email protected]>
Sent: Wednesday, May 17, 2023 5:09 PM
To: [email protected]; Xia, Chenbo <[email protected]>; [email protected]
Cc: [email protected]
Subject: [PATCH v3 1/4] vhost: changevhost_virtqueueaccess lock to a read/write oneThis change will allow the vhost interrupt datapath handling to be split between two processed without one of them holding an explicit lock.
Signed-off-by Eelco Chaudron <[email protected]>--- lib/eal/include/generic/rte_rwlock.h | 17 ++++++ lib/vhost/vhost.c | 46 +++++++++-------- lib/vhost/vhost.h | 4 +- lib/vhost/vhost_user.c | 14 +++-- lib/vhost/virtio_net.c | 90 +++++++++++++++++------------ ----- 5 files changed, 94 insertions(+), 77 deletions(-)lib/eal/include/generic/rte_rwlock.h +7
-0@@ -236,6 +236,23 @@ rte_rwlock_write_unlock(rte_rwlock_t *rwl)__atomic_fetch_sub (&rwl->cnt,RTE_RWLOCK_WRITE , __ATOMIC_RELEASE); } +/** +* Test if the write lock is taken. +* +* @param rwl +* A pointer to a rwlock structure. +* @return +* 1 if the write lock is currently taken; 0 otherwise. lib/eal/include/generic/rte_rwlock.h rte_rwlock_write_unlock(rte_rwlock_t *rwl) · line 255
Quoted 10 lines
lib/eal/include/generic/rte_rwlock.h +10
-0+*/ +static inline int +rte_rwlock_write_is_locked (rte_rwlock_t *rwl) +{ +if (__atomic_load_n (&rwl->cnt, __ATOMIC_RELAXED) &RTE_RWLOCK_WRITE ) +return 1 ; + +return 0 ; +} +Again we need to update release note as it's a new EAL API.
Quoted 43 lines
lib/eal/include/generic/rte_rwlock.h +0
-0/** * Try to execute critical section in a hardware memory transaction, if it
* fails or not available take a read locklib/vhost/vhost.c +2
-2@@ -393,9 +393,9 @@ free_vq(struct virtio_net *dev, struct vhost_virtqueue *vq) elserte_free (vq->shadow_used_split); -rte_spinlock_lock (&vq->access_lock); +rte_rwlock_write_lock (&vq->access_lock);vhost_free_async_mem (vq); -rte_spinlock_unlock (&vq->access_lock); +rte_rwlock_write_unlock (&vq->access_lock);rte_free (vq->batch_copy_elems);vhost_user_iotlb_destroy (vq);rte_free(vq->log_cache);lib/vhost/vhost.c +1
-1@@ -630,7 +630,7 @@ alloc_vring_queue(struct virtio_net *dev, uint32_t vring_idx) dev->virtqueue[i] = vq;init_vring_queue (dev, vq, i); -rte_spinlock_init (&vq->access_lock); +rte_rwlock_init (&vq->access_lock); vq->avail_wrap_counter =1 ; vq->used_wrap_counter =1 ;vq->signalled_used_valid = false;lib/vhost/vhost.c +1
-1@@ -1305,14 +1305,14 @@ rte_vhost_vring_call(int vid, uint16_t vring_idx)if (!vq)return -1 ; -rte_spinlock_lock (&vq->access_lock); +rte_rwlock_read_lock (&vq->access_lock);if (vq_is_packed (dev))vhost_vring_call_packed (dev, vq);else vhost_vring_call_split (dev, vq);Quoted 5 lines
lib/vhost/vhost.c rte_vhost_vring_call(int vid, uint16_t vring_idx) · line 1315
Quoted 2 lines
lib/vhost/vhost.c +1
-1-rte_spinlock_unlock (&vq->access_lock); +rte_rwlock_read_unlock (&vq->access_lock);Not sure about this. vhost_ring_call_packed/split is changing some field in Vq. Should we use write lock here?
Quoted 3 lines
I don't think so, the purpose of the
access_lockis not to make the datapath threads-safe, but to protect the datapath from metadata changes by the control path.
Thanks Chinbo for the review, and see Maxime’s comment above. Does this clarify your concern/question?
Quoted 4 lines
Quoted 4 lines
Thanks,
Chenbo
Xia, Chenbo
Reviewed-byRE: [PATCH v3 1/4] vhost: change vhost_virtqueue access lock to a read/write one
Quoted 121 lines
-----Original Message-----
From: Eelco Chaudron <[email protected]>
Sent: Wednesday, May 31, 2023 7:14 PM
To: Maxime Coquelin <[email protected]>
Cc: Xia, Chenbo <[email protected]>; [email protected]; [email protected]
Subject: Re: [PATCH v3 1/4] vhost: changevhost_virtqueueaccess lock to a read/write oneQuoted 12 lines · Maxime Coquelin
Quoted 11 lines · Chenbo
Hi Eelco,
Quoted 9 lines
-----Original Message-----
From: Eelco Chaudron <[email protected]>
Sent: Wednesday, May 17, 2023 5:09 PM
To: [email protected]; Xia, Chenbo <[email protected]>; [email protected]
Cc: [email protected]
Subject: [PATCH v3 1/4] vhost: changevhost_virtqueueaccess lock to a read/write oneQuoted 1 line
Quoted 1 line
Quoted 1 line
This change will allow the vhost interrupt datapath handling to be
split
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
between two processed without one of them holding an explicit lock.
Signed-off-by Eelco Chaudron <[email protected]>--- lib/eal/include/generic/rte_rwlock.h | 17 ++++++ lib/vhost/vhost.c | 46 +++++++++-------- lib/vhost/vhost.h | 4 +- lib/vhost/vhost_user.c | 14 +++-- lib/vhost/virtio_net.c | 90 +++++++++++++++++------------
Quoted 10 lines
Quoted 10 lines
lib/eal/include/generic/rte_rwlock.h rte_rwlock_write_unlock(rte_rwlock_t *rwl) · line 236
Quoted 10 lines
-----
5 files changed, 94 insertions(+), 77 deletions(-)lib/eal/include/generic/rte_rwlock.h +0
-0@@ -236,6 +236,23 @@ rte_rwlock_write_unlock(rte_rwlock_t *rwl) __atomic_fetch_sub(&rwl->cnt, RTE_RWLOCK_WRITE,
__ATOMIC_RELEASE);Quoted 22 lines
Quoted 22 lines
Quoted 9 lines
lib/eal/include/generic/rte_rwlock.h +7
-0} +/** +* Test if the write lock is taken. +* +* @param rwl +* A pointer to a rwlock structure. +* @return +* 1 if the write lock is currently taken; 0 otherwise. lib/eal/include/generic/rte_rwlock.h rte_rwlock_write_unlock(rte_rwlock_t *rwl) · line 255
Quoted 10 lines
lib/eal/include/generic/rte_rwlock.h +10
-0+*/ +static inline int +rte_rwlock_write_is_locked (rte_rwlock_t *rwl) +{ +if (__atomic_load_n (&rwl->cnt, __ATOMIC_RELAXED) &RTE_RWLOCK_WRITE ) +return 1 ; + +return 0 ; +} +Again we need to update release note as it's a new EAL API.
Quoted 2 lines
Quoted 2 lines
lib/eal/include/generic/rte_rwlock.h rte_rwlock_write_unlock(rte_rwlock_t *rwl) · line 257
Quoted 2 lines
lib/eal/include/generic/rte_rwlock.h +0
-0/** * Try to execute critical section in a hardware memory transaction, if
Quoted 7 lines
Quoted 7 lines
lib/vhost/vhost.c free_vq(struct virtio_net *dev, struct
Quoted 7 lines
it
* fails or not available take a read locklib/vhost/vhost.c +0
-0@@ -393,9 +393,9 @@ free_vq(struct virtio_net *dev, struct
vhost_virtqueueQuoted 15 lines
Quoted 15 lines
Quoted 15 lines
lib/vhost/vhost.c +2
-2*vq) elserte_free (vq->shadow_used_split); -rte_spinlock_lock (&vq->access_lock); +rte_rwlock_write_lock (&vq->access_lock);vhost_free_async_mem (vq); -rte_spinlock_unlock (&vq->access_lock); +rte_rwlock_write_unlock (&vq->access_lock);rte_free (vq->batch_copy_elems);vhost_user_iotlb_destroy (vq);rte_free(vq->log_cache);lib/vhost/vhost.c +0
-0@@ -630,7 +630,7 @@ alloc_vring_queue(struct virtio_net *dev, uint32_t vring_idx)Quoted 8 lines
Quoted 8 lines
lib/vhost/vhost.c rte_vhost_vring_call(int vid, uint16_t
Quoted 8 lines
lib/vhost/vhost.c +1
-1dev->virtqueue[i] = vq;init_vring_queue (dev, vq, i); -rte_spinlock_init (&vq->access_lock); +rte_rwlock_init (&vq->access_lock); vq->avail_wrap_counter =1 ; vq->used_wrap_counter =1 ;vq->signalled_used_valid = false;lib/vhost/vhost.c +0
-0@@ -1305,14 +1305,14 @@ rte_vhost_vring_call(int vid, uint16_t
vring_idx)Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
lib/vhost/vhost.c +1
-1if (!vq)return -1 ; -rte_spinlock_lock (&vq->access_lock); +rte_rwlock_read_lock (&vq->access_lock);if (vq_is_packed (dev))vhost_vring_call_packed (dev, vq);else vhost_vring_call_split (dev, vq);Quoted 4 lines
Quoted 4 lines
lib/vhost/vhost.c rte_vhost_vring_call(int vid, uint16_t · line 1315
Quoted 2 lines
lib/vhost/vhost.c +1
-1-rte_spinlock_unlock (&vq->access_lock); +rte_rwlock_read_unlock (&vq->access_lock);Not sure about this. vhost_ring_call_packed/split is changing some
field in
Quoted 8 lines
Quoted 5 lines
Quoted 1 line
Vq. Should we use write lock here?
I don't think so, the purpose of the
access_lockis not to make the datapath threads-safe, but to protect the datapath from metadata changes by the control path.Thanks Chinbo for the review, and see Maxime’s comment above. Does this clarify your concern/question?
Make sense to me. Thanks Eelco and Maxime!
With the release note added:
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Thanks,
Chenbo
PATCH v3 2/4 vhost: make the guest_notifications statistic counter atomic
In reply to Eelco ChaudronMaking the guest_notifications statistic counter atomic, allows it to be safely incremented while holding the read access_lock.
--- lib/vhost/vhost.c | 8 ++++++++ lib/vhost/vhost.h | 9 ++++++--- 2 files changed, 14 insertions(+), 3 deletions(-)
lib/vhost/vhost.c +8 -0
@@ -2086,6 +2086,10 @@ rte_vhost_vring_stats_get(int vid, uint16_t queue_id,rte_rwlock_write_lock (&vq->access_lock);for (i =0 ; i <VHOST_NB_VQ_STATS ; i++) { +/* +* No need to the read atomic counters as such, due to the +* above write access_lock preventing them to be updated. +*/ stats[i].value = *(uint64_t *)(((char *)vq) + vhost_vq_stat_strings[i].offset); stats[i].id = i;
@@ -2112,6 +2116,10 @@ int rte_vhost_vring_stats_reset(int vid, uint16_t queue_id) vq = dev->virtqueue[queue_id];rte_rwlock_write_lock (&vq->access_lock); +/* +* No need to the reset atomic counters as such, due to the +* above write access_lock preventing them to be updated. +*/ memset (&vq->stats,0 ,sizeof (vq->stats));rte_rwlock_write_unlock (&vq->access_lock);
lib/vhost/vhost.h +6 -3
@@ -135,11 +135,12 @@ struct virtqueue_stats {uint64_t broadcast;/* Size bins in array as RFC 2819, undersized [0], 64 [1], etc */ uint64_t size_bins[8 ]; -uint64_t guest_notifications;uint64_t iotlb_hits;uint64_t iotlb_misses;uint64_t inflight_submitted;uint64_t inflight_completed; +/* Counters below are atomic, and should be incremented as such. */ +uint64_t guest_notifications; };/**
@@ -907,7 +908,8 @@ vhost_vring_call_split(struct virtio_net *dev, struct vhost_virtqueue *vq) unlikely(!signalled_used_valid)) {eventfd_write (vq->callfd, (eventfd_t )1 );if (dev->flags &VIRTIO_DEV_STATS_ENABLED ) - vq->stats.guest_notifications++; +__atomic_fetch_add (&vq->stats.guest_notifications, +1 , __ATOMIC_RELAXED);if (dev->notify_ops->guest_notified) dev->notify_ops->guest_notified (dev->vid); }
@@ -917,7 +919,8 @@ vhost_vring_call_split(struct virtio_net *dev, struct vhost_virtqueue *vq) && (vq->callfd >= 0)) {eventfd_write (vq->callfd, (eventfd_t )1 );if (dev->flags &VIRTIO_DEV_STATS_ENABLED ) - vq->stats.guest_notifications++; +__atomic_fetch_add (&vq->stats.guest_notifications, +1 , __ATOMIC_RELAXED);if (dev->notify_ops->guest_notified) dev->notify_ops->guest_notified (dev->vid); }
Re: [PATCH v3 2/4] vhost: make the guest_notifications statistic counter atomic
Quoted 9 lines · Eelco Chaudron
Making the
guest_notificationsstatistic counter atomic, allows it to be safely incremented while holding the readaccess_lock.Signed-off-by Eelco Chaudron <[email protected]>--- lib/vhost/vhost.c | 8 ++++++++ lib/vhost/vhost.h | 9 ++++++--- 2 files changed, 14 insertions(+), 3 deletions(-)
Thanks,
Maxime
RE: [PATCH v3 2/4] vhost: make the guest_notifications statistic counter atomic
In reply to Eelco ChaudronQuoted 86 lines
-----Original Message-----
From: Eelco Chaudron <[email protected]>
Sent: Wednesday, May 17, 2023 5:09 PM
To: [email protected]; Xia, Chenbo <[email protected]>; [email protected]
Cc: [email protected]
Subject: [PATCH v3 2/4] vhost: make theguest_notificationsstatistic counter atomicMaking the
guest_notificationsstatistic counter atomic, allows it to be safely incremented while holding the readaccess_lock.Signed-off-by Eelco Chaudron <[email protected]>--- lib/vhost/vhost.c | 8 ++++++++ lib/vhost/vhost.h | 9 ++++++--- 2 files changed, 14 insertions(+), 3 deletions(-)lib/vhost/vhost.c +4
-0@@ -2086,6 +2086,10 @@ rte_vhost_vring_stats_get(int vid, uint16_t queue_id,rte_rwlock_write_lock (&vq->access_lock);for (i =0 ; i <VHOST_NB_VQ_STATS ; i++) { +/* +* No need to the read atomic counters as such, due to the +* above write access_lock preventing them to be updated. +*/ stats[i].value = *(uint64_t *)(((char *)vq) +vhost_vq_stat_strings[i].offset);
lib/vhost/vhost.c +4
-0stats[i].id = i;@@ -2112,6 +2116,10 @@ int rte_vhost_vring_stats_reset(int vid, uint16_t queue_id) vq = dev->virtqueue[queue_id];rte_rwlock_write_lock (&vq->access_lock); +/* +* No need to the reset atomic counters as such, due to the +* above write access_lock preventing them to be updated. +*/ memset (&vq->stats,0 ,sizeof (vq->stats));rte_rwlock_write_unlock (&vq->access_lock);lib/vhost/vhost.h +4
-2@@ -135,11 +135,12 @@ struct virtqueue_stats {uint64_t broadcast;/* Size bins in array as RFC 2819, undersized [0], 64 [1], etc */ uint64_t size_bins[8 ]; -uint64_t guest_notifications;uint64_t iotlb_hits;uint64_t iotlb_misses;uint64_t inflight_submitted;uint64_t inflight_completed; +/* Counters below are atomic, and should be incremented as such. */ +uint64_t guest_notifications; };/** @@ -907,7 +908,8 @@ vhost_vring_call_split(struct virtio_net *dev, struct vhost_virtqueue *vq) unlikely(!signalled_used_valid)) {eventfd_write (vq->callfd, (eventfd_t )1 );if (dev->flags &VIRTIO_DEV_STATS_ENABLED ) - vq->stats.guest_notifications++; +__atomic_fetch_add (&vq->stats.guest_notifications, +1 , __ATOMIC_RELAXED);if (dev->notify_ops->guest_notified) dev->notify_ops->guest_notified (dev->vid);lib/vhost/vhost.h +2
-1}@@ -917,7 +919,8 @@ vhost_vring_call_split(struct virtio_net *dev, struct vhost_virtqueue *vq) && (vq->callfd >= 0)) {eventfd_write (vq->callfd, (eventfd_t )1 );if (dev->flags &VIRTIO_DEV_STATS_ENABLED ) - vq->stats.guest_notifications++; +__atomic_fetch_add (&vq->stats.guest_notifications, +1 , __ATOMIC_RELAXED);if (dev->notify_ops->guest_notified) dev->notify_ops->guest_notified (dev->vid);
Quoted 1 line
}
PATCH v3 3/4 vhost: fix invalid call FD handling
In reply to Eelco ChaudronThis patch fixes cases where IRQ injection is tried while the call FD is not valid, which should not happen.
--- lib/vhost/vhost.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
lib/vhost/vhost.h +4 -4
@@ -903,9 +903,9 @@ vhost_vring_call_split(struct virtio_net *dev, struct vhost_virtqueue *vq)"%s: used_event_idx=%d, old=%d, new=%d\n" , __func__, vhost_used_event(vq), old, new); -if ((vhost_need_event (vhost_used_event (vq), new, old) && - (vq->callfd >=0 )) || -unlikely (!signalled_used_valid)) { +if ((vhost_need_event (vhost_used_event (vq), new, old) || +unlikely (!signalled_used_valid)) && + vq->callfd >=0 ) {eventfd_write (vq->callfd, (eventfd_t )1 );if (dev->flags &VIRTIO_DEV_STATS_ENABLED ) __atomic_fetch_add(&vq->stats.guest_notifications,
@@ -974,7 +974,7 @@ vhost_vring_call_packed(struct virtio_net *dev, struct vhost_virtqueue *vq)if (vhost_need_event (off, new, old)) kick = true; kick: -if (kick) { +if (kick && vq->callfd >=0 ) {eventfd_write (vq->callfd, (eventfd_t )1 );if (dev->notify_ops->guest_notified) dev->notify_ops->guest_notified (dev->vid);
Re: [PATCH v3 3/4] vhost: fix invalid call FD handling
Quoted 31 lines · Eelco Chaudron
This patch fixes cases where IRQ injection is tried while the call FD is not valid, which should not happen.
Fixes b1cce26af1dc ("vhost: add notification for packed ring")Fixes e37ff954405a ("vhost: support virtqueue interrupt/notification suppression")Signed-off-by Maxime Coquelin <[email protected]>Signed-off-by Eelco Chaudron <[email protected]>--- lib/vhost/vhost.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)lib/vhost/vhost.h +3
-3@@ -903,9 +903,9 @@ vhost_vring_call_split(struct virtio_net *dev, struct vhost_virtqueue *vq)"%s: used_event_idx=%d, old=%d, new=%d\n" , __func__, vhost_used_event(vq), old, new); -if ((vhost_need_event (vhost_used_event (vq), new, old) && - (vq->callfd >=0 )) || -unlikely (!signalled_used_valid)) { +if ((vhost_need_event (vhost_used_event (vq), new, old) || +unlikely (!signalled_used_valid)) && + vq->callfd >=0 ) {eventfd_write (vq->callfd, (eventfd_t )1 );if (dev->flags &VIRTIO_DEV_STATS_ENABLED ) __atomic_fetch_add(&vq->stats.guest_notifications,
lib/vhost/vhost.h vhost_vring_call_packed(struct virtio_net *dev, struct vhost_virtqueue *vq) · line 980
Quoted 8 lines
lib/vhost/vhost.h +1
-1@@ -974,7 +974,7 @@ vhost_vring_call_packed(struct virtio_net *dev, struct vhost_virtqueue *vq)if (vhost_need_event (off, new, old)) kick = true; kick: -if (kick) { +if (kick && vq->callfd >=0 ) {eventfd_write (vq->callfd, (eventfd_t )1 );if (dev->notify_ops->guest_notified) dev->notify_ops->guest_notified (dev->vid);
Reporting Chenbo's R-by, from the VDUSE series RFC:
RE: [PATCH v3 3/4] vhost: fix invalid call FD handling
Quoted 56 lines
-----Original Message-----
From: Maxime Coquelin <[email protected]>
Sent: Tuesday, May 30, 2023 8:54 PM
To: Eelco Chaudron <[email protected]>; Xia, Chenbo <[email protected]>; [email protected]
Cc: [email protected]
Subject: Re: [PATCH v3 3/4] vhost: fix invalid call FD handlingQuoted 5 lines · Eelco Chaudron
This patch fixes cases where IRQ injection is tried while the call FD is not valid, which should not happen.
Fixes b1cce26af1dc ("vhost: add notification for packed ring")Fixes e37ff954405a ("vhost: support virtqueue interrupt/notificationsuppression")
lib/vhost/vhost.h vhost_vring_call_split(struct virtio_net *dev,
Quoted 12 lines
Signed-off-by Maxime Coquelin <[email protected]>Signed-off-by Eelco Chaudron <[email protected]>--- lib/vhost/vhost.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)lib/vhost/vhost.h +0
-0@@ -903,9 +903,9 @@ vhost_vring_call_split(struct virtio_net *dev,struct
vhost_virtqueue*vq)lib/vhost/vhost.h vhost_vring_call_packed(struct virtio_net *dev,
Quoted 13 lines
lib/vhost/vhost.h +3
-3"%s: used_event_idx=%d, old=%d, new=%d\n" , __func__, vhost_used_event(vq), old, new); -if ((vhost_need_event (vhost_used_event (vq), new, old) && - (vq->callfd >=0 )) || -unlikely (!signalled_used_valid)) { +if ((vhost_need_event (vhost_used_event (vq), new, old) || +unlikely (!signalled_used_valid)) && + vq->callfd >=0 ) {eventfd_write (vq->callfd, (eventfd_t )1 );if (dev->flags &VIRTIO_DEV_STATS_ENABLED ) __atomic_fetch_add(&vq->stats.guest_notifications,@@ -974,7 +974,7 @@ vhost_vring_call_packed(struct virtio_net *dev,struct
vhost_virtqueue*vq)lib/vhost/vhost.h vhost_vring_call_packed(struct virtio_net *dev, struct vhost_virtqueue *vq) · line 980
Quoted 9 lines
lib/vhost/vhost.h +1
-1if (vhost_need_event (off, new, old)) kick = true; kick: -if (kick) { +if (kick && vq->callfd >=0 ) {eventfd_write (vq->callfd, (eventfd_t )1 );if (dev->notify_ops->guest_notified) dev->notify_ops->guest_notified (dev->vid);Reporting Chenbo's R-by, from the VDUSE series RFC:
Quoted 1 line
Reviewed-by Chenbo Xia <[email protected]>
Thanks Maxime! Btw: what's your plan of the same fix in VDUSE series, do you plan to drop it in VDUSE series or?
Thanks,
Chenbo
Re: [PATCH v3 3/4] vhost: fix invalid call FD handling
Quoted 56 lines · Chenbo
Quoted 56 lines
-----Original Message-----
From: Maxime Coquelin <[email protected]>
Sent: Tuesday, May 30, 2023 8:54 PM
To: Eelco Chaudron <[email protected]>; Xia, Chenbo <[email protected]>; [email protected]
Cc: [email protected]
Subject: Re: [PATCH v3 3/4] vhost: fix invalid call FD handlingQuoted 5 lines · Eelco Chaudron
This patch fixes cases where IRQ injection is tried while the call FD is not valid, which should not happen.
Fixes b1cce26af1dc ("vhost: add notification for packed ring")Fixes e37ff954405a ("vhost: support virtqueue interrupt/notificationsuppression")
lib/vhost/vhost.h vhost_vring_call_split(struct virtio_net *dev,
Quoted 12 lines
Signed-off-by Maxime Coquelin <[email protected]>Signed-off-by Eelco Chaudron <[email protected]>--- lib/vhost/vhost.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)lib/vhost/vhost.h +0
-0@@ -903,9 +903,9 @@ vhost_vring_call_split(struct virtio_net *dev,struct
vhost_virtqueue*vq)lib/vhost/vhost.h vhost_vring_call_packed(struct virtio_net *dev,
Quoted 13 lines
lib/vhost/vhost.h +3
-3"%s: used_event_idx=%d, old=%d, new=%d\n" , __func__, vhost_used_event(vq), old, new); -if ((vhost_need_event (vhost_used_event (vq), new, old) && - (vq->callfd >=0 )) || -unlikely (!signalled_used_valid)) { +if ((vhost_need_event (vhost_used_event (vq), new, old) || +unlikely (!signalled_used_valid)) && + vq->callfd >=0 ) {eventfd_write (vq->callfd, (eventfd_t )1 );if (dev->flags &VIRTIO_DEV_STATS_ENABLED ) __atomic_fetch_add(&vq->stats.guest_notifications,@@ -974,7 +974,7 @@ vhost_vring_call_packed(struct virtio_net *dev,struct
vhost_virtqueue*vq)lib/vhost/vhost.h vhost_vring_call_packed(struct virtio_net *dev, struct vhost_virtqueue *vq) · line 980
Quoted 9 lines
lib/vhost/vhost.h +1
-1if (vhost_need_event (off, new, old)) kick = true; kick: -if (kick) { +if (kick && vq->callfd >=0 ) {eventfd_write (vq->callfd, (eventfd_t )1 );if (dev->notify_ops->guest_notified) dev->notify_ops->guest_notified (dev->vid);Reporting Chenbo's R-by, from the VDUSE series RFC:
Quoted 4 lines
Quoted 1 line
Reviewed-by Chenbo Xia <[email protected]>Thanks Maxime! Btw: what's your plan of the same fix in VDUSE series, do you plan to drop it in VDUSE series or?
Yes, I'm rebasing my VDUSE series on top of Eelco's.
I just need the release note update for the new API, and I'll push Eelco series to next-virtio.
Maxime
Quoted 3 lines
Thanks,
Chenbo
PATCH v3 4/4 vhost: add device op to offload the interrupt kick
In reply to Eelco ChaudronThis patch adds an operation callback which gets called every time the library wants to call eventfd_write(). This eventfd_write() call could result in a system call, which could potentially block the PMD thread.
The callback function can decide whether it's ok to handle the eventfd_write() now or have the newly introduced function, rte_vhost_notify_guest(), called at a later time.
This can be used by 3rd party applications, like OVS, to avoid system calls being called as part of the PMD threads.
--- lib/vhost/meson.build | 2 ++ lib/vhost/rte_vhost.h | 23 +++++++++++++++++- lib/vhost/socket.c | 63 ++++++++++++++++++++++++++++++++++++++++++++++--- lib/vhost/version.map | 9 +++++++ lib/vhost/vhost.c | 38 ++++++++++++++++++++++++++++++ lib/vhost/vhost.h | 58 ++++++++++++++++++++++++++++++++------------- 6 files changed, 171 insertions(+), 22 deletions(-)
lib/vhost/meson.build +2 -0
@@ -38,3 +38,5 @@ driver_sdk_headers = files( 'vdpa_driver.h', ) deps += ['ethdev', 'cryptodev', 'hash', 'pci', 'dmadev'] + +use_function_versioning = true
lib/vhost/rte_vhost.h +22 -1
@@ -298,7 +298,13 @@ struct rte_vhost_device_ops {*/ void (*guest_notified)(int vid); -void *reserved[1 ];/**< Reserved for future extension */ +/** +* If this callback is registered, notification to the guest can +* be handled by the front-end calling rte_vhost_notify_guest(). +* If it's not handled, 'false' should be returned. This can be used +* to remove the "slow" eventfd_write() syscall from the datapath. +*/ +bool (*guest_notify)(int vid,uint16_t queue_id); };/**
@@ -433,6 +439,21 @@ void rte_vhost_log_used_vring(int vid, uint16_t vring_idx,int rte_vhost_enable_guest_notification (int vid,uint16_t queue_id,int enable); +/** +* @warning +* @b EXPERIMENTAL: this API may change, or be removed, without prior notice. +* +* Inject the offloaded interrupt into the vhost device's queue. For more +* details see the 'guest_notify' vhost device operation. +* +* @param vid +* vhost device ID +* @param queue_id +* virtio queue index +*/ +__rte_experimental +void rte_vhost_notify_guest(int vid, uint16_t queue_id); +/** * Register vhost driver. path could be different for multiple * instance support.
lib/vhost/socket.c +59 -4
98 lines not on this page · raw message
lib/vhost/version.map +9 -0
@@ -64,6 +64,12 @@ DPDK_23 { local: *; }; +DPDK_24 { + global: + + rte_vhost_driver_callback_register; +} DPDK_23; + EXPERIMENTAL { global:
@@ -98,6 +104,9 @@ EXPERIMENTAL { # added in 22.11 rte_vhost_async_dma_unconfigure; rte_vhost_vring_call_nonblock; + + # added in 23.07 + rte_vhost_notify_guest; }; INTERNAL {
lib/vhost/vhost.c +38 -0
@@ -44,6 +44,10 @@ static const struct vhost_vq_stats_name_off vhost_vq_stat_strings[] = { {"size_1024_1518_packets", offsetof(struct vhost_virtqueue, stats.size_bins[6])}, {"size_1519_max_packets", offsetof(struct vhost_virtqueue, stats.size_bins[7])}, {"guest_notifications", offsetof(struct vhost_virtqueue, stats.guest_notifications)}, + {"guest_notifications_offloaded", offsetof(struct vhost_virtqueue, + stats.guest_notifications_offloaded)}, + {"guest_notifications_error", offsetof(struct vhost_virtqueue, + stats.guest_notifications_error)}, {"iotlb_hits", offsetof(struct vhost_virtqueue, stats.iotlb_hits)}, {"iotlb_misses", offsetof(struct vhost_virtqueue, stats.iotlb_misses)}, {"inflight_submitted", offsetof(struct vhost_virtqueue, stats.inflight_submitted)},
@@ -1467,6 +1471,40 @@ rte_vhost_enable_guest_notification(int vid, uint16_t queue_id, int enable)return ret; } +void +rte_vhost_notify_guest (int vid,uint16_t queue_id) +{ +struct virtio_net *dev =get_device (vid); +struct vhost_virtqueue *vq; + +if (!dev || queue_id >=VHOST_MAX_VRING ) +return ; + + vq = dev->virtqueue[queue_id]; +if (!vq) +return ; + +rte_rwlock_read_lock (&vq->access_lock); + +if (vq->callfd >=0 ) { +int ret =eventfd_write (vq->callfd, (eventfd_t )1 ); + +if (ret) { +if (dev->flags &VIRTIO_DEV_STATS_ENABLED ) +__atomic_fetch_add (&vq->stats.guest_notifications_error, +1 , __ATOMIC_RELAXED); + }else { +if (dev->flags &VIRTIO_DEV_STATS_ENABLED ) +__atomic_fetch_add (&vq->stats.guest_notifications, +1 , __ATOMIC_RELAXED); +if (dev->notify_ops->guest_notified) + dev->notify_ops->guest_notified (dev->vid); + } + } + +rte_rwlock_read_unlock (&vq->access_lock); +} +void rte_vhost_log_write (int vid,uint64_t addr,uint64_t len) {
lib/vhost/vhost.h +41 -17
91 lines not on this page · raw message
Quoted 12 lines · Eelco Chaudron
This patch adds an operation callback which gets called every time the library wants to call
eventfd_write(). Thiseventfd_write()call could result in a system call, which could potentially block the PMD thread.The callback function can decide whether it's ok to handle the
eventfd_write()now or have the newly introduced function,rte_vhost_notify_guest(), called at a later time.This can be used by 3rd party applications, like OVS, to avoid system calls being called as part of the PMD threads.
Signed-off-by Eelco Chaudron <[email protected]>
Quoted 9 lines
--- lib/vhost/meson.build | 2 ++ lib/vhost/rte_vhost.h | 23 +++++++++++++++++- lib/vhost/socket.c | 63 ++++++++++++++++++++++++++++++++++++++++++++++--- lib/vhost/version.map | 9 +++++++ lib/vhost/vhost.c | 38 ++++++++++++++++++++++++++++++ lib/vhost/vhost.h | 58 ++++++++++++++++++++++++++++++++------------- 6 files changed, 171 insertions(+), 22 deletions(-)
The patch looks good to me, but that's the first time we use function versioning in Vhost library, so I'd like another pair of eyes to be sure I don't miss anything.
Thomas, do we need to mention it somewhere in the release note?
Thanks,
Maxime
30/05/2023 15:02, Maxime Coquelin:
Quoted 25 lines · Eelco Chaudron
Quoted 12 lines
This patch adds an operation callback which gets called every time the library wants to call
eventfd_write(). Thiseventfd_write()call could result in a system call, which could potentially block the PMD thread.The callback function can decide whether it's ok to handle the
eventfd_write()now or have the newly introduced function,rte_vhost_notify_guest(), called at a later time.This can be used by 3rd party applications, like OVS, to avoid system calls being called as part of the PMD threads.
Signed-off-by Eelco Chaudron <[email protected]>Quoted 9 lines
--- lib/vhost/meson.build | 2 ++ lib/vhost/rte_vhost.h | 23 +++++++++++++++++- lib/vhost/socket.c | 63 ++++++++++++++++++++++++++++++++++++++++++++++--- lib/vhost/version.map | 9 +++++++ lib/vhost/vhost.c | 38 ++++++++++++++++++++++++++++++ lib/vhost/vhost.h | 58 ++++++++++++++++++++++++++++++++------------- 6 files changed, 171 insertions(+), 22 deletions(-)
Quoted 7 lines
The patch looks good to me, but that's the first time we use function versioning in Vhost library, so I'd like another pair of eyes to be sure I don't miss anything.
Reviewed-by Maxime Coquelin <[email protected]>Thomas, do we need to mention it somewhere in the release note?
If compatibility is kept, I think we don't need to mention it.
Quoted 30 lines · Thomas Monjalon
30/05/2023 15:02, Maxime Coquelin:
Quoted 29 lines · Eelco Chaudron
Quoted 12 lines
This patch adds an operation callback which gets called every time the library wants to call
eventfd_write(). Thiseventfd_write()call could result in a system call, which could potentially block the PMD thread.The callback function can decide whether it's ok to handle the
eventfd_write()now or have the newly introduced function,rte_vhost_notify_guest(), called at a later time.This can be used by 3rd party applications, like OVS, to avoid system calls being called as part of the PMD threads.
Signed-off-by Eelco Chaudron <[email protected]>Quoted 9 lines
--- lib/vhost/meson.build | 2 ++ lib/vhost/rte_vhost.h | 23 +++++++++++++++++- lib/vhost/socket.c | 63 ++++++++++++++++++++++++++++++++++++++++++++++--- lib/vhost/version.map | 9 +++++++ lib/vhost/vhost.c | 38 ++++++++++++++++++++++++++++++ lib/vhost/vhost.h | 58 ++++++++++++++++++++++++++++++++------------- 6 files changed, 171 insertions(+), 22 deletions(-)The patch looks good to me, but that's the first time we use function versioning in Vhost library, so I'd like another pair of eyes to be sure I don't miss anything.
Quoted 7 lines
Quoted 3 lines
Reviewed-by Maxime Coquelin <[email protected]>Thomas, do we need to mention it somewhere in the release note?
If compatibility is kept, I think we don't need to mention it.
Thanks Thomas for the information.
Maxime
Quoted 50 lines
-----Original Message-----
From: Maxime Coquelin <[email protected]>
Sent: Tuesday, May 30, 2023 11:17 PM
To: Thomas Monjalon <[email protected]>; Eelco Chaudron <[email protected]>; Xia, Chenbo <[email protected]>; [email protected]
Cc: [email protected]
Subject: Re: [PATCH v3 4/4] vhost: add device op to offload the interrupt kickQuoted 19 lines · Thomas Monjalon
30/05/2023 15:02, Maxime Coquelin:
Quoted 18 lines · Eelco Chaudron
Quoted 16 lines
This patch adds an operation callback which gets called every time the library wants to call
eventfd_write(). Thiseventfd_write()call could result in a system call, which could potentially block the PMD thread.The callback function can decide whether it's ok to handle the
eventfd_write()now or have the newly introduced function,rte_vhost_notify_guest(), called at a later time.This can be used by 3rd party applications, like OVS, to avoid system calls being called as part of the PMD threads.
Signed-off-by Eelco Chaudron <[email protected]>--- lib/vhost/meson.build | 2 ++ lib/vhost/rte_vhost.h | 23 +++++++++++++++++- lib/vhost/socket.c | 63++++++++++++++++++++++++++++++++++++++++++++++---
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
lib/vhost/version.map | 9 +++++++ lib/vhost/vhost.c | 38 ++++++++++++++++++++++++++++++ lib/vhost/vhost.h | 58 ++++++++++++++++++++++++++++++++-------------
Quoted 6 lines
Quoted 6 lines
Quoted 2 lines
6 files changed, 171 insertions(+), 22 deletions(-)The patch looks good to me, but that's the first time we use function versioning in Vhost library, so I'd like another pair of eyes to be
sure
Quoted 6 lines
Quoted 5 lines
I don't miss anything.
Reviewed-by Maxime Coquelin <[email protected]>Thomas, do we need to mention it somewhere in the release note?
Quoted 7 lines
Quoted 3 lines
If compatibility is kept, I think we don't need to mention it.
Thanks Thomas for the information.
Maxime
About release note, except the versioning, there is also one new API introduced in this patch, so we still need to mention this in release note
Thanks,
Chenbo
Quoted 54 lines · Chenbo
Quoted 54 lines
-----Original Message-----
From: Maxime Coquelin <[email protected]>
Sent: Tuesday, May 30, 2023 11:17 PM
To: Thomas Monjalon <[email protected]>; Eelco Chaudron <[email protected]>; Xia, Chenbo <[email protected]>; [email protected]
Cc: [email protected]
Subject: Re: [PATCH v3 4/4] vhost: add device op to offload the interrupt kickQuoted 19 lines · Thomas Monjalon
30/05/2023 15:02, Maxime Coquelin:
Quoted 18 lines · Eelco Chaudron
Quoted 16 lines
This patch adds an operation callback which gets called every time the library wants to call
eventfd_write(). Thiseventfd_write()call could result in a system call, which could potentially block the PMD thread.The callback function can decide whether it's ok to handle the
eventfd_write()now or have the newly introduced function,rte_vhost_notify_guest(), called at a later time.This can be used by 3rd party applications, like OVS, to avoid system calls being called as part of the PMD threads.
Signed-off-by Eelco Chaudron <[email protected]>--- lib/vhost/meson.build | 2 ++ lib/vhost/rte_vhost.h | 23 +++++++++++++++++- lib/vhost/socket.c | 63++++++++++++++++++++++++++++++++++++++++++++++---
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
lib/vhost/version.map | 9 +++++++ lib/vhost/vhost.c | 38 ++++++++++++++++++++++++++++++ lib/vhost/vhost.h | 58 ++++++++++++++++++++++++++++++++-------------
Quoted 6 lines
Quoted 6 lines
Quoted 2 lines
6 files changed, 171 insertions(+), 22 deletions(-)The patch looks good to me, but that's the first time we use function versioning in Vhost library, so I'd like another pair of eyes to be
sure
Quoted 9 lines
Quoted 5 lines
I don't miss anything.
Reviewed-by Maxime Coquelin <[email protected]>Thomas, do we need to mention it somewhere in the release note?
If compatibility is kept, I think we don't need to mention it.
Quoted 6 lines
Quoted 3 lines
Thanks Thomas for the information.
Maxime
About release note, except the versioning, there is also one new API introduced in this patch, so we still need to mention this in release note
Right, good catch.
Eelco, let me know what you would put, I'll add it while applying (No need for a new revision).
Thanks,
Maxime
Quoted 2 lines
Thanks,
Chenbo
Quoted 57 lines · Maxime Coquelin
Quoted 56 lines · Chenbo
Quoted 56 lines
-----Original Message-----
From: Maxime Coquelin <[email protected]>
Sent: Tuesday, May 30, 2023 11:17 PM
To: Thomas Monjalon <[email protected]>; Eelco Chaudron <[email protected]>; Xia, Chenbo <[email protected]>; [email protected]
Cc: [email protected]
Subject: Re: [PATCH v3 4/4] vhost: add device op to offload the interrupt kickQuoted 19 lines · Thomas Monjalon
30/05/2023 15:02, Maxime Coquelin:
Quoted 18 lines · Eelco Chaudron
Quoted 16 lines
This patch adds an operation callback which gets called every time the library wants to call
eventfd_write(). Thiseventfd_write()call could result in a system call, which could potentially block the PMD thread.The callback function can decide whether it's ok to handle the
eventfd_write()now or have the newly introduced function,rte_vhost_notify_guest(), called at a later time.This can be used by 3rd party applications, like OVS, to avoid system calls being called as part of the PMD threads.
Signed-off-by Eelco Chaudron <[email protected]>--- lib/vhost/meson.build | 2 ++ lib/vhost/rte_vhost.h | 23 +++++++++++++++++- lib/vhost/socket.c | 63++++++++++++++++++++++++++++++++++++++++++++++---
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
lib/vhost/version.map | 9 +++++++ lib/vhost/vhost.c | 38 ++++++++++++++++++++++++++++++ lib/vhost/vhost.h | 58 ++++++++++++++++++++++++++++++++-------------
Quoted 6 lines
Quoted 6 lines
Quoted 2 lines
6 files changed, 171 insertions(+), 22 deletions(-)The patch looks good to me, but that's the first time we use function versioning in Vhost library, so I'd like another pair of eyes to be
sure
Quoted 9 lines
Quoted 5 lines
I don't miss anything.
Reviewed-by Maxime Coquelin <[email protected]>Thomas, do we need to mention it somewhere in the release note?
If compatibility is kept, I think we don't need to mention it.
Thanks Thomas for the information.
Quoted 8 lines
Quoted 4 lines
Quoted 1 line
Maxime
About release note, except the versioning, there is also one new API introduced in this patch, so we still need to mention this in release note
Right, good catch.
Eelco, let me know what you would put, I'll add it while applying (No need for a new revision).
Thanks guys! What about the following release note addition:
* **Added callback API support for interrupt handling in the vhost library.**
A new callback, guest_notify, is introduced that can be used to handle the interrupt kick outside of the datapath fast path. In addition, a new API, rte_vhost_notify_guest(), is added to raise the interrupt outside of the past path.
Please change if you see fit.
Thanks,
Eelco
Quoted 5 lines
Thanks,
MaximeQuoted 2 lines
Thanks,
Chenbo
Quoted 77 lines
-----Original Message-----
From: Maxime Coquelin <[email protected]>
Sent: Wednesday, May 31, 2023 5:29 PM
To: Xia, Chenbo <[email protected]>; Thomas Monjalon <[email protected]>; Eelco Chaudron <[email protected]>; [email protected]
Cc: [email protected]
Subject: Re: [PATCH v3 4/4] vhost: add device op to offload the interrupt kickQuoted 8 lines · Chenbo
Quoted 8 lines
-----Original Message-----
From: Maxime Coquelin <[email protected]>
Sent: Tuesday, May 30, 2023 11:17 PM
To: Thomas Monjalon <[email protected]>; Eelco Chaudron <[email protected]>; Xia, Chenbo <[email protected]>; [email protected]
Cc: [email protected]
Subject: Re: [PATCH v3 4/4] vhost: add device op to offload theinterrupt
Quoted 9 lines
Quoted 9 lines
kick
Quoted 4 lines · Thomas Monjalon
30/05/2023 15:02, Maxime Coquelin:
Quoted 3 lines · Eelco Chaudron
Quoted 1 line
This patch adds an operation callback which gets called every time
the
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
library wants to call
eventfd_write(). Thiseventfd_write()callcould
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
result in a system call, which could potentially block the PMD
thread.
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
The callback function can decide whether it's ok to handle the
eventfd_write()now or have the newly introduced function,rte_vhost_notify_guest(), called at a later time.This can be used by 3rd party applications, like OVS, to avoid
system
Quoted 11 lines
Quoted 11 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
calls being called as part of the PMD threads.
Signed-off-by Eelco Chaudron <[email protected]>--- lib/vhost/meson.build | 2 ++ lib/vhost/rte_vhost.h | 23 +++++++++++++++++- lib/vhost/socket.c | 63++++++++++++++++++++++++++++++++++++++++++++++---
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
lib/vhost/version.map | 9 +++++++ lib/vhost/vhost.c | 38 ++++++++++++++++++++++++++++++ lib/vhost/vhost.h | 58 ++++++++++++++++++++++++++++++++------
Quoted 22 lines
Quoted 21 lines
-------
Quoted 6 lines
Quoted 6 lines
Quoted 2 lines
6 files changed, 171 insertions(+), 22 deletions(-)The patch looks good to me, but that's the first time we use function versioning in Vhost library, so I'd like another pair of eyes to be
sure
Quoted 9 lines
Quoted 5 lines
I don't miss anything.
Reviewed-by Maxime Coquelin <[email protected]>Thomas, do we need to mention it somewhere in the release note?
If compatibility is kept, I think we don't need to mention it.
Thanks Thomas for the information.
Maxime
Quoted 7 lines
Quoted 1 line
About release note, except the versioning, there is also one new API
introduced
Quoted 1 line
in this patch, so we still need to mention this in release note
Right, good catch.
Eelco, let me know what you would put, I'll add it while applying (No need for a new revision).
Btw, the vhost_lib.rst also needs a new item..
Thanks,
Chenbo
Quoted 6 lines
Thanks,
MaximeQuoted 2 lines
Thanks,
Chenbo
Quoted 78 lines · Chenbo
Quoted 78 lines
-----Original Message-----
From: Maxime Coquelin <[email protected]>
Sent: Wednesday, May 31, 2023 5:29 PM
To: Xia, Chenbo <[email protected]>; Thomas Monjalon <[email protected]>; Eelco Chaudron <[email protected]>; [email protected]
Cc: [email protected]
Subject: Re: [PATCH v3 4/4] vhost: add device op to offload the interrupt kickQuoted 8 lines · Chenbo
Quoted 8 lines
-----Original Message-----
From: Maxime Coquelin <[email protected]>
Sent: Tuesday, May 30, 2023 11:17 PM
To: Thomas Monjalon <[email protected]>; Eelco Chaudron <[email protected]>; Xia, Chenbo <[email protected]>; [email protected]
Cc: [email protected]
Subject: Re: [PATCH v3 4/4] vhost: add device op to offload theinterrupt
Quoted 9 lines
Quoted 9 lines
kick
Quoted 4 lines · Thomas Monjalon
30/05/2023 15:02, Maxime Coquelin:
Quoted 3 lines · Eelco Chaudron
Quoted 1 line
This patch adds an operation callback which gets called every time
the
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
library wants to call
eventfd_write(). Thiseventfd_write()callcould
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
result in a system call, which could potentially block the PMD
thread.
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
The callback function can decide whether it's ok to handle the
eventfd_write()now or have the newly introduced function,rte_vhost_notify_guest(), called at a later time.This can be used by 3rd party applications, like OVS, to avoid
system
Quoted 11 lines
Quoted 11 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
calls being called as part of the PMD threads.
Signed-off-by Eelco Chaudron <[email protected]>--- lib/vhost/meson.build | 2 ++ lib/vhost/rte_vhost.h | 23 +++++++++++++++++- lib/vhost/socket.c | 63++++++++++++++++++++++++++++++++++++++++++++++---
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
lib/vhost/version.map | 9 +++++++ lib/vhost/vhost.c | 38 ++++++++++++++++++++++++++++++ lib/vhost/vhost.h | 58 ++++++++++++++++++++++++++++++++------
Quoted 23 lines
Quoted 14 lines
-------
Quoted 6 lines
Quoted 6 lines
Quoted 2 lines
6 files changed, 171 insertions(+), 22 deletions(-)The patch looks good to me, but that's the first time we use function versioning in Vhost library, so I'd like another pair of eyes to be
sure
Quoted 6 lines
Quoted 5 lines
I don't miss anything.
Reviewed-by Maxime Coquelin <[email protected]>Thomas, do we need to mention it somewhere in the release note?
Quoted 7 lines
Quoted 3 lines
If compatibility is kept, I think we don't need to mention it.
Thanks Thomas for the information.
Maxime
About release note, except the versioning, there is also one new API
Quoted 8 lines
Quoted 6 lines
introduced
Quoted 1 line
in this patch, so we still need to mention this in release note
Right, good catch.
Eelco, let me know what you would put, I'll add it while applying (No need for a new revision).Btw, the
vhost_lib.rstalso needs a new item..
What about the following?
doc/guides/prog_guide/vhost_lib.rst +5 -0
@@ -334,6 +334,11 @@ The following is an overview of some key Vhost API functions: Clean DMA vChannel finished to use. After this function is called, the specified DMA vChannel should no longer be used by the Vhost library. +* ``rte_vhost_notify_guest(int vid, uint16_t queue_id)`` + + Inject the offloaded interrupt received by the 'guest_notify' callback, + into the vhost device's queue. + Vhost-user Implementations --------------------------
Maxime do you want to add it, or do you want a new rev?
Quoted 9 lines
Thanks,
ChenboQuoted 6 lines
Thanks,
MaximeQuoted 2 lines
Thanks,
Chenbo
Quoted 109 lines · Eelco Chaudron
Quoted 78 lines · Chenbo
Quoted 78 lines
-----Original Message-----
From: Maxime Coquelin <[email protected]>
Sent: Wednesday, May 31, 2023 5:29 PM
To: Xia, Chenbo <[email protected]>; Thomas Monjalon <[email protected]>; Eelco Chaudron <[email protected]>; [email protected]
Cc: [email protected]
Subject: Re: [PATCH v3 4/4] vhost: add device op to offload the interrupt kickQuoted 8 lines · Chenbo
Quoted 8 lines
-----Original Message-----
From: Maxime Coquelin <[email protected]>
Sent: Tuesday, May 30, 2023 11:17 PM
To: Thomas Monjalon <[email protected]>; Eelco Chaudron <[email protected]>; Xia, Chenbo <[email protected]>; [email protected]
Cc: [email protected]
Subject: Re: [PATCH v3 4/4] vhost: add device op to offload theinterrupt
Quoted 9 lines
Quoted 9 lines
kick
Quoted 4 lines · Thomas Monjalon
30/05/2023 15:02, Maxime Coquelin:
Quoted 3 lines · Eelco Chaudron
Quoted 1 line
This patch adds an operation callback which gets called every time
the
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
library wants to call
eventfd_write(). Thiseventfd_write()callcould
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
result in a system call, which could potentially block the PMD
thread.
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
The callback function can decide whether it's ok to handle the
eventfd_write()now or have the newly introduced function,rte_vhost_notify_guest(), called at a later time.This can be used by 3rd party applications, like OVS, to avoid
system
Quoted 11 lines
Quoted 11 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
calls being called as part of the PMD threads.
Signed-off-by Eelco Chaudron <[email protected]>--- lib/vhost/meson.build | 2 ++ lib/vhost/rte_vhost.h | 23 +++++++++++++++++- lib/vhost/socket.c | 63++++++++++++++++++++++++++++++++++++++++++++++---
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
lib/vhost/version.map | 9 +++++++ lib/vhost/vhost.c | 38 ++++++++++++++++++++++++++++++ lib/vhost/vhost.h | 58 ++++++++++++++++++++++++++++++++------
Quoted 23 lines
Quoted 14 lines
-------
Quoted 6 lines
Quoted 6 lines
Quoted 2 lines
6 files changed, 171 insertions(+), 22 deletions(-)The patch looks good to me, but that's the first time we use function versioning in Vhost library, so I'd like another pair of eyes to be
sure
Quoted 6 lines
Quoted 5 lines
I don't miss anything.
Reviewed-by Maxime Coquelin <[email protected]>Thomas, do we need to mention it somewhere in the release note?
Quoted 7 lines
Quoted 3 lines
If compatibility is kept, I think we don't need to mention it.
Thanks Thomas for the information.
Maxime
About release note, except the versioning, there is also one new API
Quoted 8 lines
Quoted 6 lines
introduced
Quoted 1 line
in this patch, so we still need to mention this in release note
Right, good catch.
Eelco, let me know what you would put, I'll add it while applying (No need for a new revision).Btw, the
vhost_lib.rstalso needs a new item..What about the following?
doc/guides/prog_guide/vhost_lib.rst +5
-0@@ -334,6 +334,11 @@ The following is an overview of some key Vhost API functions: Clean DMA vChannel finished to use. After this function is called, the specified DMA vChannel should no longer be used by the Vhost library. +* ``rte_vhost_notify_guest(int vid, uint16_t queue_id)`` + + Inject the offloaded interrupt received by the 'guest_notify' callback, + into the vhost device's queue. + Vhost-user Implementations --------------------------
Quoted 1 line
Maxime do you want to add it, or do you want a new rev?
That's fine, I just added it now :) Can you check the next-virtio main branch and confirm all is OK for your series?
https://git.dpdk.org/next/dpdk-next-virtio/log/
Thanks,
Maxime
Quoted 11 lines
Quoted 10 lines
Thanks,
ChenboQuoted 6 lines
Thanks,
MaximeQuoted 2 lines
Thanks,
Chenbo
Quoted 110 lines · Maxime Coquelin
Quoted 109 lines · Eelco Chaudron
Quoted 78 lines · Chenbo
Quoted 78 lines
-----Original Message-----
From: Maxime Coquelin <[email protected]>
Sent: Wednesday, May 31, 2023 5:29 PM
To: Xia, Chenbo <[email protected]>; Thomas Monjalon <[email protected]>; Eelco Chaudron <[email protected]>; [email protected]
Cc: [email protected]
Subject: Re: [PATCH v3 4/4] vhost: add device op to offload the interrupt kickQuoted 8 lines · Chenbo
Quoted 8 lines
-----Original Message-----
From: Maxime Coquelin <[email protected]>
Sent: Tuesday, May 30, 2023 11:17 PM
To: Thomas Monjalon <[email protected]>; Eelco Chaudron <[email protected]>; Xia, Chenbo <[email protected]>; [email protected]
Cc: [email protected]
Subject: Re: [PATCH v3 4/4] vhost: add device op to offload theinterrupt
Quoted 9 lines
Quoted 9 lines
kick
Quoted 4 lines · Thomas Monjalon
30/05/2023 15:02, Maxime Coquelin:
Quoted 3 lines · Eelco Chaudron
Quoted 1 line
This patch adds an operation callback which gets called every time
the
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
library wants to call
eventfd_write(). Thiseventfd_write()callcould
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
result in a system call, which could potentially block the PMD
thread.
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
The callback function can decide whether it's ok to handle the
eventfd_write()now or have the newly introduced function,rte_vhost_notify_guest(), called at a later time.This can be used by 3rd party applications, like OVS, to avoid
system
Quoted 11 lines
Quoted 11 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
calls being called as part of the PMD threads.
Signed-off-by Eelco Chaudron <[email protected]>--- lib/vhost/meson.build | 2 ++ lib/vhost/rte_vhost.h | 23 +++++++++++++++++- lib/vhost/socket.c | 63++++++++++++++++++++++++++++++++++++++++++++++---
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
lib/vhost/version.map | 9 +++++++ lib/vhost/vhost.c | 38 ++++++++++++++++++++++++++++++ lib/vhost/vhost.h | 58 ++++++++++++++++++++++++++++++++------
Quoted 23 lines
Quoted 14 lines
-------
Quoted 6 lines
Quoted 6 lines
Quoted 2 lines
6 files changed, 171 insertions(+), 22 deletions(-)The patch looks good to me, but that's the first time we use function versioning in Vhost library, so I'd like another pair of eyes to be
sure
Quoted 6 lines
Quoted 5 lines
I don't miss anything.
Reviewed-by Maxime Coquelin <[email protected]>Thomas, do we need to mention it somewhere in the release note?
Quoted 7 lines
Quoted 3 lines
If compatibility is kept, I think we don't need to mention it.
Thanks Thomas for the information.
Maxime
About release note, except the versioning, there is also one new API
Quoted 8 lines
Quoted 6 lines
introduced
Quoted 1 line
in this patch, so we still need to mention this in release note
Right, good catch.
Eelco, let me know what you would put, I'll add it while applying (No need for a new revision).Btw, the
vhost_lib.rstalso needs a new item..What about the following?
doc/guides/prog_guide/vhost_lib.rst +5
-0@@ -334,6 +334,11 @@ The following is an overview of some key Vhost API functions: Clean DMA vChannel finished to use. After this function is called, the specified DMA vChannel should no longer be used by the Vhost library. +* ``rte_vhost_notify_guest(int vid, uint16_t queue_id)`` + + Inject the offloaded interrupt received by the 'guest_notify' callback, + into the vhost device's queue. + Vhost-user Implementations --------------------------
Quoted 7 lines
Quoted 1 line
Maxime do you want to add it, or do you want a new rev?
That's fine, I just added it now :) Can you check the next-virtio main branch and confirm all is OK for your series?
One small spelling issue, the rest looks good:
+* **Added callback API support for interrupt handling in the vhost library.** +
+ A new callback, guest_notify, is introduced that can be used to handle the + interrupt kick outside of the datapath fast path. In addition, a new API, + rte_vhost_notify_guest(), is added to raise the interrupt outside of the + past path.
Last sentence spells ‘past path’ instead of ‘fast path’.
Quoted 14 lines
Thanks,
MaximeQuoted 11 lines
Quoted 10 lines
Thanks,
ChenboQuoted 6 lines
Thanks,
MaximeQuoted 2 lines
Thanks,
Chenbo
Quoted 131 lines · Eelco Chaudron
Quoted 110 lines · Maxime Coquelin
Quoted 109 lines · Eelco Chaudron
Quoted 78 lines · Chenbo
Quoted 78 lines
-----Original Message-----
From: Maxime Coquelin <[email protected]>
Sent: Wednesday, May 31, 2023 5:29 PM
To: Xia, Chenbo <[email protected]>; Thomas Monjalon <[email protected]>; Eelco Chaudron <[email protected]>; [email protected]
Cc: [email protected]
Subject: Re: [PATCH v3 4/4] vhost: add device op to offload the interrupt kickQuoted 8 lines · Chenbo
Quoted 8 lines
-----Original Message-----
From: Maxime Coquelin <[email protected]>
Sent: Tuesday, May 30, 2023 11:17 PM
To: Thomas Monjalon <[email protected]>; Eelco Chaudron <[email protected]>; Xia, Chenbo <[email protected]>; [email protected]
Cc: [email protected]
Subject: Re: [PATCH v3 4/4] vhost: add device op to offload theinterrupt
Quoted 9 lines
Quoted 9 lines
kick
Quoted 4 lines · Thomas Monjalon
30/05/2023 15:02, Maxime Coquelin:
Quoted 3 lines · Eelco Chaudron
Quoted 1 line
This patch adds an operation callback which gets called every time
the
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
library wants to call
eventfd_write(). Thiseventfd_write()callcould
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
result in a system call, which could potentially block the PMD
thread.
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
The callback function can decide whether it's ok to handle the
eventfd_write()now or have the newly introduced function,rte_vhost_notify_guest(), called at a later time.This can be used by 3rd party applications, like OVS, to avoid
system
Quoted 11 lines
Quoted 11 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
calls being called as part of the PMD threads.
Signed-off-by Eelco Chaudron <[email protected]>--- lib/vhost/meson.build | 2 ++ lib/vhost/rte_vhost.h | 23 +++++++++++++++++- lib/vhost/socket.c | 63++++++++++++++++++++++++++++++++++++++++++++++---
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
lib/vhost/version.map | 9 +++++++ lib/vhost/vhost.c | 38 ++++++++++++++++++++++++++++++ lib/vhost/vhost.h | 58 ++++++++++++++++++++++++++++++++------
Quoted 23 lines
Quoted 14 lines
-------
Quoted 6 lines
Quoted 6 lines
Quoted 2 lines
6 files changed, 171 insertions(+), 22 deletions(-)The patch looks good to me, but that's the first time we use function versioning in Vhost library, so I'd like another pair of eyes to be
sure
Quoted 6 lines
Quoted 5 lines
I don't miss anything.
Reviewed-by Maxime Coquelin <[email protected]>Thomas, do we need to mention it somewhere in the release note?
Quoted 7 lines
Quoted 3 lines
If compatibility is kept, I think we don't need to mention it.
Thanks Thomas for the information.
Maxime
About release note, except the versioning, there is also one new API
Quoted 8 lines
Quoted 6 lines
introduced
Quoted 1 line
in this patch, so we still need to mention this in release note
Right, good catch.
Eelco, let me know what you would put, I'll add it while applying (No need for a new revision).Btw, the
vhost_lib.rstalso needs a new item..What about the following?
doc/guides/prog_guide/vhost_lib.rst +5
-0@@ -334,6 +334,11 @@ The following is an overview of some key Vhost API functions: Clean DMA vChannel finished to use. After this function is called, the specified DMA vChannel should no longer be used by the Vhost library. +* ``rte_vhost_notify_guest(int vid, uint16_t queue_id)`` + + Inject the offloaded interrupt received by the 'guest_notify' callback, + into the vhost device's queue. + Vhost-user Implementations --------------------------Quoted 7 lines
Quoted 1 line
Maxime do you want to add it, or do you want a new rev?
That's fine, I just added it now :) Can you check the next-virtio main branch and confirm all is OK for your series?
One small spelling issue, the rest looks good:
(quoted diff) +6
-0+* **Added callback API support for interrupt handling in the vhost library.** + + A new callback, guest_notify, is introduced that can be used to handle the + interrupt kick outside of the datapath fast path. In addition, a new API, + rte_vhost_notify_guest(), is added to raise the interrupt outside of the + past path.
Quoted 1 line
Last sentence spells ‘past path’ instead of ‘fast path’.
I edited the line but it didn't caught my eye!
Fixing it now.
Thanks,
Maxime
Quoted 16 lines
Quoted 15 lines
Thanks,
MaximeQuoted 11 lines
Quoted 10 lines
Thanks,
ChenboQuoted 6 lines
Thanks,
MaximeQuoted 2 lines
Thanks,
Chenbo
Quoted 24 lines · Maxime Coquelin
Quoted 12 lines · Eelco Chaudron
This patch adds an operation callback which gets called every time the library wants to call
eventfd_write(). Thiseventfd_write()call could result in a system call, which could potentially block the PMD thread.The callback function can decide whether it's ok to handle the
eventfd_write()now or have the newly introduced function,rte_vhost_notify_guest(), called at a later time.This can be used by 3rd party applications, like OVS, to avoid system calls being called as part of the PMD threads.
Signed-off-by Eelco Chaudron <[email protected]>Quoted 9 lines
--- lib/vhost/meson.build | 2 ++ lib/vhost/rte_vhost.h | 23 +++++++++++++++++- lib/vhost/socket.c | 63 ++++++++++++++++++++++++++++++++++++++++++++++--- lib/vhost/version.map | 9 +++++++ lib/vhost/vhost.c | 38 ++++++++++++++++++++++++++++++ lib/vhost/vhost.h | 58 ++++++++++++++++++++++++++++++++------------- 6 files changed, 171 insertions(+), 22 deletions(-)
Quoted 5 lines
The patch looks good to me, but that's the first time we use function versioning in Vhost library, so I'd like another pair of eyes to be sure I don't miss anything.
Reviewed-by Maxime Coquelin <[email protected]>
There may be some enhancement to do in the symbol check (wrt to the warning http://mails.dpdk.org/archives/test-report/2023-May/394865.html)
but otherwise the versioning part lgtm.
Signature · 1 line
David Marchand
Eelco, Maxime,
lib/vhost/socket.c vhost_user_socket_mem_free(struct vhost_user_socket *vsocket) · line 858
Quoted 12 lines · Eelco Chaudron
lib/vhost/socket.c +5
-0@@ -846,6 +848,11 @@ vhost_user_socket_mem_free(struct vhost_user_socket *vsocket) vsocket->path =NULL ; } +if (vsocket && vsocket->malloc_notify_ops) { +free (vsocket->malloc_notify_ops); + vsocket->malloc_notify_ops =NULL ; + } +if (vsocket) {free (vsocket); vsocket =NULL ;
Nit: we had several cleanups in the tree to remove patterns like if (ptr) free(ptr).
Here, this helper could look for vsocket being NULL first thing, then call free() unconditionnally.
And resetting the fields to NULL is probably not that useful, since the vsocket is freed at the end.
Wdyt of:
static voidvhost_user_socket_mem_free(struct vhost_user_socket *vsocket)
{
if (vsocket == NULL)
return;
free(vsocket->path);
free(vsocket->malloc_notify_ops);
free(vsocket);
}Signature · 1 line
David Marchand
Quoted 26 lines · David Marchand
Eelco, Maxime,
lib/vhost/socket.c vhost_user_socket_mem_free(struct vhost_user_socket *vsocket) · line 858
Quoted 12 lines · Eelco Chaudron
lib/vhost/socket.c +5
-0@@ -846,6 +848,11 @@ vhost_user_socket_mem_free(struct vhost_user_socket *vsocket) vsocket->path =NULL ; } +if (vsocket && vsocket->malloc_notify_ops) { +free (vsocket->malloc_notify_ops); + vsocket->malloc_notify_ops =NULL ; + } +if (vsocket) {free (vsocket); vsocket =NULL ;Nit: we had several cleanups in the tree to remove patterns like if (ptr) free(ptr).
Here, this helper could look for vsocket being NULL first thing, then callfree()unconditionnally.
And resetting the fields to NULL is probably not that useful, since the vsocket is freed at the end.
Wdyt of:static void
vhost_user_socket_mem_free(struct vhost_user_socket *vsocket)
Quoted 10 lines
{
if (vsocket == NULL)
return;
free(vsocket->path);
free(vsocket->malloc_notify_ops);
free(vsocket);
}It is indeed better, I can fix while applying if Eelco agrees.
Thanks,
Maxime
Quoted 31 lines · Maxime Coquelin
Quoted 30 lines · David Marchand
Eelco, Maxime,
lib/vhost/socket.c vhost_user_socket_mem_free(struct vhost_user_socket *vsocket) · line 858
Quoted 12 lines · Eelco Chaudron
lib/vhost/socket.c +5
-0@@ -846,6 +848,11 @@ vhost_user_socket_mem_free(struct vhost_user_socket *vsocket) vsocket->path =NULL ; } +if (vsocket && vsocket->malloc_notify_ops) { +free (vsocket->malloc_notify_ops); + vsocket->malloc_notify_ops =NULL ; + } +if (vsocket) {free (vsocket); vsocket =NULL ;Nit: we had several cleanups in the tree to remove patterns like if (ptr) free(ptr).
Here, this helper could look for vsocket being NULL first thing, then callfree()unconditionnally.
And resetting the fields to NULL is probably not that useful, since the vsocket is freed at the end.
Wdyt of:static void
vhost_user_socket_mem_free(struct vhost_user_socket *vsocket){ if (vsocket == NULL) return;
Quoted 8 lines
Quoted 6 lines
free(vsocket->path); free(vsocket->malloc_notify_ops); free(vsocket); }It is indeed better, I can fix while applying if Eelco agrees.
Looks good to me.
//Eelco
Maxime,
lib/vhost/vhost.h vhost_vring_call_packed(struct virtio_net *dev, struct vhost_virtqueue *vq) · line 998
Quoted 11 lines · Eelco Chaudron
lib/vhost/vhost.h +2
-5@@ -974,11 +994,8 @@ vhost_vring_call_packed(struct virtio_net *dev, struct vhost_virtqueue *vq)if (vhost_need_event (off, new, old)) kick = true; kick: -if (kick && vq->callfd >=0 ) { -eventfd_write (vq->callfd, (eventfd_t )1 ); -if (dev->notify_ops->guest_notified) - dev->notify_ops->guest_notified (dev->vid); - } +if (kick && vq->callfd >=0 ) +vhost_vring_inject_irq (dev, vq);
Thinking again about the VDUSE series overlap...
This hunk here is implicitely fixing an issue.
You addressed it in
https://patchwork.dpdk.org/project/dpdk/patch/[email protected]/
So I suggest you apply this patch of yours before Eelco patch 4. This way, the fix backport will be trivial.
Signature · 1 line
David Marchand
Quoted 17 lines · David Marchand
Maxime,
lib/vhost/vhost.h vhost_vring_call_packed(struct virtio_net *dev, struct vhost_virtqueue *vq) · line 998
Quoted 11 lines · Eelco Chaudron
lib/vhost/vhost.h +2
-5@@ -974,11 +994,8 @@ vhost_vring_call_packed(struct virtio_net *dev, struct vhost_virtqueue *vq)if (vhost_need_event (off, new, old)) kick = true; kick: -if (kick && vq->callfd >=0 ) { -eventfd_write (vq->callfd, (eventfd_t )1 ); -if (dev->notify_ops->guest_notified) - dev->notify_ops->guest_notified (dev->vid); - } +if (kick && vq->callfd >=0 ) +vhost_vring_inject_irq (dev, vq);Thinking again about the VDUSE series overlap...
Quoted 8 lines
This hunk here is implicitely fixing an issue.
You addressed it in
https://patchwork.dpdk.org/project/dpdk/patch/[email protected]/So I suggest you apply this patch of yours before Eelco patch 4. This way, the fix backport will be trivial.
Thanks David, this is indeed the best thing to do to ease backporting the fix to v22.11.
Maxime
Maxime Coquelin
AppliedQuoted 33 lines · Eelco Chaudron
This series adds an operation callback which gets called every time the library wants to call
eventfd_write(). Thiseventfd_write()call could result in a system call, which could potentially block the PMD thread.The callback function can decide whether it's ok to handle the
eventfd_write()now or have the newly introduced function,rte_vhost_notify_guest(), called at a later time.This can be used by 3rd party applications, like OVS, to avoid system calls being called as part of the PMD threads.
v3:
- Changed ABI compatibility code to no longer use a boolean to avoid having to disable specific GCC warnings.
- Moved the fd check fix to a separate patch (patch 3/4).
- Fixed some coding style issues.v2: - Used
vhost_virtqueue->indexto find index for operation.
- Aligned function name to VDUSE RFC patchset.
- Added error and offload statistics counter.
- Mark new API as experimental.
- Change the virtual queue spin lock to read/write spin lock.
- Made shared counters atomic.
- Add versionedrte_vhost_driver_callback_register()for ABI compliance.Eelco Chaudron (4):
vhost: changevhost_virtqueueaccess lock to a read/write one
vhost: make theguest_notificationsstatistic counter atomic
vhost: fix invalid call FD handling
vhost: add device op to offload the interrupt kick
Quoted 11 lines
lib/eal/include/generic/rte_rwlock.h | 17 +++++ lib/vhost/meson.build | 2 + lib/vhost/rte_vhost.h | 23 ++++++- lib/vhost/socket.c | 63 +++++++++++++++++-- lib/vhost/version.map | 9 +++ lib/vhost/vhost.c | 92 +++++++++++++++++++++------- lib/vhost/vhost.h | 69 ++++++++++++++------- lib/vhost/vhost_user.c | 14 ++--- lib/vhost/virtio_net.c | 90 +++++++++++++-------------- 9 files changed, 278 insertions(+), 101 deletions(-)
Applied to dpdk-next-virtio/main.
Thanks,
Maxime
Quoted 47 lines · Maxime Coquelin
Quoted 33 lines · Eelco Chaudron
This series adds an operation callback which gets called every time the library wants to call
eventfd_write(). Thiseventfd_write()call could result in a system call, which could potentially block the PMD thread.The callback function can decide whether it's ok to handle the
eventfd_write()now or have the newly introduced function,rte_vhost_notify_guest(), called at a later time.This can be used by 3rd party applications, like OVS, to avoid system calls being called as part of the PMD threads.
v3:
- Changed ABI compatibility code to no longer use a boolean to avoid having to disable specific GCC warnings.
- Moved the fd check fix to a separate patch (patch 3/4).
- Fixed some coding style issues.v2: - Used
vhost_virtqueue->indexto find index for operation.
- Aligned function name to VDUSE RFC patchset.
- Added error and offload statistics counter.
- Mark new API as experimental.
- Change the virtual queue spin lock to read/write spin lock.
- Made shared counters atomic.
- Add versionedrte_vhost_driver_callback_register()for ABI compliance.Eelco Chaudron (4):
vhost: changevhost_virtqueueaccess lock to a read/write one
vhost: make theguest_notificationsstatistic counter atomic
vhost: fix invalid call FD handling
vhost: add device op to offload the interrupt kickQuoted 11 lines
lib/eal/include/generic/rte_rwlock.h | 17 +++++ lib/vhost/meson.build | 2 + lib/vhost/rte_vhost.h | 23 ++++++- lib/vhost/socket.c | 63 +++++++++++++++++-- lib/vhost/version.map | 9 +++ lib/vhost/vhost.c | 92 +++++++++++++++++++++------- lib/vhost/vhost.h | 69 ++++++++++++++------- lib/vhost/vhost_user.c | 14 ++--- lib/vhost/virtio_net.c | 90 +++++++++++++-------------- 9 files changed, 278 insertions(+), 101 deletions(-)
Quoted 1 line
Applied to dpdk-next-virtio/main.
Thanks Maxime!
//Eelco