public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Axel Kittenberger <Axel.Kittenberger@maxxio.com>
To: linux-kernel@vger.kernel.org
Cc: riel@nl.linux.org
Subject: Patch: oom_kill
Date: Tue, 4 Feb 2003 13:32:05 +0100	[thread overview]
Message-ID: <200302041332.05096.Axel.Kittenberger@maxxio.com> (raw)

A small patch to discuss, it's about killing an process in an out-of-memory 
condition. First from the code I don't see any prohibition that it kills 
init, if reaches maximum badness points, don't think thats something anybody 
anytime wants. Sure for desktop systems this very unlikely to ever occur, but 
for small embedded systems that could happen. 

Second proposal is to give processes that are direct childs from init a 
special bonus, normally that are those we don't want to get killed. They are 
either important or get respawned eitherway creating an endless oom condition 
loop when killing them.

A position to think about is to generally bonus processes from their distance 
to init. The further down in the hirachy to more unlikely it is for the 
process to be important.

Greetings, Axel


diff -ru linux-2.4.20-org/mm/oom_kill.c linux-2.4.20/mm/oom_kill.c
--- linux-2.4.20-org/mm/oom_kill.c	Fri Nov 29 00:53:15 2002
+++ linux-2.4.20/mm/oom_kill.c	Tue Feb  4 12:10:40 2003
@@ -62,6 +62,11 @@
 	if (!p->mm)
 		return 0;
 	/*
+	 * Never kill init
+	 */
+	if (p->pid == 1)
+		return 0:        
+	/*
 	 * The memory size of the process is the basis for the badness.
 	 */
 	points = p->mm->total_vm;
@@ -101,6 +106,15 @@
 	 */
 	if (cap_t(p->cap_effective) & CAP_TO_MASK(CAP_SYS_RAWIO))
 		points /= 4;
+
+	/*
+	 * Give childs from init a bonus, they usually get respawned
+	 * eitherway, killing them might not help to solve the out of memory 
+	 * condition in the long run.
+	 */
+	if (p->p_pptr != NULL && p->p_pptr->pid == 1) 
+		points /= 4;
+        
 #ifdef DEBUG
 	printk(KERN_DEBUG "OOMkill: task %d (%s) got %d points\n",
 	p->pid, p->comm, points);


             reply	other threads:[~2003-02-04 12:26 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-02-04 12:32 Axel Kittenberger [this message]
2003-02-04 14:07 ` Patch: oom_kill Jesse Pollard
2003-02-04 14:13   ` Axel Kittenberger
2003-02-04 14:55     ` Jesse Pollard

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200302041332.05096.Axel.Kittenberger@maxxio.com \
    --to=axel.kittenberger@maxxio.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=riel@nl.linux.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox