qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Richard Henderson <richard.henderson@linaro.org>
To: Paolo Bonzini <pbonzini@redhat.com>, qemu-devel@nongnu.org
Cc: dgilbert@redhat.com
Subject: Re: [Qemu-devel] [PATCH 3/4] memory: introduce memory_global_after_dirty_log_sync
Date: Fri, 9 Feb 2018 12:20:32 -0800	[thread overview]
Message-ID: <1ee62d37-c56c-d2f0-029b-921699273cfa@linaro.org> (raw)
In-Reply-To: <20180209104546.29401-4-pbonzini@redhat.com>

On 02/09/2018 02:45 AM, Paolo Bonzini wrote:
> There is a race between TCG and accesses to the dirty log:
> 
>       vCPU thread                  reader thread
>       -----------------------      -----------------------
>       TLB check -> slow path
>         notdirty_mem_write
>           write to RAM
>           set dirty flag
>                                    clear dirty flag
>       TLB check -> fast path
>                                    read memory
>         write to RAM
> 
> Fortunately, in order to fix it, no change is required to the
> vCPU thread.  However, the reader thread must delay the read after
> the vCPU thread has finished the write.  This can be approximated
> conservatively by run_on_cpu, which waits for the end of the current
> translation block.
> 
> A similar technique is used by KVM, which has to do a synchronous TLB
> flush after doing a test-and-clear of the dirty-page flags.
> 
> Reported-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
>  exec.c                | 31 +++++++++++++++++++++++++++++++
>  include/exec/memory.h | 12 ++++++++++++
>  memory.c              | 10 +++++++++-
>  migration/ram.c       |  1 +
>  4 files changed, 53 insertions(+), 1 deletion(-)

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>


r~

  reply	other threads:[~2018-02-09 20:20 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-09 10:45 [Qemu-devel] [PATCH 0/4] tcg: fix dirty bitmap race with MTTCG Paolo Bonzini
2018-02-09 10:45 ` [Qemu-devel] [PATCH 1/4] memory: remove memory_region_test_and_clear_dirty Paolo Bonzini
2018-02-09 20:13   ` Richard Henderson
2018-02-09 10:45 ` [Qemu-devel] [PATCH 2/4] memory: hide memory_region_sync_dirty_bitmap behind DirtyBitmapSnapshot Paolo Bonzini
2018-02-09 20:16   ` Richard Henderson
2018-02-09 10:45 ` [Qemu-devel] [PATCH 3/4] memory: introduce memory_global_after_dirty_log_sync Paolo Bonzini
2018-02-09 20:20   ` Richard Henderson [this message]
2018-02-09 10:45 ` [Qemu-devel] [PATCH 4/4] memory: unify loops to sync dirty log bitmap Paolo Bonzini
2018-02-09 20:23   ` Richard Henderson
2018-02-09 11:02 ` [Qemu-devel] [PATCH 0/4] tcg: fix dirty bitmap race with MTTCG no-reply
2018-02-09 11:33 ` no-reply
2018-02-09 11:33 ` no-reply
2018-02-09 20:27 ` Dr. David Alan Gilbert
2018-02-13 11:10 ` Dr. David Alan Gilbert
2018-10-30 12:21 ` Alex Bennée
2018-10-30 13:48   ` Paolo Bonzini

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=1ee62d37-c56c-d2f0-029b-921699273cfa@linaro.org \
    --to=richard.henderson@linaro.org \
    --cc=dgilbert@redhat.com \
    --cc=pbonzini@redhat.com \
    --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).