Skip to contentSkip to conversation

Remove OOM killer from try_to_free_pages / all_unreclaimable braindamage

PATCH Werner Almesberger 3 participants 4 messages Nov 18, 2004 – Nov 19, 2004 2 messages not in the archive

lore
Share & tools
lore
#3 lore raw
In reply to Bodo Eggert
Quoted 2 lines · Bodo Eggert

You'll have some precompiled binaries causing trouble, while other precompiled binaries will be killed while you want them to stay alife.

That's why you could use a wrapper.

Quoted 3 lines

Sometimes you'll have the same binary (e.g. perl or java) running a "notme"-task like watching the log for intrusion while at the same time processing a very large image.

The wrapper could also not be part of the regular execution, and you'd only use it if you really need it, much like nice, chroot, etc.

Quoted 3 lines

The best solution I can think of is attaching a kill priority (similar to the nice value). Before killing, this value would be added to lg_2(memsize), and the least desirable process would "win", even if it's sshd running wild.

I'm extremely sceptical about solutions that require the user to quantify things. In the world of QoS, if you give users a knob to play with, the'll stare at in confusion, and ask for the "faster" button. I don't think the OOM case is much different.

A "victim" (or a "precious") flag has the advantage that the user doesn't need to estimate peak demands, but still doesn't depend solely on the verdict of some arcane algorithm working behind the scenes.

Quoted 3 lines

For the trashing problem: I like the idea of sending a signal to stop the process, but it should rather be a request to stop that can be caught by the process.

Good idea. That would also help with the problem of browsers immediately asking to be brought back to life, so that they can spin the banner ads some more.

- Werner

Signature · 3 lines
  _________________________________________________________________________
 / Werner Almesberger, Buenos Aires, Argentina         [email protected] /
/_http://www.almesberger.net/____________________________________________/
#2 lore raw
In reply to a message not in the archive
Quoted 3 lines · Werner Almesberger

A process could declare itself as usual suspect. This would then be recorded as a per-task flag, to be inherited by children. Now, one could write a launcher like this:

You'll have some precompiled binaries causing trouble, while other precompiled binaries will be killed while you want them to stay alife. Sometimes you'll have the same binary (e.g. perl or java) running a "notme"-task like watching the log for intrusion while at the same time processing a very large image.

The best solution I can think of is attaching a kill priority (similar to the nice value). Before killing, this value would be added to lg_2(memsize), and the least desirable process would "win", even if it's sshd running wild.

For the trashing problem: I like the idea of sending a signal to stop the process, but it should rather be a request to stop that can be caught by the process. A SETI-like task could save its workset and free the memory instead, a browser would discard it's memory cache and pause loading Images for the sites etc.

Signature · 4 lines
The newest and least experienced soldier will usually win the Congressional
Medal Of Honor.

Friß, Spammer: [email protected] [email protected]
#5 lore raw
Quoted 10 lines · Bodo Eggert

You'll have some precompiled binaries causing trouble, while other precompiled binaries will be killed while you want them to stay alife. Sometimes you'll have the same binary (e.g. perl or java) running a "notme"-task like watching the log for intrusion while at the same time processing a very large image.

The best solution I can think of is attaching a kill priority (similar to the nice value). Before killing, this value would be added to lg_2(memsize), and the least desirable process would "win", even if it's sshd running wild.

Quoted 5 lines

For the trashing problem: I like the idea of sending a signal to stop the process, but it should rather be a request to stop that can be caught by the process. A SETI-like task could save its workset and free the memory instead, a browser would discard it's memory cache and pause loading Images for the sites etc.

Sounds familiar. AIX has had this for years. "SIGDANGER" can be caught by applications which care to register a handler, but is otherwise fatal. Usage scenarios are exactly as proposed above.

Cheers, Andreas
--
Andreas Dilger
http://sourceforge.net/projects/ext2resize/
http://members.shaw.ca/adilger/ http://members.shaw.ca/golinux/

#4 lore raw
In reply to Werner Almesberger
Quoted 6 lines · Werner Almesberger
Quoted 2 lines · Bodo Eggert

You'll have some precompiled binaries causing trouble, while other precompiled binaries will be killed while you want them to stay alife.

That's why you could use a wrapper.

That's why I thought about a nice-like value.

Quoted 9 lines
Quoted 3 lines

The best solution I can think of is attaching a kill priority (similar to the nice value). Before killing, this value would be added to lg_2(memsize), and the least desirable process would "win", even if it's sshd running wild.

I'm extremely sceptical about solutions that require the user to quantify things. In the world of QoS, if you give users a knob to play with, the'll stare at in confusion, and ask for the "faster" button. I don't think the OOM case is much different.

Quoted 4 lines

A "victim" (or a "precious") flag has the advantage that the user doesn't need to estimate peak demands, but still doesn't depend solely on the verdict of some arcane algorithm working behind the scenes.

There would usurally be no need to tune. The OOB would select the biggest process by default, and it would allmost certainly be the the best decision.

If it isn't you'll einther need to flag all suspicious tasks before they run and prevent your users from avoiding your wrappers, or you'll need to flag the few important "notme"s. But what happens if your "notme" is dhcpd running wild (as it just happened to me because it didn't handle "permission denied" correctly)? Bye bye userland?

With the "notme"-level, your default system will kill the biggest process. This will usurally be the best process, but on some systems, it would kill the DB engine with the login table instead. You'll need to tune here, sicne no OS will know when your DB is just big and when it's eating memory. In this case, you would adjust only the database process, and you'd choose a small value. For a 2-GB-Process to "lose" against a 500 MB mozilla, you'll need a "notme"-value ("OOM-Adjustment"?) of -2; -4 would be allmost overkill to the system and -sizeof(void*)*8 will create a privileged class of processes that will only be killed if all other processes are killed (I repeat: you don't want that).

OTOH, there is nothing hindering you from creating goat processes by running your web-browser on +127, if you like it being killed as soon as your vi starts eating memory. (Even here I'd limit the value to +2.)

Summary:

The "notme"-value will autotune, while the "victim"-flag needs to be adjusted on every system. In rare cases, "notme" will need to be adjusted for large daemons, and even in those cases, it won't need much adjustment. The "notme"-value _is_ more complicated, but you only need to count to 5.

The "victim"-flag can be circumvented by users, while the "notme"-value will be as safe as "nice".

The "precious"-flag does not protect against mad processes, while the "notme"-value can be adjusted to match your specific need.

Further considerations:

Both systems will need an additional per-process-value, but they can share their space with existing flags.
(Even the 8 bit per value I asumed above may be overkill, and they aren't supposed to be touched often (set, fork and OOM only).)

You'll usurally want to kill forked processes before the parent (e.g. inetd), and legacy applications won't adjust the setting for you. Therefore you'll need a second value for the childs.

The adjustment to OOM-Killer for "victim" is a flag telling you the flag status of the last found candidate, and it could skip calculating the memory size if there is a flagged-to-be-better victim.

"notme" will require a level (lg_2()+"notme") instead of the flag, and it would usurally have to calculate the memory size, especially if the adjustment is limited to <=5 bit.
-or-
You'd use a larger data type for the calculated memory size and bit-shift the result by (adjustment+minval). I guess it's cheaper, but it only works for small adjustments (5 or 6 bit, depending on arch).

Both should be easy to implement if somebody else is doing the work.-)

[0] This can be difficult: Shall we kill process A even if most memory is shared and we don't gain much? What if it's a large forkbomb? :(){:|:};:

Signature · 1 line
'.... now touch these wires to your tongue!'