qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Jun Koi <junkoi2004@gmail.com>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: "qemu-devel@nongnu.org" <qemu-devel@nongnu.org>
Subject: Re: [Qemu-devel] How to break cpu_tb_exec()?
Date: Sat, 4 Jul 2015 01:24:15 +0800	[thread overview]
Message-ID: <CA+g7VZ1SQ9euLSAurhsBQAjbTB4OPsa5e-inSW3_RT1+Tvi5xA@mail.gmail.com> (raw)
In-Reply-To: <CAFEAcA92zTP9n6qQ7efY0w-rN39vwQpj5uQPciE5dmnKCgw5hw@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1477 bytes --]

On Sat, Jul 4, 2015 at 1:12 AM, Peter Maydell <peter.maydell@linaro.org>
wrote:

> On 3 July 2015 at 18:10, Jun Koi <junkoi2004@gmail.com> wrote:
> > On Sat, Jul 4, 2015 at 1:06 AM, Peter Maydell <peter.maydell@linaro.org>
> > wrote:
> >> On 3 July 2015 at 18:02, Jun Koi <junkoi2004@gmail.com> wrote:
> >> > If this is true, then what if this TB is running infinitely, and do
> not
> >> > return, or it is in a very long loop? In this case, TCG thread cannot
> be
> >> > interrupted?
> >>
> >> Every TB starts with a little bit of generated code that checks
> >> the 'tcg_exit_req' flag in the CPUState for the CPU (see the
> >> gen_tb_start() function). If some other part of QEMU wants the
> >> CPU to stop running guest code and return to the top level loop,
> >> it calls cpu_exit() which sets this flag.
> >
> >
> > But this does not answer my question yet: if we the flag is only
> > enable when TB already enters the "long loop", then nothing can break
> > this TB execution?
>
> We check the flag for every TB we execute. Therefore in any
> loop we must check the flag each time round the loop. So
> if another thread sets the flag, we will exit.
>
> (A TB is always ended by any kind of branch instruction,
> so you can't have a loop within a single TB. A tight loop
> turns into a TB that ends with "branch back to the start
> of this TB", but that will re-execute the flag-check code.)
>

Oh right, this tight loop is my main concern. It makes sense now.

Thanks!!

[-- Attachment #2: Type: text/html, Size: 2212 bytes --]

  reply	other threads:[~2015-07-03 17:24 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-03 17:02 [Qemu-devel] How to break cpu_tb_exec()? Jun Koi
2015-07-03 17:06 ` Peter Maydell
2015-07-03 17:10   ` Jun Koi
2015-07-03 17:12     ` Peter Maydell
2015-07-03 17:24       ` Jun Koi [this message]
2015-07-06 11:26         ` Lluís Vilanova
2015-07-21  7:02           ` Richard Henderson

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=CA+g7VZ1SQ9euLSAurhsBQAjbTB4OPsa5e-inSW3_RT1+Tvi5xA@mail.gmail.com \
    --to=junkoi2004@gmail.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    /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).