summaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
authorHeikki Linnakangas <heikki.linnakangas@iki.fi>2014-01-29 13:44:45 +0200
committerHeikki Linnakangas <heikki.linnakangas@iki.fi>2014-01-29 14:08:30 +0200
commit1a3458b6d8d202715a83c88474a1b63726d0929e (patch)
treeea1f7c5a36cefc7b5b5dee50ac1b99fe082ed9c9 /src/include
parentb7643b19f0fdbfb1636db52e39db4be6f0174ce0 (diff)
Allow using huge TLB pages on Linux (MAP_HUGETLB)
This patch adds an option, huge_tlb_pages, which allows requesting the shared memory segment to be allocated using huge pages, by using the MAP_HUGETLB flag in mmap(). This can improve performance. The default is 'try', which means that we will attempt using huge pages, and fall back to non-huge pages if it doesn't work. Currently, only Linux has MAP_HUGETLB. On other platforms, the default 'try' behaves the same as 'off'. In the passing, don't try to round the mmap() size to a multiple of pagesize. mmap() doesn't require that, and there's no particular reason for PostgreSQL to do that either. When using MAP_HUGETLB, however, round the request size up to nearest 2MB boundary. This is to work around a bug in some Linux kernel versions, but also to avoid wasting memory, because the kernel will round the size up anyway. Many people were involved in writing this patch, including Christian Kruse, Richard Poole, Abhijit Menon-Sen, reviewed by Peter Geoghegan, Andres Freund and me.
Diffstat (limited to 'src/include')
-rw-r--r--src/include/storage/pg_shmem.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/include/storage/pg_shmem.h b/src/include/storage/pg_shmem.h
index 22ef901e891..df094e801d9 100644
--- a/src/include/storage/pg_shmem.h
+++ b/src/include/storage/pg_shmem.h
@@ -38,6 +38,16 @@ typedef struct PGShmemHeader /* standard header for all Postgres shmem */
#endif
} PGShmemHeader;
+/* GUC variable */
+extern int huge_tlb_pages;
+
+/* Possible values for huge_tlb_pages */
+typedef enum
+{
+ HUGE_TLB_OFF,
+ HUGE_TLB_ON,
+ HUGE_TLB_TRY
+} HugeTlbType;
#ifdef EXEC_BACKEND
#ifndef WIN32