From: Gerard J. C. <gj...@ci...> - 2008-06-24 19:58:04
|
Marc Andre Tanner wrote: > Hi, > > I would like to know what is considered to be the right way to handle > generic errors like malloc failures? As far as i understand the kernel > is normally overcommitting memory, so malloc shouldn't fail and if it > does then there is really no more memory available. Also since the file > system is just a normal process it may be killed by the OOM Killer. > > With help of google i found a lwn.net article[1] from 2004 which mentions > a patch which introduces a new ioctl to prevent processes from being > killed. Do you know whether something like this hit mainline? Or is the > setting in /proc/<pid>/oom_adj as mentioned in [2] the correct way to > tweak the OOM Killer? > > Given these things, does it even make sense to test for malloc failures > and if so what should be done when an error occurs? Simply aborting is > probably not an option since there might be other file system operations > active which could be completed without new memory. > > Is returning ENOMEM the prefered solution? > > Some comments/advices would be appreciated. > > Thanks, > Marc > > [1] http://lwn.net/Articles/104179/ > [2] http://linux-mm.org/OOM_Killer > > I return ENOMEM |