stubdom: optimize block io completion polling
PATCH 1/1 stubdom: optimize block io completion polling
stubdom: optimize block io completion polling
by not polling all the time but just when some requests have completed.
Signed-off-by Samuel Thibault <[email protected]>
extras/mini-os/blkfront.c +4 -0
@@ -370,6 +370,10 @@ moretodo:RING_FINAL_CHECK_FOR_RESPONSES (&dev->ring, more);if (more) goto moretodo; +#ifdef HAVE_LIBC +if (!nr_consumed) + files[dev->fd].read =0 ; +#endif return nr_consumed; }
tools/ioemu/block-vbd.c +7 -3
@@ -67,6 +67,12 @@ static int vbd_probe(const uint8_t *buf,return 100 ; } +static void vbd_io_completed (void *opaque) +{ +BDRVVbdState *s = opaque; +blkfront_aio_poll (s->dev); +} +static int vbd_open (BlockDriverState *bs,const char *filename,int flags) {BDRVVbdState *s = bs->opaque;
@@ -85,6 +91,7 @@ static int vbd_open(BlockDriverState *bs } s->fd =blkfront_open (s->dev); +qemu_set_fd_handler (s->fd, vbd_io_completed,NULL , s);QEMU_LIST_INSERT_HEAD (&vbds, s, list);
@@ -102,9 +109,6 @@ void qemu_aio_init(void)void qemu_aio_poll (void ) { -BDRVVbdState *s; -for (s = vbds.lh_first; s; s = s->list.le_next) -blkfront_aio_poll (s->dev); }/* Wait for all IO requests to complete. */
Quoted 2 lines · Samuel Thibault, le Wed 13 Feb 2008 13:59:59 +0000, a écrit :
stubdom: optimize block io completion polling
by not polling all the time but just when some requests have completed.
Oops, sorry, although it never happened during my tests, I'm pretty sure there is a race, please use this patch instead:
stubdom: optimize block io completion polling
by not polling all the time but just when some requests have completed.
Signed-off-by Samuel Thibault <[email protected]>
extras/mini-os/blkfront.c +5 -0
@@ -327,6 +327,11 @@struct blkif_response *rsp; moretodo: +#ifdef HAVE_LIBC + files[dev->fd].read =0 ; +mb ();/* Make sure to let the handler set read to 1 before we start looking at the ring */ +#endif + rp = dev->ring.sring->rsp_prod;rmb ();/* Ensure we see queued responses up to 'rp'. */ cons = dev->ring.rsp_cons;
tools/ioemu/block-vbd.c +7 -3
@@ -67,6 +67,12 @@return 100 ; } +static void vbd_io_completed (void *opaque) +{ +BDRVVbdState *s = opaque; +blkfront_aio_poll (s->dev); +} +static int vbd_open (BlockDriverState *bs,const char *filename,int flags) {BDRVVbdState *s = bs->opaque;
@@ -85,6 +91,7 @@ } s->fd =blkfront_open (s->dev); +qemu_set_fd_handler (s->fd, vbd_io_completed,NULL , s);QEMU_LIST_INSERT_HEAD (&vbds, s, list);
@@ -102,9 +109,6 @@void qemu_aio_poll (void ) { -BDRVVbdState *s; -for (s = vbds.lh_first; s; s = s->list.le_next) -blkfront_aio_poll (s->dev); }/* Wait for all IO requests to complete. */