aarch64 Linux: outline atomics never use LSE

Aperta
#166,418 12 commenti 1 reazione 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

  • #166430 di @ali-vercel — chiusa senza merge

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
18/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
rust

Direzione di ricerca

Read rust-lang/compiler-builtins#1354 first, then the aarch64 outline-atomics helpers that define __aarch64_ldadd8_acq_rel and the runtime LSE feature check they branch on. Reproduce with the issue's script, comparing the disassembly of nightly-2026-10-28 against nightly-2026-10-29 under qemu-aarch64 -cpu max. Done means the helper emits ldaddal again when the LSE feature bit is set. Note that pull request #166430 is already open against this issue.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

A-compiler-builtins C-bug I-slow O-Arm O-linux P-high regression-untriaged S-has-bisection T-libs

Ever since rust nightly 2026-10-29, outline atomics on aarch64 linux don't use LSE. Appears to have been caused by rust-lang/compiler-builtins#1354. This causes poor performance because it falls back to an LL/SC retry loop.

Reproduction

use std::sync::atomic::{AtomicU64, Ordering};

static COUNTER: AtomicU64 = AtomicU64::new(0);

fn main() {
    COUNTER.fetch_add(1, Ordering::SeqCst);
}
Reproduction script to check arm64 instructions Install rustup and qemu-user.
#!/bin/bash
set -e
for toolchain in nightly-2026-10-28 nightly-2026-10-29; do
  rustup -q toolchain install --profile minimal $toolchain
  RUSTFLAGS="-C relocation-model=static" cargo +$toolchain build -q --release --target-dir target-$toolchain
  bin=target-$toolchain/release/lsemin
  helper=$(nm -S $bin | awk '/ __aarch64_ldadd8_acq_rel$/ {print "0x" $1 "+0x" $2}')
  echo "== $toolchain"
  qemu-aarch64 -cpu max -d in_asm -dfilter $helper $bin 2>&1 | grep '^0x'
done

Ran on qemu-aarch64 -cpu max. The helper __aarch64_ldadd8_acq_rel uses the following instructions

  adrp     x8, #0x460000
  ldrb     w8, [x8, #0xb0c]
  cbz      w8, #0x435a64
  mov      x16, x0
  ldaxr    x0, [x1]
  add      x17, x0, x16
  stlxr    w15, x17, [x1]
  cbnz     w15, #0x435a68
  ret

But I expected it to use ldaddal. Here's output from nightly-2026-10-28.

  adrp     x16, #0x460000
  ldrb     w16, [x16, #0xb0c]
  cbz      w16, #0x435b14
  ldaddal  x0, x0, [x1]
  ret

Claude Opus 5.5 helped me find and bisect this.

Meta

rustc +nightly-2026-10-29 --version --verbose:

rustc 1.101.0-nightly (92ffebece 2026-10-28)
binary: rustc
commit-hash: 92ffebeceaa0a071066f233873c2438e73d70fe7
commit-date: 2026-10-28
host: aarch64-unknown-linux-gnu
release: 1.101.0-nightly
LLVM version: 23.1.4
Lingua principale
Rust
Stelle
123k
Fork
16.6k
Merge medio
2g 17h
PR unite (30g)
532

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di rust-lang/rust

Tutte le issue di rust-lang/rust

Issue simili

Altre issue su Rust

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.