From: Sasha Levin <levinsasha928@gmail.com>
To: penberg@kernel.org
Cc: john@jfloren.net, kvm@vger.kernel.org, mingo@elte.hu,
asias.hejun@gmail.com, gorcunov@gmail.com,
prasadjoshi124@gmail.com, Sasha Levin <levinsasha928@gmail.com>
Subject: [PATCH 2/4] kvm tools: Use ioeventfd in virtio-blk
Date: Fri, 27 May 2011 13:36:59 +0300 [thread overview]
Message-ID: <1306492621-10208-2-git-send-email-levinsasha928@gmail.com> (raw)
In-Reply-To: <1306492621-10208-1-git-send-email-levinsasha928@gmail.com>
Use ioeventfds to receive notifications of IO events in virtio-blk.
Doing so prevents an exit every time we read/write from/to the
virtio disk.
Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
---
tools/kvm/virtio/blk.c | 26 +++++++++++++++++++++++++-
1 files changed, 25 insertions(+), 1 deletions(-)
diff --git a/tools/kvm/virtio/blk.c b/tools/kvm/virtio/blk.c
index a8f9d8c..eb38038 100644
--- a/tools/kvm/virtio/blk.c
+++ b/tools/kvm/virtio/blk.c
@@ -10,6 +10,7 @@
#include "kvm/kvm.h"
#include "kvm/pci.h"
#include "kvm/threadpool.h"
+#include "kvm/ioeventfd.h"
#include <linux/virtio_ring.h>
#include <linux/virtio_blk.h>
@@ -243,11 +244,19 @@ static struct ioport_operations virtio_blk_io_ops = {
.io_out = virtio_blk_pci_io_out,
};
+static void ioevent_callback(struct kvm *kvm, void *param)
+{
+ struct blk_dev_job *job = param;
+
+ thread_pool__do_job(job->job_id);
+}
+
void virtio_blk__init(struct kvm *kvm, struct disk_image *disk)
{
u16 blk_dev_base_addr;
- u8 dev, pin, line;
+ u8 dev, pin, line, i;
struct blk_dev *bdev;
+ struct ioevent ioevent;
if (!disk)
return;
@@ -293,6 +302,20 @@ void virtio_blk__init(struct kvm *kvm, struct disk_image *disk)
bdev->pci_hdr.irq_line = line;
pci__register(&bdev->pci_hdr, dev);
+
+ for (i = 0; i < NUM_VIRT_QUEUES; i++) {
+ ioevent = (struct ioevent) {
+ .start = blk_dev_base_addr + VIRTIO_PCI_QUEUE_NOTIFY,
+ .len = sizeof(u16),
+ .ioevent_callback_fn = ioevent_callback,
+ .datamatch = i,
+ .ptr = &bdev->jobs[i],
+ .kvm = kvm,
+ .event_fd = eventfd(0, 0),
+ };
+
+ ioeventfd__add_event(kvm, &ioevent);
+ }
}
void virtio_blk__init_all(struct kvm *kvm)
@@ -309,6 +332,7 @@ void virtio_blk__delete_all(struct kvm *kvm)
struct blk_dev *bdev;
bdev = list_first_entry(&bdevs, struct blk_dev, list);
+ ioeventfd__del_event(kvm, bdev->base_addr + VIRTIO_PCI_QUEUE_NOTIFY, 0);
list_del(&bdev->list);
free(bdev);
}
--
1.7.5.rc3
next prev parent reply other threads:[~2011-05-27 10:37 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-05-27 10:36 [PATCH 1/4] kvm tools: Add ioeventfd support Sasha Levin
2011-05-27 10:36 ` Sasha Levin [this message]
2011-05-27 10:37 ` [PATCH 3/4] kvm tools: Use ioeventfd in virtio-net Sasha Levin
2011-05-27 10:37 ` [PATCH 4/4] kvm tools: Use ioeventfd in virtio-rng Sasha Levin
2011-05-27 10:47 ` [PATCH 1/4] kvm tools: Add ioeventfd support Stefan Hajnoczi
2011-05-27 10:57 ` Sasha Levin
2011-05-27 10:52 ` Pekka Enberg
2011-05-27 10:54 ` Ingo Molnar
2011-05-27 11:02 ` Sasha Levin
2011-05-27 11:29 ` Ingo Molnar
2011-05-27 11:30 ` Pekka Enberg
2011-05-27 11:38 ` Ingo Molnar
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=1306492621-10208-2-git-send-email-levinsasha928@gmail.com \
--to=levinsasha928@gmail.com \
--cc=asias.hejun@gmail.com \
--cc=gorcunov@gmail.com \
--cc=john@jfloren.net \
--cc=kvm@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=penberg@kernel.org \
--cc=prasadjoshi124@gmail.com \
/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