From: Paolo Bonzini <pbonzini@redhat.com>
To: Kevin Wolf <kwolf@redhat.com>
Cc: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>,
qemu-block@nongnu.org, qemu-devel@nongnu.org,
Stefan Hajnoczi <stefanha@redhat.com>,
hreitz@redhat.com,
Emanuele Giuseppe Esposito <eesposit@redhat.com>
Subject: Re: aio_wait_bh_oneshot() thread-safety question
Date: Tue, 24 May 2022 19:21:37 +0200 [thread overview]
Message-ID: <84c5fad5-9e8c-84df-9aad-90ab1b79a5db@redhat.com> (raw)
In-Reply-To: <YozSW5PT4L//qVOk@redhat.com>
On 5/24/22 14:40, Kevin Wolf wrote:
> Why is the barrier in aio_bh_enqueue() not enough? Is the comment there
> wrong?
>
> aio_notify() has another barrier. This is a little bit too late, but if
> I misunderstood the aio_bh_enqueue() one, it could explain why it was
> never observed.
The missing one that I (and I think Vladimir) were talking about is at the
end of the execution of the bottom half, not at the beginning:
/* Context: BH in IOThread */
static void aio_wait_bh(void *opaque)
{
AioWaitBHData *data = opaque;
data->cb(data->opaque);
data->done = true;
aio_wait_kick();
}
void aio_wait_kick(void)
{
/* The barrier (or an atomic op) is in the caller. */
if (qatomic_read(&global_aio_wait.num_waiters)) {
aio_bh_schedule_oneshot(qemu_get_aio_context(), dummy_bh_cb, NULL);
}
}
where there is no barrier in the caller to separate reading data->done
(qatomic_set would be nice, if only for clarity) from reading num_waiters.
Paolo
next prev parent reply other threads:[~2022-05-24 17:22 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 [this message]
2022-05-24 17:56 ` Emanuele Giuseppe Esposito
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=84c5fad5-9e8c-84df-9aad-90ab1b79a5db@redhat.com \
--to=pbonzini@redhat.com \
--cc=eesposit@redhat.com \
--cc=hreitz@redhat.com \
--cc=kwolf@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).