From 5a19816c3b4268d4e2279119e1c7c4272bad73c9 Mon Sep 17 00:00:00 2001
From: Andres Freund <andres@anarazel.de>
Date: Sun, 10 Apr 2016 21:47:14 -0700
Subject: [PATCH 2/3] Align individual parts of an slru.

---
 src/backend/access/transam/slru.c | 34 +++++++++++++++++-----------------
 1 file changed, 17 insertions(+), 17 deletions(-)

diff --git a/src/backend/access/transam/slru.c b/src/backend/access/transam/slru.c
index 36a011c..71b6d16 100644
--- a/src/backend/access/transam/slru.c
+++ b/src/backend/access/transam/slru.c
@@ -146,18 +146,18 @@ SimpleLruShmemSize(int nslots, int nlsns)
 	Size		sz;
 
 	/* we assume nslots isn't so large as to risk overflow */
-	sz = MAXALIGN(sizeof(SlruSharedData));
-	sz += MAXALIGN(nslots * sizeof(char *));	/* page_buffer[] */
-	sz += MAXALIGN(nslots * sizeof(SlruPageStatus));	/* page_status[] */
-	sz += MAXALIGN(nslots * sizeof(bool));		/* page_dirty[] */
-	sz += MAXALIGN(nslots * sizeof(int));		/* page_number[] */
-	sz += MAXALIGN(nslots * sizeof(int));		/* page_lru_count[] */
-	sz += MAXALIGN(nslots * sizeof(LWLockPadded)); /* buffer_locks[] */
+	sz = CACHELINEALIGN(sizeof(SlruSharedData));
+	sz += CACHELINEALIGN(nslots * sizeof(char *));	/* page_buffer[] */
+	sz += CACHELINEALIGN(nslots * sizeof(SlruPageStatus));	/* page_status[] */
+	sz += CACHELINEALIGN(nslots * sizeof(bool));		/* page_dirty[] */
+	sz += CACHELINEALIGN(nslots * sizeof(int));		/* page_number[] */
+	sz += CACHELINEALIGN(nslots * sizeof(int));		/* page_lru_count[] */
+	sz += CACHELINEALIGN(nslots * sizeof(LWLockPadded)); /* buffer_locks[] */
 
 	if (nlsns > 0)
-		sz += MAXALIGN(nslots * nlsns * sizeof(XLogRecPtr));	/* group_lsn[] */
+		sz += CACHELINEALIGN(nslots * nlsns * sizeof(XLogRecPtr));	/* group_lsn[] */
 
-	return BUFFERALIGN(sz) + BLCKSZ * nslots;
+	return CACHELINEALIGN(sz) + BLCKSZ * nslots;
 }
 
 void
@@ -192,22 +192,22 @@ SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
 		/* shared->latest_page_number will be set later */
 
 		ptr = (char *) shared;
-		offset = MAXALIGN(sizeof(SlruSharedData));
+		offset = CACHELINEALIGN(sizeof(SlruSharedData));
 		shared->page_buffer = (char **) (ptr + offset);
-		offset += MAXALIGN(nslots * sizeof(char *));
+		offset += CACHELINEALIGN(nslots * sizeof(char *));
 		shared->page_status = (SlruPageStatus *) (ptr + offset);
-		offset += MAXALIGN(nslots * sizeof(SlruPageStatus));
+		offset += CACHELINEALIGN(nslots * sizeof(SlruPageStatus));
 		shared->page_dirty = (bool *) (ptr + offset);
-		offset += MAXALIGN(nslots * sizeof(bool));
+		offset += CACHELINEALIGN(nslots * sizeof(bool));
 		shared->page_number = (int *) (ptr + offset);
-		offset += MAXALIGN(nslots * sizeof(int));
+		offset += CACHELINEALIGN(nslots * sizeof(int));
 		shared->page_lru_count = (int *) (ptr + offset);
-		offset += MAXALIGN(nslots * sizeof(int));
+		offset += CACHELINEALIGN(nslots * sizeof(int));
 
 		if (nlsns > 0)
 		{
 			shared->group_lsn = (XLogRecPtr *) (ptr + offset);
-			offset += MAXALIGN(nslots * nlsns * sizeof(XLogRecPtr));
+			offset += CACHELINEALIGN(nslots * nlsns * sizeof(XLogRecPtr));
 		}
 
 		/* Initialize LWLocks */
@@ -220,7 +220,7 @@ SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
 		shared->lwlock_tranche.array_base = shared->buffer_locks;
 		shared->lwlock_tranche.array_stride = sizeof(LWLockPadded);
 
-		ptr += BUFFERALIGN(offset);
+		ptr += CACHELINEALIGN(offset);
 		for (slotno = 0; slotno < nslots; slotno++)
 		{
 			LWLockInitialize(&shared->buffer_locks[slotno].lock,
-- 
2.7.0.229.g701fa7f

