diff mbox series

vduse: Use proper spinlock for IRQ injection

Message ID 20230705114505.63274-1-maxime.coquelin@redhat.com (mailing list archive)
State Not Applicable
Headers show
Series vduse: Use proper spinlock for IRQ injection | expand

Checks

Context Check Description
netdev/tree_selection success Not a local patch

Commit Message

Maxime Coquelin July 5, 2023, 11:45 a.m. UTC
The IRQ injection work used spin_lock_irq() to protect the
scheduling of the softirq, but spin_lock_bh() should be
used.

With spin_lock_irq(), we noticed delay of more than 6
seconds between the time a NAPI polling work is scheduled
and the time it is executed.

Fixes: c8a6153b6c59 ("vduse: Introduce VDUSE - vDPA Device in Userspace")
Cc: xieyongji@bytedance.com

Suggested-by: Jason Wang <jasowang@redhat.com>
Signed-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>
---
 drivers/vdpa/vdpa_user/vduse_dev.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Comments

Jason Wang July 26, 2023, 5:38 a.m. UTC | #1
On Wed, Jul 5, 2023 at 7:45 PM Maxime Coquelin
<maxime.coquelin@redhat.com> wrote:
>
> The IRQ injection work used spin_lock_irq() to protect the
> scheduling of the softirq, but spin_lock_bh() should be
> used.
>
> With spin_lock_irq(), we noticed delay of more than 6
> seconds between the time a NAPI polling work is scheduled
> and the time it is executed.
>
> Fixes: c8a6153b6c59 ("vduse: Introduce VDUSE - vDPA Device in Userspace")
> Cc: xieyongji@bytedance.com
>
> Suggested-by: Jason Wang <jasowang@redhat.com>
> Signed-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>

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

Thanks


> ---
>  drivers/vdpa/vdpa_user/vduse_dev.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/vdpa/vdpa_user/vduse_dev.c b/drivers/vdpa/vdpa_user/vduse_dev.c
> index dc38ed21319d..df7869537ef1 100644
> --- a/drivers/vdpa/vdpa_user/vduse_dev.c
> +++ b/drivers/vdpa/vdpa_user/vduse_dev.c
> @@ -935,10 +935,10 @@ static void vduse_dev_irq_inject(struct work_struct *work)
>  {
>         struct vduse_dev *dev = container_of(work, struct vduse_dev, inject);
>
> -       spin_lock_irq(&dev->irq_lock);
> +       spin_lock_bh(&dev->irq_lock);
>         if (dev->config_cb.callback)
>                 dev->config_cb.callback(dev->config_cb.private);
> -       spin_unlock_irq(&dev->irq_lock);
> +       spin_unlock_bh(&dev->irq_lock);
>  }
>
>  static void vduse_vq_irq_inject(struct work_struct *work)
> @@ -946,10 +946,10 @@ static void vduse_vq_irq_inject(struct work_struct *work)
>         struct vduse_virtqueue *vq = container_of(work,
>                                         struct vduse_virtqueue, inject);
>
> -       spin_lock_irq(&vq->irq_lock);
> +       spin_lock_bh(&vq->irq_lock);
>         if (vq->ready && vq->cb.callback)
>                 vq->cb.callback(vq->cb.private);
> -       spin_unlock_irq(&vq->irq_lock);
> +       spin_unlock_bh(&vq->irq_lock);
>  }
>
>  static bool vduse_vq_signal_irqfd(struct vduse_virtqueue *vq)
> --
> 2.41.0
>
Yongji Xie July 31, 2023, 2:24 a.m. UTC | #2
On Wed, Jul 5, 2023 at 7:45 PM Maxime Coquelin
<maxime.coquelin@redhat.com> wrote:
>
> The IRQ injection work used spin_lock_irq() to protect the
> scheduling of the softirq, but spin_lock_bh() should be
> used.
>
> With spin_lock_irq(), we noticed delay of more than 6
> seconds between the time a NAPI polling work is scheduled
> and the time it is executed.
>
> Fixes: c8a6153b6c59 ("vduse: Introduce VDUSE - vDPA Device in Userspace")
> Cc: xieyongji@bytedance.com
>
> Suggested-by: Jason Wang <jasowang@redhat.com>
> Signed-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>

Reviewed-by: Xie Yongji <xieyongji@bytedance.com>

Thanks,
Yongji
diff mbox series

Patch

diff --git a/drivers/vdpa/vdpa_user/vduse_dev.c b/drivers/vdpa/vdpa_user/vduse_dev.c
index dc38ed21319d..df7869537ef1 100644
--- a/drivers/vdpa/vdpa_user/vduse_dev.c
+++ b/drivers/vdpa/vdpa_user/vduse_dev.c
@@ -935,10 +935,10 @@  static void vduse_dev_irq_inject(struct work_struct *work)
 {
 	struct vduse_dev *dev = container_of(work, struct vduse_dev, inject);
 
-	spin_lock_irq(&dev->irq_lock);
+	spin_lock_bh(&dev->irq_lock);
 	if (dev->config_cb.callback)
 		dev->config_cb.callback(dev->config_cb.private);
-	spin_unlock_irq(&dev->irq_lock);
+	spin_unlock_bh(&dev->irq_lock);
 }
 
 static void vduse_vq_irq_inject(struct work_struct *work)
@@ -946,10 +946,10 @@  static void vduse_vq_irq_inject(struct work_struct *work)
 	struct vduse_virtqueue *vq = container_of(work,
 					struct vduse_virtqueue, inject);
 
-	spin_lock_irq(&vq->irq_lock);
+	spin_lock_bh(&vq->irq_lock);
 	if (vq->ready && vq->cb.callback)
 		vq->cb.callback(vq->cb.private);
-	spin_unlock_irq(&vq->irq_lock);
+	spin_unlock_bh(&vq->irq_lock);
 }
 
 static bool vduse_vq_signal_irqfd(struct vduse_virtqueue *vq)