Skip to content

Commit

Permalink
oom_kill: don't call for int_sqrt(0)
Browse files Browse the repository at this point in the history
There is no need to call for int_sqrt if argument is 0.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Cc: Pekka Enberg <penberg@cs.helsinki.fi>
Cc: Christoph Lameter <cl@linux-foundation.org>
Acked-by: David Rientjes <rientjes@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Cyrill Gorcunov authored and Linus Torvalds committed Apr 1, 2009
1 parent d086817 commit a12888f
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions mm/oom_kill.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ static DEFINE_SPINLOCK(zone_scan_lock);

unsigned long badness(struct task_struct *p, unsigned long uptime)
{
unsigned long points, cpu_time, run_time, s;
unsigned long points, cpu_time, run_time;
struct mm_struct *mm;
struct task_struct *child;

Expand Down Expand Up @@ -110,12 +110,10 @@ unsigned long badness(struct task_struct *p, unsigned long uptime)
else
run_time = 0;

s = int_sqrt(cpu_time);
if (s)
points /= s;
s = int_sqrt(int_sqrt(run_time));
if (s)
points /= s;
if (cpu_time)
points /= int_sqrt(cpu_time);
if (run_time)
points /= int_sqrt(int_sqrt(run_time));

/*
* Niced processes are most likely less important, so double
Expand Down

0 comments on commit a12888f

Please sign in to comment.