[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-block] [PATCH v2 5/6] iothread: fix iothread_stop() race condi
From: |
Eric Blake |
Subject: |
Re: [Qemu-block] [PATCH v2 5/6] iothread: fix iothread_stop() race condition |
Date: |
Thu, 7 Dec 2017 16:42:16 -0600 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 |
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 <address@hidden>
> ---
> 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 <address@hidden>
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3266
Virtualization: qemu.org | libvirt.org
signature.asc
Description: OpenPGP digital signature
- [Qemu-block] [PATCH v2 0/6] block: avoid recursive AioContext acquire in bdrv_inactivate_all(), Stefan Hajnoczi, 2017/12/07
- [Qemu-block] [PATCH v2 2/6] docs: mark nested AioContext locking as a legacy API, Stefan Hajnoczi, 2017/12/07
- [Qemu-block] [PATCH v2 1/6] block: avoid recursive AioContext acquire in bdrv_inactivate_all(), Stefan Hajnoczi, 2017/12/07
- [Qemu-block] [PATCH v2 3/6] blockdev: add x-blockdev-set-iothread force boolean, Stefan Hajnoczi, 2017/12/07
- [Qemu-block] [PATCH v2 4/6] iotests: add VM.add_object(), Stefan Hajnoczi, 2017/12/07
- [Qemu-block] [PATCH v2 5/6] iothread: fix iothread_stop() race condition, Stefan Hajnoczi, 2017/12/07
- Re: [Qemu-block] [PATCH v2 5/6] iothread: fix iothread_stop() race condition,
Eric Blake <=
- [Qemu-block] [PATCH v2 6/6] qemu-iotests: add 203 savevm with IOThreads test, Stefan Hajnoczi, 2017/12/07
- Re: [Qemu-block] [PATCH v2 0/6] block: avoid recursive AioContext acquire in bdrv_inactivate_all(), Paolo Bonzini, 2017/12/13
- Re: [Qemu-block] [PATCH v2 0/6] block: avoid recursive AioContext acquire in bdrv_inactivate_all(), Stefan Hajnoczi, 2017/12/14