qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Alex Bennée" <alex.bennee@linaro.org>
To: Sergey Fedorov <serge.fdrv@gmail.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>,
	Peter Crosthwaite <crosthwaite.peter@gmail.com>,
	QEMU Developers <qemu-devel@nongnu.org>,
	Sergey Fedorov <sergey.fedorov@linaro.org>,
	Richard Henderson <rth@twiddle.net>
Subject: Re: [Qemu-devel] tcg: reworking tb_invalidated_flag
Date: Thu, 31 Mar 2016 14:37:24 +0100	[thread overview]
Message-ID: <87wpoig44r.fsf@linaro.org> (raw)
In-Reply-To: <56FD22A5.10501@gmail.com>


Sergey Fedorov <serge.fdrv@gmail.com> writes:

> On 30/03/16 21:13, Paolo Bonzini wrote:
>>
>> On 30/03/2016 19:08, Sergey Fedorov wrote:
>>> The second approach is to make 'tb_invalidated_flag' per-CPU. This
>>> would be conceptually similar to what we have, but would give us thread
>>> safety. With this approach, we need to be careful to correctly clear and
>>> set the flag.
>> You can just ensure that setting and clearing it is done under tb_lock.
>
> So it could remain sitting in 'tcg_ctx.tb_ctx'. I'm just wondering what
> could be real benefits for making it per-CPU then?
>
>> Because TranslationBlocks live in tcg_ctx.tb_ctx.tbs you need
>> special code to exit all CPUs at tb_flush time, otherwise you risk that
>> a tb_alloc reuses a TranslationBlock while it is in use by a VCPU.
>
> Looks like no matter which approach we use, it's ultimately necessary to
> ensure all CPUs have exited from translated code before the translation
> buffer may be safely flushed.

One approach would be to have multiple translation contexts with their
own buffers and then you can safely flush TBs if no vCPUs are currently
executing in those regions. But I suspect that is a much more complex
future optimisation.

Having said that is it safe to flush TBs from a given page if we know
no vCPUs are currently executing in that page? As the execution loop has
to exit the chained TBs as we cross page boundaries we could just keep
account of which vCPUs are currently in which page.

--
Alex Bennée

  reply	other threads:[~2016-03-31 13:37 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-30 17:08 [Qemu-devel] tcg: reworking tb_invalidated_flag Sergey Fedorov
2016-03-30 18:13 ` Paolo Bonzini
2016-03-31 13:14   ` Sergey Fedorov
2016-03-31 13:37     ` Alex Bennée [this message]
2016-03-31 14:06       ` Sergey Fedorov
2016-03-31 19:03         ` Sergey Fedorov
2016-03-31 19:56           ` Paolo Bonzini
2016-04-01 11:11         ` Alex Bennée
2016-04-01 11:23           ` Sergey Fedorov
2016-03-31 13:40     ` Paolo Bonzini
2016-03-31 14:35       ` Sergey Fedorov
2016-03-31 14:44         ` Paolo Bonzini
2016-03-30 19:08 ` Richard Henderson
2016-03-30 21:21   ` Sergey Fedorov
2016-03-31 10:48 ` Alex Bennée
2016-03-31 12:42   ` Sergey Fedorov
2016-03-31 16:25     ` 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=87wpoig44r.fsf@linaro.org \
    --to=alex.bennee@linaro.org \
    --cc=crosthwaite.peter@gmail.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=rth@twiddle.net \
    --cc=serge.fdrv@gmail.com \
    --cc=sergey.fedorov@linaro.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).