From 4720ffe5c804c6ad2f4ebddcc9e5e35ee7890360 Mon Sep 17 00:00:00 2001 From: Bertrand Drouvot 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