Skip to content

Commit a12888f

Browse files
cyrillostorvalds
authored andcommitted
oom_kill: don't call for int_sqrt(0)
There is no need to call for int_sqrt if argument is 0. Signed-off-by: Cyrill Gorcunov <[email protected]> Cc: Pekka Enberg <[email protected]> Cc: Christoph Lameter <[email protected]> Acked-by: David Rientjes <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent d086817 commit a12888f

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

mm/oom_kill.c

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ static DEFINE_SPINLOCK(zone_scan_lock);
5555

5656
unsigned long badness(struct task_struct *p, unsigned long uptime)
5757
{
58-
unsigned long points, cpu_time, run_time, s;
58+
unsigned long points, cpu_time, run_time;
5959
struct mm_struct *mm;
6060
struct task_struct *child;
6161

@@ -110,12 +110,10 @@ unsigned long badness(struct task_struct *p, unsigned long uptime)
110110
else
111111
run_time = 0;
112112

113-
s = int_sqrt(cpu_time);
114-
if (s)
115-
points /= s;
116-
s = int_sqrt(int_sqrt(run_time));
117-
if (s)
118-
points /= s;
113+
if (cpu_time)
114+
points /= int_sqrt(cpu_time);
115+
if (run_time)
116+
points /= int_sqrt(int_sqrt(run_time));
119117

120118
/*
121119
* Niced processes are most likely less important, so double

0 commit comments

Comments
 (0)