Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vMXB7-00Crex-1P for pgsql-hackers@arkaria.postgresql.org; Fri, 21 Nov 2025 19:52:21 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vMXB6-009Lad-0J for pgsql-hackers@arkaria.postgresql.org; Fri, 21 Nov 2025 19:52:20 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vMXB5-009LUq-29 for pgsql-hackers@lists.postgresql.org; Fri, 21 Nov 2025 19:52:20 +0000 Received: from fout-b1-smtp.messagingengine.com ([202.12.124.144]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vMXB3-000mIK-2Q for pgsql-hackers@lists.postgresql.org; Fri, 21 Nov 2025 19:52:19 +0000 Received: from phl-compute-05.internal (phl-compute-05.internal [10.202.2.45]) by mailfout.stl.internal (Postfix) with ESMTP id F24721D000B0; Fri, 21 Nov 2025 14:52:14 -0500 (EST) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-05.internal (MEProxy); Fri, 21 Nov 2025 14:52:15 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=burd.me; h=cc:cc :content-transfer-encoding:content-type:content-type:date:date :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm1; t=1763754734; x=1763841134; bh=iI+3YfFv0kiJS1w5kgJCQF6d09ETwguD3WXhXMzAnWg=; b= STk8DBmqzzZf0iBovCy8Bu1tzKZM8EZVPSIg/DX+kk84VteVdZgZVeACWsJxX4Dx RyYBzv7WBONBryz8ONuqBcTyPr190xPGbQXNRDgwt+HSE8WVTErCNF/7wS8X5oLz 4IfZH6gqQpHXvqfK613zGvf3MU+zQvPnyrDEWB2In/lv65tw8lNUf2D6levgMQAf BrvtiFm6PSS9J/5PUwEWUN5TYWrePrHkADBpzR0GNKb6/bFoSILge6C8M+7sR4Pk 4uLUA2Et+i6fjAeHTDQ+blD9BffFkOBrnfSY+vPyb5WGp0qTX7yRkA8m/EyHXDJK op1dgIbSvnPsxIfb3Kp1Cw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t=1763754734; x= 1763841134; bh=iI+3YfFv0kiJS1w5kgJCQF6d09ETwguD3WXhXMzAnWg=; b=y pYWbis+liUB9cFL+tsWUH5pG6cBnsJyhYx+wtfwiIRT+QbuF/x9N7glQn/uHjcmn EiVEbZ9PyKgXruLHonffqVKpkFZmS9cf3m2U/+8nAyZAuqzHtexhLDrh+bhweoCC Qz0myeV0U8OJZuUAHpPcp15HCFxLkkrLlbcbWDaVjQy4/yk6OTi5KacrycZ/QivZ yUotItFB7T8amIy8W7hDnLeRylMeI4dfUrqBOwbJFmCwnVwPFTluP+pmKiAEMTYY OKWdOOEI0I4A+ADbMZ0YH5Jl+wBaE8W4qxktT6RQ4bfInmJmNHcWra3O9Gn/eiIN Z1Cy0d1zeZxPd2Lhov4/A== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdeggddvfedtkeehucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujf gurhepfffhvfevkfgjfhfuofggtgfgugesthhqmhdtredtjeenucfhrhhomhepifhrvghg uceuuhhrugcuoehgrhgvghessghurhgurdhmvgeqnecuggftrfgrthhtvghrnhephedtle fhjefffeekvefhtedvgeetheeggeeihfekleeggfehhfetueehjeetteeknecuffhomhgr ihhnpehmihgtrhhoshhofhhtrdgtohhmpdifihhkihhpvgguihgrrdhorhhgpdhpohhsth hgrhgvshhqlhdrohhrghenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgr ihhlfhhrohhmpehgrhgvghessghurhgurdhmvgdpnhgspghrtghpthhtohepfedpmhhoug gvpehsmhhtphhouhhtpdhrtghpthhtohepthhhohhmrghsrdhmuhhnrhhosehgmhgrihhl rdgtohhmpdhrtghpthhtohepphhgshhqlhdqhhgrtghkvghrsheslhhishhtshdrphhosh htghhrvghsqhhlrdhorhhgpdhrtghpthhtohepuggrvhgvtghrrghmvghrsehgmhgrihhl rdgtohhm X-ME-Proxy: Feedback-ID: i675e48f3:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 21 Nov 2025 14:52:14 -0500 (EST) Date: Fri, 21 Nov 2025 14:52:03 -0500 From: Greg Burd To: Thomas Munro Cc: PostgreSQL Hackers , Dave Cramer Message-ID: In-Reply-To: References: Subject: Re: [PATCH] Fix ARM64/MSVC atomic memory ordering issues on Win11 by adding explicit DMB =?utf-8?Q?=E2=80=8Bbarriers?= X-Mailer: Mailspring MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Nov 20 2025, at 7:08 pm, Thomas Munro wrote= : > On =46ri, Nov 21, 2025 at 9:45=E2=80=AFAM Greg Burd wr= ote: >> Dave and I have been working together to get ARM64 with MSVC functiona= l. >> The attached patches accomplish that. Dave is the author of the first= >> which addresses some build issues and fixes the spin=5Fdelay() semanti= cs, >> I did the second which fixes some atomics in this combination. > =20 > A couple of immediate thoughts: Hey Thomas, I'm always interested in your thoughts. Thanks for taking a look at this. > https://learn.microsoft.com/en-us/cpp/intrinsics/interlockedexchangeadd= -intrinsic-functions=3Fview=3Dmsvc-170 > =20 > Doesn't seem to match your conclusion. > =20 > + if cc.get=5Fid() =3D=3D 'msvc' > + cdata.set('USE=5FARMV8=5FCRC32C', false) > + cdata.set('USE=5FARMV8=5FCRC32C=5FWITH=5FRUNTIME=5FCHECK', 1) > =20 > USE=5FARMV8=5FCRC32C=5FWITH=5FRUNTIME=5FCHECK (pg=5Fcrc32c=5Farmv8=5Fch= oose.c) won't > actually work on Windows, but I don't think we should waste time > implementing it: vendor-supported versions of Windows 11 require > ARMv8.1A to boot=5B1=5D=5B2=5D, and that has it, so I think we should p= robably > just define USE=5FARMV8=5FCRC32C. I'll give that a go, I think your logic is sound. > +static =5F=5Fforceinline void > +spin=5Fdelay(void) > +=7B > + /* Reference: > https://learn.microsoft.com/en-us/cpp/intrinsics/arm64-intrinsics=23Bar= rierRestrictions > */ > + =5F=5Fisb(=5FARM64=5FBARRIER=5FSY); > +=7D > =20 > I don't doubt that barriers are missing in a few places, but how can > this be the right place=3F Well, with the compiler flag that Andres mentioned I need to reconsider this change. > If you have an environment set up so it's easy to test, I would also > be very interested to know if my patch set=5B3=5D that nukes all this > stuff and includes instead, which is green on > Windows/x86 CI, will just work=E2=84=A2 there too. I do, and I will as soon as I get this sorted. =20 > =5B1=5D https://en.wikipedia.org/wiki/Windows=5F11=5Fversion=5Fhistory > =5B2=5D https://learn.microsoft.com/en-us/lifecycle/products/windows-11= -home-and-pro > =5B3=5D https://www.postgresql.org/message-id/flat/CA%2BhUKGK=46vu3zyvv= 3aaj5hHs9VtWcj=46AmisOwOc7aOZNc5A=463NA%40mail.gmail.com best. -greg