From f2e14c2a69147927b7ba090a7ba5a13b2b2b7d5f Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Tue, 8 Jan 2019 12:03:53 -0500 Subject: [PATCH] Doc: update our docs about kernel IPC parameters on *BSD. runtime.sgml said that you couldn't change SysV IPC parameters on OpenBSD except by rebuilding the kernel. That's definitely wrong in OpenBSD 6.x, and excavation in their man pages says it changed in OpenBSD 3.3. Update NetBSD and OpenBSD sections to recommend adjustment of the SEMMNI and SEMMNS settings, which are painfully small by default on those platforms. (The discussion thread contemplated recommending that people select POSIX semaphores instead, but the performance consequences of that aren't really clear, so I'll refrain.) Remove pointless discussion of SEMMNU and SEMMAP from the FreeBSD section. Minor other wordsmithing. Discussion: https://postgr.es/m/27582.1546928073@sss.pgh.pa.us --- doc/src/sgml/runtime.sgml | 62 +++++++++++++++++++++++++++------------ 1 file changed, 43 insertions(+), 19 deletions(-) diff --git a/doc/src/sgml/runtime.sgml b/doc/src/sgml/runtime.sgml index 8d9d40664b..333adda408 100644 --- a/doc/src/sgml/runtime.sgml +++ b/doc/src/sgml/runtime.sgml @@ -796,7 +796,8 @@ psql: could not connect to server: No such file or directory In some cases it might also be necessary to increase SEMMAP to be at least on the order of - SEMMNS. This parameter defines the size of the semaphore + SEMMNS. If the system has this parameter + (many do not), it defines the size of the semaphore resource map, in which each contiguous block of available semaphores needs an entry. When a semaphore set is freed it is either added to an existing entry that is adjacent to the freed block or it is @@ -853,7 +854,7 @@ psql: could not connect to server: No such file or directory - The default settings can be changed using + The default IPC settings can be changed using the sysctl or loader interfaces. The following parameters can be set using sysctl: @@ -872,13 +873,9 @@ psql: could not connect to server: No such file or directory kern.ipc.semmni=256 kern.ipc.semmns=512 -kern.ipc.semmnu=256 - After modifying these values a reboot is required for the new + After modifying that file, a reboot is required for the new settings to take effect. - (Note: FreeBSD does not use SEMMAP. Older versions - would accept but ignore a setting for kern.ipc.semmap; - newer versions reject it altogether.) @@ -902,7 +899,7 @@ kern.ipc.semmnu=256 FreeBSD versions before 4.0 work like - OpenBSD (see below). + old OpenBSD (see below). @@ -917,12 +914,19 @@ kern.ipc.semmnu=256 IPC parameters can be adjusted using sysctl, for example: -$ sysctl -w kern.ipc.shmmax=16777216 +# sysctl -w kern.ipc.semmni=100 - To have these settings persist over reboots, modify + To make these settings persist over reboots, modify /etc/sysctl.conf. + + You will usually want to increase kern.ipc.semmni + and kern.ipc.semmns, + as NetBSD's default settings + for these are uncomfortably small. + + You might also want to configure your kernel to lock shared memory into RAM and prevent it from being paged out to swap. @@ -931,10 +935,10 @@ kern.ipc.semmnu=256 - NetBSD versions before 5.0 work like - OpenBSD (see below), except that - parameters should be set with the keyword options not - option. + NetBSD versions before 5.0 + work like old OpenBSD + (see below), except that kernel parameters should be set with the + keyword options not option. @@ -945,11 +949,31 @@ kern.ipc.semmnu=256 - The options SYSVSHM and SYSVSEM need - to be enabled when the kernel is compiled. (They are by - default.) The maximum size of shared memory is determined by - the option SHMMAXPGS (in pages). The following - shows an example of how to set the various parameters: + In OpenBSD 3.3 and later, + IPC parameters can be adjusted using sysctl, + for example: + +# sysctl kern.seminfo.semmni=100 + + To make these settings persist over reboots, modify + /etc/sysctl.conf. + + + + You will usually want to + increase kern.seminfo.semmni + and kern.seminfo.semmns, + as OpenBSD's default settings + for these are uncomfortably small. + + + + In older OpenBSD versions, + you will need to build a custom kernel to change the IPC parameters. + Make sure that the options SYSVSHM + and SYSVSEM are enabled, too. (They are by + default.) The following shows an example of how to set the various + parameters in the kernel configuration file: option SYSVSHM option SHMMAXPGS=4096