linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: David Rientjes <rientjes@google.com>
To: Dave Jones <davej@redhat.com>,
	KOSAKI Motohiro <kosaki.motohiro@gmail.com>,
	Linux Kernel <linux-kernel@vger.kernel.org>,
	linux-mm@kvack.org
Subject: Re: oomkillers gone wild.
Date: Sun, 10 Jun 2012 16:52:50 -0700 (PDT)	[thread overview]
Message-ID: <alpine.DEB.2.00.1206101652180.18114@chino.kir.corp.google.com> (raw)
In-Reply-To: <20120610201055.GA27662@redhat.com>

On Sun, 10 Jun 2012, Dave Jones wrote:

> To double check, here it is in rc2 (which has that patch)..
> 
> $ uname -r
> 3.5.0-rc2+
> $ cat /proc/$(pidof dbus-daemon)/oom_score{_adj,}
> -900
> 7441500919753
> $ grep RSS /proc/$(pidof dbus-daemon)/status
> VmRSS:	    1604 kB

Eek, yes, that's definitely wrong.  The following should fix it.
---
 mm/oom_kill.c |   15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/mm/oom_kill.c b/mm/oom_kill.c
--- a/mm/oom_kill.c
+++ b/mm/oom_kill.c
@@ -184,6 +184,7 @@ unsigned long oom_badness(struct task_struct *p, struct mem_cgroup *memcg,
 			  const nodemask_t *nodemask, unsigned long totalpages)
 {
 	long points;
+	long adj;
 
 	if (oom_unkillable_task(p, memcg, nodemask))
 		return 0;
@@ -192,7 +193,8 @@ unsigned long oom_badness(struct task_struct *p, struct mem_cgroup *memcg,
 	if (!p)
 		return 0;
 
-	if (p->signal->oom_score_adj == OOM_SCORE_ADJ_MIN) {
+	adj = p->signal->oom_score_adj;
+	if (adj == OOM_SCORE_ADJ_MIN) {
 		task_unlock(p);
 		return 0;
 	}
@@ -210,14 +212,11 @@ unsigned long oom_badness(struct task_struct *p, struct mem_cgroup *memcg,
 	 * implementation used by LSMs.
 	 */
 	if (has_capability_noaudit(p, CAP_SYS_ADMIN))
-		points -= 30 * totalpages / 1000;
+		adj -= 30;
 
-	/*
-	 * /proc/pid/oom_score_adj ranges from -1000 to +1000 such that it may
-	 * either completely disable oom killing or always prefer a certain
-	 * task.
-	 */
-	points += p->signal->oom_score_adj * totalpages / 1000;
+	/* Normalize to oom_score_adj units */
+	adj *= totalpages / 1000;
+	points += adj;
 
 	/*
 	 * Never return 0 for an eligible task regardless of the root bonus and

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

  reply	other threads:[~2012-06-10 23:52 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-04 15:27 Dave Jones
2012-06-04 23:30 ` David Rientjes
2012-06-05 17:44   ` Dave Jones
2012-06-05 18:52     ` Dave Jones
2012-06-08 19:57       ` David Rientjes
2012-06-08 20:03         ` Dave Jones
2012-06-08 20:37         ` Thomas Gleixner
2012-06-10  2:15           ` David Rientjes
2012-06-08 20:15     ` David Rientjes
2012-06-08 21:03       ` Dave Jones
2012-06-10  2:21         ` David Rientjes
2012-06-10  3:21           ` KOSAKI Motohiro
2012-06-10 20:10             ` Dave Jones
2012-06-10 23:52               ` David Rientjes [this message]
2012-06-11  0:46                 ` Dave Jones
2012-06-11  9:11                   ` [patch 3.5-rc2] mm, oom: fix and cleanup oom score calculations David Rientjes
2012-06-11 19:13                     ` Dave Jones

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=alpine.DEB.2.00.1206101652180.18114@chino.kir.corp.google.com \
    --to=rientjes@google.com \
    --cc=davej@redhat.com \
    --cc=kosaki.motohiro@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.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