All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] vhost_vdpa: remove unnecessary spin_lock in vhost_vring_call
@ 2020-09-09  6:52 Zhu Lingshan
  2020-09-09  9:04   ` Jason Wang
  0 siblings, 1 reply; 3+ messages in thread
From: Zhu Lingshan @ 2020-09-09  6:52 UTC (permalink / raw)
  To: jasowang, mst; +Cc: virtualization, netdev, kvm, Zhu Lingshan

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>
---
 drivers/vhost/vdpa.c  | 8 +-------
 drivers/vhost/vhost.c | 3 ---
 drivers/vhost/vhost.h | 1 -
 3 files changed, 1 insertion(+), 11 deletions(-)

diff --git a/drivers/vhost/vdpa.c b/drivers/vhost/vdpa.c
index 3fab94f88894..bc679d0b7b87 100644
--- a/drivers/vhost/vdpa.c
+++ b/drivers/vhost/vdpa.c
@@ -97,26 +97,20 @@ static void vhost_vdpa_setup_vq_irq(struct vhost_vdpa *v, u16 qid)
 		return;
 
 	irq = ops->get_vq_irq(vdpa, qid);
-	spin_lock(&vq->call_ctx.ctx_lock);
 	irq_bypass_unregister_producer(&vq->call_ctx.producer);
-	if (!vq->call_ctx.ctx || irq < 0) {
-		spin_unlock(&vq->call_ctx.ctx_lock);
+	if (!vq->call_ctx.ctx || irq < 0)
 		return;
-	}
 
 	vq->call_ctx.producer.token = vq->call_ctx.ctx;
 	vq->call_ctx.producer.irq = irq;
 	ret = irq_bypass_register_producer(&vq->call_ctx.producer);
-	spin_unlock(&vq->call_ctx.ctx_lock);
 }
 
 static void vhost_vdpa_unsetup_vq_irq(struct vhost_vdpa *v, u16 qid)
 {
 	struct vhost_virtqueue *vq = &v->vqs[qid];
 
-	spin_lock(&vq->call_ctx.ctx_lock);
 	irq_bypass_unregister_producer(&vq->call_ctx.producer);
-	spin_unlock(&vq->call_ctx.ctx_lock);
 }
 
 static void vhost_vdpa_reset(struct vhost_vdpa *v)
diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c
index b45519ca66a7..99f27ce982da 100644
--- a/drivers/vhost/vhost.c
+++ b/drivers/vhost/vhost.c
@@ -302,7 +302,6 @@ static void vhost_vring_call_reset(struct vhost_vring_call *call_ctx)
 {
 	call_ctx->ctx = NULL;
 	memset(&call_ctx->producer, 0x0, sizeof(struct irq_bypass_producer));
-	spin_lock_init(&call_ctx->ctx_lock);
 }
 
 static void vhost_vq_reset(struct vhost_dev *dev,
@@ -1637,9 +1636,7 @@ long vhost_vring_ioctl(struct vhost_dev *d, unsigned int ioctl, void __user *arg
 			break;
 		}
 
-		spin_lock(&vq->call_ctx.ctx_lock);
 		swap(ctx, vq->call_ctx.ctx);
-		spin_unlock(&vq->call_ctx.ctx_lock);
 		break;
 	case VHOST_SET_VRING_ERR:
 		if (copy_from_user(&f, argp, sizeof f)) {
diff --git a/drivers/vhost/vhost.h b/drivers/vhost/vhost.h
index 9032d3c2a9f4..486dcf371e06 100644
--- a/drivers/vhost/vhost.h
+++ b/drivers/vhost/vhost.h
@@ -64,7 +64,6 @@ enum vhost_uaddr_type {
 struct vhost_vring_call {
 	struct eventfd_ctx *ctx;
 	struct irq_bypass_producer producer;
-	spinlock_t ctx_lock;
 };
 
 /* The virtqueue structure describes a queue attached to a device. */
-- 
2.18.4


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] vhost_vdpa: remove unnecessary spin_lock in vhost_vring_call
  2020-09-09  6:52 [PATCH] vhost_vdpa: remove unnecessary spin_lock in vhost_vring_call Zhu Lingshan
@ 2020-09-09  9:04   ` Jason Wang
  0 siblings, 0 replies; 3+ messages in thread
