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 1sOc75-000FZF-9N for pgsql-hackers@arkaria.postgresql.org; Tue, 02 Jul 2024 11:55: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 1sOc72-001MX6-Uj for pgsql-hackers@arkaria.postgresql.org; Tue, 02 Jul 2024 11:55:57 +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 1sOc72-001MWx-3W for pgsql-hackers@lists.postgresql.org; Tue, 02 Jul 2024 11:55:57 +0000 Received: from fout8-smtp.messagingengine.com ([103.168.172.151]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sOc6z-0001vd-RK for pgsql-hackers@lists.postgresql.org; Tue, 02 Jul 2024 11:55:55 +0000 Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailfout.nyi.internal (Postfix) with ESMTP id 57CB5138057D; Tue, 2 Jul 2024 07:55:52 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Tue, 02 Jul 2024 07:55:52 -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=1719921352; x= 1720007752; bh=fuLZE7DqhPPLVw+RlaMfC1F4pwrMqifLkfR+T3B2Sbo=; b=k HgMiv4TiGM2M1iVGNuS1f3JiLI1L40Lo8SSNoVgvzmM7zVBPLj4u8/s9/TujkA/g Ls04N/UDlIdYHDsdAj+M3AmRQUWNsvA9AU0vlERI+0lG1r4LUR/CMrfQThDWnvNW iQ0CpznuK/1nD8J9jnOxa26H7aT9xOVt71+cfkQst2Dl39zjF7mfdoAf7JR+f7kO 9tXNbOQCVLZZY1RNXMGyhX54LenD68ktNHJ5UnqXCIL6RRbfXueU5fC7FQcI5Iy9 i0R2KsdKWJGoOJe+zkExgUZakHbSKNr+bY16j4WXpjJ/Fvtbk2oiBdFtqpLOsnN5 pnMEMeA2KUZ1hAF2CLInw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddrudehgdegfecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpeffhffvvefukfggtggugfgjsehtkeertddttdejnecuhfhrohhmpeetlhhvrghr ohcujfgvrhhrvghrrgcuoegrlhhvhhgvrhhrvgesrghlvhhhrdhnohdqihhprdhorhhgqe enucggtffrrghtthgvrhhnpeffueejheegfeeiiefgleejfeevudeuteeihfejfeetjeek leeiheevgfejkeejudenucffohhmrghinhepvghnthgvrhhprhhishgvuggsrdgtohhmpd hgnhhurdhorhhgnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhf rhhomheprghlvhhhvghrrhgvsegrlhhvhhdrnhhoqdhiphdrohhrgh X-ME-Proxy: Feedback-ID: ia2694551:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 2 Jul 2024 07:55:51 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alvh.no-ip.org; s=schmee; t=1719921349; bh=NOh3iXkl8SqQ60Hta6iqwv7W18biTuKCrbTboZk54Ww=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=YaU/J4A94q+Z2yff5i1bjeCImJ8mBYApIj4Iu7dZrw3kRf8hQpwVSNfTiYXUrtPLO 3NX0LFM09lk+KMcekh5dcj6nMSzinXL0M7KNLdiYOkYO2oAH62BQuKMSFog5R+g4S5 +XFZv66OglS7tc8FifgaljaAO+n8F6Setlj4DNRfbsO6wvYf8UlWrx5GMW5iiYvsVd mgfJk/8kj1oEHNT5v+AGLTJd+UdvdNt732kwAS7bA8wYf1IJPKKiZzX8q5qmFCwMQq c/8oMogr9Is2W2/tfk85bNXNg6fNu7SmyvfsiOLG5xYu4hRG/Eek+M8lX51ueg1mxP vPbKH/wla9pew== Received: by schmee.alvh.no-ip.org (Postfix, from userid 1000) id 619FD8F; Tue, 2 Jul 2024 13:55:49 +0200 (CEST) Date: Tue, 2 Jul 2024 13:55:49 +0200 From: Alvaro Herrera To: Andres Freund Cc: Alexander Lakhin , Bharath Rupireddy , Tom Lane , Jeff Davis , pgsql-hackers@lists.postgresql.org, Jaime Casanova Subject: Re: LogwrtResult contended spinlock Message-ID: <202407021155.s3f4knnte6gv@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <202407011912.diw4rf4rgd76@alvherre.pgsql> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 2024-Jul-01, Alvaro Herrera wrote: > On 2024-Jul-01, Andres Freund wrote: > > > On 2024-07-01 11:10:24 +0200, Alvaro Herrera wrote: > > > In the meantime I noticed that pg_attribute_aligned() is not supported > > > in every platform/compiler, so for safety sake I think it's better to go > > > with what we do for PGAlignedBlock: use a union with a double member. > > > That should be 8-byte aligned on x86 as well, unless I misunderstand. > > > > If a platform wants to support 8 byte atomics, it better provides a way to > > make variables 8 bytes aligned. We already rely on that, actually. See use of > > pg_attribute_aligned in e.g. src/include/port/atomics/generic-msvc.h I noticed that all definitions have the value struct member named "value", so I gave this a quick try, and hit another issue: the "expected" argument of pg_atomic_compare_exchange_u64_impl() is not volatile, which pg_atomic_uint64.value is, so we get this warning: In file included from /pgsql/source/master/src/include/storage/lwlock.h:21, from /pgsql/source/master/src/include/storage/lock.h:23, from /pgsql/source/master/src/include/access/twophase.h:20, from /pgsql/source/master/src/backend/access/transam/xlog.c:57: /pgsql/source/master/src/include/port/atomics.h: In function ‘pg_atomic_monotonic_advance_u64’: /pgsql/source/master/src/include/port/atomics.h:600:62: warning: passing argument 2 of ‘pg_atomic_compare_exchange_u64_impl’ discards ‘volatile’ qualifier from pointer target type [-Wdiscarded-qualifiers] 600 | if (pg_atomic_compare_exchange_u64_impl(ptr, &currval.value, target_)) | ^~~~~~~~~~~~~~ In file included from /pgsql/source/master/src/include/port/atomics.h:69: /pgsql/source/master/src/include/port/atomics/arch-x86.h:206:81: note: expected ‘uint64 *’ {aka ‘long unsigned int *’} but argument is of type ‘volatile uint64 *’ {aka ‘volatile long unsigned int *’} 206 | uint64 *expected, uint64 newval) | ~~~~~~~~^~~~~~~~ -- Álvaro Herrera 48°01'N 7°57'E — https://www.EnterpriseDB.com/ "Most hackers will be perfectly comfortable conceptualizing users as entropy sources, so let's move on." (Nathaniel Smith) https://mail.gnu.org/archive/html/monotone-devel/2007-01/msg00080.html