Skip to content

Commit 86e182f

Browse files
Zhu Lingshanmstsirkin
authored andcommitted
vhost_vdpa: remove unnecessary spin_lock in vhost_vring_call
This commit removed unnecessary spin_locks in vhost_vring_call and related operations. Because we manipulate irq offloading contents in vhost_vdpa ioctl code path which is already protected by dev mutex and vq mutex. Signed-off-by: Zhu Lingshan <lingshan.zhu@intel.com> Link: https://lore.kernel.org/r/20200909065234.3313-1-lingshan.zhu@intel.com Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Acked-by: Jason Wang <jasowang@redhat.com>
1 parent 5745bcf commit 86e182f

3 files changed

Lines changed: 1 addition & 11 deletions

File tree

drivers/vhost/vdpa.c

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -96,26 +96,20 @@ static void vhost_vdpa_setup_vq_irq(struct vhost_vdpa *v, u16 qid)
9696
return;
9797

9898
irq = ops->get_vq_irq(vdpa, qid);
99-
spin_lock(&vq->call_ctx.ctx_lock);
10099
irq_bypass_unregister_producer(&vq->call_ctx.producer);
101-
if (!vq->call_ctx.ctx || irq < 0) {
102-
spin_unlock(&vq->call_ctx.ctx_lock);
100+
if (!vq->call_ctx.ctx || irq < 0)
103101
return;
104-
}
105102

106103
vq->call_ctx.producer.token = vq->call_ctx.ctx;
107104
vq->call_ctx.producer.irq = irq;
108105
ret = irq_bypass_register_producer(&vq->call_ctx.producer);
109-
spin_unlock(&vq->call_ctx.ctx_lock);
110106
}
111107

112108
static void vhost_vdpa_unsetup_vq_irq(struct vhost_vdpa *v, u16 qid)
113109
{
114110
struct vhost_virtqueue *vq = &v->vqs[qid];
115111

116-
spin_lock(&vq->call_ctx.ctx_lock);
117112
irq_bypass_unregister_producer(&vq->call_ctx.producer);
118-
spin_unlock(&vq->call_ctx.ctx_lock);
119113
}
120114

121115
static void vhost_vdpa_reset(struct vhost_vdpa *v)

drivers/vhost/vhost.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,6 @@ static void vhost_vring_call_reset(struct vhost_vring_call *call_ctx)
302302
{
303303
call_ctx->ctx = NULL;
304304
memset(&call_ctx->producer, 0x0, sizeof(struct irq_bypass_producer));
305-
spin_lock_init(&call_ctx->ctx_lock);
306305
}
307306

308307
static void vhost_vq_reset(struct vhost_dev *dev,
@@ -1650,9 +1649,7 @@ long vhost_vring_ioctl(struct vhost_dev *d, unsigned int ioctl, void __user *arg
16501649
break;
16511650
}
16521651

1653-
spin_lock(&vq->call_ctx.ctx_lock);
16541652
swap(ctx, vq->call_ctx.ctx);
1655-
spin_unlock(&vq->call_ctx.ctx_lock);
16561653
break;
16571654
case VHOST_SET_VRING_ERR:
16581655
if (copy_from_user(&f, argp, sizeof f)) {

drivers/vhost/vhost.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ enum vhost_uaddr_type {
6464
struct vhost_vring_call {
6565
struct eventfd_ctx *ctx;
6666
struct irq_bypass_producer producer;
67-
spinlock_t ctx_lock;
6867
};
6968

7069
/* The virtqueue structure describes a queue attached to a device. */

0 commit comments

Comments
 (0)