summaryrefslogtreecommitdiffstats
path: root/sched-Fix-spurious-system-load-spikes-in-proc-loadav.patch
blob: 926b9b9546ccfd575b3286078dbd5d3cda92f56d (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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
From 6ad402ac5ca7d3ebcf79a52592523f5c70ced90b Mon Sep 17 00:00:00 2001
From: Luis Claudio R. Goncalves <lclaudio@uudg.org>
Date: Fri, 3 Jul 2009 08:30:21 -0500
Subject: [PATCH] sched: Fix spurious system load spikes in /proc/loadavgrt

commit 6c24cddbab29f64c31256444d083328936e9be18 in tip.

Hello,

The values in /proc/loadavgrt are sometimes the real load and sometimes
garbage. As you can see in th tests below, it occurs from in 2.6.21.5-rt20
to 2.6.23-rc2-rt2. The code for calc_load(), in kernel/timer.c has not
changed much in -rt patches.

        [lclaudio@lab sandbox]$ ls /proc/loadavg*
        /proc/loadavg  /proc/loadavgrt
        [lclaudio@lab sandbox]$ uname -a
        Linux lab.casa 2.6.21-34.el5rt #1 SMP PREEMPT RT Thu Jul 12 15:26:48 EDT 2007 x86_64 x86_64 x86_64 GNU/Linux
        [lclaudio@lab sandbox]$ cat /proc/loadavg*
        4.57 4.90 4.16 3/146 23499
        0.44 0.98 1.78 0/146 23499
        ...
        [lclaudio@lab sandbox]$ cat /proc/loadavg*
        4.65 4.80 4.75 5/144 20720
        23896.04 -898421.23 383170.94 2/144 20720

        [root@neverland ~]# uname -a
        Linux neverland.casa 2.6.21.5-rt20 #2 SMP PREEMPT RT Fri Jul 1318:31:38 BRT 2007 i686 athlon i386 GNU/Linux
        [root@neverland ~]# cat /proc/loadavg*
        0.16 0.16 0.15 1/184 11240
        344.65 0.38 311.71 0/184 11240

        [williams@torg ~]$ uname -a
        Linux torg 2.6.23-rc2-rt2 #14 SMP PREEMPT RT Tue Aug 7 20:07:31 CDT 2007 x86_64 x86_64 x86_64 GNU/Linux
        [williams@torg ~]$ cat /proc/loadavg*
        0.88 0.76 0.57 1/257 7267
        122947.70 103790.53 -564712.87 0/257 7267

---------->

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 <lclaudio@uudg.org>
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_rt.c |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/kernel/sched_rt.c b/kernel/sched_rt.c
index 1996902..cbdaa6e 100644
--- a/kernel/sched_rt.c
+++ b/kernel/sched_rt.c
@@ -918,6 +918,13 @@ unsigned long rt_nr_uninterruptible(void)
 	for_each_online_cpu(i)
 		sum += cpu_rq(i)->rt.rt_nr_uninterruptible;
 
+	/*
+	 * 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