diff mbox

[RFC,v2,0/8] packed ring virtio-net userspace backend support

Message ID 1528225683-11413-1-git-send-email-wexu@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Wei Xu June 5, 2018, 7:07 p.m. UTC
From: Wei Xu <wexu@redhat.com>

Todo:
- address Rx slow performance
- event index interrupt suppression test

v1->v2
- sync to tiwei's v5
- reuse memory cache function with 1.0
- dropped detach patch and notification helper(04 & 05 in v1)
- guest virtio-net driver unload/reload support
- event suppression support(not tested)
- addressed feedback from v1

About guest virtio-net load/unload:
Since last_avail, avail_wrap_count, used_idx and used_wrap_count are
all 16 or bool type variables, so I turned to merge them to
'vhost_vring_state.num' in stead of introducing a new case
in handling ioctl, test has been done with a tweak in kernel side like:


Wei Xu (8):
  virtio: feature bit, data structure, init for packed ring
  virtio: memory cache for packed ring
  virtio: empty check and desc read for packed ring
  virtio: get avail bytes check for packed ring
  virtio: queue pop support for packed ring
  virtio: flush/push support for packed ring
  virtio: event suppression support for packed ring
  virtio: support guest driver reload for vhost-net

 hw/net/vhost_net.c                             |   2 +
 hw/virtio/virtio.c                             | 677 +++++++++++++++++++++++--
 include/hw/virtio/virtio.h                     |   4 +-
 include/standard-headers/linux/virtio_config.h |  15 +
 4 files changed, 649 insertions(+), 49 deletions(-)

Comments

Jason Wang June 6, 2018, 2:34 a.m. UTC | #1
On 2018年06月06日 03:07, wexu@redhat.com wrote:
> From: Wei Xu <wexu@redhat.com>
>
> Todo:
> - address Rx slow performance
> - event index interrupt suppression test

Tiwei's code support event index, you can try with that.

Actually, unless you disable event_idx explicitly, it work by default.

>
> v1->v2
> - sync to tiwei's v5
> - reuse memory cache function with 1.0
> - dropped detach patch and notification helper(04 & 05 in v1)
> - guest virtio-net driver unload/reload support
> - event suppression support(not tested)
> - addressed feedback from v1
>
> About guest virtio-net load/unload:
> Since last_avail, avail_wrap_count, used_idx and used_wrap_count are
> all 16 or bool type variables, so I turned to merge them to
> 'vhost_vring_state.num' in stead of introducing a new case
> in handling ioctl, test has been done with a tweak in kernel side like:

s.num is unsigned int which is 32bit, but you want to hold 2 16bit vars 
and a boolean.

So I'm afraid it won't work...

