Re: [PATCH 1/9] kernel: Provide READ_ONCE and ASSIGN_ONCE

2014-12-05 Thread George Spelvin
> Of prefer it to match the put_user model, which is (val, ptr). But as long > as there is your safety (and the whole point of the macro is that it > figures out the type from the pointer), I guess it doesn't matter too much > in practice. > > I think my original suggestion also wrote it in lower

Re: [PATCH 1/9] kernel: Provide READ_ONCE and ASSIGN_ONCE

2014-12-05 Thread George Spelvin
>> Minor style nit: is it necessary to name a non-pointer variable "p"? >> I expect typeof(p) to be a pointer type. > v might be better. The current ACCESS_ONCE uses x. I also considered "var" and "mem". >> (The other fun style question, which is a lot less minor, is whether >> ASSIGN_ONCE shou

Re: [PATCH 1/9] kernel: Provide READ_ONCE and ASSIGN_ONCE

2014-12-05 Thread Christian Borntraeger
Am 05.12.2014 um 03:12 schrieb George Spelvin: >> +#define READ_ONCE(p) \ >> + typeof(p) __val; __read_once_size(&p, &__val, sizeof(__val)); __val; }) >> + >> +#define ASSIGN_ONCE(val, p) \ >> +({ typeof(p) __val; __val = val; __assign_once_size(&p, &__val, >> sizeof(__val)); __val; }) >

Re: [PATCH 1/9] kernel: Provide READ_ONCE and ASSIGN_ONCE

2014-12-04 Thread George Spelvin
> +#define READ_ONCE(p) \ > + typeof(p) __val; __read_once_size(&p, &__val, sizeof(__val)); __val; }) > + > +#define ASSIGN_ONCE(val, p) \ > + ({ typeof(p) __val; __val = val; __assign_once_size(&p, &__val, > sizeof(__val)); __val; }) Minor style nit: is it necessary to name a non-pointe

Re: [PATCH 1/9] kernel: Provide READ_ONCE and ASSIGN_ONCE

2014-12-04 Thread Paul E. McKenney
On Thu, Dec 04, 2014 at 10:24:47AM +0100, Christian Borntraeger wrote: > Am 04.12.2014 um 01:07 schrieb Paul E. McKenney: > > On Wed, Dec 03, 2014 at 11:30:13PM +0100, Christian Borntraeger wrote: > >> ACCESS_ONCE does not work reliably on non-scalar types. For > >> example gcc 4.6 and 4.7 might re

Re: [PATCH 1/9] kernel: Provide READ_ONCE and ASSIGN_ONCE

2014-12-04 Thread Christian Borntraeger
Am 04.12.2014 um 01:07 schrieb Paul E. McKenney: > On Wed, Dec 03, 2014 at 11:30:13PM +0100, Christian Borntraeger wrote: >> ACCESS_ONCE does not work reliably on non-scalar types. For >> example gcc 4.6 and 4.7 might remove the volatile tag for such >> accesses during the SRA (scalar replacement o

Re: [PATCH 1/9] kernel: Provide READ_ONCE and ASSIGN_ONCE

2014-12-03 Thread Paul E. McKenney
On Wed, Dec 03, 2014 at 11:30:13PM +0100, Christian Borntraeger wrote: > ACCESS_ONCE does not work reliably on non-scalar types. For > example gcc 4.6 and 4.7 might remove the volatile tag for such > accesses during the SRA (scalar replacement of aggregates) step > https://gcc.gnu.org/bugzilla/show

[PATCH 1/9] kernel: Provide READ_ONCE and ASSIGN_ONCE

2014-12-03 Thread Christian Borntraeger
ACCESS_ONCE does not work reliably on non-scalar types. For example gcc 4.6 and 4.7 might remove the volatile tag for such accesses during the SRA (scalar replacement of aggregates) step https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58145) Let's provide READ_ONCE/ASSIGN_ONCE that will do all access