Hi, On Sat, Aug 30, 2025 at 09:14:46AM -0500, Nathan Bossart wrote: > On Fri, Aug 29, 2025 at 09:51:38PM -0500, Nathan Bossart wrote: > > I've also attached a rebased patch that addresses all the latest feedback. > > A reworked verison of the test patch is also included, but that's mostly > > intended for CI purposes and is still not intended for commit (yet). > > And here's an attempt at fixing the alignment problems revealed by cfbot.
Indeed: ==24409==Using libbacktrace symbolizer. ../src/backend/storage/lmgr/lwlock.c:441:31: runtime error: store to misaligned address 0x7f7644188904 for type 'char *', which requires 8 byte alignment Changes look good. Not directly related, but I think that we can get rid of: size = add_size(size, LWLOCK_PADDED_SIZE); in LWLockShmemSize() and of: ptr += LWLOCK_PADDED_SIZE - ((uintptr_t) ptr) % LWLOCK_PADDED_SIZE; in CreateLWLocks(), and just make use of CACHELINEALIGN(). Attached, a patch doing so. It applies on top of your v20. Regards, -- Bertrand Drouvot PostgreSQL Contributors Team RDS Open Source Databases Amazon Web Services: https://aws.amazon.com
>From 4720ffe5c804c6ad2f4ebddcc9e5e35ee7890360 Mon Sep 17 00:00:00 2001 From: Bertrand Drouvot <[email protected]> Date: Mon, 1 Sep 2025 07:30:19 +0000 Subject: [PATCH v20 3/3] Make use of CACHELINEALIGN in LWLockShmemSize() and CreateLWLocks() Let's get rid of the LWLOCK_PADDED_SIZE usage in those functions and use CACHELINEALIGN() that perfectly fits with our needs. The current approach was wasting some bytes. --- src/backend/storage/lmgr/lwlock.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 100.0% src/backend/storage/lmgr/ diff --git a/src/backend/storage/lmgr/lwlock.c b/src/backend/storage/lmgr/lwlock.c index b4636d86ca6..2443dfd3d59 100644 --- a/src/backend/storage/lmgr/lwlock.c +++ b/src/backend/storage/lmgr/lwlock.c @@ -408,7 +408,7 @@ LWLockShmemSize(void) size = add_size(size, mul_size(MAX_NAMED_TRANCHES, NAMEDATALEN)); /* Space for the LWLock array, plus room for cache line alignment. */ - size = add_size(size, LWLOCK_PADDED_SIZE); + size = CACHELINEALIGN(size); size = add_size(size, mul_size(numLocks, sizeof(LWLockPadded))); return size; @@ -444,7 +444,7 @@ CreateLWLocks(void) } /* Ensure desired alignment of LWLock array */ - ptr += LWLOCK_PADDED_SIZE - ((uintptr_t) ptr) % LWLOCK_PADDED_SIZE; + ptr = (char *) CACHELINEALIGN(ptr); MainLWLockArray = (LWLockPadded *) ptr; /* Initialize all LWLocks */ -- 2.34.1
