3 ms·
"Overcommit" is when the processes running on the system have been promised more memory than is available. If you run an ordinary Linux program, exactly how mu
by burfog 9y ago
"Overcommit" is when the processes running on the system have been promised more memory than is available.
If you run an ordinary Linux program, exactly how much memory should be allocated to the stack? That question is essentially unanswered. At the ABI level, considering just the ELF binary itself, there is no limit in place. (no fixed size) This is a promise to provide unlimited memory.
It is obvious that giving unlimited memory to every running process is not possible.
If we were to eliminate overcommit and attempt to boot the system, the init process could not legitimately start. That process implicitly requests an unlimited amount of memory for the stack, which is obviously unavailable, so it can not be started.
- geofft 9y ago> If you run an ordinary Linux program, exactly how much memory should be allocated to the stack? That question is essentially unanswered. Not at all: (initramfs) grep stack /proc/1/limits Max stack size 8388608 unlimited bytes (initramfs) grep stack /proc/1/maps 7ffca6fb3000-7ffca6fd4000 rw-p 00000000 00:00 0 [stack] init can request more than 8 MB if it needs it, but the binary starts with 128 kB allocated (and more faultable if you hit the guard page) and an 8 MB limit. It can change its own rlimits, sure, but it needs to do that within its existing 8 MB stack. It would be perfectly straightforward to permit setrlimit to fail if you request too much of a stack, and disable overcommit entirely. So init can raise its stack by some amount, but not more than the available physical memory on the machine. See also public header file <linux/resource.h>: /* * Limit the stack by to some sane default: root can always * increase this limit if needed.. 8MB seems reasonable. */ #define _STK_LIM (8*1024*1024) > At the ABI level, considering just the ELF binary itself, there is no limit in place. (no fixed size) This is a promise to provide unlimited memory. The ABI also provides no limit on the size of bss, or on the size of the program itself. This is hardly a promise to provide unlimited memory for global variables or program text or anything else. The amount of memory is finite and unspecified by the SysV ABI and left up to implementations.
- burfog 9y agoI am well aware of that 8 MiB rlimit. It's just a default that root can change. It's both too much and not enough. It's too much because even 8 MiB is excessive without overcommit. It's not enough because nothing about the ELF binary even bothers to claim that any particular amount of stack is enough. I really wouldn't call "8 MiB" an answer to how much stack space should be allocated or committed.