There are two expressions in kernel/sched.c that are always false since 
they test for <0 but the result of the expression is unsigned so they will 
never be less than zero. This patch implement the logic that I believe is 
intended without the signedness issue and without the nasty casts.
<disclaimer>patch is compile tested only</disclaimer>


Signed-off-by: Jesper Juhl <[EMAIL PROTECTED]>
---

 sched.c |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)

--- linux-2.6.12-rc2-mm3-orig/kernel/sched.c    2005-04-11 21:20:56.000000000 
+0200
+++ linux-2.6.12-rc2-mm3/kernel/sched.c 2005-04-15 01:37:48.000000000 +0200
@@ -2697,9 +2697,10 @@ need_resched_nonpreemptible:
        schedstat_inc(rq, sched_cnt);
        now = sched_clock();
        if (likely((long long)now - prev->timestamp < NS_MAX_SLEEP_AVG)) {
-               run_time = now - prev->timestamp;
-               if (unlikely((long long)now - prev->timestamp < 0))
+               if (unlikely(prev->timestamp > now))
                        run_time = 0;
+               else
+                       run_time = now - prev->timestamp;
        } else
                run_time = NS_MAX_SLEEP_AVG;
 
@@ -2776,7 +2777,7 @@ go_idle:
 
        if (!rt_task(next) && next->activated > 0) {
                unsigned long long delta = now - next->timestamp;
-               if (unlikely((long long)now - next->timestamp < 0))
+               if (unlikely(next->timestamp > now))
                        delta = 0;
 
                if (next->activated == 1)


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to