[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH] mini-os: fix bit ops comments and memory clobbers.



Samuel Thibault, le Wed 18 Jun 2014 11:33:05 +0200, a écrit :
> Andrew Cooper, le Wed 18 Jun 2014 10:30:03 +0100, a écrit :
> > On 18/06/14 09:29, Samuel Thibault wrote:
> > > This fixes comments about test_and_clear_bit, set_bit and clear_bit,
> > > which are actually not atomic, can be reordered and are not memory
> > > barriers.
> > >
> > > This also drops the empty LOCK and LOCK_PREFIX macros which bring to the
> > > confusion.
> > >
> > > This also adds missing memory clobbers to set_bit and clear_bit.
> > >
> > > Signed-off-by: Samuel Thibault <samuel.thibault@xxxxxxxxxxxx>
> > 
> > Do you mean reordered by the compiler or reordered by the pipeline?
> 
> Yes.
> 
> > The memory clobbers prevent the compiler reordering, but lack of
> > [lsm]fence instructions allow the pipeline to reorder the reads/writes
> > if it chooses.
> 
> Ah, actually I was adding the memory clobbers to tell the compiler that
> we are modifying memory, but here we already properly tell so through
> "=m". Let me redo the patch without it.

Actually no, the patch is right: these functions can take an arbitrary
bit position, so the assembly snippet may modify in an arbitrary
position, and thus we have to use the clobber to tell the compiler to
assume that the memory has changed in unpredictable ways.

Samuel

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.