qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: "Pavel Dovgalyuk" <dovgaluk@ispras.ru>,
	"Emilio G. Cota" <cota@braap.org>,
	"Alex Bennée" <alex.bennee@linaro.org>,
	"QEMU Developers" <qemu-devel@nongnu.org>,
	"Richard Henderson" <rth@twiddle.net>
Subject: Re: [Qemu-devel] TCG icount interaction with timer deadlines
Date: Thu, 5 Apr 2018 22:01:06 +0200	[thread overview]
Message-ID: <d7f67671-c8e8-f05e-722b-7616a2ac11c0@redhat.com> (raw)
In-Reply-To: <CAFEAcA-vUuGWqPfDEz9Qu+q3PGqctSw-YxRnH3jWJGH+QVLHsg@mail.gmail.com>



----- Original Message -----
> From: "Peter Maydell" <peter.maydell@linaro.org>
> To: "Paolo Bonzini" <pbonzini@redhat.com>
> Cc: "QEMU Developers" <qemu-devel@nongnu.org>, "Alex Bennée" <alex.bennee@linaro.org>, "Richard Henderson"
> <rth@twiddle.net>, "Emilio G. Cota" <cota@braap.org>, "Pavel Dovgalyuk" <dovgaluk@ispras.ru>
> Sent: Thursday, April 5, 2018 7:35:56 PM
> Subject: Re: TCG icount interaction with timer deadlines
> 
> On 5 April 2018 at 18:07, Paolo Bonzini <pbonzini@redhat.com> wrote:
> > On 05/04/2018 18:01, Peter Maydell wrote:
> >>  * however, if the guest reprograms the clock during the tcg_cpu_exec()
> >>    run, we don't do anything to cause us to stop earlier
> >
> > Anything that does this from the vCPU thread should be between
> > gen_icount_start and gen_icount_end.  (In fact, it's the entire reason
> > why cpu_io_recompile exists).
> 
> Yes, and this does cause us to do a cpu_io_recompile, which
> rebuilds the TB and does a longjmp. However:
>  (1) that only takes us out to cpu_exec(), which will then
>  just go ahead and execute the next TB, whereas the
>  recalculation of deadlines happens at the next level out
>  in tcg_cpu_exec()
>  (2) the io_recompile happens *before* the guest writes to
>  the timer register that reprograms the deadline, so even
>  if we recomputed deadlines after this longjmp they wouldn't
>  be correct

Right - that part would be handled here:

void qemu_timer_notify_cb(void *opaque, QEMUClockType type)
{
    if (!use_icount || type != QEMU_CLOCK_VIRTUAL) {
        qemu_notify_event();
        return;
    }

    if (!qemu_in_vcpu_thread() && first_cpu) {
        /* qemu_cpu_kick is not enough to kick a halted CPU out of
         * qemu_tcg_wait_io_event.  async_run_on_cpu, instead,
         * causes cpu_thread_is_idle to return false.  This way,
         * handle_icount_deadline can run.
         */
        async_run_on_cpu(first_cpu, do_nothing, RUN_ON_CPU_NULL);
    }
}

(called by timerlist_notify, called in turn by timerlist_rearm)
but that second "if" is too restrictive.  Maybe just removing
the first arm is enough.  All this was broken by MTTCG.

Paolo

      reply	other threads:[~2018-04-05 20:01 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-05 16:01 [Qemu-devel] TCG icount interaction with timer deadlines Peter Maydell
2018-04-05 17:07 ` Paolo Bonzini
2018-04-05 17:35   ` Peter Maydell
2018-04-05 20:01     ` Paolo Bonzini [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=d7f67671-c8e8-f05e-722b-7616a2ac11c0@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=alex.bennee@linaro.org \
    --cc=cota@braap.org \
    --cc=dovgaluk@ispras.ru \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=rth@twiddle.net \
    /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).