5

According to the RHEL document, the total amount of shared memory available on the system equals shmall*PAGE_SIZE.

After I completed the installation of RHEL 6, the value of the shmall kernel parameter defaults to 4294967296, which means that the total amount of shared memory pages that can be used system-wide is 4294967296, and the page size is 4096 B. So, based on the formula, the size of shared memory is

4294967296*4096/1024/1024/1024/1024 = 16 TB

... which is much more than the size of RAM (8 GB) the operating system has. How can an OS find 16 TB of shared memory to allocate?

So, is the size of /dev/shm equal to the size of shared memory? If not, how can I get the actual size of the shared memory?

Kusalananda
  • 333,661
  • Please don't ask multiple questions in a single post. I have removed the second one, you can ask it as a separate question. Also, please [edit] your question and i) clarify why you say the system has less memory than what you show. What kind of memory are you referring to? How do you measure it? ii) How do you get 16TB from your formula? What you show is 16 gigabits, not 16 terabytes. – terdon Nov 02 '16 at 09:24

1 Answers1

0

Your calculation is correct. shmall can be set higher than the available virtual memory. If you would try to use all of it then it would not fail because of shmall is exceeded but because of other reasons.

BTW there are also commands to find these IPC limits:

ipcs -l
lsipc  # util-linux>=2.27

Note that even the virtual memory is unlimited on Linux by default, greater-than RAM+swap. See

https://serverfault.com/questions/606185/how-does-vm-overcommit-memory-work

How the OOM killer decides which process to kill first?

On the other hand you could limit the virtual memory per process using ulimt -v which wouldn't affect kernel's /proc/sys/kernel/shmall neither.

rudimeier
  • 10,315
  • the result of ipcs -l is depend on the setting shmall,it does not show the real limits – user4535727 Nov 02 '16 at 11:42
  • @user4535727 Probably a bug because of integer overflow. Maybe it's correct for smaller values echo $(( 1024*1024*1024 )) > /proc/sys/kernel/shmall; ipcs -l – rudimeier Nov 02 '16 at 11:59