From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50231) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YxEEk-0002HV-P9 for qemu-devel@nongnu.org; Tue, 26 May 2015 08:45:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YxEEg-0001mD-84 for qemu-devel@nongnu.org; Tue, 26 May 2015 08:45:38 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35284) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YxEEf-0001lt-PM for qemu-devel@nongnu.org; Tue, 26 May 2015 08:45:34 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t4QCjXq5019952 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Tue, 26 May 2015 08:45:33 -0400 Date: Tue, 26 May 2015 20:45:30 +0800 From: Fam Zheng Message-ID: <20150526124530.GA13749@ad.nay.redhat.com> References: <1430152117-100558-1-git-send-email-pbonzini@redhat.com> <1430152117-100558-29-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1430152117-100558-29-git-send-email-pbonzini@redhat.com> Subject: Re: [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: Paolo Bonzini Cc: qemu-devel@nongnu.org, stefanha@redhat.com, mst@redhat.com On Mon, 04/27 18:28, Paolo Bonzini wrote: > 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 Reviewed-by: Fam Zheng > --- > 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 > >