All of lore.kernel.org
 help / color / mirror / Atom feed
From: Luca Di Maio <luca@edera.dev>
To: xen-devel@lists.xenproject.org
Cc: Luca Di Maio <luca@edera.dev>,
	Stefano Stabellini <sstabellini@kernel.org>,
	Julien Grall <julien@xen.org>,
	Bertrand Marquis <bertrand.marquis@arm.com>,
	Michal Orzel <michal.orzel@amd.com>,
	Volodymyr Babchuk <Volodymyr_Babchuk@epam.com>,
	Alex Zenla <alex@edera.dev>,
	"Alexander M. Merritt" <alexander@edera.dev>,
	Andres Rodriguez <andres@edera.dev>,
	Simon Veith <simon@edera.dev>, Steven Noonan <steven@edera.dev>
Subject: [PATCH v2 0/5] xen/arm64: use LSE atomics when the CPU has them
Date: Tue,  1 Dec 2026 17:08:10 +0100	[thread overview]
Message-ID: <20261201160817.466800-1-luca@edera.dev> (raw)

On a two-socket Graviton4 (AWS c8g.metal-48xl, 192 Neoverse V2 cores),
dom0 hangs about two minutes into its boot. All 96 pCPUs of one socket
spin in the exclusive loop of atomic_add_return() on dom0's p2m rwlock:
nobody holds the lock, the increment itself never completes. The lock
is hot because every trapped-WFI block copies the vCPU's runstate to a
guest virtual address, and that translation takes the p2m read lock.

LSE atomics guarantee forward progress, and with them dom0 came up in
every boot I tried. Following Linux, the series detects LSE at boot and
puts a check patched by the alternatives in front of each existing
exclusive loop, so CPUs without LSE run the same code as today. Each
LSE sequence keeps the barriers of the loop it bypasses, so the
ordering is the same or stronger.

Tested on the 48xl with our 4.22-based tree, with guests running, and
on staging under QEMU with and without LSE (neoverse-n2, cortex-a57).

Changes in v2:
- Patch 1: check the assembler for LSE in Kconfig instead of arch.mk (Jan).

Luca Di Maio (5):
  xen/arm64: detect the LSE atomic instructions
  xen/arm64: use LSE in the atomic_t operations
  xen/arm64: use LSE in xchg() and cmpxchg()
  xen/arm64: use LSE in the bitops
  xen/arm64: use LSE for arch_fetch_and_add()

 xen/arch/arm/Kconfig                     |  4 ++
 xen/arch/arm/arm64/lib/bitops.c          | 47 ++++++++++++++++----
 xen/arch/arm/cpufeature.c                | 10 +++++
 xen/arch/arm/include/asm/arm64/atomic.h  | 55 ++++++++++++++++++++++++
 xen/arch/arm/include/asm/arm64/cmpxchg.h | 41 ++++++++++++++++++
 xen/arch/arm/include/asm/arm64/lse.h     | 31 +++++++++++++
 xen/arch/arm/include/asm/arm64/system.h  | 20 +++++++++
 xen/arch/arm/include/asm/cpufeature.h    |  3 +-
 xen/arch/arm/include/asm/system.h        |  2 +
 9 files changed, 204 insertions(+), 9 deletions(-)
 create mode 100644 xen/arch/arm/include/asm/arm64/lse.h


base-commit: 091d3c200281ea44846ccdf1e5d39985321c643e
-- 
2.47.3



             reply	other threads:[~2026-12-01 16:09 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-01 16:08 Luca Di Maio [this message]
2026-12-01 16:08 ` [PATCH v2 1/5] xen/arm64: detect the LSE atomic instructions Luca Di Maio
2026-12-01 16:08 ` [PATCH v2 2/5] xen/arm64: use LSE in the atomic_t operations Luca Di Maio
2026-12-01 16:08 ` [PATCH v2 3/5] xen/arm64: use LSE in xchg() and cmpxchg() Luca Di Maio
2026-12-01 16:08 ` [PATCH v2 4/5] xen/arm64: use LSE in the bitops Luca Di Maio
2026-12-01 16:08 ` [PATCH v2 5/5] xen/arm64: use LSE for arch_fetch_and_add() Luca Di Maio

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261201160817.466800-1-luca@edera.dev \
    --to=luca@edera.dev \
    --cc=Volodymyr_Babchuk@epam.com \
    --cc=alex@edera.dev \
    --cc=alexander@edera.dev \
    --cc=andres@edera.dev \
    --cc=bertrand.marquis@arm.com \
    --cc=julien@xen.org \
    --cc=michal.orzel@amd.com \
    --cc=simon@edera.dev \
    --cc=sstabellini@kernel.org \
    --cc=steven@edera.dev \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.