summaryrefslogtreecommitdiff
path: root/extra/irqbalance/Special-interrupt-counts-line-NMI-may-start-with-a-s.patch
blob: c2e69c218c1822e97bb40a910b84e374e6a2ad5a (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
From: Shawn Bohrer <sbohrer@rgmadvisors.com>

Special interrupt counts line NMI may start with a space

The kernel determines the maximum number of possible IRQs and pads the
first field of /proc/interrupts appropriately.  With four or more digits
of precession the special interrupt counts all start with a space
instead of a letter.  This caused the special interrupt counts to be
counted on my system and that caused the cpunr count to be off when it
reached the ERR and MIS lines forcing a CPU rescan.

Signed-off-by: Shawn Bohrer <sbohrer@rgmadvisors.com>
---
 procinterrupts.c |   24 +++++++++++-------------
 1 files changed, 11 insertions(+), 13 deletions(-)

diff --git a/procinterrupts.c b/procinterrupts.c
index e336efe..322f4de 100644
--- a/procinterrupts.c
+++ b/procinterrupts.c
@@ -55,20 +55,18 @@ void parse_proc_interrupts(void)
 		if (getline(&line, &size, file)==0)
 			break;
 
-
+		number = strtoul(line, &c, 10);
 		/* lines with letters in front are special, like NMI count. Ignore */
-		if (!(line[0]==' ' || (line[0]>='0' && line[0]<='9')))
-			break;
-		c = strchr(line, ':');
-		if (!c)
+		if (line == c)
+			continue;
+
+		if (c[0] == ':')
+			++c;
+		else
 			continue;
-		*c = 0;
-		c++;
-		number = strtoul(line, NULL, 10);
+
 		count = 0;
 		cpunr = 0;
-
-		c2=NULL;
 		while (1) {
 			uint64_t C;
 			C = strtoull(c, &c2, 10);
@@ -78,11 +76,11 @@ void parse_proc_interrupts(void)
 			c=c2;
 			cpunr++;
 		}
-		if (cpunr != core_count) 
+		if (cpunr != core_count)
 			need_cpu_rescan = 1;
-		
+
 		set_interrupt_count(number, count);
-	}		
+	}
 	fclose(file);
 	free(line);
 }
-- 
1.6.5.2