[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 3/4] memory: introduce memory_global_after_dirty
From: |
Richard Henderson |
Subject: |
Re: [Qemu-devel] [PATCH 3/4] memory: introduce memory_global_after_dirty_log_sync |
Date: |
Fri, 9 Feb 2018 12:20:32 -0800 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 |
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 <address@hidden>
> Signed-off-by: Paolo Bonzini <address@hidden>
> ---
> 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 <address@hidden>
r~
- [Qemu-devel] [PATCH 0/4] tcg: fix dirty bitmap race with MTTCG, Paolo Bonzini, 2018/02/09
- [Qemu-devel] [PATCH 3/4] memory: introduce memory_global_after_dirty_log_sync, Paolo Bonzini, 2018/02/09
- Re: [Qemu-devel] [PATCH 3/4] memory: introduce memory_global_after_dirty_log_sync,
Richard Henderson <=
- [Qemu-devel] [PATCH 1/4] memory: remove memory_region_test_and_clear_dirty, Paolo Bonzini, 2018/02/09
- [Qemu-devel] [PATCH 4/4] memory: unify loops to sync dirty log bitmap, Paolo Bonzini, 2018/02/09
- [Qemu-devel] [PATCH 2/4] memory: hide memory_region_sync_dirty_bitmap behind DirtyBitmapSnapshot, Paolo Bonzini, 2018/02/09
- Re: [Qemu-devel] [PATCH 0/4] tcg: fix dirty bitmap race with MTTCG, no-reply, 2018/02/09
- Re: [Qemu-devel] [PATCH 0/4] tcg: fix dirty bitmap race with MTTCG, no-reply, 2018/02/09
- Re: [Qemu-devel] [PATCH 0/4] tcg: fix dirty bitmap race with MTTCG, no-reply, 2018/02/09
- Re: [Qemu-devel] [PATCH 0/4] tcg: fix dirty bitmap race with MTTCG, Dr. David Alan Gilbert, 2018/02/09