Re: [PATCH] - Taming OOM killer, 2.4.17-rc1

Denis Vlasenko (vda@port.imtp.ilyichevsk.odessa.ua)
Fri, 11 Jan 2002 23:13:17 -0200


On 15 December 2001 00:25, M.H.VanLeeuwen wrote:
> The attached patch changes the attributes of the out_of_memory function to:
>
> 1. wait longer before attempting to kill processes; "MB of cache" seconds.
> 2. OOM occurrences must be 10*(MB of cache) once "1." is satisfied.
>
> This allows the system to be less likely to kill processes when there is
> still cache memory available, i.e. the OOM killer is dynamic based on the
> system cache size.
>
> We probably should be killing processes without a least first shrinking
> cache size somewhat first. It would be much better to have processes run
> at the expense of cache than the other way around, i.e.. a predictably slow
> system due to low memory thus little cache is better than a fast system
> that unpredictably keeps killing processes because large amount of memory
> are held in cache.

This patch does make OOM killer wait much longer before killing, thus system
stays under mem pressure longer and cache shrinks fully:

bash-2.03# oom_trigger; free
Terminated
total used free shared buffers cached
Mem: 126208 69068 57140 <== 0 0 12876
-/+ buffers/cache: 56192 70016
Swap: 0 0 0
bash-2.03# oom_trigger; free
Terminated
total used free shared buffers cached
Mem: 126208 65568 60640 <== 0 0 9412
-/+ buffers/cache: 56156 70052
Swap: 0 0 0

Note that second free isn't less than first one. With stock kernel you'll get
'free' falling after each oom kill.

> I realize this patch is just chasing a symptom, but it is self tuning so
> seems to be a good change regardless. Yes, it still kills ;)

Yes indeed :-)

> --------------------------------------------------------------------
> out_of_memory: cache size 41 Mb, since = 0.06
> out_of_memory: cache size 41 Mb, since = 0.11
> out_of_memory: cache size 41 Mb, since = 0.74
> out_of_memory: cache size 41 Mb, since = 0.83
> out_of_memory: cache size 40 Mb, since = 1.29
> out_of_memory: cache size 40 Mb, since = 1.48
> out_of_memory: cache size 40 Mb, since = 1.57
> out_of_memory: cache size 40 Mb, since = 2.37
<<< snip >>>
> out_of_memory: cache size 40 Mb, since = 29.46
> out_of_memory: cache size 40 Mb, since = 29.52
> out_of_memory: cache size 40 Mb, since = 30.04
> out_of_memory: cache size 40 Mb, since = 30.41
> out_of_memory: cache size 40 Mb, since = 30.78 << ~29 SECONDS AND NO CACHE
> SHRINKAGE!!??!! ***
> out_of_memory: cache size 39 Mb, since = 31.11
> out_of_memory: cache size 39 Mb, since = 31.25
> out_of_memory: cache size 39 Mb, since = 31.34
> out_of_memory: cache size 39 Mb, since = 31.44
> out_of_memory: cache size 39 Mb, since = 31.63

Same here. I modified the printk (# of pages instead of Mb):

-printk(KERN_DEBUG "out_of_memory: cache size %d Mb, since =
%lu.%02lu\n",mega, since/HZ, since%HZ);
+printk(KERN_DEBUG "out_of_memory: page_cache_size=%d,
since=%lu.%02lu\n",page_cache_size.counter, since/HZ, since%HZ);

out_of_memory: page_cache_size=6236, since=23.33
out_of_memory: page_cache_size=6220, since=23.49
out_of_memory: page_cache_size=6220, since=23.50
out_of_memory: page_cache_size=6220, since=23.55
out_of_memory: page_cache_size=6178, since=23.80
out_of_memory: page_cache_size=6178, since=23.88
Out of Memory: Killed process 1987 (a.out).

--
vda
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/