2001-03-01 22:34:02

by Rik van Riel

[permalink] [raw]
Subject: [PATCH] oom-killer trigger

Hi,

the OOM killer in Linux 2.4 has a rather embarrasing bug.

1. the OOM killer never triggers if we have > freepages.min
of free memory
2. __alloc_pages() never allocates pages to < freepages.min
for user allocations

==> the OOM killer never gets triggered under some workloads;
the system just sits around with nr_free_pages == freepages.min

The patch below trivially fixes this by upping the OOM kill limit
by a really small number of pages ...

Now lets hope it won't trigger too early (but since it'll only
trigger when we're completely out of swap, etc...).

regards,

Rik
--
Virtual memory is like a game you can't win;
However, without VM there's truly nothing to lose...

http://www.surriel.com/
http://www.conectiva.com/ http://distro.conectiva.com/


--- mm/oom_kill.c.orig Thu Mar 1 18:57:11 2001
+++ mm/oom_kill.c Thu Mar 1 18:58:23 2001
@@ -188,13 +188,17 @@
*
* Returns 0 if there is still enough memory left,
* 1 when we are out of memory (otherwise).
+ *
+ * Note that since __alloc_pages() never lets user
+ * allocations go below freepages.min, we have to
+ * use a slightly higher threshold here...
*/
int out_of_memory(void)
{
struct sysinfo swp_info;

/* Enough free memory? Not OOM. */
- if (nr_free_pages() > freepages.min)
+ if (nr_free_pages() > freepages.min + 4)
return 0;

if (nr_free_pages() + nr_inactive_clean_pages() > freepages.low)


2001-03-01 22:53:13

by David Mansfield

[permalink] [raw]
Subject: Re: [PATCH] oom-killer trigger

>
> 1. the OOM killer never triggers if we have > freepages.min
> of free memory
> 2. __alloc_pages() never allocates pages to < freepages.min
> for user allocations
>
> ==> the OOM killer never gets triggered under some workloads;
> the system just sits around with nr_free_pages == freepages.min
>
> The patch below trivially fixes this by upping the OOM kill limit
> by a really small number of pages ...

> + if (nr_free_pages() > freepages.min + 4)


Call me stupid, but why not just change the > to >= (or < to <=) rather
than introducing a magic number (4). Or at least make the magic number
interesting, like:

+ if (nr_free_pages() > freepages.min + 42)

:-)

Thanks for the bugfix,
David

--
David Mansfield (718) 963-2020
[email protected]
Ultramaster Group, LLC http://www.ultramaster.com