linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Greg Thelen <gthelen@google.com>
To: David Rientjes <rientjes@google.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>,
	KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>,
	Balbir Singh <balbir@linux.vnet.ibm.com>,
	linux-mm@kvack.org
Subject: Re: [patch -mm] oom: avoid divide by zero
Date: Tue, 27 Apr 2010 23:26:20 -0700	[thread overview]
Message-ID: <xr93zl0om6sz.fsf@ninji.mtv.corp.google.com> (raw)
In-Reply-To: <alpine.DEB.2.00.1004271600220.19364@chino.kir.corp.google.com> (David Rientjes's message of "Tue, 27 Apr 2010 16:01:00 -0700 (PDT)")

David Rientjes <rientjes@google.com> writes:

> It's evidently possible for a memory controller to have a limit of 0
> bytes, so it's possible for the oom killer to have a divide by zero error
> in such circumstances.
>
> When this is the case, each candidate task's rss and swap is divided by
> one so they are essentially ranked according to whichever task attached
> to the cgroup has the most resident RAM and swap.
>
> Reported-by: Greg Thelen <gthelen@google.com>
> Signed-off-by: David Rientjes <rientjes@google.com>
> ---
>  mm/oom_kill.c |    8 ++++++++
>  1 files changed, 8 insertions(+), 0 deletions(-)
>
> diff --git a/mm/oom_kill.c b/mm/oom_kill.c
> --- a/mm/oom_kill.c
> +++ b/mm/oom_kill.c
> @@ -189,6 +189,14 @@ unsigned int oom_badness(struct task_struct *p, unsigned long totalpages)
>  	p = find_lock_task_mm(p);
>  	if (!p)
>  		return 0;
> +
> +	/*
> +	 * The memory controller can have a limit of 0 bytes, so avoid a divide
> +	 * by zero if necessary.
> +	 */
> +	if (!totalpages)
> +		totalpages = 1;
> +
>  	/*
>  	 * The baseline for the badness score is the proportion of RAM that each
>  	 * task's rss and swap space use.

I tested 2.6.34-rc5 + mmotm-2010-04-22-16-38 and the provided patch
fixes the reported problem.

Thanks David.

Tested-by: Greg Thelen <gthelen@google.com>

--
Greg

--
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>

      parent reply	other threads:[~2010-04-28  6:26 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-04-27 23:01 David Rientjes
2010-04-28  0:56 ` KAMEZAWA Hiroyuki
2010-04-28  6:26 ` Greg Thelen [this message]

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=xr93zl0om6sz.fsf@ninji.mtv.corp.google.com \
    --to=gthelen@google.com \
    --cc=akpm@linux-foundation.org \
    --cc=balbir@linux.vnet.ibm.com \
    --cc=kamezawa.hiroyu@jp.fujitsu.com \
    --cc=kosaki.motohiro@jp.fujitsu.com \
    --cc=linux-mm@kvack.org \
    --cc=rientjes@google.com \
    /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