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.94.2) (envelope-from ) id 1tqbeA-007ddL-19 for pgsql-hackers@arkaria.postgresql.org; Fri, 07 Mar 2025 17:38:06 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1tqbe8-00D8jC-Oj for pgsql-hackers@arkaria.postgresql.org; Fri, 07 Mar 2025 17:38:04 +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.94.2) (envelope-from ) id 1tqbe8-00D8i2-FL for pgsql-hackers@lists.postgresql.org; Fri, 07 Mar 2025 17:38:04 +0000 Received: from fhigh-b5-smtp.messagingengine.com ([202.12.124.156]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1tqbe6-001X8d-2K for pgsql-hackers@postgresql.org; Fri, 07 Mar 2025 17:38:03 +0000 Received: from phl-compute-12.internal (phl-compute-12.phl.internal [10.202.2.52]) by mailfhigh.stl.internal (Postfix) with ESMTP id 27E5425400D0; Fri, 7 Mar 2025 12:38:02 -0500 (EST) Received: from phl-mailfrontend-02 ([10.202.2.163]) by phl-compute-12.internal (MEProxy); Fri, 07 Mar 2025 12:38:02 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=anarazel.de; h= cc:cc: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=1741369082; x=1741455482; bh=PRhKI+TBkh oejDthAJi4kMAaWWNyLexgELPjCDw6Mw0=; b=WUg742zkLaW1582vkZ5l+D+LEd YcsppKajvhMzWEApQnyR+TnXu4FTC64Nij2P/Pe7rrwg36iJ7kyee/PkIjgInmIx wzp1Bnl19UWqiZu3jKKa2qLqV04QAoA2n9PQ6+xwPchDhnePl/7EI/bm5HUKNfHp V9522IqwPpNS7A5IH1/NXNDS924b9qhmnVCgatFWvk9NLJFgkRrODjhJn+4UO8F+ HzMOWmF5RMi0B0KTfeTb970WANEbZMkFaUimwuvYiiC1+tAnSFxjkHrhCOB8CgjH LNVnBljwyRkBBPoRMLWwbh+RzwC6kyXw14sIpwmVr92KuzV8f6aXLldi939A== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc: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=fm1; t= 1741369082; x=1741455482; bh=PRhKI+TBkhoejDthAJi4kMAaWWNyLexgELP jCDw6Mw0=; b=7UpvbMc3XXb/HQk8Yn5i0CFgX/MdMvH3qe1HsINObQ8oY/tFb2F br0s7HgRnZDvZRcmR3ESjtfHOdazyAFWq7MBkPRlfBVRzZ/hi8KV1iXLAT8B3jev eUvQrbnnbuWoRwC6HH1nO1LefdBigG1feoN9HApBhL2iGw4Tuo2imFCCDahITFtT JpsFWMzDxxLDTrvh5/6mo+iLdd9SrOUl8WhBuemzn4QtHZFm/3gCt6oj51PWGxZi a/Ac1oWkhQEDkj6gf0EVC91DiALPBrF5Htm/ra7+KhxhEs+ZV+ILGHCXjpJT5Sdf oSRqC8p9wZRKvBGKLx7Xm5oAFf08N8UCx/w== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefvddrtddtgdduudduvdekucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggv pdfurfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpih gvnhhtshculddquddttddmnecujfgurhepfffhvfevuffkfhggtggujgesthdtsfdttddt vdenucfhrhhomheptehnughrvghsucfhrhgvuhhnugcuoegrnhgurhgvshesrghnrghrrg iivghlrdguvgeqnecuggftrfgrthhtvghrnhepfeffgfelvdffgedtveelgfdtgefghfdv kefggeetieevjeekteduleevjefhueegnecuvehluhhsthgvrhfuihiivgeptdenucfrrg hrrghmpehmrghilhhfrhhomheprghnughrvghssegrnhgrrhgriigvlhdruggvpdhnsggp rhgtphhtthhopeefpdhmohguvgepshhmthhpohhuthdprhgtphhtthhopegrvghkohhroh htkhhovhesghhmrghilhdrtghomhdprhgtphhtthhopehprghshhhkihhnrdgvlhhfvges ghhmrghilhdrtghomhdprhgtphhtthhopehpghhsqhhlqdhhrggtkhgvrhhssehpohhsth hgrhgvshhqlhdrohhrgh X-ME-Proxy: Feedback-ID: id4a34324:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 7 Mar 2025 12:38:01 -0500 (EST) Date: Fri, 7 Mar 2025 12:38:00 -0500 From: Andres Freund To: Pavel Borisov Cc: Alexander Korotkov , pgsql-hackers Subject: Re: pg_atomic_compare_exchange_*() and memory barriers Message-ID: References: <2muwyx6a5vojkg7iegknhnkcch3lfxptsxk7icwuh7szkvvu2y@vc3ukkfvnu6i> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi, On 2025-03-07 21:08:34 +0400, Pavel Borisov wrote: > On Fri, 7 Mar 2025 at 20:40, Alexander Korotkov wrote: > > Yes, there surely should be a memory barrier on another side. But > > does __ATOMIC_SEQ_CST works as a barrier for the regular read/write > > operations on the same side? > According to a reference posted by Andres [1]: > "Within a thread of execution, accesses (reads and writes) through > volatile lvalues cannot be reordered past observable side-effects > (including other volatile accesses) that are separated by a sequence > point within the same thread, but this order is not guaranteed to be > observed by another thread, since volatile access does not establish > inter-thread synchronization." How is volatile relevant here? > Also: "as soon as atomic operations that are not tagged > memory_order_seq_cst enter the picture, the sequential consistency is > lost" Sequential consistency is lost, but that does *NOT* mean that acquire/release guarantees that are also guaranteed by ATOMIC_SEQ_CST are lost. Greetings, Andres Freund