summaryrefslogtreecommitdiffstats
path: root/sched-Fix-spurious-load-spikes.patch
blob: 4c04ed630d1cdf15aa64e87b708f7e5f921c0b96 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
From 736d081ecb434beb9c4d738fb6ec2a185f52196a 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>
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
---
 kernel/sched.c |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/kernel/sched.c b/kernel/sched.c
index ff58409..17cef67 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -3139,6 +3139,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.0.4