From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (prime256v1) server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 298F9606A32F for ; Thu, 3 Dec 2026 01:04:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=SkGRCMKm Received: from list by lists.xenproject.org with outflank-mailman.1511376.1703816 (Exim 4.92) (envelope-from ) id 1xYvFE-0005MY-NA; Thu, 03 Dec 2026 01:04:20 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 1511376.1703816; Thu, 03 Dec 2026 01:04:20 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1xYvFE-0005MR-KI; Thu, 03 Dec 2026 01:04:20 +0000 Received: by outflank-mailman (input) for mailman id 1511376; Thu, 03 Dec 2026 01:04:20 +0000 Received: from mx.expurgate.net ([195.190.135.20]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1xYvFE-0005ML-2N for xen-devel@lists.xenproject.org; Thu, 03 Dec 2026 01:04:20 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1xYvFD-0006Of-El for xen-devel@lists.xenproject.org; Thu, 03 Dec 2026 02:04:19 +0100 Received: from [10.42.69.10] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6b10bff3-e002-0a2a0a5209dd-0a2a450ad912-28 for ; Thu, 03 Dec 2026 02:04:19 +0100 Received: from [172.105.4.254] (helo=tor.source.kernel.org) by tlsNG-4011c0.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6b10c012-f2d2-0a2a450a0019-ac6904fe9a10-3 for ; Thu, 03 Dec 2026 02:04:19 +0100 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by tor.source.kernel.org (Postfix) with ESMTP id A83BD60AB4; Thu, 3 Dec 2026 01:04:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 521EF1F00896; Thu, 3 Dec 2026 01:04:16 +0000 (UTC) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Post: List-Help: List-Subscribe: , Precedence: list Sender: "Xen-devel" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=k20260515 header.d=kernel.org header.i="@kernel.org" header.h="Date:From:To:cc:Subject:In-Reply-To:References" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796259857; bh=QoSsyPeLW4Y9+fiY4bcyUg7n7F3d3aZgisfOa7ERHeQ=; h=Date:From:To:cc:Subject:In-Reply-To:References; b=SkGRCMKmLT/uFerfxRXmPHk8doKLNISbP9GWB2N8gPkjnTC/McpkHEomX5CodxCQ6 FLy6I1DwvvBomTM3S2iDeMxN2EP09eb78HlZjlanua7pwpOLCvKD6Cct45uaDBtGKA VQRb4HCEjRN97ijfPuESQLfk/1bg+DR3n13c5xE2DlCUidhmPgSUaQ8jXo+GxDMSpj muDvtx9cCyN7BpLHc4tAUAFc1AnR7FzcrLour6rCieD3leyFcnPU6ixME+FhGuH86V o7h43hxeGVa4frsuKIx8D/RjL3so0M/5QJGqUICV+dMQ0wu1ekOfHmsUvWYczvNMJq sfmTLMhIAWtmg== Date: Wed, 2 Dec 2026 17:04:15 -0800 (PST) From: Stefano Stabellini To: Luca Di Maio cc: xen-devel@lists.xenproject.org, Stefano Stabellini , Julien Grall , Bertrand Marquis , Michal Orzel , Volodymyr Babchuk Subject: Re: [PATCH v2 4/5] xen/arm64: use LSE in the bitops In-Reply-To: <20261201160817.466800-5-luca@edera.dev> Message-ID: References: <20261201160817.466800-1-luca@edera.dev> <20261201160817.466800-5-luca@edera.dev> X-Archived-By: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-purgate-ID: tlsNG-4011c0/1796259859-522C0CFC-D5FFE129/0/0 X-purgate-type: clean X-purgate-size: 6088 X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_PASS, SPF_PASS,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 On Tue, 1 Dec 2026, Luca Di Maio wrote: > As for the atomic_t operations, use ST{SET,CLR,EOR} and > LD{SET,CLR,EOR}AL when the CPU has LSE, with the same barriers; the > macros take the LSE operation as a new argument. The _timeout variants > now succeed on their first try. > > Assisted-by: Claude:claude-opus-5-5 > Signed-off-by: Luca Di Maio Reviewed-by: Stefano Stabellini > --- > xen/arch/arm/arm64/lib/bitops.c | 47 +++++++++++++++++++++++++++------ > 1 file changed, 39 insertions(+), 8 deletions(-) > > diff --git a/xen/arch/arm/arm64/lib/bitops.c b/xen/arch/arm/arm64/lib/bitops.c > index 275a780329..0153e4f68b 100644 > --- a/xen/arch/arm/arm64/lib/bitops.c > +++ b/xen/arch/arm/arm64/lib/bitops.c > @@ -15,6 +15,7 @@ > */ > > #include > +#include > #include > > /* > @@ -28,7 +29,7 @@ > * XXX: Rework the interface to use unsigned int. > */ > > -#define bitop(name, instr) \ > +#define bitop(name, instr, lse_op) \ > static always_inline bool int_##name(int nr, volatile void *p, bool timeout,\ > unsigned int max_try) \ > { \ > @@ -37,6 +38,15 @@ static always_inline bool int_##name(int nr, volatile void *p, bool timeout,\ > const uint32_t mask = BITOP_MASK((unsigned int)nr); \ > unsigned long res, tmp; \ > \ > + if ( system_uses_lse_atomics() ) \ > + { \ > + asm volatile ( __LSE_PREAMBLE \ > + " st" #lse_op " %w1, %0\n" \ > + : "+Q" (*ptr) \ > + : "r" (mask) ); \ > + return true; \ > + } \ > + \ > do \ > { \ > asm volatile ("// " __stringify(name) "\n" \ > @@ -64,7 +74,7 @@ bool name##_timeout(int nr, volatile void *p, unsigned int max_try) \ > return int_##name(nr, p, true, max_try); \ > } > > -#define testop(name, instr) \ > +#define testop(name, instr, lse_op) \ > static always_inline bool int_##name(int nr, volatile void *p, int *oldbit, \ > bool timeout, unsigned int max_try) \ > { \ > @@ -74,6 +84,18 @@ static always_inline bool int_##name(int nr, volatile void *p, int *oldbit, \ > const uint32_t mask = BITOP_MASK(bit); \ > unsigned long res, tmp; \ > \ > + if ( system_uses_lse_atomics() ) \ > + { \ > + asm volatile ( __LSE_PREAMBLE \ > + " ld" #lse_op "al %w2, %w0, %1\n" \ > + : "=&r" (tmp), "+Q" (*ptr) \ > + : "r" (mask) \ > + : "memory" ); \ > + dmb(ish); \ > + *oldbit = (tmp >> bit) & 1; \ > + return true; \ > + } \ > + \ > do \ > { \ > asm volatile ("// " __stringify(name) "\n" \ > @@ -112,19 +134,28 @@ bool name##_timeout(int nr, volatile void *p, \ > return int_##name(nr, p, oldbit, true, max_try); \ > } > > -bitop(change_bit, eor) > -bitop(clear_bit, bic) > -bitop(set_bit, orr) > +bitop(change_bit, eor, eor) > +bitop(clear_bit, bic, clr) > +bitop(set_bit, orr, set) > > -testop(test_and_change_bit, eor) > -testop(test_and_clear_bit, bic) > -testop(test_and_set_bit, orr) > +testop(test_and_change_bit, eor, eor) > +testop(test_and_clear_bit, bic, clr) > +testop(test_and_set_bit, orr, set) > > static always_inline bool int_clear_mask16(uint16_t mask, volatile uint16_t *p, > bool timeout, unsigned int max_try) > { > unsigned long res, tmp; > > + if ( system_uses_lse_atomics() ) > + { > + asm volatile ( __LSE_PREAMBLE > + " stclrh %w1, %0\n" > + : "+Q" (*p) > + : "r" (mask) ); > + return true; > + } > + > do > { > asm volatile ("// int_clear_mask16\n" > -- > 2.47.3 >