From: Emanuele Giuseppe Esposito <eesposit@redhat.com>
To: Paolo Bonzini <pbonzini@redhat.com>,
Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>,
qemu-block@nongnu.org, qemu-devel@nongnu.org
Cc: kwolf@redhat.com, Stefan Hajnoczi <stefanha@redhat.com>,
hreitz@redhat.com
Subject: Re: aio_wait_bh_oneshot() thread-safety question
Date: Tue, 24 May 2022 19:56:51 +0200 [thread overview]
Message-ID: <5debc575-cc9c-57a8-6dae-48ccee55c83d@redhat.com> (raw)
In-Reply-To: <a774787e-46ac-36e0-8573-8adc114df784@redhat.com>
Am 24/05/2022 um 09:08 schrieb Paolo Bonzini:
> On 5/23/22 18:04, Vladimir Sementsov-Ogievskiy wrote:
>>
>> I have a doubt about how aio_wait_bh_oneshot() works. Exactly, I see
>> that data->done is not accessed atomically, and doesn't have any
>> barrier protecting it..
>>
>> Is following possible:
>>
>> main-loop iothread
>> |
>> aio_wait_bh_oneshot() |
>> aio_bh_schedule_oneshot() |
>> | handle bh:
>> | 1. set data->done = true
>> | 2. call aio_wait_kick(), inserting the
>> | dummy bh into main context
>> |
>> ... in AIO_WAIT_WHILE():
>> handle dummy bh, go to next
>> iteration, but still read
>> data->done=false due to some
>> processor data reordering,
>> go to next iteration of polling
>> and hang
> Yes, barriers are missing:
>
> https://lore.kernel.org/qemu-devel/You6FburTi7gVyxy@stefanha-x1.localdomain/T/#md97146c6eae1fce2ddd687fdc3f2215eee03f6f4
>
>
> It seems like the issue was never observed, at least on x86.
>
> Paolo
>
Sent the fix as a separate patch:
https://patchew.org/QEMU/20220524173054.12651-1-eesposit@redhat.com/
Thank you,
Emanuele
prev parent reply other threads:[~2022-05-24 17:58 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-23 16:04 aio_wait_bh_oneshot() thread-safety question Vladimir Sementsov-Ogievskiy
2022-05-24 7:08 ` Paolo Bonzini
2022-05-24 12:40 ` Kevin Wolf
2022-05-24 13:46 ` Vladimir Sementsov-Ogievskiy
2022-05-24 17:21 ` Paolo Bonzini
2022-05-24 17:56 ` Emanuele Giuseppe Esposito [this message]
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=5debc575-cc9c-57a8-6dae-48ccee55c83d@redhat.com \
--to=eesposit@redhat.com \
--cc=hreitz@redhat.com \
--cc=kwolf@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
--cc=vsementsov@yandex-team.ru \
/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).