Thread (192 messages) 192 messages, 41 authors, 2022-10-16

Re: [PATCH 00/13] [RFC] Rust support

From: Peter Zijlstra <peterz@infradead.org>
Date: 2021-04-19 08:35:42
Also in: linux-kbuild, lkml, rust-for-linux

On Mon, Apr 19, 2021 at 10:26:57AM +0200, Peter Zijlstra wrote:
https://godbolt.org/z/85xoPxeE5
That wants _Atomic on the seq definition for clang.
void writer(void)
{
    atomic_store_explicit(&seq, seq+1, memory_order_relaxed);
    atomic_thread_fence(memory_order_acquire);

    X = 1;
    Y = 2;

    atomic_store_explicit(&seq, seq+1, memory_order_release);
}

gives:

writer:
        adrp    x1, .LANCHOR0
        add     x0, x1, :lo12:.LANCHOR0
        ldr     w2, [x1, #:lo12:.LANCHOR0]
        add     w2, w2, 1
        str     w2, [x0]
        dmb     ishld
        ldr     w1, [x1, #:lo12:.LANCHOR0]
        mov     w3, 1
        mov     w2, 2
        stp     w3, w2, [x0, 4]
        add     w1, w1, w3
        stlr    w1, [x0]
        ret

Which, afaict, is completely buggered. What it seems to be doing is
turning the seq load into a load-acquire, but what we really need is to
make sure the seq store (increment) is ordered before the other stores.
Put differently, what you seem to want is store-acquire, but there ain't
no such thing.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help