大网数据广告活动
服务器运维问答

What's the difference between ipcs -lm and cat /sys/proc/kernel/xxxx

· 52CE 我爱测

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…

问题原文

原帖链接 · 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/shmall units are pages, ipcs converts max total shared memory to KB.
  • /proc/sys/kernel/shmmax units are bytes, ipcs converts max seg size to 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.)

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2019-07-25)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。