News for hackers. Stuff that matters.
Re:Linux Memory Overcommit (2007) by layer8 on Sunday August 18, 2024 @06:54PM (#41286210)
Can this be set for a specific process (or process group/tree), or only globally?
Re:Linux Memory Overcommit (2007) by nabla9 on Sunday August 18, 2024 @07:13PM (#41286310)
Globally

For a process you can use setrlimit() (ulimit command)

Re:Linux Memory Overcommit (2007) by silon42 on Monday August 19, 2024 @04:57AM (#41289201)
I'd want the OOM killer to kill processes with more over-commit first.
Re:Linux Memory Overcommit (2007) by jart on Monday August 19, 2024 @05:33AM (#41289389)
Why? There are many innocent applications that consume lots of virtual memory with no intention of using it. Sometimes sparse algorithms call for that sort of thing. It can be a nice crutch when you're in a pinch for time. A good example of a tool that does this is TSAN. It gobbles up virtual address space, which is practically free, thanks to the magic of modern MMUs. That's too powerful and good a thing to need to give up completely.
Re:Linux Memory Overcommit (2007) by kaba0 on Monday August 19, 2024 @06:08AM (#41289579)
Another example would be the JVM’s new low-latency GC, ZGC, that does some smart addressing tricks to store some information in pointer addresses themselves, effectively tripling the actual memory usage when naively looked at through virt memory.
Re:Linux Memory Overcommit (2007) by layer8 on Monday August 19, 2024 @07:31AM (#41290086)
Such applications could handle this explicitly, e.g. with mmap and mprotect. In principle there is no reason for such use-cases to rely on implicit overcommit behavior. Which also isn't present on Windows.
Re:Linux Memory Overcommit (2007) by jart on Monday August 19, 2024 @08:16AM (#41290369)
That's because Windows forces you to use special userspace libraries that account for memory and let you create "reservations" for large regions, without actually populating entries in the MMU (i.e. PML4t). Linux doesn't have that. You create reservations for large memory regions by allocating virtual memory, which of course doesn't become real (resident) until you use it. That's overcommit. But since there's no userspace libraries like WIN32 forced upon you on Linux, there's really no way for the kernel to know your intent when it comes to memory, because the abstractions for memory on Linux are so simple. Windows has a ridiculous byzantine system, which some people think is better. But people are really missing the point when they try to make an apples-to-apples comparison between the two systems of memory management. It's not a question of (a) overcommit good, vs. (b) overcommit bad. Anyone who thinks either is a fool. Linux is simply a system that requires a smart system administrator who understands your use cases and can tune sysctl accordingly when you want to push beyond the normal boundaries.
Re:Linux Memory Overcommit (2007) by layer8 on Monday August 19, 2024 @08:43AM (#41290551)
It seems to me that the prot parameter and/or MAP_NORESERVE would indicate the intent.
Re:Linux Memory Overcommit (2007) by kaba0 on Monday August 19, 2024 @07:54AM (#41290221)
It might actually be using that, I’m not intimately familiar with the topic.
Re:Linux Memory Overcommit (2007) by layer8 on Monday August 19, 2024 @07:57AM (#41290235)
Yes, I would expect that as well.

Implicit overcommit is really only necessary for fork and general backwards compatibility.

Re:Linux Memory Overcommit (2007) by ackfoobar on Friday August 23, 2024 @02:34PM (#41331708)
BTW the newer Generational ZGC is not using multi-mapped memory any more.