From: Nathan F. <nf...@au...> - 2009-09-02 21:24:33
|
When setting or retrieving system wide attributes such as the smt-snooze-delay or dscr we should only be concerned with online cpus/threads. Offline cpus/threads will not have these attributes in their sysfs directory. Signed-off-by: Nathan Fontenot <nf...@au...> --- Index: powerpc-utils/src/ppc64_cpu.c =================================================================== --- powerpc-utils.orig/src/ppc64_cpu.c 2009-09-02 18:47:59.000000000 -0500 +++ powerpc-utils/src/ppc64_cpu.c 2009-09-02 19:09:23.000000000 -0500 @@ -193,6 +193,19 @@ return 0; } +int cpu_online(int thread) +{ + char path[SYSFS_PATH_MAX]; + int rc, online; + + sprintf(path, SYSFS_CPUDIR"/online", thread); + rc = get_attribute(path, &online); + if (rc || !online) + return 0; + + return 1; +} + int get_system_attribute(char *attribute) { char path[SYSFS_PATH_MAX]; @@ -202,8 +215,11 @@ for (i = 0; i < MAX_THREADS; i++) { int cpu_attribute; - sprintf(path, SYSFS_CPUDIR"/%s", i, attribute); + /* only check online cpus */ + if (!cpu_online(i)) + continue; + sprintf(path, SYSFS_CPUDIR"/%s", i, attribute); rc = get_attribute(path, &cpu_attribute); if (rc) continue; @@ -223,6 +239,10 @@ int i, rc; for (i = 0; i < MAX_THREADS; i++) { + /* only set online cpus */ + if (!cpu_online(i)) + continue; + sprintf(path, SYSFS_CPUDIR"/%s", i, attribute); rc = set_attribute(path, state); if (rc) |