Re: 2.6.0-test8-mm1

From: Thomas Schlichter
Date: Mon Oct 20 2003 - 06:19:46 EST


On Monday 20 October 2003 11:05, Andrew Morton wrote:
> ftp://ftp.kernel.org/pub/linux/kernel/people/akpm/patches/2.6/2.6.0-test8/2
>.6.0-test8-mm1
~~ snip ~~
> +fix-sqrt.patch
>
> Fix int_sqrt().

I really like this one... ;-)

The problem ist that oom_kill.c assumes that int_sqrt() never returns 0. So we
could get a division by zero there :-(

The attached patch fixes that...

Regards
Thomas
--- linux-2.6.0-test8-mm1/mm/oom_kill.c.orig Mon Oct 20 12:49:58 2003
+++ linux-2.6.0-test8-mm1/mm/oom_kill.c Mon Oct 20 12:52:55 2003
@@ -63,8 +63,8 @@
cpu_time = (p->utime + p->stime) >> (SHIFT_HZ + 3);
run_time = (get_jiffies_64() - p->start_time) >> (SHIFT_HZ + 10);

- points /= int_sqrt(cpu_time);
- points /= int_sqrt(int_sqrt(run_time));
+ points /= cpu_time ? int_sqrt(cpu_time) : 1;
+ points /= run_time ? int_sqrt(int_sqrt(run_time)) : 1;

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

Attachment: pgp00001.pgp
Description: signature