lkml.org 
[lkml]   [2012]   [Aug]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
SubjectRe: [PATCH] sched: fix divide by zero at {thread_group,task}_times
From
Date
On Wed, 2012-08-08 at 21:50 +0200, Mike Galbraith wrote:
> 32bit built do_div()
> and div64_u64() both sucked equally compared to 64bit

/me peeks at div64_u64 fallback implementation and sees why, it still
does a single div, it does some neat fls tricks.

Ok, no point in avoiding this then..

I did the below little edit, no point in mixing the old and new
primitives.. those __force things annoy me, but I guess otherwise we'll
upset sparse.

---
Index: linux-2.6/kernel/sched/core.c
===================================================================
--- linux-2.6.orig/kernel/sched/core.c
+++ linux-2.6/kernel/sched/core.c
@@ -3149,7 +3149,7 @@ static cputime_t scale_utime(cputime_t u
temp *= (__force u64) utime;

if (sizeof(cputime_t) == 4)
- do_div(temp, (__force u32) total);
+ temp = div_u64(temp, (__force u32) total);
else
temp = div64_u64(temp, (__force u64) total);




\
 
 \ /
  Last update: 2012-08-08 22:41    [W:0.051 / U:0.344 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site