From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35017) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ymlw0-0002ky-O5 for qemu-devel@nongnu.org; Mon, 27 Apr 2015 12:31:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Ymlvz-0003Pc-PT for qemu-devel@nongnu.org; Mon, 27 Apr 2015 12:31:04 -0400 Received: from mail-wi0-x22a.google.com ([2a00:1450:400c:c05::22a]:35203) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ymlvz-0003PM-JX for qemu-devel@nongnu.org; Mon, 27 Apr 2015 12:31:03 -0400 Received: by widdi4 with SMTP id di4so106419755wid.0 for ; Mon, 27 Apr 2015 09:31:03 -0700 (PDT) Sender: Paolo Bonzini From: Paolo Bonzini Date: Mon, 27 Apr 2015 18:28:36 +0200 Message-Id: <1430152117-100558-29-git-send-email-pbonzini@redhat.com> In-Reply-To: <1430152117-100558-1-git-send-email-pbonzini@redhat.com> References: <1430152117-100558-1-git-send-email-pbonzini@redhat.com> Subject: [Qemu-devel] [PATCH 28/29] memory: make cpu_physical_memory_sync_dirty_bitmap() fully atomic List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: famz@redhat.com, stefanha@redhat.com, mst@redhat.com From: Stefan Hajnoczi The fast path of cpu_physical_memory_sync_dirty_bitmap() directly manipulates the dirty bitmap. Use atomic_xchg() to make the test-and-clear atomic. Signed-off-by: Stefan Hajnoczi Message-Id: <1417519399-3166-7-git-send-email-stefanha@redhat.com> [Only do xchg on nonzero words. - Paolo] Signed-off-by: Paolo Bonzini --- include/exec/ram_addr.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/exec/ram_addr.h b/include/exec/ram_addr.h index ea77187..0baba41 100644 --- a/include/exec/ram_addr.h +++ b/include/exec/ram_addr.h @@ -224,12 +224,12 @@ uint64_t cpu_physical_memory_sync_dirty_bitmap(unsigned long *dest, for (k = page; k < page + nr; k++) { if (src[k]) { + unsigned long bits = atomic_xchg(&src[k], 0); unsigned long new_dirty; new_dirty = ~dest[k]; - dest[k] |= src[k]; - new_dirty &= src[k]; + dest[k] |= bits; + new_dirty &= bits; num_dirty += ctpopl(new_dirty); - src[k] = 0; } } } else { -- 1.8.3.1