From: KOSAKI Motohiro <kosaki.motohiro@gmail.com>
To: David Rientjes <rientjes@google.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>,
Andrew Morton <akpm@linux-foundation.org>,
Oleg Nesterov <oleg@redhat.com>, Dave Jones <davej@redhat.com>,
Hugh Dickins <hughd@google.com>, Ingo Molnar <mingo@elte.hu>,
Peter Zijlstra <peterz@infradead.org>,
Srikar Dronamraju <srikar@linux.vnet.ibm.com>,
KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>,
Ananth N Mavinakayanahalli <ananth@in.ibm.com>,
Anton Arapov <anton@redhat.com>,
Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>,
linux-kernel@vger.kernel.org, kosaki.motohiro@gmail.com
Subject: Re: [patch for-3.5-rc1] mm, oom: fix badness score underflow
Date: Sat, 09 Jun 2012 18:25:46 -0400 [thread overview]
Message-ID: <4FD3CD6A.9020801@gmail.com> (raw)
In-Reply-To: <alpine.DEB.2.00.1206081317120.19054@chino.kir.corp.google.com>
(6/8/12 4:21 PM), David Rientjes wrote:
> If the privileges given to root threads (3% of allowable memory) or a
> negative value of /proc/pid/oom_score_adj happen to exceed the amount of
> rss of a thread, its badness score overflows as a result of a7f638f999ff
> ("mm, oom: normalize oom scores to oom_score_adj scale only for
> userspace").
>
> Fix this by making the type signed and return 1, meaning the thread is
> still eligible for kill, if the value is negative.
>
> Reported-by: Dave Jones<davej@redhat.com>
> Acked-by: Oleg Nesterov<oleg@redhat.com>
> Signed-off-by: David Rientjes<rientjes@google.com>
> ---
> mm/oom_kill.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/mm/oom_kill.c b/mm/oom_kill.c
> --- a/mm/oom_kill.c
> +++ b/mm/oom_kill.c
> @@ -183,7 +183,7 @@ static bool oom_unkillable_task(struct task_struct *p,
> unsigned long oom_badness(struct task_struct *p, struct mem_cgroup *memcg,
> const nodemask_t *nodemask, unsigned long totalpages)
> {
> - unsigned long points;
> + long points;
>
> if (oom_unkillable_task(p, memcg, nodemask))
> return 0;
> @@ -223,7 +223,7 @@ unsigned long oom_badness(struct task_struct *p, struct mem_cgroup *memcg,
> * Never return 0 for an eligible task regardless of the root bonus and
> * oom_score_adj (oom_score_adj can't be OOM_SCORE_ADJ_MIN here).
> */
> - return points ? points : 1;
> + return points> 0 ? points : 1;
> }
Use long long. following line is dangerous.
points += p->signal->oom_score_adj * totalpages / 1000;
maximum oom_score_adj is 1000. then if system has >8G memory on 32bit
(i.e. LONG_MAX [pages] * 4096 [pagesize] / 1000), it might get an overflow.
Or, don't use normalized oom_score_adj. i.e, oom_score_adj_write() convert
oom_score_adj into rss based modifier.
This is oom-killer code. A micro optimization don't bring us a performance benefit.
prev parent reply other threads:[~2012-06-09 22:25 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-06-07 16:59 [PATCH 0/3] uprobes fixes for 3.5 Oleg Nesterov
2012-06-07 17:00 ` [PATCH 1/3] uprobes: valid_vma() should reject VM_HUGETLB Oleg Nesterov
2012-06-15 6:22 ` Srikar Dronamraju
2012-06-07 17:00 ` [PATCH 2/3] uprobes: __copy_insn() should ensure a_ops->readpage != NULL Oleg Nesterov
2012-06-15 6:25 ` Srikar Dronamraju
2012-06-15 12:10 ` Ingo Molnar
2012-06-07 17:00 ` [PATCH 3/3] uprobes: write_opcode()->__replace_page() can race with try_to_unmap() Oleg Nesterov
2012-06-08 8:47 ` Peter Zijlstra
2012-06-08 10:03 ` Oleg Nesterov
2012-06-08 16:55 ` Oleg Nesterov
2012-06-15 6:12 ` Srikar Dronamraju
2012-06-15 12:11 ` Ingo Molnar
2012-06-15 15:48 ` Oleg Nesterov
2012-06-16 7:11 ` Ingo Molnar
2012-06-08 14:03 ` oom-killer is crazy? (Was: [PATCH 0/3] uprobes fixes for 3.5) Oleg Nesterov
2012-06-08 14:26 ` Dave Jones
2012-06-08 15:04 ` Oleg Nesterov
2012-06-08 20:21 ` [patch for-3.5-rc1] mm, oom: fix badness score underflow David Rientjes
2012-06-09 22:25 ` KOSAKI Motohiro [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=4FD3CD6A.9020801@gmail.com \
--to=kosaki.motohiro@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=ananth@in.ibm.com \
--cc=anton@redhat.com \
--cc=davej@redhat.com \
--cc=hughd@google.com \
--cc=kosaki.motohiro@jp.fujitsu.com \
--cc=linux-kernel@vger.kernel.org \
--cc=masami.hiramatsu.pt@hitachi.com \
--cc=mingo@elte.hu \
--cc=oleg@redhat.com \
--cc=peterz@infradead.org \
--cc=rientjes@google.com \
--cc=srikar@linux.vnet.ibm.com \
--cc=torvalds@linux-foundation.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.