Skip to content

Commit 073458d

Browse files
stefanhaRHkevmw
authored andcommitted
virtio-blk: remove batch notification BH
There is a batching mechanism for virtio-blk Used Buffer Notifications that is no longer needed because the previous commit added batching to virtio_notify_irqfd(). Note that this mechanism was rarely used in practice because it is only enabled when EVENT_IDX is not negotiated by the driver. Modern drivers enable EVENT_IDX. Reviewed-by: Eric Blake <[email protected]> Signed-off-by: Stefan Hajnoczi <[email protected]> Message-ID: <[email protected]> Reviewed-by: Michael S. Tsirkin <[email protected]> Reviewed-by: Kevin Wolf <[email protected]> Signed-off-by: Kevin Wolf <[email protected]>
1 parent 84d61e5 commit 073458d

File tree

1 file changed

+1
-47
lines changed

1 file changed

+1
-47
lines changed

hw/block/dataplane/virtio-blk.c

+1-47
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,6 @@ struct VirtIOBlockDataPlane {
3131

3232
VirtIOBlkConf *conf;
3333
VirtIODevice *vdev;
34-
QEMUBH *bh; /* bh for guest notification */
35-
unsigned long *batch_notify_vqs;
36-
bool batch_notifications;
3734

3835
/* Note that these EventNotifiers are assigned by value. This is
3936
* fine as long as you do not call event_notifier_cleanup on them
@@ -47,36 +44,7 @@ struct VirtIOBlockDataPlane {
4744
/* Raise an interrupt to signal guest, if necessary */
4845
void virtio_blk_data_plane_notify(VirtIOBlockDataPlane *s, VirtQueue *vq)
4946
{
50-
if (s->batch_notifications) {
51-
set_bit(virtio_get_queue_index(vq), s->batch_notify_vqs);
52-
qemu_bh_schedule(s->bh);
53-
} else {
54-
virtio_notify_irqfd(s->vdev, vq);
55-
}
56-
}
57-
58-
static void notify_guest_bh(void *opaque)
59-
{
60-
VirtIOBlockDataPlane *s = opaque;
61-
unsigned nvqs = s->conf->num_queues;
62-
unsigned long bitmap[BITS_TO_LONGS(nvqs)];
63-
unsigned j;
64-
65-
memcpy(bitmap, s->batch_notify_vqs, sizeof(bitmap));
66-
memset(s->batch_notify_vqs, 0, sizeof(bitmap));
67-
68-
for (j = 0; j < nvqs; j += BITS_PER_LONG) {
69-
unsigned long bits = bitmap[j / BITS_PER_LONG];
70-
71-
while (bits != 0) {
72-
unsigned i = j + ctzl(bits);
73-
VirtQueue *vq = virtio_get_queue(s->vdev, i);
74-
75-
virtio_notify_irqfd(s->vdev, vq);
76-
77-
bits &= bits - 1; /* clear right-most bit */
78-
}
79-
}
47+
virtio_notify_irqfd(s->vdev, vq);
8048
}
8149

8250
/* Context: QEMU global mutex held */
@@ -126,9 +94,6 @@ bool virtio_blk_data_plane_create(VirtIODevice *vdev, VirtIOBlkConf *conf,
12694
} else {
12795
s->ctx = qemu_get_aio_context();
12896
}
129-
s->bh = aio_bh_new_guarded(s->ctx, notify_guest_bh, s,
130-
&DEVICE(vdev)->mem_reentrancy_guard);
131-
s->batch_notify_vqs = bitmap_new(conf->num_queues);
13297

13398
*dataplane = s;
13499

@@ -146,8 +111,6 @@ void virtio_blk_data_plane_destroy(VirtIOBlockDataPlane *s)
146111

147112
vblk = VIRTIO_BLK(s->vdev);
148113
assert(!vblk->dataplane_started);
149-
g_free(s->batch_notify_vqs);
150-
qemu_bh_delete(s->bh);
151114
if (s->iothread) {
152115
object_unref(OBJECT(s->iothread));
153116
}
@@ -173,12 +136,6 @@ int virtio_blk_data_plane_start(VirtIODevice *vdev)
173136

174137
s->starting = true;
175138

176-
if (!virtio_vdev_has_feature(vdev, VIRTIO_RING_F_EVENT_IDX)) {
177-
s->batch_notifications = true;
178-
} else {
179-
s->batch_notifications = false;
180-
}
181-
182139
/* Set up guest notifier (irq) */
183140
r = k->set_guest_notifiers(qbus->parent, nvqs, true);
184141
if (r != 0) {
@@ -370,9 +327,6 @@ void virtio_blk_data_plane_stop(VirtIODevice *vdev)
370327

371328
aio_context_release(s->ctx);
372329

373-
qemu_bh_cancel(s->bh);
374-
notify_guest_bh(s); /* final chance to notify guest */
375-
376330
/* Clean up guest notifier (irq) */
377331
k->set_guest_notifiers(qbus->parent, nvqs, false);
378332

0 commit comments

Comments
 (0)