[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v2] xen/arm64/atomic: Clear exclusive monitor on cmpxchg failure


  • To: Julien Grall <julien@xxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: 岡本 涼二 <okamoto@xxxxxxxxxxxxx>
  • Date: Fri, 11 Sep 2026 08:14:45 +0000
  • Accept-language: en-US, ja-JP
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=valinux.co.jp; dmarc=pass action=none header.from=valinux.co.jp; dkim=pass header.d=valinux.co.jp; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=8/RdIz3FwChimoBZoyKFPw9Aj/VFpl/IZC7XOrK7vow=; b=nlvb8YcGoo9505vn3oGiLuAeMsOCJM5GAGgOItB9zBQl74RLwcek6e5IXPU6FA07PBp7RRdWqGjWVD+ijCXjHSmab0VfKLNFWMl4d4gBz/+jKzVGtABEOOwXZzMnU/vrIjm7w04peqom54hl9r4BkB86Jtdngif9HegKOOzT67YZiQkAEuwhENDZA7AVM81UiwEcaw1+JFsCNpojc6TiQkpyOh35tyovYjZi9lm6kWsiIbqkmJ0rWNAHKWMkIxmeeDu1ljCHjIrU5Vj1Lk+NUYFLlqji/GP4mGcAm05dqLJ5mSlMJtwbiVFTBdY89+L5k7CkHVrQ7meheiIUegTCEg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=m89xnvwaSFmj/ZIKPZYPv4fWfhR236ZqAyg9xR3aDXn24LmOMTbyP1Qt0nNHXLz3M/NIqZmXxs6yW1TuOVJq2Va7rCBBBFk68aPWkFkiHQjDOx5i9ZsKjDdkqaavcsPvfAGgN07os2E+hkZO/MmP/Swkk1AOtEevL1XZGiuUkHBWB6OhjrPDdXVFsz3E0DTk0RQN+yDM0t0VpQt2IufPZRZ4hWlvddY8iDqo3S0oDBj1yUWg1oSDQ8Cdyw0comrTjWavPR9Z3oTJ8iOvb83fDi4qKlyjlI5WKcoLyPerxPOm24GN+gJCOavM6F3gBtM2rt1ITi4D5juMvqVFgVCkFA==
  • Authentication-results: eu.smtp.expurgate.cloud; dkim=pass header.s=selector1 header.d=valinux.co.jp header.i="@valinux.co.jp" header.h="From:Date:Subject:Message-ID:Content-Type:MIME-Version:x-ms-exchange-senderadcheck"
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=valinux.co.jp;
  • Cc: Hirokazu Takahashi <taka@xxxxxxxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Bertrand Marquis <bertrand.marquis@xxxxxxx>, Michal Orzel <michal.orzel@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>
  • Delivery-date: Fri, 11 Sep 2026 08:15:07 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Msip_labels:
  • Thread-index: AQHdQCJBEKmlsPmU00mRFpT1XSXe0LbF1F0AgAMw5Ro=
  • Thread-topic: [PATCH v2] xen/arm64/atomic: Clear exclusive monitor on cmpxchg failure

Hi Julien,
Thanks for pointing this out.
I revisited the rationale for adding CLREX here, and I don't think there is a sufficient reason for Xen to do so.
I found a rejected RFC^[1] in Linux in 2015 to add CLREX in atomic operations. In that RFC, Linux arm maintainers said there is no need to add CLREX.
I also found a patch^[2] that makes LLVM emit CLREX on this path, with the rationale that keeping the monitor set might have a negative performance impact on some microarchitectures. However, I have not been able to find concrete microarchitecture-specific evidence or measurements demonstrating such an impact.
Please consider this patch withdrawn.
Thanks for the review.
Regards,
Ryoji


From: Julien Grall <julien@xxxxxxx>
Sent: Wednesday, September 9, 2026 16:10
To: 岡本 涼二 <okamoto@xxxxxxxxxxxxx>; xen-devel@xxxxxxxxxxxxxxxxxxxx <xen-devel@xxxxxxxxxxxxxxxxxxxx>
Cc: Hirokazu Takahashi <taka@xxxxxxxxxxxxx>; Stefano Stabellini <sstabellini@xxxxxxxxxx>; Bertrand Marquis <bertrand.marquis@xxxxxxx>; Michal Orzel <michal.orzel@xxxxxxx>; Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>
Subject: Re: [PATCH v2] xen/arm64/atomic: Clear exclusive monitor on cmpxchg failure
 
Hi Ryoji,

On 09/09/2026 08:12, Ryoji Okamoto wrote:
> When the value comparison fails in atomic_cmpxchg, the code branches
> out without executing stxr, leaving the exclusive monitor in the
> exclusive state set by ldxr.
>
> Add `clrex` to the failure path to explicitly clear the exclusive
> monitor.

The Xen atomics operations were originally taken from Linux. Looking at
the implementation there, I don't see a clrex on the failure path. Do
you have more details why we would want it?

Also, if this is necessary on arm64, then we most likely we want the
same for the arm32 implementation (including __atomic_add_unless()).
       

Cheers,

--
Julien Grall


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.