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 1sOIQl-00DWXN-HL for pgsql-hackers@arkaria.postgresql.org; Mon, 01 Jul 2024 14:54:59 +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 1sOIQj-002foc-RY for pgsql-hackers@arkaria.postgresql.org; Mon, 01 Jul 2024 14:54:58 +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 1sOIQj-002fnu-DC for pgsql-hackers@lists.postgresql.org; Mon, 01 Jul 2024 14:54:57 +0000 Received: from fout3-smtp.messagingengine.com ([103.168.172.146]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sOIQh-0042zW-2m for pgsql-hackers@lists.postgresql.org; Mon, 01 Jul 2024 14:54:56 +0000 Received: from compute7.internal (compute7.nyi.internal [10.202.2.48]) by mailfout.nyi.internal (Postfix) with ESMTP id ED76E1380167; Mon, 1 Jul 2024 10:54:53 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute7.internal (MEProxy); Mon, 01 Jul 2024 10:54:53 -0400 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 :reply-to:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t=1719845693; x= 1719932093; bh=nVsSbqAz9bLz0cu/xV6qWp7bf/9RuwEmCHLjcbzKiCY=; b=J TM5vN7Hp1yd/bz8c6+6W+4fVl/N/E8htH5iRa5bja+dp+TjGDGoQ0IhaTuNwCjQH DJIe/psKig4YCZDW1VzZSerX1o3tVcyNnasEgmmbPWkkzjx3bmU1AaiRRZSsOG2Y VyRlcGyVZHnbyp4fdUGflH922NGug9853NcTapx1jH4gn6xd8Atp2qQtRPL+WhX+ zPLjuraWGAzskxMyoE/3+yZn4rapUkBfQFOPW6RI+qEFbuTKbrmup/p5QzYsbtuJ x+IyKHm06A0dk3BQGCBNctsU0TSFJnlEOqmlRtxl3F/gWVaGdj+PdSnv4ppFcWFN tplZ3aVgBUljy4q4oSF4Q== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddrudefgdekudcutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpeffhffvvefukfggtggugfgjsehtkeertddttdejnecuhfhrohhmpeetlhhvrghr ohcujfgvrhhrvghrrgcuoegrlhhvhhgvrhhrvgesrghlvhhhrdhnohdqihhprdhorhhgqe enucggtffrrghtthgvrhhnpedvkedtffduffdtffffheffhfejjefhgfeiueeukeejkeff gfdufffhudffffeuveenucffohhmrghinhepvghnthgvrhhprhhishgvuggsrdgtohhmne cuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheprghlvhhh vghrrhgvsegrlhhvhhdrnhhoqdhiphdrohhrgh X-ME-Proxy: Feedback-ID: ia2694551:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 1 Jul 2024 10:54:53 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alvh.no-ip.org; s=schmee; t=1719845691; bh=ZfLDE4SGMqOjKm8HsJLKAoQdKqeKykEQ1qQcsecT6VE=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=URFxQHViRy07ZNJcbqYq0na43c+iycCCCCdn1Z8p3ShrHSWHskxwVj2r8hWWtZXDb 3Gti5MWPGDWWQwWvtX+isp5Qf82AH8QfnJau/AGEA6V2oWf/3UJsmxgg13klfrgdtF AbKI01cltIs35Hc3RXv85j7CU1ua/lglk75eVfK/7Nwo2bJMFiMMiUBtSRCvy2/WGU kUFFSMh/s79o4CeAfLQSlptirTCgsswFkpYQK5dIy36CfSUkJlFRp49pw2QA95riC+ V1U3JuvIjlFK3bVUuPX30SLrEfF1KRN9U+s2Z/kH7qtx8tAQRNjVItX4LsDYGuSeMy W5geSO894gGzg== Received: by schmee.alvh.no-ip.org (Postfix, from userid 1000) id EBA31529; Mon, 1 Jul 2024 16:54:51 +0200 (CEST) Date: Mon, 1 Jul 2024 16:54:51 +0200 From: Alvaro Herrera To: Tom Lane Cc: Alexander Lakhin , Bharath Rupireddy , Andres Freund , Jeff Davis , pgsql-hackers@lists.postgresql.org, Jaime Casanova Subject: Re: LogwrtResult contended spinlock Message-ID: <202407011454.hni6ldpc3hoa@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <202407011435.oiv2idunr7ps@alvherre.pgsql> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Maybe we can do something like this, diff --git a/src/include/port/atomics.h b/src/include/port/atomics.h index 78987f3154..f6fa90bad8 100644 --- a/src/include/port/atomics.h +++ b/src/include/port/atomics.h @@ -580,7 +580,20 @@ pg_atomic_sub_fetch_u64(volatile pg_atomic_uint64 *ptr, int64 sub_) static inline uint64 pg_atomic_monotonic_advance_u64(volatile pg_atomic_uint64 *ptr, uint64 target_) { + /* + * When using actual (not simulated) atomics, the target variable for + * pg_atomic_compare_exchange_u64 must have suitable alignment, which + * is acquired naturally on most platforms, but not on 32-bit ones; + * persuade the compiler in that case, but fail if we + * cannot. + */ +#if MAXIMUM_ALIGNOF >= 8 uint64 currval; +#elif defined(pg_attribute_aligned) && !defined(PG_HAVE_ATOMIC_U64_SIMULATION) + pg_attribute_aligned(8) uint64 currval; +#else +#error "Must have pg_attribute aligned or simulated atomics" +#endif #ifndef PG_HAVE_ATOMIC_U64_SIMULATION AssertPointerAlignment(ptr, 8); -- Álvaro Herrera 48°01'N 7°57'E — https://www.EnterpriseDB.com/ "Just treat us the way you want to be treated + some extra allowance for ignorance." (Michael Brusser)