--- oom_kill.c.orig Wed Dec 12 22:16:06 2001 +++ oom_kill.c Thu Dec 13 22:31:01 2001 @@ -22,6 +22,7 @@ #include /* #define DEBUG */ +#define DEBUG1 /** * int_sqrt - oom_kill.c internal function, rough approximation to sqrt @@ -200,6 +201,7 @@ { static unsigned long first, last, count; unsigned long now, since; + int mega; /* * Enough swap space left? Not OOM. @@ -215,23 +217,30 @@ * If it's been a long time since last failure, * we're not oom. */ - last = now; + if (since > 5*HZ) goto reset; /* - * If we haven't tried for at least one second, + * If we haven't tried for at least mega*seconds, * we're not really oom. + * Where mega is the number of megabytes of outstanding cache. */ + + mega = atomic_read(&page_cache_size) >> (20 - PAGE_SHIFT); since = now - first; - if (since < HZ) + if (since < mega * HZ) { +#ifdef DEBUG1 + printk(KERN_DEBUG "out_of_memory: cache size %d Mb, since = %lu.%02lu\n",mega, since/HZ, since%HZ); +#endif return; + } /* * If we have gotten only a few failures, * we're not really oom. */ - if (++count < 10) + if (++count < mega * 10) return; /*