From: Xie Yongji <xieyongji@bytedance.com>
To: mst@redhat.com, jasowang@redhat.com, stefanha@redhat.com,
sgarzare@redhat.com, parav@nvidia.com, bob.liu@oracle.com,
hch@infradead.org, rdunlap@infradead.org, willy@infradead.org,
viro@zeniv.linux.org.uk, axboe@kernel.dk, bcrl@kvack.org,
corbet@lwn.net
Cc: virtualization@lists.linux-foundation.org,
netdev@vger.kernel.org, kvm@vger.kernel.org, linux-aio@kvack.org,
linux-fsdevel@vger.kernel.org
Subject: [RFC v4 10/11] vduse: Introduce a workqueue for irq injection
Date: Tue, 23 Feb 2021 19:50:47 +0800 [thread overview]
Message-ID: <20210223115048.435-11-xieyongji@bytedance.com> (raw)
In-Reply-To: <20210223115048.435-1-xieyongji@bytedance.com>
This patch introduces a workqueue to support injecting
virtqueue's interrupt asynchronously. This is mainly
for performance considerations which makes sure the push()
and pop() for used vring can be asynchronous.
Signed-off-by: Xie Yongji <xieyongji@bytedance.com>
---
drivers/vdpa/vdpa_user/vduse_dev.c | 29 +++++++++++++++++++++++------
1 file changed, 23 insertions(+), 6 deletions(-)
diff --git a/drivers/vdpa/vdpa_user/vduse_dev.c b/drivers/vdpa/vdpa_user/vduse_dev.c
index 8042d3fa57f1..f5adeb9ee027 100644
--- a/drivers/vdpa/vdpa_user/vduse_dev.c
+++ b/drivers/vdpa/vdpa_user/vduse_dev.c
@@ -42,6 +42,7 @@ struct vduse_virtqueue {
spinlock_t irq_lock;
struct eventfd_ctx *kickfd;
struct vdpa_callback cb;
+ struct work_struct inject;
};
struct vduse_dev;
@@ -99,6 +100,7 @@ static DEFINE_IDA(vduse_ida);
static dev_t vduse_major;
static struct class *vduse_class;
+static struct workqueue_struct *vduse_irq_wq;
static inline struct vduse_dev *vdpa_to_vduse(struct vdpa_device *vdpa)
{
@@ -852,6 +854,17 @@ static int vduse_kickfd_setup(struct vduse_dev *dev,
return 0;
}
+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);
+ if (vq->ready && vq->cb.callback)
+ vq->cb.callback(vq->cb.private);
+ spin_unlock_irq(&vq->irq_lock);
+}
+
static long vduse_dev_ioctl(struct file *file, unsigned int cmd,
unsigned long arg)
{
@@ -917,12 +930,7 @@ static long vduse_dev_ioctl(struct file *file, unsigned int cmd,
break;
vq = &dev->vqs[arg];
- spin_lock_irq(&vq->irq_lock);
- if (vq->ready && vq->cb.callback) {
- vq->cb.callback(vq->cb.private);
- ret = 0;
- }
- spin_unlock_irq(&vq->irq_lock);
+ queue_work(vduse_irq_wq, &vq->inject);
break;
}
case VDUSE_INJECT_CONFIG_IRQ:
@@ -1109,6 +1117,7 @@ static int vduse_create_dev(struct vduse_dev_config *config)
for (i = 0; i < dev->vq_num; i++) {
dev->vqs[i].index = i;
+ INIT_WORK(&dev->vqs[i].inject, vduse_vq_irq_inject);
spin_lock_init(&dev->vqs[i].kick_lock);
spin_lock_init(&dev->vqs[i].irq_lock);
}
@@ -1333,6 +1342,11 @@ static int vduse_init(void)
if (ret)
goto err_chardev;
+ vduse_irq_wq = alloc_workqueue("vduse-irq",
+ WQ_HIGHPRI | WQ_SYSFS | WQ_UNBOUND, 0);
+ if (!vduse_irq_wq)
+ goto err_wq;
+
ret = vduse_domain_init();
if (ret)
goto err_domain;
@@ -1344,6 +1358,8 @@ static int vduse_init(void)
return 0;
err_mgmtdev:
vduse_domain_exit();
+err_wq:
+ destroy_workqueue(vduse_irq_wq);
err_domain:
unregister_chrdev_region(vduse_major, VDUSE_DEV_MAX);
err_chardev:
@@ -1359,6 +1375,7 @@ static void vduse_exit(void)
misc_deregister(&vduse_misc);
class_destroy(vduse_class);
unregister_chrdev_region(vduse_major, VDUSE_DEV_MAX);
+ destroy_workqueue(vduse_irq_wq);
vduse_domain_exit();
vduse_mgmtdev_exit();
}
--
2.11.0
next prev parent reply other threads:[~2021-02-23 12:01 UTC|newest]
Thread overview: 65+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-23 11:50 [RFC v4 00/11] Introduce VDUSE - vDPA Device in Userspace Xie Yongji
2021-02-23 11:50 ` [RFC v4 01/11] eventfd: Increase the recursion depth of eventfd_signal() Xie Yongji
2021-03-02 6:44 ` Jason Wang
2021-03-02 10:32 ` Yongji Xie
2021-02-23 11:50 ` [RFC v4 02/11] vhost-vdpa: protect concurrent access to vhost device iotlb Xie Yongji
2021-03-02 6:47 ` Jason Wang
2021-03-02 10:20 ` Yongji Xie
2021-02-23 11:50 ` [RFC v4 03/11] vhost-iotlb: Add an opaque pointer for vhost IOTLB Xie Yongji
2021-03-02 6:49 ` Jason Wang
2021-02-23 11:50 ` [RFC v4 04/11] vdpa: Add an opaque pointer for vdpa_config_ops.dma_map() Xie Yongji
2021-03-02 6:50 ` Jason Wang
2021-02-23 11:50 ` [RFC v4 05/11] vdpa: Support transferring virtual addressing during DMA mapping Xie Yongji
2021-03-03 10:52 ` Mika Penttilä
2021-03-03 12:45 ` Yongji Xie
2021-03-03 13:38 ` Mika Penttilä
2021-03-04 3:07 ` Jason Wang
2021-03-04 5:40 ` Yongji Xie
2021-02-23 11:50 ` [RFC v4 06/11] vduse: Implement an MMU-based IOMMU driver Xie Yongji
2021-03-04 4:20 ` Jason Wang
2021-03-04 5:12 ` Yongji Xie
2021-03-05 3:35 ` Jason Wang
2021-03-05 6:15 ` Yongji Xie
[not found] ` <4db35f8c-ee3a-90fb-8d14-5d6014b4f6fa@redhat.com>
2021-03-05 7:13 ` Yongji Xie
2021-03-05 7:27 ` Jason Wang
2021-03-05 7:59 ` Yongji Xie
2021-03-08 3:17 ` Jason Wang
2021-03-08 3:45 ` Yongji Xie
2021-03-08 3:52 ` Jason Wang
2021-03-08 5:05 ` Yongji Xie
2021-03-08 7:04 ` Jason Wang
2021-03-08 7:08 ` Yongji Xie
2021-02-23 11:50 ` [RFC v4 07/11] vduse: Introduce VDUSE - vDPA Device in Userspace Xie Yongji
2021-03-04 6:27 ` Jason Wang
2021-03-04 8:05 ` Yongji Xie
2021-03-05 3:20 ` Jason Wang
2021-03-05 3:49 ` Yongji Xie
2021-03-10 12:58 ` Jason Wang
2021-03-11 2:28 ` Yongji Xie
2021-02-23 11:50 ` [RFC v4 08/11] vduse: Add config interrupt support Xie Yongji
2021-02-23 11:50 ` [RFC v4 09/11] Documentation: Add documentation for VDUSE Xie Yongji
2021-03-04 6:39 ` Jason Wang
2021-03-04 10:35 ` Yongji Xie
2021-02-23 11:50 ` Xie Yongji [this message]
2021-03-04 6:59 ` [RFC v4 10/11] vduse: Introduce a workqueue for irq injection Jason Wang
2021-03-04 8:58 ` Yongji Xie
2021-03-05 3:04 ` Jason Wang
2021-03-05 3:30 ` Yongji Xie
2021-03-05 3:42 ` Jason Wang
2021-03-05 6:36 ` Yongji Xie
2021-03-05 7:01 ` Jason Wang
2021-03-05 7:27 ` Yongji Xie
2021-03-05 7:36 ` Jason Wang
2021-03-05 8:12 ` Yongji Xie
2021-03-08 3:04 ` Jason Wang
2021-03-08 4:50 ` Yongji Xie
2021-03-08 7:01 ` Jason Wang
2021-03-08 7:16 ` Yongji Xie
2021-03-08 7:29 ` Jason Wang
2021-02-23 11:50 ` [RFC v4 11/11] vduse: Support binding irq to the specified cpu Xie Yongji
2021-03-04 7:30 ` Jason Wang
2021-03-04 8:19 ` Yongji Xie
2021-03-05 3:11 ` Jason Wang
2021-03-05 3:37 ` Yongji Xie
2021-03-05 3:44 ` Jason Wang
2021-03-05 6:40 ` Yongji Xie
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210223115048.435-11-xieyongji@bytedance.com \
--to=xieyongji@bytedance.com \
--cc=axboe@kernel.dk \
--cc=bcrl@kvack.org \
--cc=bob.liu@oracle.com \
--cc=corbet@lwn.net \
--cc=hch@infradead.org \
--cc=jasowang@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=linux-aio@kvack.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=mst@redhat.com \
--cc=netdev@vger.kernel.org \
--cc=parav@nvidia.com \
--cc=rdunlap@infradead.org \
--cc=sgarzare@redhat.com \
--cc=stefanha@redhat.com \
--cc=viro@zeniv.linux.org.uk \
--cc=virtualization@lists.linux-foundation.org \
--cc=willy@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).