|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Xen-devel] read_atomic, write_atomic, add_sized
Hi Jan, On 13/06/17 13:48, Jan Beulich wrote: On 13.06.17 at 11:42, <julien.grall@xxxxxxx> wrote:On 12/06/2017 16:38, Jan Beulich wrote:On 12.06.17 at 17:19, <andre.przywara@xxxxxxx> wrote:On 12/06/17 11:55, Jan Beulich wrote:On 12.06.17 at 12:24, <julien.grall@xxxxxxx> wrote:I am trying to understand why we decided to implement the helpers read_atomic, write_atomic, add_sized in assembly rather than directly in C. AFAICT implementation in C similar to Linux helpers WRITE_ONCE/READ_ONCE would work here. Did I miss anything? That's from an x86 POV. ARM (at least until ARMv8.0) does not have read-modify-write operations. If the compiler is not using them on x86 then maybe you should look at fixing that in the compiler? However, looking at the patch that introduced add_sized, the intention was not about preventing the compiler to use 3 insns: add_sized(ptr, inc) adds inc to the value at ptr using only the correct size of loads and stores for the type of *ptr. The add is /not/ atomic.This is needed for ticket locks to ensure the increment of the head ticket does not affect the tail ticket. Anyway, I think Xen already make a lot of assumption in the code on the compiler (and flags used). IHMO, It would be very difficult to Xen compiling properly with compiler doing insane things. And then, as the cited code still visible above shows, atomicity is not going to be guaranteed for most of the access sizes anyway. How can you imply that the given constructs are safe to use as atomic accesses for some variables, but not for others? Such a property ought to be universal (and the build should fail if it is being violated). Otherwise a simple type change of some variable may render the code buggy possibly without anyone noticing. It is a choice from Linux side to allow using READ_ONCE/WRITE_ONCE with bigger size. I am not suggesting to do the same on Xen but avoiding the bigger size. Cheers, -- Julien Grall _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx https://lists.xen.org/xen-devel
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |