问题原文
原帖链接 · Rico · CC BY-SA 4.0
I tried
ipcs -lm
------ Shared Memory Limits --------
max number of segments = 4096
max seg size (kbytes) = 67108864
max total shared memory (kbytes) = 34359738368
min seg size (bytes) = 1
and
cat /proc/sys/kernel/shmmni
4096
cat /proc/sys/kernel/shmmax
68719476736
cat /proc/sys/kernel/shmall
8589934592
From the documentation I've read I understood they're describing the same values yet they're different. Can you please explain me what's the difference between them?
Cheers
已采纳解答
原帖链接 · John Mahowald · CC BY-SA 4.0
On Linux, ipcs does read shared memory limits from /proc. Only if that fails does it fall back to using shmctl(). And there is a # define SHMMIN 1 as apparently that isn't in /proc.
/proc/sys/kernel/shmallunits are pages, ipcs convertsmax total shared memoryto KB./proc/sys/kernel/shmmaxunits are bytes, ipcs convertsmax seg sizeto KB.
The source code is the util-linux package, one mirror of which is at https://github.com/karelzak/util-linux/blob/stable/v2.33/sys-utils/ipcs.c
Notice that do_shm() does a page size unit conversion:
uint64_t tmp, pgsz = getpagesize();
tmp = (uint64_t) lim.shmall * pgsz;
(Because max total shared memory / shmall = page size, can tell your machine has 4 KB pages. Expected, that is extremely common.)
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
