What is shmmax, shmall, shmmni? Shared Memory Max

by Yuji

This mysterious setting has been explained pretty well here: and am reposting my findings since last time I dealt with these settings, I just solved my problem and got the hell out of there.

It’s actually more a post to a few other posts.

What are these things?

shmmax appears to be a setting that sets the maximum size of memory allowed to be reserved by a process

http://www.csl.mtu.edu/cs4411/www/NOTES/process/shm/what-is-shm.html

shmall appears to be the maximum available memory to use as shared memory.
You can check yours by typing ipcs -lm or cat /proc/sys/kernel/shmall/

I’m seeing oracle documentation suggesting 50-75% of max ram, but my shmall is set pretty low assuming it’s in bytes like the other shm settings (2097152). Update: this value is multiplied by your page size which ends up being like 8gb.

How can I see what segments are currently being used?

Thanks to this post: http://www.unixbod.com/kb/how-to-change-shared-memory-and-semaphore-settings-in-linux/

It seems I can type:

$> ipcs -m
------ Shared Memory Segments --------
key        shmid      owner      perms      bytes      nattch     status      
0x0052e2c1 98304      postgres   600        108486656  4    

Finally, I can see how much my postgres is claiming based on my configuration!

These are baby steps towards understanding these settings…

I have questions:

1. Is all of shared memory shared across processes? Or is a single segment block completely reserved for a process? The name implies sharing… then what happens as we reach the maximum and multiple processes have shared_memory settings? I assume it doesn’t actually /consume/ memory, and each process can use up TO the amount available via your shared memory setting.

2. Do we start swapping into virtual memory if shmmall is too low even if we have ram?

It sounds like shared memory is a certain subset of memory the system can allocate via the shmmall parameter, and that each process can consume up to the amount specified in its config files. So why have a limit on shmmax? A safeguard against individual process settings with huge default shared memory reservations?

About these ads