From: "Alex Bennée" <alex.bennee@linaro.org>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: MTTCG Devel <mttcg@greensocs.com>,
QEMU Developers <qemu-devel@nongnu.org>,
a.rigo@virtualopensystems.com, "Emilio G. Cota" <cota@braap.org>,
Sergey Fedorov <serge.fdrv@gmail.com>,
Richard Henderson <rth@twiddle.net>,
Frederic Konrad <fred.konrad@greensocs.com>
Subject: Re: [Qemu-devel] Making cputlb.c operations safe for MTTCG
Date: Tue, 27 Sep 2016 23:15:31 +0100 [thread overview]
Message-ID: <87twd1f0qk.fsf@linaro.org> (raw)
In-Reply-To: <5d48957b-780b-aa9c-7061-cba6808909b4@redhat.com>
Paolo Bonzini <pbonzini@redhat.com> writes:
> On 02/08/2016 08:37, Alex Bennée wrote:
>>> - in notdirty_mem_write, care must be put in the ordering of
>>> tb_invalidate_phys_page_fast (which itself calls tlb_unprotect_code and
>>> takes the tb_lock in tb_invalidate_phys_page_range) and tlb_set_dirty.
>>> At least it seems to me that the call to tb_invalidate_phys_page_fast
>>> should be after the write, but that's not all. Perhaps merge this part
>>> of notdirty_mem_write:
>
> I looked at it again and you are already doing the right thing in patch 19.
> It's possible to simplify it a bit though like this:
>
> diff --git a/exec.c b/exec.c
> index c8389f9..7850c39 100644
> --- a/exec.c
> +++ b/exec.c
> @@ -1944,9 +1944,6 @@ ram_addr_t qemu_ram_addr_from_host(void *ptr)
> static void notdirty_mem_write(void *opaque, hwaddr ram_addr,
> uint64_t val, unsigned size)
> {
> - if (!cpu_physical_memory_get_dirty_flag(ram_addr, DIRTY_MEMORY_CODE)) {
> - tb_invalidate_phys_page_fast(ram_addr, size);
> - }
> switch (size) {
> case 1:
> stb_p(qemu_map_ram_ptr(NULL, ram_addr), val);
> @@ -1960,11 +1957,19 @@ static void notdirty_mem_write(void *opaque, hwaddr ram_addr,
> */
> cpu_physical_memory_set_dirty_range(ram_addr, size,
> DIRTY_CLIENTS_NOCODE);
> + tb_lock();
> + if (!cpu_physical_memory_get_dirty_flag(ram_addr, DIRTY_MEMORY_CODE)) {
> + /* tb_invalidate_phys_page_range will call tlb_unprotect_code
> + * once the last TB in this page is gone.
> + */
> + tb_invalidate_phys_page_fast(ram_addr, size);
> + }
> /* we remove the notdirty callback only if the code has been
> flushed */
> if (!cpu_physical_memory_is_clean(ram_addr)) {
> tlb_set_dirty(current_cpu, current_cpu->mem_io_vaddr);
> }
> + tb_unlock();
> }
>
> static bool notdirty_mem_accepts(void *opaque, hwaddr addr,
>
>
> Anyhow, the next step is to merge either cmpxchg-based atomics
> or iothread-free single-threaded TCG. Either will do. :)
By iothread-free single-threaded TCG you mean dropping the need to grab
the BQL when we start the TCG thread and making the BQL purely an
on-demand/when needed thing?
The cmpxchg stuff is looking good to me - I still have to do a pass over
rth's patch set since he re-based on async safe work. In fact once your
updated PULL req is in even better ;-)
> I think that even iothread-free single-threaded TCG requires this
> TLB stuff, because the iothread's address_space_write (and hence
> invalidate_and_set_dirty) can race against the TCG thread's
> code generation.
Yes.
>
> Thanks,
>
> Paolo
--
Alex Bennée
next prev parent reply other threads:[~2016-09-27 22:15 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-07-26 12:09 [Qemu-devel] Making cputlb.c operations safe for MTTCG Alex Bennée
2016-07-26 14:03 ` [Qemu-devel] [PATCH] cputlb: make tlb_reset_dirty " Alex Bennée
2016-08-01 14:54 ` [Qemu-devel] Making cputlb.c operations " Paolo Bonzini
2016-08-02 6:37 ` Alex Bennée
2016-08-02 10:26 ` Paolo Bonzini
2016-08-03 17:25 ` Richard Henderson
2016-08-03 20:56 ` Paolo Bonzini
2016-09-27 16:16 ` Paolo Bonzini
2016-09-27 22:15 ` Alex Bennée [this message]
2016-09-27 22:29 ` Emilio G. Cota
2016-09-27 23:04 ` Alex Bennée
2016-09-27 23:05 ` Richard Henderson
2016-09-27 23:32 ` Alex Bennée
2016-09-28 0:34 ` 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=87twd1f0qk.fsf@linaro.org \
--to=alex.bennee@linaro.org \
--cc=a.rigo@virtualopensystems.com \
--cc=cota@braap.org \
--cc=fred.konrad@greensocs.com \
--cc=mttcg@greensocs.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=rth@twiddle.net \
--cc=serge.fdrv@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.