From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40495) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YbBkb-00064V-Hg for qemu-devel@nongnu.org; Thu, 26 Mar 2015 13:39:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YbBkZ-0003iA-SG for qemu-devel@nongnu.org; Thu, 26 Mar 2015 13:39:25 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43889) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YbBkZ-0003i2-NU for qemu-devel@nongnu.org; Thu, 26 Mar 2015 13:39:23 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id 5A15732E3A7 for ; Thu, 26 Mar 2015 17:39:23 +0000 (UTC) From: Paolo Bonzini Date: Thu, 26 Mar 2015 18:38:39 +0100 Message-Id: <1427391520-29497-22-git-send-email-pbonzini@redhat.com> In-Reply-To: <1427391520-29497-1-git-send-email-pbonzini@redhat.com> References: <1427391520-29497-1-git-send-email-pbonzini@redhat.com> Subject: [Qemu-devel] [PATCH 21/22] 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: Stefan Hajnoczi 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 b7357ac..c4e5624 100644 --- a/include/exec/ram_addr.h +++ b/include/exec/ram_addr.h @@ -220,12 +220,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 { -- 2.3.3