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 1vVHYo-00HXr9-1o for pgsql-hackers@arkaria.postgresql.org; Mon, 15 Dec 2025 23:00:59 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vVHYl-002y9q-2Z for pgsql-hackers@arkaria.postgresql.org; Mon, 15 Dec 2025 23:00:56 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vVHYl-002y9i-16 for pgsql-hackers@lists.postgresql.org; Mon, 15 Dec 2025 23:00:56 +0000 Received: from mail-ot1-x32a.google.com ([2607:f8b0:4864:20::32a]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1vVHYk-000riC-0D for pgsql-hackers@lists.postgresql.org; Mon, 15 Dec 2025 23:00:55 +0000 Received: by mail-ot1-x32a.google.com with SMTP id 46e09a7af769-7c75b829eb6so2998868a34.1 for ; Mon, 15 Dec 2025 15:00:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1765839653; x=1766444453; darn=lists.postgresql.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=p7prh/WYh8A6szaVhlZwumyvB2Ccy+JTfbL4Edjcd0I=; b=FmGcDy0LYrov6f5bsuO/CZwlGhkBz31eAKPcPE+nBNxSTEXOZ46Xef1QgUJJJHxWxZ 8VFHIS5nI+hqq4163kDbQ+eFJVspFn5uzsgsMVpgAUaZDTiAZIkXTsBAR+zrWqaOL+/q 3gtVCoJ2eolcxyV5xVKLgXQwc5CkwwuImRkxe8OqZTiOFZTQ2ZenPv9jQjczLxkqkLhq /6Y/6nXoXnEiRsb+1Gy/lqSpVJFFJa78Uz/TOXfOZ+cJ5pbfeTROBYpwdCe0LBDV5fWE BB+bIaLxTWxMKwRQEGdWgkXOsZB0Z+KP4fvO/JZoIUfl3iCVeU+IPn7xbKERgLqPUklt RMQA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1765839653; x=1766444453; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=p7prh/WYh8A6szaVhlZwumyvB2Ccy+JTfbL4Edjcd0I=; b=d2Xkxu8oQIVKLFY/TJIZ/sM2SXW/QNSPSq2Otv8lnB+T4BIWg5gWFAo6HhDmG9TBwQ +8Ih/qLlXMJhqbgxAxOAVRtMgyEFElZ9ZfGTDO3Nvo4xLpG7IgZCazcU7fGWjq8TgkW7 J66Hz1GFKxDaFr0ykft55z8SC3zw5YFH/VTGF1N7PJiL1Dt2d2GjXrxXYhITioxOjojV /wcNPN6oQhOsDKfpJZHURyJT/gUo75E3ztoL6bTMAi6vtg2e8bXvFp+zKLZUitUDSUfK jE135qZ2gTYibVKeOasqD/vENdQI4+6vA1Sy39vGG9YTQqzRozYVlk4SPoeG/3qEyG3T hZSQ== X-Forwarded-Encrypted: i=1; AJvYcCXVFz9/GP0lKQR9gKDKkV3kUpddMreYEGN9/i5dTLjO8vP3o5R9SuwKf8fwZEK/+1wl2qNb+Tzm1+e+Ncz6@lists.postgresql.org X-Gm-Message-State: AOJu0YzEYsPXtONULEM9f8WoVj8uGTCsqtAB4pvPP3KHqPOrDyVeHPIR eHkLhUcK9rwVpA8d+yLwgTrUJS71beT4qRPPYT5ZFkH7fO7VjHAmWWt4wbpjlQ== X-Gm-Gg: AY/fxX4fCUfvxqC663ghv9646hdGBNUB4qzVqG2IWrJvOhUk5L1LRzApd3xIQ2bibOG QCwOUo67BZkJoXhyU2onlDkSTWZt58FtnSx0u1W2CDRuYVM7iAdbQhcbl9dEmIIYWYDqN6Fok9H mhTGRUCJDdzlMUI7uuAnSPwf6ZOFHDBhM/0tbrzzWA4afTUmtOBxGON0O7cUuZZPXxwMhkeql/M AcaPhcDsiSIWcS5C8DmRNoUfORRml8m6fBgK32laoHkUXlzFcUtmwVJlbVWY9sA6dc4xo97nEao Lux2pIQQKv6zo09owPtjysOeYMBFHMcrPAv5PHV3zpLXRJdcAWC9i3cEjlOkeQlQa8oQWMulIKB L2Vd37KebvNg19qaPyJlcgvUXqVz5ODN+l84UwXvVwogvy4Ix4HPujNpfVWf3L4mKLJ22nkcE6Z IDDBckD5aPabaL3YO2xmYPhaW4mi3PqDa10OiIdSJtd3x/EzbbujSZCpJzZhTAKrG8LSLRJGJjo aTt X-Google-Smtp-Source: AGHT+IFI9PitcjKmVWg1EkjXJzrlJ4c1ImmNYqJTXxdnq0J3ZmAa7deqUyQXF2j1Tc+Bywd5O3ShUQ== X-Received: by 2002:a05:6830:6e23:b0:7c7:80e5:245f with SMTP id 46e09a7af769-7cae8366d4cmr5628925a34.30.1765839652658; Mon, 15 Dec 2025 15:00:52 -0800 (PST) Received: from nathan (162-195-168-172.lightspeed.stlsmo.sbcglobal.net. [162.195.168.172]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-7cadb200661sm10342555a34.8.2025.12.15.15.00.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Dec 2025 15:00:49 -0800 (PST) Date: Mon, 15 Dec 2025 17:00:47 -0600 From: Nathan Bossart To: Andres Freund Cc: Greg Burd , Thomas Munro , PostgreSQL Hackers , Peter Eisentraut , Dave Cramer Subject: Re: [PATCH] Fix ARM64/MSVC atomic memory ordering issues on Win11 by adding explicit DMB ?barriers Message-ID: References: <5e169c16-9e54-4325-8027-1f52a5bb5c1e@app.fastmail.com> <1c2a29b8-5b1e-44f7-a871-71ec5fefc120@app.fastmail.com> <8e926f26-0a97-434f-a665-8bb6f9159b08@app.fastmail.com> <6646f9f4-3609-41e2-8d9f-dcd63e9f915e@app.fastmail.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="75SgnF0Jxi868KJh" Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --75SgnF0Jxi868KJh Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Mon, Dec 15, 2025 at 05:32:36PM -0500, Andres Freund wrote: > On 2025-12-15 15:38:49 -0600, Nathan Bossart wrote: >> - if cc.links(prog, name: '__crc32cb, __crc32ch, __crc32cw, and __crc32cd without -march=armv8-a+crc', >> + if (host_cpu == 'aarch64' and cc.get_id() == 'msvc') or \ >> + cc.links(prog, name: '__crc32cb, __crc32ch, __crc32cw, and __crc32cd without -march=armv8-a+crc', >> args: test_c_args) >> # Use ARM CRC Extension unconditionally >> cdata.set('USE_ARMV8_CRC32C', 1) > > I still think this should have a comment explaining that we can > unconditionally rely on crc32 support due to window's baseline requirements. Done. >> +#ifdef _M_ARM64 >> +static __forceinline void >> +spin_delay(void) >> +{ >> + /* Research indicates ISB is better than __yield() on AArch64. */ >> + __isb(_ARM64_BARRIER_SY); > > It'd be good to link the research in some form or another. Otherwise it's > harder to evolve the code in the future, because we don't know if the research > was "I liked the color better" or "one is catastrophically slower than the > other". Done. >> #include >> +#ifdef _M_ARM64 >> +#pragma intrinsic(_InterlockedExchange) >> + >> +/* _ReadWriteBarrier() is insufficient on non-TSO architectures. */ >> +#define S_UNLOCK(lock) _InterlockedExchange(lock, 0) >> +#else >> #pragma intrinsic(_ReadWriteBarrier) >> >> #define S_UNLOCK(lock) \ >> do { _ReadWriteBarrier(); (*(lock)) = 0; } while (0) >> >> #endif >> +#endif > > The newline placement looks odd here. I'd add newlines around the #else. Done. -- nathan --75SgnF0Jxi868KJh Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v11-0001-Enable-the-Microsoft-Windows-ARM64-MSVC-platform.patch