Re: MiniProposal (Re: Memory overcommitting (was Re: http://www.redhat.com/redhat/))

Theodore Y. Ts'o (tytso@MIT.EDU)
Thu, 20 Feb 1997 12:49:09 -0500


Date: Thu, 20 Feb 1997 13:40:13 GMT
From: "Adam D. Moss" <adam@uunet.pipex.com>

Theodore Y. Ts'o writes:
> One can imagine systems where processes are killed by the kernel when
> you run out of memory. Many Unix systems in fact do play games like
> this, including the original BSD systems, and even IBM's AIX will kill
> processes when memory is tight.

Last I heard, this is what Linux does also. And, at least in
preference to the old behaviour of disappearing up its own behind, so
to speak :-) it seems to work okay.

The only (okay, it's quite a biggie) fly in the ointment is that when
faced with a no-memory situation, Linux seems to kill the process with
the most resources, which in most cases for me at least is X Windows -
which also in effect kills most of whatever I was working on. Sigh.

In desperate a no-memory situation, Linux will kill the process that
tried to fault in a page, for which no page was available.

I propose that the following relatively simple procedure be evaluated;
that the victim-selection procedure be weighted to be somewhat less
likely to kill a process with child processes, and MORE likely to kill
a process which is itself a deeply-nested child.

The algorithm which AIX uses is to choose the most recently started
(non-root) process, presumably on the assumption that recently started
processes have the least amount of CPU time invested, and the likelihood
that the new process was the cause of the memory starvation.

I suspect something as simple as non-root, most recently started process
would be a good starting point. And we'd want to do this *before* we're
so desparate that we're inside a fault handler and don't have the memory
we need to fault in a page. So this is something we'd want a kernel
swapper daemon to do; in cases of really bad memory starvation, and
where there isn't enough swap space to swap out a process, swap out the
process by killing it. :-/

- Ted