| From d9087cc52a280af77fbc52a3f9581c56dca9a8e6 Mon Sep 17 00:00:00 2001 |
| From: Luis Claudio R. Goncalves <lgoncalv@redhat.com> |
| Date: Fri, 3 Jul 2009 08:44:09 -0500 |
| Subject: [PATCH] sched: Fix spurious load spikes |
| |
| commit b97d674747b5499e4942d0297fb2a90757c4f519 in tip. |
| |
| Fixes spurious system load spikes observed in /proc/loadavgrt, as described in: |
| |
| Bug 253103: /proc/loadavgrt issues weird results |
| https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=253103 |
| |
| Signed-off-by: Luis Claudio R. Goncalves <lgoncalv@redhat.com>> |
| Signed-off-by: Ingo Molnar <mingo@elte.hu> |
| Signed-off-by: Thomas Gleixner <tglx@linutronix.de> |
| |
| diff --git a/kernel/sched.c b/kernel/sched.c |
| index 0ebeac1..adc845c 100644 |
| --- a/kernel/sched.c |
| +++ b/kernel/sched.c |
| @@ -3153,6 +3153,13 @@ unsigned long nr_iowait(void) |
| for_each_possible_cpu(i) |
| sum += atomic_read(&cpu_rq(i)->nr_iowait); |
| |
| + /* |
| + * Since we read the counters lockless, it might be slightly |
| + * inaccurate. Do not allow it to go below zero though: |
| + */ |
| + if (unlikely((long)sum < 0)) |
| + sum = 0; |
| + |
| return sum; |
| } |
| |
| -- |
| 1.7.1.1 |
| |