qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Eric Blake <eblake@redhat.com>
To: Stefan Hajnoczi <stefanha@redhat.com>, qemu-devel@nongnu.org
Cc: qemu-block@nongnu.org, Kevin Wolf <kwolf@redhat.com>,
	Paolo Bonzini <pbonzini@redhat.com>
Subject: Re: [Qemu-devel] [PATCH v2 5/6] iothread: fix iothread_stop() race condition
Date: Thu, 7 Dec 2017 16:42:16 -0600	[thread overview]
Message-ID: <54bf1d3e-4417-4f7e-74e6-ff8d69621643@redhat.com> (raw)
In-Reply-To: <20171207201320.19284-6-stefanha@redhat.com>

[-- Attachment #1: Type: text/plain, Size: 1430 bytes --]

On 12/07/2017 02:13 PM, Stefan Hajnoczi wrote:
> There is a small chance that iothread_stop() hangs as follows:
> 

> 
> The bug is explained by the AioContext->notify_me doc comments:
> 
>   "If this field is 0, everything (file descriptors, bottom halves,
>   timers) will be re-evaluated before the next blocking poll(), thus the
>   event_notifier_set call can be skipped."
> 
> The problem is that "everything" does not include checking
> iothread->stopping.  This means iothread_run() will block in aio_poll()
> if aio_notify() was called just before aio_poll().
> 
> This patch fixes the hang by replacing aio_notify() with
> aio_bh_schedule_oneshot().  This makes aio_poll() or g_main_loop_run()
> to return.

s/to //

> 
> Implementing this properly required a new bool running flag.  The new
> flag prevents races that are tricky if we try to use iothread->stopping.
> Now iothread->stopping is purely for iothread_stop() and
> iothread->running is purely for the iothread_run() thread.
> 
> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
> ---
> I'm including this patch in this series because it is needed to make the
> test case reliable.  It's unrelated to the main goal of the patch
> series.
> ---
Reviewed-by: Eric Blake <eblake@redhat.com>

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 619 bytes --]

  reply	other threads:[~2017-12-07 22:42 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-07 20:13 [Qemu-devel] [PATCH v2 0/6] block: avoid recursive AioContext acquire in bdrv_inactivate_all() Stefan Hajnoczi
2017-12-07 20:13 ` [Qemu-devel] [PATCH v2 1/6] " Stefan Hajnoczi
2017-12-07 22:04   ` Eric Blake
2017-12-07 20:13 ` [Qemu-devel] [PATCH v2 2/6] docs: mark nested AioContext locking as a legacy API Stefan Hajnoczi
2017-12-07 22:34   ` Eric Blake
2017-12-07 20:13 ` [Qemu-devel] [PATCH v2 3/6] blockdev: add x-blockdev-set-iothread force boolean Stefan Hajnoczi
2017-12-07 22:38   ` Eric Blake
2017-12-07 20:13 ` [Qemu-devel] [PATCH v2 4/6] iotests: add VM.add_object() Stefan Hajnoczi
2017-12-07 22:39   ` Eric Blake
2017-12-07 20:13 ` [Qemu-devel] [PATCH v2 5/6] iothread: fix iothread_stop() race condition Stefan Hajnoczi
2017-12-07 22:42   ` Eric Blake [this message]
2017-12-07 20:13 ` [Qemu-devel] [PATCH v2 6/6] qemu-iotests: add 203 savevm with IOThreads test Stefan Hajnoczi
2017-12-07 22:46   ` Eric Blake
2017-12-13 21:23 ` [Qemu-devel] [PATCH v2 0/6] block: avoid recursive AioContext acquire in bdrv_inactivate_all() Paolo Bonzini
2017-12-14 11:12 ` Stefan Hajnoczi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=54bf1d3e-4417-4f7e-74e6-ff8d69621643@redhat.com \
    --to=eblake@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).