Linux Kernel – Default SHMMAX Values Configuration

kernelmemoryshared memory

I'm just wondering where these values are being set and what they default to? Mine is currently 18446744073692774399. I didn't set it anywhere that I can see.

$ cat /proc/sys/kernel/shmmax 
18446744073692774399

$ sysctl kernel.shmmax
kernel.shmmax = 18446744073692774399

Best Answer

The __init function ipc_ns_init sets the initial value of shmmax by calling shm_init_ns, which sets it to the value of the SHMMAX macro.

The definition of SHMMAX is in <uapi/linux/shm.h>:

#define SHMMAX (ULONG_MAX - (1UL << 24)) /* max shared seg size (bytes) */

On 64-bit machines, that definition equals the value you found, 18446744073692774399.

Related Question