10

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 

2 Answers 2

9

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.

2

On the fly you can just echo into /proc/sys/kernel/shmmax!

# echo 20446744073692774399 > /proc/sys/kernel/shmmax 

But most people edit /etc/sysctl.conf with a line similar to:

kernel.shmmax=your_new_value_here 

See the sysctl(8) man page.

3
  • That's not the question. Where are the defaults set? That is, if you don't write to shmmax yourself, what does it default to? Commented Jun 14, 2017 at 2:09
  • 2
    On some Linux distros (RHEL 5&6 I believe is one) it is set in /etc/sysctl.conf. But I think the default is set in the kernel code to the theoretical limit (guessing that's 2^64 - 1?). Commented Jun 14, 2017 at 2:48
  • Wolfram-Alpha says: 2^64-1 = 18446744073709551615 which isn't the number he is looking for. Commented Feb 18, 2024 at 4:11

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.