From: Shawn Bohrer 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 --- 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