* [Qemu-devel] [PULL v2 0/3] Block patches
@ 2018-02-15 9:42 Stefan Hajnoczi
2018-02-15 9:42 ` [Qemu-devel] [PULL v2 1/3] vl: pause vcpus before stopping iothreads Stefan Hajnoczi
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Stefan Hajnoczi @ 2018-02-15 9:42 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-block, Peter Maydell, Stefan Hajnoczi
The following changes since commit bec9c64ef7be8063f1192608b83877bc5c9ea217:
Merge remote-tracking branch 'remotes/bonzini/tags/for-upstream' into staging (2018-02-13 18:24:08 +0000)
are available in the Git repository at:
git://github.com/stefanha/qemu.git tags/block-pull-request
for you to fetch changes up to d2f668b74907cbd96d9df0774971768ed06de2f0:
misc: fix spelling (2018-02-15 09:39:49 +0000)
----------------------------------------------------------------
Pull request
v2:
* Dropped Fam's git-publish series because there is still ongoing discussion
----------------------------------------------------------------
Marc-André Lureau (1):
misc: fix spelling
Stefan Hajnoczi (1):
vl: pause vcpus before stopping iothreads
Wolfgang Bumiller (1):
ratelimit: don't align wait time with slices
include/qemu/ratelimit.h | 11 +++++------
util/qemu-coroutine-lock.c | 2 +-
vl.c | 12 ++++++++++--
3 files changed, 16 insertions(+), 9 deletions(-)
--
2.14.3
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Qemu-devel] [PULL v2 1/3] vl: pause vcpus before stopping iothreads
2018-02-15 9:42 [Qemu-devel] [PULL v2 0/3] Block patches Stefan Hajnoczi
@ 2018-02-15 9:42 ` Stefan Hajnoczi
2018-02-15 9:42 ` [Qemu-devel] [PULL v2 2/3] ratelimit: don't align wait time with slices Stefan Hajnoczi
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Stefan Hajnoczi @ 2018-02-15 9:42 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-block, Peter Maydell, Stefan Hajnoczi
Commit dce8921b2baaf95974af8176406881872067adfa ("iothread: Stop threads
before main() quits") introduced iothread_stop_all() to avoid the
following virtio-scsi assertion failure:
assert(blk_get_aio_context(d->conf.blk) == s->ctx);
Back then the assertion failed because when bdrv_close_all() made
d->conf.blk NULL, blk_get_aio_context() returned the global AioContext
instead of s->ctx.
The same assertion can still fail today when vcpus submit new I/O
requests after iothread_stop_all() has moved the BDS to the global
AioContext.
This patch hardens the iothread_stop_all() approach by pausing vcpus
before calling iothread_stop_all().
Note that the assertion failure is a race condition. It is not possible
to reproduce it reliably.
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Message-id: 20180201110708.8080-1-stefanha@redhat.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
vl.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/vl.c b/vl.c
index 21878496ec..7a5554bc41 100644
--- a/vl.c
+++ b/vl.c
@@ -4767,10 +4767,18 @@ int main(int argc, char **argv, char **envp)
main_loop();
replay_disable_events();
+
+ /* The ordering of the following is delicate. Stop vcpus to prevent new
+ * I/O requests being queued by the guest. Then stop IOThreads (this
+ * includes a drain operation and completes all request processing). At
+ * this point emulated devices are still associated with their IOThreads
+ * (if any) but no longer have any work to do. Only then can we close
+ * block devices safely because we know there is no more I/O coming.
+ */
+ pause_all_vcpus();
iothread_stop_all();
-
- pause_all_vcpus();
bdrv_close_all();
+
res_free();
/* vhost-user must be cleaned up before chardevs. */
--
2.14.3
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [Qemu-devel] [PULL v2 2/3] ratelimit: don't align wait time with slices
2018-02-15 9:42 [Qemu-devel] [PULL v2 0/3] Block patches Stefan Hajnoczi
2018-02-15 9:42 ` [Qemu-devel] [PULL v2 1/3] vl: pause vcpus before stopping iothreads Stefan Hajnoczi
@ 2018-02-15 9:42 ` Stefan Hajnoczi
2018-02-15 9:42 ` [Qemu-devel] [PULL v2 3/3] misc: fix spelling Stefan Hajnoczi
2018-02-15 17:16 ` [Qemu-devel] [PULL v2 0/3] Block patches Peter Maydell
3 siblings, 0 replies; 5+ messages in thread
From: Stefan Hajnoczi @ 2018-02-15 9:42 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-block, Peter Maydell, Wolfgang Bumiller, Stefan Hajnoczi
From: Wolfgang Bumiller <w.bumiller@proxmox.com>
It is possible for rate limited writes to keep overshooting a slice's
quota by a tiny amount causing the slice-aligned waiting period to
effectively halve the rate.
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
Reviewed-by: Alberto Garcia <berto@igalia.com>
Message-id: 20180207071758.6818-1-w.bumiller@proxmox.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
include/qemu/ratelimit.h | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/include/qemu/ratelimit.h b/include/qemu/ratelimit.h
index 8dece483f5..1b38291823 100644
--- a/include/qemu/ratelimit.h
+++ b/include/qemu/ratelimit.h
@@ -36,7 +36,7 @@ typedef struct {
static inline int64_t ratelimit_calculate_delay(RateLimit *limit, uint64_t n)
{
int64_t now = qemu_clock_get_ns(QEMU_CLOCK_REALTIME);
- uint64_t delay_slices;
+ double delay_slices;
assert(limit->slice_quota && limit->slice_ns);
@@ -55,12 +55,11 @@ static inline int64_t ratelimit_calculate_delay(RateLimit *limit, uint64_t n)
return 0;
}
- /* Quota exceeded. Calculate the next time slice we may start
- * sending data again. */
- delay_slices = (limit->dispatched + limit->slice_quota - 1) /
- limit->slice_quota;
+ /* Quota exceeded. Wait based on the excess amount and then start a new
+ * slice. */
+ delay_slices = (double)limit->dispatched / limit->slice_quota;
limit->slice_end_time = limit->slice_start_time +
- delay_slices * limit->slice_ns;
+ (uint64_t)(delay_slices * limit->slice_ns);
return limit->slice_end_time - now;
}
--
2.14.3
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [Qemu-devel] [PULL v2 3/3] misc: fix spelling
2018-02-15 9:42 [Qemu-devel] [PULL v2 0/3] Block patches Stefan Hajnoczi
2018-02-15 9:42 ` [Qemu-devel] [PULL v2 1/3] vl: pause vcpus before stopping iothreads Stefan Hajnoczi
2018-02-15 9:42 ` [Qemu-devel] [PULL v2 2/3] ratelimit: don't align wait time with slices Stefan Hajnoczi
@ 2018-02-15 9:42 ` Stefan Hajnoczi
2018-02-15 17:16 ` [Qemu-devel] [PULL v2 0/3] Block patches Peter Maydell
3 siblings, 0 replies; 5+ messages in thread
From: Stefan Hajnoczi @ 2018-02-15 9:42 UTC (permalink / raw)
To: qemu-devel
Cc: qemu-block, Peter Maydell, Marc-André Lureau,
Stefan Hajnoczi
From: Marc-André Lureau <marcandre.lureau@redhat.com>
s/pupulate/populate
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Message-id: 20180208162447.10851-1-marcandre.lureau@redhat.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
util/qemu-coroutine-lock.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/util/qemu-coroutine-lock.c b/util/qemu-coroutine-lock.c
index 78fb79acf8..5a80c10690 100644
--- a/util/qemu-coroutine-lock.c
+++ b/util/qemu-coroutine-lock.c
@@ -89,7 +89,7 @@ void qemu_co_queue_run_restart(Coroutine *co)
* invalid memory. Therefore, use a temporary queue and do not touch
* the "co" coroutine as soon as you enter another one.
*
- * In its turn resumed "co" can pupulate "co_queue_wakeup" queue with
+ * In its turn resumed "co" can populate "co_queue_wakeup" queue with
* new coroutines to be woken up. The caller, who has resumed "co",
* will be responsible for traversing the same queue, which may cause
* a different wakeup order but not any missing wakeups.
--
2.14.3
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [PULL v2 0/3] Block patches
2018-02-15 9:42 [Qemu-devel] [PULL v2 0/3] Block patches Stefan Hajnoczi
` (2 preceding siblings ...)
2018-02-15 9:42 ` [Qemu-devel] [PULL v2 3/3] misc: fix spelling Stefan Hajnoczi
@ 2018-02-15 17:16 ` Peter Maydell
3 siblings, 0 replies; 5+ messages in thread
From: Peter Maydell @ 2018-02-15 17:16 UTC (permalink / raw)
To: Stefan Hajnoczi; +Cc: QEMU Developers, Qemu-block
On 15 February 2018 at 09:42, Stefan Hajnoczi <stefanha@redhat.com> wrote:
> The following changes since commit bec9c64ef7be8063f1192608b83877bc5c9ea217:
>
> Merge remote-tracking branch 'remotes/bonzini/tags/for-upstream' into staging (2018-02-13 18:24:08 +0000)
>
> are available in the Git repository at:
>
> git://github.com/stefanha/qemu.git tags/block-pull-request
>
> for you to fetch changes up to d2f668b74907cbd96d9df0774971768ed06de2f0:
>
> misc: fix spelling (2018-02-15 09:39:49 +0000)
>
> ----------------------------------------------------------------
> Pull request
>
> v2:
> * Dropped Fam's git-publish series because there is still ongoing discussion
>
> ----------------------------------------------------------------
>
> Marc-André Lureau (1):
> misc: fix spelling
>
> Stefan Hajnoczi (1):
> vl: pause vcpus before stopping iothreads
>
> Wolfgang Bumiller (1):
> ratelimit: don't align wait time with slices
>
> include/qemu/ratelimit.h | 11 +++++------
> util/qemu-coroutine-lock.c | 2 +-
> vl.c | 12 ++++++++++--
> 3 files changed, 16 insertions(+), 9 deletions(-)
Applied, thanks.
-- PMM
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2018-02-15 17:16 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-02-15 9:42 [Qemu-devel] [PULL v2 0/3] Block patches Stefan Hajnoczi
2018-02-15 9:42 ` [Qemu-devel] [PULL v2 1/3] vl: pause vcpus before stopping iothreads Stefan Hajnoczi
2018-02-15 9:42 ` [Qemu-devel] [PULL v2 2/3] ratelimit: don't align wait time with slices Stefan Hajnoczi
2018-02-15 9:42 ` [Qemu-devel] [PULL v2 3/3] misc: fix spelling Stefan Hajnoczi
2018-02-15 17:16 ` [Qemu-devel] [PULL v2 0/3] Block patches Peter Maydell
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).