mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Wanlong Gao <gaowanlong@cn.fujitsu.com>
To: linux-kernel@vger.kernel.org
Cc: "James E.J. Bottomley" <JBottomley@parallels.com>,
	Paolo Bonzini <pbonzini@redhat.com>,
	Rusty Russell <rusty@rustcorp.com.au>,
	linux-scsi@vger.kernel.org, kvm@vger.kernel.org,
	Wanlong Gao <gaowanlong@cn.fujitsu.com>
Subject: [PATCH 4/5] virtio-scsi: create a separate work queue for virtio-scsi
Date: Wed, 7 Nov 2012 18:18:13 +0800	[thread overview]
Message-ID: <1352283494-31200-5-git-send-email-gaowanlong@cn.fujitsu.com> (raw)
In-Reply-To: <1352283494-31200-1-git-send-email-gaowanlong@cn.fujitsu.com>

Create a separate work queue for virtio-scsi to improve the performance.

Cc: James E.J. Bottomley <JBottomley@parallels.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Rusty Russell <rusty@rustcorp.com.au>
Cc: linux-scsi@vger.kernel.org
Cc: kvm@vger.kernel.org
Signed-off-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>
---
 drivers/scsi/virtio_scsi.c | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/drivers/scsi/virtio_scsi.c b/drivers/scsi/virtio_scsi.c
index 765138a..fc05240 100644
--- a/drivers/scsi/virtio_scsi.c
+++ b/drivers/scsi/virtio_scsi.c
@@ -27,6 +27,8 @@
 #define VIRTIO_SCSI_MEMPOOL_SZ 64
 #define VIRTIO_SCSI_EVENT_LEN 8
 
+struct workqueue_struct *virtscsi_wq;
+
 /* Command queue element */
 struct virtio_scsi_cmd {
 	struct scsi_cmnd *sc;
@@ -337,7 +339,7 @@ static void virtscsi_complete_event(void *buf)
 	struct virtio_scsi_event_node *event_node = buf;
 
 	INIT_WORK(&event_node->work, virtscsi_handle_event);
-	schedule_work(&event_node->work);
+	queue_work(virtscsi_wq, &event_node->work);
 }
 
 static void virtscsi_event_done(struct virtqueue *vq)
@@ -788,6 +790,12 @@ static int __init init(void)
 {
 	int ret = -ENOMEM;
 
+	virtscsi_wq = alloc_workqueue("virtio-scsi", 0, 0);
+	if (!virtscsi_wq) {
+		pr_err("alloc_workqueue() for virtscsi_wq failed\n");
+		goto error;
+	}
+
 	virtscsi_cmd_cache = KMEM_CACHE(virtio_scsi_cmd, 0);
 	if (!virtscsi_cmd_cache) {
 		pr_err("kmem_cache_create() for virtscsi_cmd_cache failed\n");
@@ -817,6 +825,10 @@ error:
 		kmem_cache_destroy(virtscsi_cmd_cache);
 		virtscsi_cmd_cache = NULL;
 	}
+	if (virtscsi_wq) {
+		destroy_workqueue(virtscsi_wq);
+		virtscsi_wq = NULL;
+	}
 	return ret;
 }
 
@@ -825,6 +837,7 @@ static void __exit fini(void)
 	unregister_virtio_driver(&virtio_scsi_driver);
 	mempool_destroy(virtscsi_cmd_pool);
 	kmem_cache_destroy(virtscsi_cmd_cache);
+	destroy_workqueue(virtscsi_wq);
 }
 module_init(init);
 module_exit(fini);
-- 
1.8.0


  parent reply	other threads:[~2012-11-07 10:48 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-07 10:18 [PATCH 0/5] virtio-scsi: create a separate workqueue Wanlong Gao
2012-11-07 10:18 ` [PATCH 1/5] virtio-scsi: remove the useless assignment Wanlong Gao
2012-11-07 10:18 ` [PATCH 2/5] virtio-scsi: remove the needless variable gfp_mask Wanlong Gao
2012-11-07 10:18 ` [PATCH 3/5] virtio-scsi: use pr_err instead of printk Wanlong Gao
2012-11-07 10:18 ` Wanlong Gao [this message]
2012-11-07 10:18 ` [PATCH 5/5] virtio-scsi: tidy up the goto label in init() Wanlong Gao
2012-11-07 12:23 ` [PATCH 0/5] virtio-scsi: create a separate workqueue Asias He
2012-11-07 12:40   ` Wanlong Gao
2012-11-07 22:12 ` Paolo Bonzini
2012-11-07 23:38   ` Wanlong Gao

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=1352283494-31200-5-git-send-email-gaowanlong@cn.fujitsu.com \
    --to=gaowanlong@cn.fujitsu.com \
    --cc=JBottomley@parallels.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=rusty@rustcorp.com.au \
    /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

all inboxes | Powered by JetHome®