From: Kevin Wolf <kwolf@redhat.com>
To: "Philippe Mathieu-Daudé" <philmd@redhat.com>
Cc: "Thomas Huth" <thuth@redhat.com>,
"Pavel Dovgalyuk" <pavel.dovgalyuk@ispras.ru>,
"Eduardo Habkost" <ehabkost@redhat.com>,
Qemu-block <qemu-block@nongnu.org>,
"QEMU Developers" <qemu-devel@nongnu.org>,
"Wainer dos Santos Moschetta" <wainersm@redhat.com>,
"Stefan Hajnoczi" <stefanha@redhat.com>,
"Cleber Rosa" <crosa@redhat.com>,
"Paolo Bonzini" <pbonzini@redhat.com>,
"Alex Bennée" <alex.bennee@linaro.org>
Subject: Re: acceptance-system-fedora failures
Date: Thu, 8 Oct 2020 13:50:18 +0200 [thread overview]
Message-ID: <20201008115018.GD4672@linux.fritz.box> (raw)
In-Reply-To: <43eac2fb-7325-9e9f-ce13-d0774638753f@redhat.com>
Am 08.10.2020 um 12:26 hat Philippe Mathieu-Daudé geschrieben:
> On 10/7/20 3:11 PM, Pavel Dovgalyuk wrote:
> > On 07.10.2020 15:49, Philippe Mathieu-Daudé wrote:
> >> On 10/7/20 2:20 PM, Pavel Dovgalyuk wrote:
> >>> On 07.10.2020 14:22, Alex Bennée wrote:
> >>>>
> >>>> Philippe Mathieu-Daudé <philmd@redhat.com> writes:
> >>>>
> >>>>> On 10/7/20 10:51 AM, Pavel Dovgalyuk wrote:
> >>>>>> On 07.10.2020 11:23, Thomas Huth wrote:
> >>>>>>> On 07/10/2020 09.13, Philippe Mathieu-Daudé wrote:
> >>>>>>> Thanks, that was helpful. ... and the winner is:
> >>>>>>>
> >>>>>>>       commit  55adb3c45620c31f29978f209e2a44a08d34e2da
> >>>>>>> Â Â Â Â Â Â Author:Â John Snow <jsnow@redhat.com>
> >>>>>>> Â Â Â Â Â Â Date:Â Â Â Fri Jul 24 01:23:00 2020 -0400
> >>>>>>> Â Â Â Â Â Â Subject: ide: cancel pending callbacks on SRST
> >>>>>>>
> >>>>>>> ... starting with this commit, the tests starts failing. John, any
> >>>>>>> idea what
> >>>>>>> might be causing this?
> >>>>>>
> >>>>>> This patch includes the following lines:
> >>>>>>
> >>>>>> +Â Â Â Â Â Â Â aio_bh_schedule_oneshot(qemu_get_aio_context(),
> >>>>>> +Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â ide_bus_perform_srst, bus);
> >>>>>>
> >>>>>> replay_bh_schedule_oneshot_event should be used instead of this
> >>>>>> function, because it synchronizes non-deterministic BHs.
> >>>>>
> >>>>> Why do we have 2 different functions? BH are already complex
> >>>>> enough, and we need to also think about the replay API...
> >>>>>
> >>>>> What about the other cases such vhost-user (blk/net), virtio-blk?
> >>>>
> >>>> This does seem like something that should be wrapped up inside
> >>>> aio_bh_schedule_oneshot itself or maybe we need a
> >>>> aio_bh_schedule_transaction_oneshot to distinguish it from the other
> >>>> uses the function has.
> >>>>
> >>>
> >>> Maybe there should be two functions:
> >>> - one for the guest modification
> >>
> >> aio_bh_schedule_oneshot_deterministic()?
> >>
> >>> - one for internal qemu things
> >>
> >> Not sure why there is a difference, BH are used to
> >> avoid delaying the guest, so there always something
> >> related to "guest modification".
> >
> > Not exactly. At least there is one non-related-to-guest case
> > in monitor_init_qmp:
> > Â Â Â Â Â Â Â /*
> > Â Â Â Â Â Â Â Â * We can't call qemu_chr_fe_set_handlers() directly here
> > Â Â Â Â Â Â Â Â * since chardev might be running in the monitor I/O
> >         * thread. Schedule a bottom half.
> > Â Â Â Â Â Â Â Â */
> > Â Â Â Â Â Â Â aio_bh_schedule_oneshot(iothread_get_aio_context(mon_iothread),
> > Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â monitor_qmp_setup_handlers_bh, mon);
>
> I don't understand the documentation in docs/devel/replay.txt:
>
> ---
> Bottom halves
> =============
>
> Bottom half callbacks, that affect the guest state, should be invoked
> through
> replay_bh_schedule_event or replay_bh_schedule_oneshot_event functions.
> Their invocations are saved in record mode and synchronized with the
> existing
> log in replay mode.
> ---
>
> But then it is only used in block drivers, which are not
> related to guest state:
Pavel can tell you the details, but I think the idea was that you need
to use this function not when the code calling it modifies guest state,
but when the BH implementation can do so.
In the case of generic callbacks like provided by the blk_aio_*()
functions, we don't know whether this is the case, but it's generally
device emulation code, so chances are relatively high that they do.
I seem to remember that when reviewing the code that introduced
replay_bh_schedule_event(), I was relatively sure that we didn't catch
all necessary instances, but since it worked for Pavel and I didn't feel
like getting too involved with replay code, we just merged it anyway.
As I said, the details are a question for Pavel.
Kevin
> $ git grep replay_bh_schedule_oneshot_event
> block/block-backend.c:1385:
> replay_bh_schedule_oneshot_event(blk_get_aio_context(blk),
> block/block-backend.c:1450:
> replay_bh_schedule_oneshot_event(blk_get_aio_context(blk),
> block/io.c:371:
> replay_bh_schedule_oneshot_event(bdrv_get_aio_context(bs),
> block/iscsi.c:286:
> replay_bh_schedule_oneshot_event(iTask->iscsilun->aio_context,
> block/nfs.c:262:
> replay_bh_schedule_oneshot_event(task->client->aio_context,
> block/null.c:183:
> replay_bh_schedule_oneshot_event(bdrv_get_aio_context(bs),
> block/nvme.c:323: replay_bh_schedule_oneshot_event(q->aio_context,
> block/nvme.c:1075: replay_bh_schedule_oneshot_event(data->ctx,
> nvme_rw_cb_bh, data);
> block/rbd.c:865:
> replay_bh_schedule_oneshot_event(bdrv_get_aio_context(acb->common.bs),
> docs/devel/replay.txt:25:replay_bh_schedule_event or
> replay_bh_schedule_oneshot_event functions.
> include/sysemu/replay.h:178:void
> replay_bh_schedule_oneshot_event(AioContext *ctx,
> replay/replay-events.c:141:void
> replay_bh_schedule_oneshot_event(AioContext *ctx,
> stubs/replay-user.c:5:void replay_bh_schedule_oneshot_event(AioContext *ctx,
>
> Is replay_bh_schedule_oneshot_event ever used by replay?
> Maybe we can remove it and use aio_bh_schedule_oneshot()
> in place?
>
> Else the documentation need to be clarified please.
>
> >
> >
> >>
> >>>
> >>> The first one may be implemented though the rr+second one.
> >>> Maybe replay_ prefix is confusing and the whole BH interface should look
> >>> like that?
> >>
> >> Yes, but it would be safer/clearer if we don't need to use
> >> a replay_ API.
> >>
> >> Can we embed these functions?
> >>
> >> - replay_bh_schedule_event
> >> - replay_bh_schedule_oneshot_event
> >>
> >> If compiled without rr, events_enabled=false and
> >> compiler can optimize:
> >>
> >> -- >8 --
> >> diff --git a/util/async.c b/util/async.c
> >> index f758354c6a..376b6d4e27 100644
> >> --- a/util/async.c
> >> +++ b/util/async.c
> >> @@ -109,14 +109,19 @@ static QEMUBH *aio_bh_dequeue(BHList *head,
> >> unsigned *flags)
> >>
> >> Â void aio_bh_schedule_oneshot(AioContext *ctx, QEMUBHFunc *cb, void
> >> *opaque)
> >> Â {
> >> -Â Â Â QEMUBH *bh;
> >> -Â Â Â bh = g_new(QEMUBH, 1);
> >> -Â Â Â *bh = (QEMUBH){
> >> -Â Â Â Â Â Â Â .ctx = ctx,
> >> -Â Â Â Â Â Â Â .cb = cb,
> >> -Â Â Â Â Â Â Â .opaque = opaque,
> >> -Â Â Â };
> >> -Â Â Â aio_bh_enqueue(bh, BH_SCHEDULED | BH_ONESHOT);
> >> +Â Â Â if (events_enabled) {
> >> +Â Â Â Â Â Â Â replay_add_event(REPLAY_ASYNC_EVENT_BH_ONESHOT, cb,
> >> +Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â opaque, replay_get_current_icount());
> >> +Â Â Â } else {
> >> +Â Â Â Â Â Â Â QEMUBH *bh;
> >> +Â Â Â Â Â Â Â bh = g_new(QEMUBH, 1);
> >> +Â Â Â Â Â Â Â *bh = (QEMUBH){
> >> +Â Â Â Â Â Â Â Â Â Â Â .ctx = ctx,
> >> +Â Â Â Â Â Â Â Â Â Â Â .cb = cb,
> >> +Â Â Â Â Â Â Â Â Â Â Â .opaque = opaque,
> >> +Â Â Â Â Â Â Â };
> >> +Â Â Â Â Â Â Â aio_bh_enqueue(bh, BH_SCHEDULED | BH_ONESHOT);
> >> +Â Â Â }
> >> Â }
> >>
> >> Â QEMUBH *aio_bh_new(AioContext *ctx, QEMUBHFunc *cb, void *opaque)
> >> @@ -178,7 +183,12 @@ void qemu_bh_schedule_idle(QEMUBH *bh)
> >>
> >> Â void qemu_bh_schedule(QEMUBH *bh)
> >
> > qemu_bh_schedule is even worse.
> > Many modules use it (e.g., loadvm_postcopy_handle_run), and there is no
> > need to use replay version there. In such cases QEMU will halt if trying
> > to call replay_bh_schedule_event.
> >
> >> Â {
> >> -Â Â Â aio_bh_enqueue(bh, BH_SCHEDULED);
> >> +Â Â Â if (events_enabled) {
> >> +Â Â Â Â Â Â Â replay_add_event(REPLAY_ASYNC_EVENT_BH, bh, NULL,
> >> +Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â replay_get_current_icount());
> >> +Â Â Â } else {
> >> +Â Â Â Â Â Â Â aio_bh_enqueue(bh, BH_SCHEDULED);
> >> +Â Â Â }
> >> Â }
> >>
> >
>
>
next prev parent reply other threads:[~2020-10-08 11:51 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-06 23:07 acceptance-system-fedora failures John Snow
2020-10-07 5:20 ` Philippe Mathieu-Daudé
2020-10-07 7:13 ` Philippe Mathieu-Daudé
2020-10-07 8:23 ` Thomas Huth
2020-10-07 8:51 ` Pavel Dovgalyuk
2020-10-07 9:57 ` Philippe Mathieu-Daudé
2020-10-07 11:22 ` Alex Bennée
2020-10-07 12:20 ` Pavel Dovgalyuk
2020-10-07 12:49 ` Philippe Mathieu-Daudé
2020-10-07 13:11 ` Pavel Dovgalyuk
2020-10-08 10:26 ` Philippe Mathieu-Daudé
2020-10-08 11:50 ` Kevin Wolf [this message]
2020-10-09 10:37 ` Pavel Dovgalyuk
2020-10-13 8:57 ` Philippe Mathieu-Daudé
2020-10-07 12:17 ` Pavel Dovgalyuk
2020-10-07 14:03 ` John Snow
2020-10-07 7:23 ` Thomas Huth
2020-10-07 8:19 ` Philippe Mathieu-Daudé
2020-10-07 14:38 ` Cleber Rosa
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=20201008115018.GD4672@linux.fritz.box \
--to=kwolf@redhat.com \
--cc=alex.bennee@linaro.org \
--cc=crosa@redhat.com \
--cc=ehabkost@redhat.com \
--cc=pavel.dovgalyuk@ispras.ru \
--cc=pbonzini@redhat.com \
--cc=philmd@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
--cc=thuth@redhat.com \
--cc=wainersm@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).