]> Pileus Git - ~andy/linux/commitdiff
vhost: avoid backend flush on vring ops
authorMichael S. Tsirkin <mst@redhat.com>
Thu, 6 Dec 2012 12:03:34 +0000 (14:03 +0200)
committerMichael S. Tsirkin <mst@redhat.com>
Thu, 6 Dec 2012 15:09:18 +0000 (17:09 +0200)
vring changes already do a flush internally where appropriate, so we do
not need a second flush.

It's currently not very expensive but a follow-up patch makes flush more
heavy-weight, so remove the extra flush here to avoid regressing
performance if call or kick fds are changed on data path.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
drivers/vhost/net.c
drivers/vhost/tcm_vhost.c
drivers/vhost/vhost.c
drivers/vhost/vhost.h

index ff6c91995c96ca25389e1249d80cb42e2402c6de..1802ab662082ab9e741cd24be8b894f13e05b2ce 100644 (file)
@@ -942,8 +942,11 @@ static long vhost_net_ioctl(struct file *f, unsigned int ioctl,
                return vhost_net_reset_owner(n);
        default:
                mutex_lock(&n->dev.mutex);
-               r = vhost_dev_ioctl(&n->dev, ioctl, arg);
-               vhost_net_flush(n);
+               r = vhost_dev_ioctl(&n->dev, ioctl, argp);
+               if (r == -ENOIOCTLCMD)
+                       r = vhost_vring_ioctl(&n->dev, ioctl, argp);
+               else
+                       vhost_net_flush(n);
                mutex_unlock(&n->dev.mutex);
                return r;
        }
index ef88844824391c3893641c6841884591b1bdacfe..33e5f90dfcf5c2447fe001b12ecc53d90868d461 100644 (file)
@@ -970,7 +970,10 @@ static long vhost_scsi_ioctl(struct file *f, unsigned int ioctl,
                return vhost_scsi_set_features(vs, features);
        default:
                mutex_lock(&vs->dev.mutex);
-               r = vhost_dev_ioctl(&vs->dev, ioctl, arg);
+               r = vhost_dev_ioctl(&vs->dev, ioctl, argp);
+               /* TODO: flush backend after dev ioctl. */
+               if (r == -ENOIOCTLCMD)
+                       r = vhost_vring_ioctl(&vs->dev, ioctl, argp);
                mutex_unlock(&vs->dev.mutex);
                return r;
        }
index 5a3d0f1eaf9490c7151dd4052295e227512cf459..34389f75fe65693a4ad5baa36715159fd5759bbb 100644 (file)
@@ -607,7 +607,7 @@ static long vhost_set_memory(struct vhost_dev *d, struct vhost_memory __user *m)
        return 0;
 }
 
-static long vhost_set_vring(struct vhost_dev *d, int ioctl, void __user *argp)
+long vhost_vring_ioctl(struct vhost_dev *d, int ioctl, void __user *argp)
 {
        struct file *eventfp, *filep = NULL;
        bool pollstart = false, pollstop = false;
@@ -802,9 +802,8 @@ static long vhost_set_vring(struct vhost_dev *d, int ioctl, void __user *argp)
 }
 
 /* Caller must have device mutex */
-long vhost_dev_ioctl(struct vhost_dev *d, unsigned int ioctl, unsigned long arg)
+long vhost_dev_ioctl(struct vhost_dev *d, unsigned int ioctl, void __user *argp)
 {
-       void __user *argp = (void __user *)arg;
        struct file *eventfp, *filep = NULL;
        struct eventfd_ctx *ctx = NULL;
        u64 p;
@@ -875,7 +874,7 @@ long vhost_dev_ioctl(struct vhost_dev *d, unsigned int ioctl, unsigned long arg)
                        fput(filep);
                break;
        default:
-               r = vhost_set_vring(d, ioctl, argp);
+               r = -ENOIOCTLCMD;
                break;
        }
 done:
index 5e19e3d5db8cda6d77a516a8d3aa27bc92efbf9a..2639c58b23ab497ace850895f3322df661a965df 100644 (file)
@@ -164,7 +164,8 @@ long vhost_dev_check_owner(struct vhost_dev *);
 long vhost_dev_reset_owner(struct vhost_dev *);
 void vhost_dev_cleanup(struct vhost_dev *, bool locked);
 void vhost_dev_stop(struct vhost_dev *);
-long vhost_dev_ioctl(struct vhost_dev *, unsigned int ioctl, unsigned long arg);
+long vhost_dev_ioctl(struct vhost_dev *, unsigned int ioctl, void __user *argp);
+long vhost_vring_ioctl(struct vhost_dev *d, int ioctl, void __user *argp);
 int vhost_vq_access_ok(struct vhost_virtqueue *vq);
 int vhost_log_access_ok(struct vhost_dev *);