mirror of
https://github.com/postgres/postgres.git
synced 2025-06-26 12:21:12 +03:00
Add GUC parameter "huge_pages_status"
This is useful to show the allocation state of huge pages when setting up a server with "huge_pages = try", where allocating huge pages would be attempted but the server would continue its startup sequence even if the allocation fails. The effective status of huge pages is not easily visible without OS-level tools (or for instance, a lookup at /proc/N/smaps), and the environments where Postgres runs may not authorize that. Like the other GUCs related to huge pages, this works for Linux and Windows. This GUC can report as values: - "on", if huge pages were allocated. - "off", if huge pages were not allocated. - "unknown", a special state that could only be seen when using for example postgres -C because it is only possible to know if the shared memory allocation worked after we can check for the GUC values, even if checking a runtime-computed GUC. This value should never be seen when querying for the GUC on a running server. An assertion is added to check that. The discussion has also turned around having a new function to grab this status, but this would have required more tricks for -DEXEC_BACKEND, something that GUCs already handle. Noriyoshi Shinoda has initiated the thread that has led to the result of this commit. Author: Justin Pryzby Reviewed-by: Nathan Bossart, Kyotaro Horiguchi, Michael Paquier Discussion: https://postgr.es/m/TU4PR8401MB1152EBB0D271F827E2E37A01EECC9@TU4PR8401MB1152.NAMPRD84.PROD.OUTLOOK.COM
This commit is contained in:
@ -365,6 +365,13 @@ static const struct config_enum_entry huge_pages_options[] = {
|
||||
{NULL, 0, false}
|
||||
};
|
||||
|
||||
static const struct config_enum_entry huge_pages_status_options[] = {
|
||||
{"off", HUGE_PAGES_OFF, false},
|
||||
{"on", HUGE_PAGES_ON, false},
|
||||
{"unknown", HUGE_PAGES_UNKNOWN, false},
|
||||
{NULL, 0, false}
|
||||
};
|
||||
|
||||
static const struct config_enum_entry recovery_prefetch_options[] = {
|
||||
{"off", RECOVERY_PREFETCH_OFF, false},
|
||||
{"on", RECOVERY_PREFETCH_ON, false},
|
||||
@ -550,6 +557,7 @@ int ssl_renegotiation_limit;
|
||||
*/
|
||||
int huge_pages = HUGE_PAGES_TRY;
|
||||
int huge_page_size;
|
||||
int huge_pages_status = HUGE_PAGES_UNKNOWN;
|
||||
|
||||
/*
|
||||
* These variables are all dummies that don't do anything, except in some
|
||||
@ -4876,6 +4884,17 @@ struct config_enum ConfigureNamesEnum[] =
|
||||
NULL, NULL, NULL
|
||||
},
|
||||
|
||||
{
|
||||
{"huge_pages_status", PGC_INTERNAL, PRESET_OPTIONS,
|
||||
gettext_noop("Indicates the status of huge pages."),
|
||||
NULL,
|
||||
GUC_NOT_IN_SAMPLE | GUC_DISALLOW_IN_FILE
|
||||
},
|
||||
&huge_pages_status,
|
||||
HUGE_PAGES_UNKNOWN, huge_pages_status_options,
|
||||
NULL, NULL, NULL
|
||||
},
|
||||
|
||||
{
|
||||
{"recovery_prefetch", PGC_SIGHUP, WAL_RECOVERY,
|
||||
gettext_noop("Prefetch referenced blocks during recovery."),
|
||||
|
Reference in New Issue
Block a user