irqbalance: Fix detection of CPUs in sysfs
The current approach still let wrong patterns like "cpu0_idle", "cpu000_idle", "cpu0idle" and "cpu10001a" pass through. Of course it's highly unlikely that directories with these names will ever show in /sys/devices/system/cpu/, but here's the patch against the latest git if you want to fix it. Signed-off-by: Leonardo Chiquitto <lchiquitto@suse.com> Signed-off-by: Neil Horman <nhorman@tuxdriver.com>
This commit is contained in:
parent
430c88e502
commit
d7829d21b0
17
cputree.c
17
cputree.c
|
@ -27,6 +27,7 @@
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <dirent.h>
|
#include <dirent.h>
|
||||||
|
@ -334,15 +335,17 @@ void parse_cpu_tree(void)
|
||||||
if (!dir)
|
if (!dir)
|
||||||
return;
|
return;
|
||||||
do {
|
do {
|
||||||
|
int num;
|
||||||
|
char pad;
|
||||||
entry = readdir(dir);
|
entry = readdir(dir);
|
||||||
if (entry && strlen(entry->d_name)>3 && strstr(entry->d_name,"cpu")) {
|
/*
|
||||||
|
* We only want to count real cpus, not cpufreq and
|
||||||
|
* cpuidle
|
||||||
|
*/
|
||||||
|
if (entry &&
|
||||||
|
sscanf(entry->d_name, "cpu%d%c", &num, &pad) == 1 &&
|
||||||
|
!strchr(entry->d_name, ' ')) {
|
||||||
char new_path[PATH_MAX];
|
char new_path[PATH_MAX];
|
||||||
/*
|
|
||||||
* We only want to count real cpus, not cpufreq and
|
|
||||||
* cpuidle
|
|
||||||
*/
|
|
||||||
if ((entry->d_name[3] < 0x30) | (entry->d_name[3] > 0x39))
|
|
||||||
continue;
|
|
||||||
sprintf(new_path, "/sys/devices/system/cpu/%s", entry->d_name);
|
sprintf(new_path, "/sys/devices/system/cpu/%s", entry->d_name);
|
||||||
do_one_cpu(new_path);
|
do_one_cpu(new_path);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue