qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH 10/18] virtio-blk: use bitmap_foreach


From: Marc-André Lureau
Subject: [Qemu-devel] [PATCH 10/18] virtio-blk: use bitmap_foreach
Date: Mon, 5 Sep 2016 02:20:31 +0400

Signed-off-by: Marc-André Lureau <address@hidden>
---
 hw/block/dataplane/virtio-blk.c | 29 +++++++++++------------------
 1 file changed, 11 insertions(+), 18 deletions(-)

diff --git a/hw/block/dataplane/virtio-blk.c b/hw/block/dataplane/virtio-blk.c
index 704a763..dce2675 100644
--- a/hw/block/dataplane/virtio-blk.c
+++ b/hw/block/dataplane/virtio-blk.c
@@ -51,30 +51,23 @@ void virtio_blk_data_plane_notify(VirtIOBlockDataPlane *s, 
VirtQueue *vq)
     qemu_bh_schedule(s->bh);
 }
 
-static void notify_guest_bh(void *opaque)
+static void notify_vq(int i, void *opaque)
 {
     VirtIOBlockDataPlane *s = opaque;
-    unsigned nvqs = s->conf->num_queues;
-    unsigned long bitmap[BITS_TO_LONGS(nvqs)];
-    unsigned j;
-
-    memcpy(bitmap, s->batch_notify_vqs, sizeof(bitmap));
-    memset(s->batch_notify_vqs, 0, sizeof(bitmap));
+    VirtQueue *vq = virtio_get_queue(s->vdev, i);
 
-    for (j = 0; j < nvqs; j += BITS_PER_LONG) {
-        unsigned long bits = bitmap[j];
+    if (virtio_should_notify(s->vdev, vq)) {
+        event_notifier_set(virtio_queue_get_guest_notifier(vq));
+    }
 
-        while (bits != 0) {
-            unsigned i = j + ctzl(bits);
-            VirtQueue *vq = virtio_get_queue(s->vdev, i);
+}
 
-            if (virtio_should_notify(s->vdev, vq)) {
-                event_notifier_set(virtio_queue_get_guest_notifier(vq));
-            }
+static void notify_guest_bh(void *opaque)
+{
+    VirtIOBlockDataPlane *s = opaque;
+    unsigned nvqs = s->conf->num_queues;
 
-            bits &= bits - 1; /* clear right-most bit */
-        }
-    }
+    bitmap_foreach(s->batch_notify_vqs, nvqs, notify_vq, s);
 }
 
 /* Context: QEMU global mutex held */
-- 
2.9.0




reply via email to

[Prev in Thread] Current Thread [Next in Thread]