-
Notifications
You must be signed in to change notification settings - Fork 32
/
Copy pathsysv_shmem.patch
39 lines (35 loc) · 1.22 KB
/
sysv_shmem.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
--- src/backend/port/sysv_shmem.c.orig 2013-11-19 16:45:58.825487864 +0400
+++ src/backend/port/sysv_shmem.c 2013-11-19 16:45:44.485488312 +0400
@@ -61,6 +61,8 @@
#define MAP_FAILED ((void *) -1)
#endif
+#define LINUX_SHMEM_LIMIT (256LL*1024*1024*1024)
+
unsigned long UsedShmemSegID = 0;
void *UsedShmemSegAddr = NULL;
@@ -369,10 +371,17 @@
IpcMemoryId shmid;
struct stat statbuf;
Size sysvsize = size;
+ int mmapFlags = PG_MMAP_FLAGS;
/* Room for a header? */
Assert(size > MAXALIGN(sizeof(PGShmemHeader)));
+#ifdef MAP_HUGETLB
+ if (size > LINUX_SHMEM_LIMIT) {
+ mmapFlags |= MAP_HUGETLB;
+ }
+#endif
+
/*
* As of PostgreSQL 9.3, we normally allocate only a very small amount of
* System V shared memory, and only for the purposes of providing an
@@ -410,8 +419,7 @@
* out to be false, we might need to add a run-time test here and do
* this only if the running kernel supports it.
*/
- AnonymousShmem = mmap(NULL, size, PROT_READ | PROT_WRITE, PG_MMAP_FLAGS,
- -1, 0);
+ AnonymousShmem = mmap(NULL, size, PROT_READ | PROT_WRITE, mmapFlags, -1, 0);
if (AnonymousShmem == MAP_FAILED)
ereport(FATAL,
(errmsg("could not map anonymous shared memory: %m"),