From: Jason Wang @ 2020-09-09  9:04 UTC (permalink / raw)
  To: Zhu Lingshan, mst; +Cc: virtualization, netdev, kvm


On 2020/9/9 下午2:52, Zhu Lingshan wrote:
> 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>


Acked-by: Jason Wang <jasowang@redhat.com>


> ---
>   drivers/vhost/vdpa.c  | 8 +-------
>   drivers/vhost/vhost.c | 3 ---
>   drivers/vhost/vhost.h | 1 -
>   3 files changed, 1 insertion(+), 11 deletions(-)
>
> diff --git a/drivers/vhost/vdpa.c b/drivers/vhost/vdpa.c
> index 3fab94f88894..bc679d0b7b87 100644
> --- a/drivers/vhost/vdpa.c
> +++ b/drivers/vhost/vdpa.c
> @@ -97,26 +97,20 @@ static void vhost_vdpa_setup_vq_irq(struct vhost_vdpa *v, u16 qid)
>   		return;
>   
>   	irq = ops->get_vq_irq(vdpa, qid);
> -	spin_lock(&vq->call_ctx.ctx_lock);
>   	irq_bypass_unregister_producer(&vq->call_ctx.producer);
> -	if (!vq->call_ctx.ctx || irq < 0) {
> -		spin_unlock(&vq->call_ctx.ctx_lock);
> +	if (!vq->call_ctx.ctx || irq < 0)
>   		return;
> -	}
>   
>   	vq->call_ctx.producer.token = vq->call_ctx.ctx;
>   	vq->call_ctx.producer.irq = irq;
>   	ret = irq_bypass_register_producer(&vq->call_ctx.producer);
> -	spin_unlock(&vq->call_ctx.ctx_lock);
>   }
>   
>   static void vhost_vdpa_unsetup_vq_irq(struct vhost_vdpa *v, u16 qid)
>   {
>   	struct vhost_virtqueue *vq = &v->vqs[qid];
>   
> -	spin_lock(&vq->call_ctx.ctx_lock);
>   	irq_bypass_unregister_producer(&vq->call_ctx.producer);
> -	spin_unlock(&vq->call_ctx.ctx_lock);
>   }
>   
>   static void vhost_vdpa_reset(struct vhost_vdpa *v)
> diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c
> index b45519ca66a7..99f27ce982da 100644
> --- a/drivers/vhost/vhost.c
> +++ b/drivers/vhost/vhost.c
> @@ -302,7 +302,6 @@ static void vhost_vring_call_reset(struct vhost_vring_call *call_ctx)
>   {
>   	call_ctx->ctx = NULL;
>   	memset(&call_ctx->producer, 0x0, sizeof(struct irq_bypass_producer));
> -	spin_lock_init(&call_ctx->ctx_lock);
>   }
>   
>   static void vhost_vq_reset(struct vhost_dev *dev,
> @@ -1637,9 +1636,7 @@ long vhost_vring_ioctl(struct vhost_dev *d, unsigned int ioctl, void __user *arg
>   			break;
>   		}
>   
> -		spin_lock(&vq->call_ctx.ctx_lock);
>   		swap(ctx, vq->call_ctx.ctx);
> -		spin_unlock(&vq->call_ctx.ctx_lock);
>   		break;
>   	case VHOST_SET_VRING_ERR:
>   		if (copy_from_user(&f, argp, sizeof f)) {
> diff --git a/drivers/vhost/vhost.h b/drivers/vhost/vhost.h
> index 9032d3c2a9f4..486dcf371e06 100644
> --- a/drivers/vhost/vhost.h
> +++ b/drivers/vhost/vhost.h
> @@ -64,7 +64,6 @@ enum vhost_uaddr_type {
>   struct vhost_vring_call {
>   	struct eventfd_ctx *ctx;
>   	struct irq_bypass_producer producer;
> -	spinlock_t ctx_lock;
>   };
>   
>   /* The virtqueue structure describes a queue attached to a device. */


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] vhost_vdpa: remove unnecessary spin_lock in vhost_vring_call
@ 2020-09-09  9:04   ` Jason Wang
  0 siblings, 0 replies; 3+ messages in thread
From: Jason Wang @ 2020-09-09  9:04 UTC (permalink / raw)
  To: Zhu Lingshan, mst; +Cc: netdev, kvm, virtualization


On 2020/9/9 下午2:52, Zhu Lingshan wrote:
> 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>


Acked-by: Jason Wang <jasowang@redhat.com>


> ---
>   drivers/vhost/vdpa.c  | 8 +-------
>   drivers/vhost/vhost.c | 3 ---
>   drivers/vhost/vhost.h | 1 -
>   3 files changed, 1 insertion(+), 11 deletions(-)
>
> diff --git a/drivers/vhost/vdpa.c b/drivers/vhost/vdpa.c
> index 3fab94f88894..bc679d0b7b87 100644
> --- a/drivers/vhost/vdpa.c
> +++ b/drivers/vhost/vdpa.c
> @@ -97,26 +97,20 @@ static void vhost_vdpa_setup_vq_irq(struct vhost_vdpa *v, u16 qid)
>   		return;
>   
>   	irq = ops->get_vq_irq(vdpa, qid);
> -	spin_lock(&vq->call_ctx.ctx_lock);
>   	irq_bypass_unregister_producer(&vq->call_ctx.producer);
> -	if (!vq->call_ctx.ctx || irq < 0) {
> -		spin_unlock(&vq->call_ctx.ctx_lock);
> +	if (!vq->call_ctx.ctx || irq < 0)
>   		return;
> -	}
>   
>   	vq->call_ctx.producer.token = vq->call_ctx.ctx;
>   	vq->call_ctx.producer.irq = irq;
>   	ret = irq_bypass_register_producer(&vq->call_ctx.producer);
> -	spin_unlock(&vq->call_ctx.ctx_lock);
>   }
>   
>   static void vhost_vdpa_unsetup_vq_irq(struct vhost_vdpa *v, u16 qid)
>   {
>   	struct vhost_virtqueue *vq = &v->vqs[qid];
>   
> -	spin_lock(&vq->call_ctx.ctx_lock);
>   	irq_bypass_unregister_producer(&vq->call_ctx.producer);
> -	spin_unlock(&vq->call_ctx.ctx_lock);
>   }
>   
>   static void vhost_vdpa_reset(struct vhost_vdpa *v)
> diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c
> index b45519ca66a7..99f27ce982da 100644
> --- a/drivers/vhost/vhost.c
> +++ b/drivers/vhost/vhost.c
> @@ -302,7 +302,6 @@ static void vhost_vring_call_reset(struct vhost_vring_call *call_ctx)
>   {
>   	call_ctx->ctx = NULL;
>   	memset(&call_ctx->producer, 0x0, sizeof(struct irq_bypass_producer));
> -	spin_lock_init(&call_ctx->ctx_lock);
>   }
>   
>   static void vhost_vq_reset(struct vhost_dev *dev,
> @@ -1637,9 +1636,7 @@ long vhost_vring_ioctl(struct vhost_dev *d, unsigned int ioctl, void __user *arg
>   			break;
>   		}
>   
> -		spin_lock(&vq->call_ctx.ctx_lock);
>   		swap(ctx, vq->call_ctx.ctx);
> -		spin_unlock(&vq->call_ctx.ctx_lock);
>   		break;
>   	case VHOST_SET_VRING_ERR:
>   		if (copy_from_user(&f, argp, sizeof f)) {
> diff --git a/drivers/vhost/vhost.h b/drivers/vhost/vhost.h
> index 9032d3c2a9f4..486dcf371e06 100644
> --- a/drivers/vhost/vhost.h
> +++ b/drivers/vhost/vhost.h
> @@ -64,7 +64,6 @@ enum vhost_uaddr_type {
>   struct vhost_vring_call {
>   	struct eventfd_ctx *ctx;
>   	struct irq_bypass_producer producer;
> -	spinlock_t ctx_lock;
>   };
>   
>   /* The virtqueue structure describes a queue attached to a device. */

_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-09-09  9:05 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-09  6:52 [PATCH] vhost_vdpa: remove unnecessary spin_lock in vhost_vring_call Zhu Lingshan
2020-09-09  9:04 ` Jason Wang
2020-09-09  9:04   ` Jason Wang

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.