[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20141124204614.GU5050@linux.vnet.ibm.com>
Date: Mon, 24 Nov 2014 12:46:14 -0800
From: "Paul E. McKenney" <paulmck@...ux.vnet.ibm.com>
To: Linus Torvalds <torvalds@...ux-foundation.org>
Cc: Christian Borntraeger <borntraeger@...ibm.com>,
Alexei Starovoitov <alexei.starovoitov@...il.com>,
David Howells <dhowells@...hat.com>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"linux-arch@...r.kernel.org" <linux-arch@...r.kernel.org>,
linux-mips <linux-mips@...ux-mips.org>,
linux-x86_64@...r.kernel.org,
linux-s390 <linux-s390@...r.kernel.org>,
Paolo Bonzini <pbonzini@...hat.com>,
Ingo Molnar <mingo@...nel.org>,
Catalin Marinas <catalin.marinas@....com>,
Will Deacon <will.deacon@....com>
Subject: Re: [PATCH/RFC 7/7] kernel: Force ACCESS_ONCE to work only on scalar
types
On Mon, Nov 24, 2014 at 12:19:11PM -0800, Linus Torvalds wrote:
> On Mon, Nov 24, 2014 at 11:42 AM, Paul E. McKenney
> <paulmck@...ux.vnet.ibm.com> wrote:
> >
> > OK, how about the following?
>
> Ugh. Disgusting.
>
> Why the heck isn't it just "sizeof(*__vp) <= sizeof(long)"?
>
> If the architecture has a 3-byte scalar type, then it probably has a
> 3-byte load.
Because I was allowing for the possibility of a 3-byte struct, which
as you point out below...
> > It complains if the variable is too large, for example, long long on
> > 32-bit systems or large structures. It is OK loading from and storing
> > to small structures as well, which I am having a hard time thinking of
> > as a disadvantage.
>
> .. but that's *exactly* the gcc bug in question. It's a word-sized
> struct that gcc loads twice.
...was a stupid thought anyway.
OK, how about the attempt below? The initialization of __p complains
for structures and unions, but gets optimized out.
Thanx, Paul
-------------------------------------------------------------------------
#define get_scalar_volatile_pointer(x) ({ \
typeof(x) __maybe_unused __p = 0; \
volatile typeof(x) *__vp = &(x); \
BUILD_BUG_ON(sizeof(*__vp) > sizeof(long)); \
__vp; })
#define ACCESS_ONCE(x) (*get_scalar_volatile_pointer(x))
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists