diff options
author | Thomas Munro <tmunro@postgresql.org> | 2020-07-17 14:33:00 +1200 |
---|---|---|
committer | Thomas Munro <tmunro@postgresql.org> | 2020-07-17 14:33:00 +1200 |
commit | d2bddc2500fb74d56e5bc53a1cfa269e2e846510 (patch) | |
tree | caf1a941a50374e61f327fce8e717c7b62b0a031 /src/backend/utils/misc/guc.c | |
parent | d66b23b032d75614e1be47ca182020960d89206d (diff) |
Add huge_page_size setting for use on Linux.
This allows the huge page size to be set explicitly. The default is 0,
meaning it will use the system default, as before.
Author: Odin Ugedal <odin@ugedal.com>
Discussion: https://postgr.es/m/20200608154639.20254-1-odin%40ugedal.com
Diffstat (limited to 'src/backend/utils/misc/guc.c')
-rw-r--r-- | src/backend/utils/misc/guc.c | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 031ca0327f0..99a3e4f6f65 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -20,11 +20,14 @@ #include <float.h> #include <math.h> #include <limits.h> -#include <unistd.h> +#ifndef WIN32 +#include <sys/mman.h> +#endif #include <sys/stat.h> #ifdef HAVE_SYSLOG #include <syslog.h> #endif +#include <unistd.h> #include "access/commit_ts.h" #include "access/gin.h" @@ -198,6 +201,7 @@ static bool check_max_wal_senders(int *newval, void **extra, GucSource source); static bool check_autovacuum_work_mem(int *newval, void **extra, GucSource source); static bool check_effective_io_concurrency(int *newval, void **extra, GucSource source); static bool check_maintenance_io_concurrency(int *newval, void **extra, GucSource source); +static bool check_huge_page_size(int *newval, void **extra, GucSource source); static void assign_pgstat_temp_directory(const char *newval, void *extra); static bool check_application_name(char **newval, void **extra, GucSource source); static void assign_application_name(const char *newval, void *extra); @@ -576,6 +580,7 @@ int ssl_renegotiation_limit; * need to be duplicated in all the different implementations of pg_shmem.c. */ int huge_pages; +int huge_page_size; /* * These variables are all dummies that don't do anything, except in some @@ -3381,6 +3386,17 @@ static struct config_int ConfigureNamesInt[] = NULL, assign_tcp_user_timeout, show_tcp_user_timeout }, + { + {"huge_page_size", PGC_POSTMASTER, RESOURCES_MEM, + gettext_noop("The size of huge page that should be requested."), + NULL, + GUC_UNIT_KB + }, + &huge_page_size, + 0, 0, INT_MAX, + check_huge_page_size, NULL, NULL + }, + /* End-of-list marker */ { {NULL, 0, 0, NULL, NULL}, NULL, 0, 0, 0, NULL, NULL, NULL @@ -11565,6 +11581,20 @@ check_maintenance_io_concurrency(int *newval, void **extra, GucSource source) return true; } +static bool +check_huge_page_size(int *newval, void **extra, GucSource source) +{ +#if !(defined(MAP_HUGE_MASK) && defined(MAP_HUGE_SHIFT)) + /* Recent enough Linux only, for now. See GetHugePageSize(). */ + if (*newval != 0) + { + GUC_check_errdetail("huge_page_size must be 0 on this platform."); + return false; + } +#endif + return true; +} + static void assign_pgstat_temp_directory(const char *newval, void *extra) { |