Re: [PATCH 9/9] kernel: tighten rules for ACCESS ONCE

From: Paul E. McKenney
Date: Thu Dec 04 2014 - 09:42:04 EST


On Thu, Dec 04, 2014 at 10:28:25AM +0100, Christian Borntraeger wrote:
> Am 04.12.2014 um 01:16 schrieb Paul E. McKenney:
> >> * merging, or refetching absolutely anything at any time. Its main intended
> >> > * use is to mediate communication between process-level code and irq/NMI
> >> > * handlers, all running on the same CPU.
> > This comment is obsolete in the same way as that of READ_ONCE() and
> > ASSIGN_ONCE(), but probably more to the point to just get rid of
> > ACCESS_ONCE(). ;-)
> >
> >> >
>
> Its now
>
> /*
> * Prevent the compiler from merging or refetching accesses. The compiler
> * is also forbidden from reordering successive instances of ACCESS_ONCE(),
> * but only when the compiler is aware of some particular ordering. One way
> * to make the compiler aware of ordering is to put the two invocations of
> * ACCESS_ONCE() in different C statements.
> *
> * ACCESS_ONCE will only work on scalar types. For union types, ACCESS_ONCE
> * on a union member will work as long as the size of the member matches the
> * size of the union and the size is smaller than word size.
> *
> * The major use cases of ACCESS_ONCE used to be (1) Mediating communication
> * between process-level code and irq/NMI handlers, all running on the same CPU,
> * and (2) Ensuring that the compiler does not fold, spindle, or otherwise
> * mutilate accesses that either do not require ordering or that interact
> * with an explicit memory barrier or atomic instruction that provides the
> * required ordering.
> *
> * If possible use READ_ONCE/ASSIGN_ONCE instead.
> */

Looks good!

Thanx, Paul

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/