[PATCH 1/2] Fix detection of CPUs in sysfs

From: Shawn Bohrer
Date: Thu Sep 23 2010 - 17:45:53 EST


Only count directories that match /sys/devices/system/cpu/cpu[0-9]+ as
CPUs. Previously any directory that started with cpu was counted which
caused cpufreq and cpuidle to be counted as CPUs.

Signed-off-by: Shawn Bohrer <sbohrer@xxxxxxxxxxxxxxx>
---
cputree.c | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/cputree.c b/cputree.c
index 3b0c982..b879785 100644
--- a/cputree.c
+++ b/cputree.c
@@ -25,6 +25,7 @@
*/

#include "config.h"
+#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
@@ -321,7 +322,7 @@ void parse_cpu_tree(void)
return;
do {
entry = readdir(dir);
- if (entry && strlen(entry->d_name)>3 && strstr(entry->d_name,"cpu")) {
+ if (entry && !strncmp(entry->d_name,"cpu", 3) && isdigit(entry->d_name[3])) {
char new_path[PATH_MAX];
sprintf(new_path, "/sys/devices/system/cpu/%s", entry->d_name);
do_one_cpu(new_path);
--
1.6.5.2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/