From: Nathan F. <nf...@au...> - 2009-09-08 18:08:38
|
When making changes to increase the smt state, the cpus that are brought online come online with the same smt-snooze-delay they had when they were taken offline. This leads to a mix of smt-snooze-delay states for a system. This patch will update the cpus after an smt state change so that they all have the same smt-snooze-delay value if that value was consistant across the cpus prior to changing the smt state. If there was a mix of smt-snooze-delay values prior to the smt state change then no attempt is made to update the smt-snooze-delay state. Signed-off-by: Nathan Fontenot <nf...@au...> --- Index: powerpc-utils/src/ppc64_cpu.c =================================================================== --- powerpc-utils.orig/src/ppc64_cpu.c 2009-09-02 19:09:43.000000000 -0500 +++ powerpc-utils/src/ppc64_cpu.c 2009-09-04 14:15:04.000000000 -0500 @@ -53,6 +53,65 @@ 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]; + int i, rc; + int system_attribute = -1; + + for (i = 0; i < MAX_THREADS; i++) { + int cpu_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; + + if (system_attribute == -1) + system_attribute = cpu_attribute; + else if (system_attribute != cpu_attribute) + return -1; + } + + return system_attribute; +} + +int set_system_attribute(char *attribute, int state) +{ + char path[SYSFS_PATH_MAX]; + 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) + return -1; + } + + return 0; +} + int get_threads_per_cpu(void) { DIR *d; @@ -170,6 +229,9 @@ int set_smt_state(int smt_state) { int i, rc; + int ssd; + + ssd = get_system_attribute("smt_snooze_delay"); for (i = 0; i < MAX_THREADS; i += threads_per_cpu) { rc = set_one_smt_state(i, smt_state); @@ -177,6 +239,8 @@ break; } + set_system_attribute("smt_snooze_delay", ssd); + return rc; } @@ -194,65 +258,6 @@ } 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]; - int i, rc; - int system_attribute = -1; - - for (i = 0; i < MAX_THREADS; i++) { - int cpu_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; - - if (system_attribute == -1) - system_attribute = cpu_attribute; - else if (system_attribute != cpu_attribute) - return -1; - } - - return system_attribute; -} - -int set_system_attribute(char *attribute, int state) -{ - char path[SYSFS_PATH_MAX]; - 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) - return -1; - } - - return 0; } int do_smt(char *state) |