qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH v3 2/2] block: disable I/O throttling on sync api
@ 2012-03-30  8:50 zwu.kernel
  2012-03-30 10:29 ` Stefan Hajnoczi
  0 siblings, 1 reply; 6+ messages in thread
From: zwu.kernel @ 2012-03-30  8:50 UTC (permalink / raw)
  To: qemu-devel; +Cc: kwolf, wuzhy, stefanha

From: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>

Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Signed-off-by: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>
---
 block.c |   22 ++++++++++++++++++++++
 1 files changed, 22 insertions(+), 0 deletions(-)

diff --git a/block.c b/block.c
index 1fbf4dd..6de6f89 100644
--- a/block.c
+++ b/block.c
@@ -1477,6 +1477,17 @@ static int bdrv_rw_co(BlockDriverState *bs, int64_t sector_num, uint8_t *buf,
 
     qemu_iovec_init_external(&qiov, &iov, 1);
 
+    /**
+     * In sync call context, when the vcpu is blocked, this throttling timer
+     * will not fire; so the I/O throttling function has to be disabled here
+     * if it has been enabled.
+     */
+    if (bs->io_limits_enabled) {
+        fprintf(stderr, "Disabling I/O throttling on '%s' due "
+                        "to synchronous I/O.\n", bdrv_get_device_name(bs));
+        bdrv_io_limits_disable(bs);
+    }
+
     if (qemu_in_coroutine()) {
         /* Fast-path if already in coroutine context */
         bdrv_rw_co_entry(&rwco);
@@ -1983,10 +1994,21 @@ static int guess_disk_lchs(BlockDriverState *bs,
     struct partition *p;
     uint32_t nr_sects;
     uint64_t nb_sectors;
+    bool enabled;
 
     bdrv_get_geometry(bs, &nb_sectors);
 
+    /**
+     * The function will be invoked during startup not only in sync I/O mode,
+     * but also in async I/O mode. So the I/O throttling function has to
+     * be disabled temporarily here, not permanently.
+     * When all sync I/O drivers are converted to async I/O, it will be restored
+     * to the original state.
+     */
+    enabled = bs->io_limits_enabled;
+    bs->io_limits_enabled = false;
     ret = bdrv_read(bs, 0, buf, 1);
+    bs->io_limits_enabled = enabled;
     if (ret < 0)
         return -1;
     /* test msdos magic */
-- 
1.7.6

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [Qemu-devel] [PATCH v3 2/2] block: disable I/O throttling on sync api
  2012-03-30  8:50 [Qemu-devel] [PATCH v3 2/2] block: disable I/O throttling on sync api zwu.kernel
@ 2012-03-30 10:29 ` Stefan Hajnoczi
  2012-03-31 12:07   ` Zhi Yong Wu
  2012-03-31 12:09   ` Zhi Yong Wu
  0 siblings, 2 replies; 6+ messages in thread
From: Stefan Hajnoczi @ 2012-03-30 10:29 UTC (permalink / raw)
  To: zwu.kernel; +Cc: kwolf, wuzhy, qemu-devel, stefanha

On Fri, Mar 30, 2012 at 9:50 AM,  <zwu.kernel@gmail.com> wrote:
> +     * When all sync I/O drivers are converted to async I/O, it will be restored
> +     * to the original state.

The problem here is that guess_disk_lchs() uses bdrv_read(), not
whether device emulation uses sync or async I/O.  Converting devices
to async I/O will not fix this.

Stefan

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Qemu-devel] [PATCH v3 2/2] block: disable I/O throttling on sync api
  2012-03-30 10:29 ` Stefan Hajnoczi
@ 2012-03-31 12:07   ` Zhi Yong Wu
  2012-04-02  7:31     ` Stefan Hajnoczi
  2012-03-31 12:09   ` Zhi Yong Wu
  1 sibling, 1 reply; 6+ messages in thread
From: Zhi Yong Wu @ 2012-03-31 12:07 UTC (permalink / raw)
  To: Stefan Hajnoczi; +Cc: kwolf, wuzhy, qemu-devel, stefanha

On Fri, Mar 30, 2012 at 6:29 PM, Stefan Hajnoczi <stefanha@gmail.com> wrote:
> On Fri, Mar 30, 2012 at 9:50 AM,  <zwu.kernel@gmail.com> wrote:
>> +     * When all sync I/O drivers are converted to async I/O, it will be restored
>> +     * to the original state.
>
> The problem here is that guess_disk_lchs() uses bdrv_read(), not
> whether device emulation uses sync or async I/O.  Converting devices
> to async I/O will not fix this.
Yeah, but when all sync emulated devices drivers are converted to
async mode, the code change need to be rolled back. This is what i
mean.
>
> Stefan



-- 
Regards,

Zhi Yong Wu

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Qemu-devel] [PATCH v3 2/2] block: disable I/O throttling on sync api
  2012-03-30 10:29 ` Stefan Hajnoczi
  2012-03-31 12:07   ` Zhi Yong Wu
@ 2012-03-31 12:09   ` Zhi Yong Wu
  2012-04-02  7:42     ` Stefan Hajnoczi
  1 sibling, 1 reply; 6+ messages in thread