>
> --- a/drivers/vhost/vhost.c
> +++ b/drivers/vhost/vhost.c
> @@ -1439,10 +1439,16 @@ long vhost_vring_ioctl(struct vhost_dev *d, int ioctl, void __user *argp)
>              r = -EFAULT;
>              break;
>          }
> -               if (s.num > 0xffff) {
> -                       r = -EINVAL;
> -                       break;
> -               }
> +               if (vhost_has_feature(vq, VIRTIO_F_RING_PACKED)) {
> +                       vq->avail_wrap_counter = (bool)(uint16_t)(s.num >> 16);
> +                       vq->last_used_idx = (uint16_t)(s.num >> 32);
> +                       vq->used_wrap_counter = (bool)(uint16_t)(s.num >> 48);
> +                } else {
> +                    if (s.num > 0xffff) {
> +                            r = -EINVAL;
> +                            break;
> +                    }
> +                }
>          vq->last_avail_idx = s.num;
>          /* Forget the cached index value. */
>          vq->avail_idx = vq->last_avail_idx;
> @@ -1450,8 +1456,15 @@ long vhost_vring_ioctl(struct vhost_dev *d, int ioctl, void __user *argp)
>      case VHOST_GET_VRING_BASE:
>          s.index = idx;
>          s.num = vq->last_avail_idx;
> +               if (vhost_has_feature(vq, VIRTIO_F_RING_PACKED)) {
> +                       s.num |= vq->avail_wrap_counter << 16;
> +                       s.num |= vq->last_used_idx << 32;
> +                       s.num |= vq->used_wrap_counter << 48;
> +                }
>          if (copy_to_user(argp, &s, sizeof s))
>              r = -EFAULT;
> +               if (vhost_has_feature(vq, VIRTIO_F_RING_PACKED))
> +                       s.num |= vq->avail_wrap_counter << 31;
>          break;
>      case VHOST_SET_VRING_ADDR:
>          if (copy_from_user(&a, argp, sizeof a)) {
>
> Wei Xu (8):
>    virtio: feature bit, data structure, init for packed ring
>    virtio: memory cache for packed ring
>    virtio: empty check and desc read for packed ring
>    virtio: get avail bytes check for packed ring
>    virtio: queue pop support for packed ring
>    virtio: flush/push support for packed ring
>    virtio: event suppression support for packed ring
>    virtio: support guest driver reload for vhost-net
>
>   hw/net/vhost_net.c                             |   2 +
>   hw/virtio/virtio.c                             | 677 +++++++++++++++++++++++--
>   include/hw/virtio/virtio.h                     |   4 +-
>   include/standard-headers/linux/virtio_config.h |  15 +
>   4 files changed, 649 insertions(+), 49 deletions(-)
>
Jason Wang June 6, 2018, 3:49 a.m. UTC | #2
On 2018年06月06日 03:07, wexu@redhat.com wrote:
> From: Wei Xu<wexu@redhat.com>
>
> Todo:
> - address Rx slow performance
> - event index interrupt suppression test

And there's something more need to test:

- vIOMMU support
- migration

Thanks
Wei Xu June 19, 2018, 7:41 a.m. UTC | #3
On Wed, Jun 06, 2018 at 11:49:22AM +0800, Jason Wang wrote:
> 
> 
> On 2018年06月06日 03:07, wexu@redhat.com wrote:
> >From: Wei Xu<wexu@redhat.com>
> >
> >Todo:
> >- address Rx slow performance
> >- event index interrupt suppression test
> 
> And there's something more need to test:
> 
> - vIOMMU support
> - migration

OK, I will test it and put it to next version.

> 
> Thanks
diff mbox

Patch

--- a/drivers/vhost/vhost.c
+++ b/drivers/vhost/vhost.c
@@ -1439,10 +1439,16 @@  long vhost_vring_ioctl(struct vhost_dev *d, int ioctl, void __user *argp)
            r = -EFAULT;
            break;
        }
-               if (s.num > 0xffff) {
-                       r = -EINVAL;
-                       break;
-               }
+               if (vhost_has_feature(vq, VIRTIO_F_RING_PACKED)) {
+                       vq->avail_wrap_counter = (bool)(uint16_t)(s.num >> 16);
+                       vq->last_used_idx = (uint16_t)(s.num >> 32);
+                       vq->used_wrap_counter = (bool)(uint16_t)(s.num >> 48);
+                } else {
+                    if (s.num > 0xffff) {
+                            r = -EINVAL;
+                            break;
+                    }
+                }
        vq->last_avail_idx = s.num;
        /* Forget the cached index value. */
        vq->avail_idx = vq->last_avail_idx;
@@ -1450,8 +1456,15 @@  long vhost_vring_ioctl(struct vhost_dev *d, int ioctl, void __user *argp)
    case VHOST_GET_VRING_BASE:
        s.index = idx;
        s.num = vq->last_avail_idx;
+               if (vhost_has_feature(vq, VIRTIO_F_RING_PACKED)) {
+                       s.num |= vq->avail_wrap_counter << 16;
+                       s.num |= vq->last_used_idx << 32;
+                       s.num |= vq->used_wrap_counter << 48;
+                }
        if (copy_to_user(argp, &s, sizeof s))
            r = -EFAULT;
+               if (vhost_has_feature(vq, VIRTIO_F_RING_PACKED))
+                       s.num |= vq->avail_wrap_counter << 31;
        break;
    case VHOST_SET_VRING_ADDR:
        if (copy_from_user(&a, argp, sizeof a)) {