From: | "Qingqing Zhou" <zhouqq(at)cs(dot)toronto(dot)edu> |
---|---|
To: | pgsql-hackers(at)postgresql(dot)org |
Subject: | ShmemAlloc() alignment patch |
Date: | 2006-07-14 06:50:31 |
Message-ID: | e97esc$1aa6$1@news.hub.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
In ShmemAlloc() we have:
newStart = BUFFERALIGN(newStart);
newSpace = (void *) (ShmemBase + newStart);
return newSpace;
Notice that though newStart is ALIGNOF_BUFFER, ShmemBase is not. Thus the
newSpace is not aligned as we disired.
Attached please find the patch.
Regards,
Qingqing
Index: src/backend/storage/ipc/shmem.c
===================================================================
RCS file: /projects/cvsroot/pgsql/src/backend/storage/ipc/shmem.c,v
retrieving revision 1.92
diff -c -r1.92 shmem.c
*** src/backend/storage/ipc/shmem.c 13 Jul 2006 16:49:16 -0000 1.92
--- src/backend/storage/ipc/shmem.c 14 Jul 2006 06:47:43 -0000
***************
*** 169,178 ****
SpinLockAcquire(ShmemLock);
newStart = shmemseghdr->freeoffset;
/* extra alignment for large requests, since they are probably
buffers */
if (size >= BLCKSZ)
! newStart = BUFFERALIGN(newStart);
newFree = newStart + size;
if (newFree <= shmemseghdr->totalsize)
--- 169,179 ----
SpinLockAcquire(ShmemLock);
newStart = shmemseghdr->freeoffset;
+ newSpace = (void *) MAKE_PTR(newStart);
/* extra alignment for large requests, since they are probably
buffers */
if (size >= BLCKSZ)
! newStart = MAKE_OFFSET(BUFFERALIGN(newSpace));
newFree = newStart + size;
if (newFree <= shmemseghdr->totalsize)
From | Date | Subject | |
---|---|---|---|
Next Message | Lukas Smith | 2006-07-14 06:52:48 | Re: monolithic distro |
Previous Message | Lukas Smith | 2006-07-14 06:47:12 | Re: monolithic distro |