From: Zhi Yong Wu @ 2012-03-31 12:09 UTC (permalink / raw)
  To: Stefan Hajnoczi; +Cc: kwolf, wuzhy, qemu-devel, stefanha

On Fri, Mar 30, 2012 at 6:29 PM, Stefan Hajnoczi <stefanha@gmail.com> wrote:
> On Fri, Mar 30, 2012 at 9:50 AM,  <zwu.kernel@gmail.com> wrote:
>> +     * When all sync I/O drivers are converted to async I/O, it will be restored
>> +     * to the original state.
>
> The problem here is that guess_disk_lchs() uses bdrv_read(), not
> whether device emulation uses sync or async I/O.  Converting devices
> to async I/O will not fix this.
By the way, when you did testing, you applied #1 of this patchset? I
think that it make sense for that assert issue to be fixed.

>
> Stefan



-- 
Regards,

Zhi Yong Wu

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Qemu-devel] [PATCH v3 2/2] block: disable I/O throttling on sync api
  2012-03-31 12:07   ` Zhi Yong Wu
@ 2012-04-02  7:31     ` Stefan Hajnoczi
  0 siblings, 0 replies; 6+ messages in thread
From: Stefan Hajnoczi @ 2012-04-02  7:31 UTC (permalink / raw)
  To: Zhi Yong Wu; +Cc: kwolf, Stefan Hajnoczi, wuzhy, qemu-devel

On Sat, Mar 31, 2012 at 08:07:25PM +0800, Zhi Yong Wu wrote:
> On Fri, Mar 30, 2012 at 6:29 PM, Stefan Hajnoczi <stefanha@gmail.com> wrote:
> > On Fri, Mar 30, 2012 at 9:50 AM,  <zwu.kernel@gmail.com> wrote:
> >> +     * When all sync I/O drivers are converted to async I/O, it will be restored
> >> +     * to the original state.
> >
> > The problem here is that guess_disk_lchs() uses bdrv_read(), not
> > whether device emulation uses sync or async I/O.  Converting devices
> > to async I/O will not fix this.
> Yeah, but when all sync emulated devices drivers are converted to
> async mode, the code change need to be rolled back. This is what i
> mean.

There are places outside device emulation that call bdrv_read(), like
guest_disk_lchs() and bdrv_commit().  We would need to convert them
before it's safe to remove the code to disable I/O throttling in
bdrv_read()/bdrv_write().

It's not okay to drop the code before all bdrv_read()/bdrv_write()
callers that are in a code path where I/O limits can be enabled have
been fixed (including guest_disk_lchs()) because a request that exceeds
I/O limits would cause QEMU to hang.

Once all devices have been converted it might be possible to temporarily
disable throttling in bdrv_read()/bdrv_write() and never disable it
permanently.  This is because the bdrv_read()/bdrv_write() calls would
only come from QEMU code that is not directly driven by the guest - here
we probably don't need to apply I/O limits anyway.  In other words,
devices use bdrv_aio_*() and I/O limits apply, QEMU internal code might
still use bdrv_read()/bdrv_write() and limits will not apply.

Anyway, I think it's best to drop this part of the comment because it's
more related to the disable code in bdrv_read()/bdrv_write() than to
this patch.

Stefan

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Qemu-devel] [PATCH v3 2/2] block: disable I/O throttling on sync api
  2012-03-31 12:09   ` Zhi Yong Wu
@ 2012-04-02  7:42     ` Stefan Hajnoczi
  0 siblings, 0 replies; 6+ messages in thread
From: Stefan Hajnoczi @ 2012-04-02  7:42 UTC (permalink / raw)
  To: Zhi Yong Wu; +Cc: kwolf, wuzhy, qemu-devel, stefanha

On Sat, Mar 31, 2012 at 08:09:46PM +0800, Zhi Yong Wu wrote:
> On Fri, Mar 30, 2012 at 6:29 PM, Stefan Hajnoczi <stefanha@gmail.com> wrote:
> > On Fri, Mar 30, 2012 at 9:50 AM,  <zwu.kernel@gmail.com> wrote:
> >> +     * When all sync I/O drivers are converted to async I/O, it will be restored
> >> +     * to the original state.
> >
> > The problem here is that guess_disk_lchs() uses bdrv_read(), not
> > whether device emulation uses sync or async I/O.  Converting devices
> > to async I/O will not fix this.
> By the way, when you did testing, you applied #1 of this patchset? I
> think that it make sense for that assert issue to be fixed.

Yes, I applied both patches 1 and 2.

Stefan

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2012-04-02  8:27 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-03-30  8:50 [Qemu-devel] [PATCH v3 2/2] block: disable I/O throttling on sync api zwu.kernel
2012-03-30 10:29 ` Stefan Hajnoczi
2012-03-31 12:07   ` Zhi Yong Wu
2012-04-02  7:31     ` Stefan Hajnoczi
2012-03-31 12:09   ` Zhi Yong Wu
2012-04-02  7:42     ` Stefan Hajnoczi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).