From 930d3af052bcbe7cbea5f6c510cc7eee2c16b79b Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Wed, 10 Feb 2016 16:13:51 -0800 Subject: [PATCH] Fix ARM /proc/cpuinfo parsing. Also fix related warning message typos. --- src/console_reporter.cc | 2 +- src/csv_reporter.cc | 2 +- src/sysinfo.cc | 16 ++++++++++------ 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/console_reporter.cc b/src/console_reporter.cc index bee3c857..092936d5 100644 --- a/src/console_reporter.cc +++ b/src/console_reporter.cc @@ -37,7 +37,7 @@ bool ConsoleReporter::ReportContext(const Context& context) { if (context.cpu_scaling_enabled) { std::cerr << "***WARNING*** CPU scaling is enabled, the benchmark " - "real time measurements may be noisy and will incure extra " + "real time measurements may be noisy and will incur extra " "overhead.\n"; } diff --git a/src/csv_reporter.cc b/src/csv_reporter.cc index a8369433..d78a9dfb 100644 --- a/src/csv_reporter.cc +++ b/src/csv_reporter.cc @@ -34,7 +34,7 @@ bool CSVReporter::ReportContext(const Context& context) { if (context.cpu_scaling_enabled) { std::cerr << "***WARNING*** CPU scaling is enabled, the benchmark " - "real time measurements may be noisy and will incure extra " + "real time measurements may be noisy and will incur extra " "overhead.\n"; } diff --git a/src/sysinfo.cc b/src/sysinfo.cc index d1f31202..e10e19df 100644 --- a/src/sysinfo.cc +++ b/src/sysinfo.cc @@ -174,12 +174,16 @@ void InitializeSystemInfo() { if (freqstr[1] != '\0' && *err == '\0' && bogo_clock > 0) saw_bogo = true; } - } else if (strncasecmp(line, "processor", sizeof("processor") - 1) == 0) { + } else if (strncmp(line, "processor", sizeof("processor") - 1) == 0) { + // The above comparison is case-sensitive because ARM kernels often + // include a "Processor" line that tells you about the CPU, distinct + // from the usual "processor" lines that give you CPU ids. No current + // Linux architecture is using "Processor" for CPU ids. num_cpus++; // count up every time we see an "processor :" entry - const char* freqstr = strchr(line, ':'); - if (freqstr) { - const long cpu_id = strtol(freqstr + 1, &err, 10); - if (freqstr[1] != '\0' && *err == '\0' && max_cpu_id < cpu_id) + const char* id_str = strchr(line, ':'); + if (id_str) { + const long cpu_id = strtol(id_str + 1, &err, 10); + if (id_str[1] != '\0' && *err == '\0' && max_cpu_id < cpu_id) max_cpu_id = cpu_id; } } @@ -201,7 +205,7 @@ void InitializeSystemInfo() { } else { if ((max_cpu_id + 1) != num_cpus) { fprintf(stderr, - "CPU ID assignments in /proc/cpuinfo seems messed up." + "CPU ID assignments in /proc/cpuinfo seem messed up." " This is usually caused by a bad BIOS.\n"); } cpuinfo_num_cpus = num_cpus;