WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

RE: [Xen-devel] xenbus stress testing

To: "Ian Jackson" <Ian.Jackson@xxxxxxxxxxxxx>
Subject: RE: [Xen-devel] xenbus stress testing
From: "James Harper" <james.harper@xxxxxxxxxxxxxxxx>
Date: Fri, 18 Feb 2011 23:42:11 +1100
Cc: xen-devel@xxxxxxxxxxxxxxxxxxx
Delivery-date: Fri, 18 Feb 2011 04:43:08 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <19806.25935.34149.438825@xxxxxxxxxxxxxxxxxxxxxxxx>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
References: <AEC6C66638C05B468B556EA548C1A77D01C556B6@trantor><19805.29093.996401.185391@xxxxxxxxxxxxxxxxxxxxxxxx><AEC6C66638C05B468B556EA548C1A77D01C556C5@trantor> <19806.25935.34149.438825@xxxxxxxxxxxxxxxxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
Thread-index: AcvPZwL0wbQaDjbBQuOYlz03kK9mWAAAf4Yw
Thread-topic: [Xen-devel] xenbus stress testing
> 
> James Harper writes ("RE: [Xen-devel] xenbus stress testing"):
> > I think I have found the error and it was probably a 1 in a million
race
> > so stress testing might not have helped anyway. My code went:
> >
> > len = min(ring->rsp_prod - ring->rsp_cons, msg_size)
> >
> > and the ASSERT was hit because len was > msg_size, and the only
possible
> > way I can ever see that happening is if ring->rsp_prod changed
between
> > the if in the min() and the assignment. I'm now snapshotting
rsp_prod to
> > a local variable at the start. Kind of embarrassing really as plenty
of
> > example code exists.
> 
> You need to think about memory barriers and/or volatile.  Simply
> "snapshotting" with an ordinary assignment doesn't work.
> 
> I don't know how this is done in Windows but the Linux kernel has a
> clear explanation of the problem and how it's solved in Linux.  Look
> in the kernel source tree in Documentation/memory-barriers.txt.
> 

I issue a barrier (KeMemoryBarrier() which is a compiler and a memory
barrier) after copying rsp_prod, eg:

rsp_prod = ring->rsp_prod;
KeMemoryBarrier();
Access the actual ring buffer

Is there anything else required?

James

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel