From patchwork Sun May 23 15:56:05 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 101743 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o4NG1KPQ018566 for ; Sun, 23 May 2010 16:01:21 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752921Ab0EWQA4 (ORCPT ); Sun, 23 May 2010 12:00:56 -0400 Received: from mx1.redhat.com ([209.132.183.28]:12337 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752581Ab0EWQAz (ORCPT ); Sun, 23 May 2010 12:00:55 -0400 Received: from int-mx05.intmail.prod.int.phx2.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.18]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o4NG0IKw020609 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Sun, 23 May 2010 12:00:18 -0400 Received: from redhat.com (vpn1-7-182.ams2.redhat.com [10.36.7.182]) by int-mx05.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with SMTP id o4NG0ETx027565; Sun, 23 May 2010 12:00:15 -0400 Date: Sun, 23 May 2010 18:56:05 +0300 From: "Michael S. Tsirkin" To: Rusty Russell Cc: Avi Kivity , linux-kernel@vger.kernel.org, virtualization@lists.linux-foundation.org, kvm@vger.kernel.org, qemu-devel@nongnu.org Subject: Re: [Qemu-devel] [PATCH RFC] virtio: put last seen used index into ring itself Message-ID: <20100523155605.GB14733@redhat.com> References: <20100505205814.GA7090@redhat.com> <4BF39C12.7090407@redhat.com> <201005201431.51142.rusty@rustcorp.com.au> <201005201438.17010.rusty@rustcorp.com.au> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <201005201438.17010.rusty@rustcorp.com.au> User-Agent: Mutt/1.5.19 (2009-01-05) X-Scanned-By: MIMEDefang 2.67 on 10.5.11.18 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Sun, 23 May 2010 16:01:21 +0000 (UTC) diff --git a/cachebounce.c b/cachebounce.c index 0387027..ebe5a37 100644 --- a/cachebounce.c +++ b/cachebounce.c @@ -77,6 +77,7 @@ int main(int argc, char *argv[]) count++; counter->cacheline1 = count; count++; + __sync_synchronize(); } break; case UNSHARE: @@ -86,6 +87,7 @@ int main(int argc, char *argv[]) count++; counter->cacheline2 = count; count++; + __sync_synchronize(); } break; case LOCKSHARE: @@ -98,6 +100,7 @@ int main(int argc, char *argv[]) break; case LOCKUNSHARE: while (count < MAX_BOUNCES) { + __sync_synchronize(); /* Spin waiting for other side to change it. */ while (counter->cacheline1 != count); __sync_val_compare_and_swap(&counter->cacheline2, count, count+1); @@ -115,6 +118,7 @@ int main(int argc, char *argv[]) count++; counter->cacheline1 = count; count++; + __sync_synchronize(); } break; case UNSHARE: @@ -124,6 +128,7 @@ int main(int argc, char *argv[]) count++; counter->cacheline1 = count; count++; + __sync_synchronize(); } break; case LOCKSHARE: