# Re: \[PATCH 04/18\] alpha: Override READ\_ONCE() with barriered implementation

- From: Arnd Bergmann \<arnd@arndb.de\>
- Date: 2020-07-02 11:39:31 
- List: virtualization
- Page: https://ratatoskr.run/virtualization/2020/07/6023153
- Thread: https://ratatoskr.run/linux-arm-kernel/2020/06/6020640/t.md

```text
On Thu, Jul 2, 2020 at 1:18 PM Will Deacon [ref] wrote:
> On Thu, Jul 02, 2020 at 12:08:41PM +0200, Arnd Bergmann wrote:
> > On Thu, Jul 2, 2020 at 11:48 AM Will Deacon [ref] wrote:
> > > On Thu, Jul 02, 2020 at 10:32:39AM +0100, Mark Rutland wrote:

> Not sure I follow you here, but I can confirm that what you're worried
> about doesn't happen for the usual case of a pointer-to-volatile scalar.
>
> For example, ignoring dependency ordering:
>
> unsigned long foo(volatile unsigned long *p)
> {
>         return smp_load_acquire(p) + 1;
> }
>
> Ends up looking like:
>
>         unsigned long ___p1 = *(const volatile unsigned long *)p;
>         smp_mb();
>         (volatile unsigned long)___p1;
>
> My understanding is that casting a non-pointer type to volatile doesn't
> do anything, so we're good.

Right, I mixed up the correct

        (typeof(*p))___p;

with the incorrect

       *typeof(p)&___p;

which would dereference a volatile pointer and cause the
problem.

The code is all fine then.

    Arnd
```
