On Mon, Sep 27, 2021 at 9:04 PM PG Doc comments form
<nore...@postgresql.org> wrote:
> The following documentation comment has been logged on the website:
>
> Page: https://www.postgresql.org/docs/13/kernel-resources.html
> Description:
>
> It seems that the huge_pages parameter is ignored when shared_memory_type is
> sysv. The server successfully starts with huge_pages=on, but actually
> doesn't use huge pages (relying on /proc/meminfo).  I think that this is
> worth mentioning in the "Linux Huge Pages" section.

Yeah.  The thread that added shared_memory_type=sysv had an unfinished
follow-up patch that stalled[1].  The goal of that patch was to add
huge page support for shared_memory_type=sysv on AIX, and it is still
waiting for testing and polishing by an AIX-enabled hacker.  That
second patch included exactly such a documentation adjustment, and an
error message too (the idea was to reject that combination on Linux
but allow it on AIX).  Here are those bits, extracted.

https://www.postgresql.org/message-id/flat/HE1PR0202MB28126DB4E0B6621CC6A1A91286D90%40HE1PR0202MB2812.eurprd02.prod.outlook.com
From c27b1eae1a528f04ab09f60de80ccfa8fbaa7534 Mon Sep 17 00:00:00 2001
From: Thomas Munro <thomas.mu...@gmail.com>
Date: Fri, 22 Oct 2021 16:49:22 +1300
Subject: [PATCH] Reject huge_pages=on if shared_memory_type=sysv.

It doesn't work (it could, but hasn't been implemented).
Back-patch to 12, where shared_memory_type arrived.

Reported-by: Alexander Lakhin <exclus...@gmail.com>
Discussion: https://postgr.es/m/163271880203.22789.1125998876173795...@wrigleys.postgresql.org
---
 doc/src/sgml/config.sgml      | 4 +++-
 src/backend/port/sysv_shmem.c | 6 ++++++
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml
index 0bcc6fd322..1c13f995a5 100644
--- a/doc/src/sgml/config.sgml
+++ b/doc/src/sgml/config.sgml
@@ -1664,7 +1664,9 @@ include_dir 'conf.d'
        <para>
         At present, this setting is supported only on Linux and Windows. The
         setting is ignored on other systems when set to
-        <literal>try</literal>.
+        <literal>try</literal>.  On Linux, it is only supported when
+        <varname>shared_memory_type</varname> is set to <literal>mmap</literal>
+        (the default).
        </para>
 
        <para>
diff --git a/src/backend/port/sysv_shmem.c b/src/backend/port/sysv_shmem.c
index cd385c4df6..e7474cee59 100644
--- a/src/backend/port/sysv_shmem.c
+++ b/src/backend/port/sysv_shmem.c
@@ -703,6 +703,12 @@ PGSharedMemoryCreate(Size size,
 				 errmsg("huge pages not supported on this platform")));
 #endif
 
+	/* For now, we don't support huge pages in SysV memory */
+	if (huge_pages == HUGE_PAGES_ON && shared_memory_type != SHMEM_TYPE_MMAP)
+		ereport(ERROR,
+				(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
+				 errmsg("huge pages not supported with the current shared_memory_type setting")));
+
 	/* Room for a header? */
 	Assert(size > MAXALIGN(sizeof(PGShmemHeader)));
 
-- 
2.30.2

Reply via email to