Taming the OOM killer
Posted Feb 6, 2009 8:58 UTC (Fri) by dlang (subscriber, #313)
you probably already have tools in place to detect processes dieing and either restart them (if the memory preasure is temporary) or failover to another box (gracefully for all the other processes on the box)
Posted Jul 15, 2014 2:27 UTC (Tue) by bbulkow (guest, #87167)
Posted Jul 15, 2014 2:52 UTC (Tue) by dlang (subscriber, #313)
True, it would happen at malloc() time instead of randomly, but given that most programs don't check return codes, this would help less than it should
Posted Jul 15, 2014 9:41 UTC (Tue) by dgm (subscriber, #49227)
IMHO, this should be treated like a bug.
> the memory system would say that it couldn't guarantee memory that ends up *never being used*
Posted Jul 15, 2014 19:11 UTC (Tue) by dlang (subscriber, #313)
> IMHO, this should be treated like a bug.
you have a right to your opinion, but in practice, your opinion doesn't matter that much
>> the memory system would say that it couldn't guarantee memory that ends up *never being used*
> This too.
exactly how would you expect the linux kernel to know that the application that just forked is never going to touch some of the memory of the parent and therefor doesn't need it to be duplicated (at least in allocation)?
this is especially important for large programs that are forking so that the child can then exec some other program. In this case you may have a multi-GB allocation that's not needed because the only thing the child does is to close some file discripters and exec some other program. With the default overcommit and Copy-on-Write, this 'just works', but with overcommit disabled, the kernel needs to allocate the multiple GB of RAM (or at least virtual memory) just in case the application is going to need it. This will cause failures if the system doesn't have a few extra GB around to handle these wasteful allocations.
not to mention that there's overhead in updating the global allocations, so allocating and then deallocating memory like that has a cost.
Posted Jul 16, 2014 11:23 UTC (Wed) by dgm (subscriber, #49227)
What about telling it that you're just about to call execv, so it doesn't need to? What about auto-detecting this by simply watching what the first syscall after fork is?
Not bad for just 15 seconds of thinking about it, isn't it?
Posted Jul 16, 2014 12:05 UTC (Wed) by JGR (subscriber, #93631)
Posted Jul 16, 2014 12:18 UTC (Wed) by dgm (subscriber, #49227)
Posted Jul 16, 2014 15:07 UTC (Wed) by nybble41 (subscriber, #55106)
CoW is still a form of overcommit, even if it's not referred to as such. In the one case you commit to allocating a new page in the future, on the first write, and pre-filling it with a copy of an existing page. In the other case you commit to allocating a new page in the future, probably on the first write, and pre-filling it with zeros. In both cases you're writing an IOU for memory which may not actually exist when it's needed.
You could pre-allocate memory for CoW while deferring the actual copy, but that would only be a performance optimization. You'd still have the problem that fork() may fail in a large process for lack of available memory even though the child isn't going to need most of it.
Posted Jul 16, 2014 14:06 UTC (Wed) by mpr22 (subscriber, #60784)
Posted Jul 16, 2014 18:50 UTC (Wed) by nix (subscriber, #2304)
Posted Jul 17, 2014 14:22 UTC (Thu) by mathstuf (subscriber, #69389)
Also that you don't expand it too much and crash in your stack_balloon function.
Posted Jul 15, 2014 14:44 UTC (Tue) by raven667 (subscriber, #5198)
Copyright © 2018, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds