--- ./mm/oom_kill.c Mon Nov 5 19:45:10 2001 +++ /usr/src/linux/./mm/oom_kill.c Sun Dec 30 21:35:19 2001 @@ -198,7 +198,7 @@ */ void out_of_memory(void) { - static unsigned long first, last, count; + static unsigned long first, last, count, mega; unsigned long now, since; /* @@ -220,19 +220,30 @@ goto reset; /* - * If we haven't tried for at least one second, + * If cache is still shrinking, we're not oom. + */ + if (mega > pages_to_mb(atomic_read(&page_cache_size))) { + goto reset; + } + + /* + * If we haven't tried for at least mega*second(s), * we're not really oom. */ since = now - first; - if (since < HZ) + if (since < mega * HZ) { + printk(KERN_DEBUG "out_of_memory: cache size %d Mb, since = %lu.%02lu\n",mega, since/HZ, since%HZ); return; + } /* - * If we have gotten only a few failures, + * If we haven't gotten mega failures, * we're not really oom. */ - if (++count < 10) + if (++count < mega * 10) { + printk(KERN_DEBUG "out_of_memory: cache size %d Mb, since = %lu.%02lu, count %d\n",mega, since/HZ, since%HZ, count); return; + } /* * Ok, really out of memory. Kill something. @@ -240,6 +251,7 @@ oom_kill(); reset: + mega = pages_to_mb(atomic_read(&page_cache_size)); first = now; count = 0; }