From: Alvaro Herrera <alvherre@alvh.no-ip.org>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Alexander Lakhin <exclusion@gmail.com>
Cc: Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
Cc: Andres Freund <andres@anarazel.de>
Cc: Jeff Davis <pgsql@j-davis.com>
Cc: pgsql-hackers@lists.postgresql.org, Jaime Casanova <jcasanov@systemguards.com.ec>
Subject: Re: LogwrtResult contended spinlock
Date: Mon, 1 Jul 2024 16:54:51 +0200
Message-ID: <202407011454.hni6ldpc3hoa@alvherre.pgsql> (raw)
In-Reply-To: <202407011435.oiv2idunr7ps@alvherre.pgsql>
Maybe we can do something like this,
diff --git a/src/include/port/atomics.h b/src/include/port/atomics.hindex 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)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-hackers@postgresql.org
Cc: alvherre@alvh.no-ip.org, tgl@sss.pgh.pa.us, exclusion@gmail.com, bharath.rupireddyforpostgres@gmail.com, andres@anarazel.de, pgsql@j-davis.com, jcasanov@systemguards.com.ec
Subject: Re: LogwrtResult contended spinlock
In-Reply-To: <202407011454.hni6ldpc3hoa@alvherre.pgsql>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox