aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorAbhishek Goel <huntbag@linux.vnet.ibm.com>2017-11-15 03:40:02 -0500
committerShuah Khan <shuahkh@osg.samsung.com>2017-11-15 10:37:42 -0500
commitdbdc468f35ee827cab2753caa1c660bdb832243a (patch)
tree009fbaa59b5cde86d28b3fefa9d370dc2ef5e7b4 /tools
parent53d1cd6b125fb9d69303516a1179ebc3b72f797a (diff)
cpupower : Fix cpupower working when cpu0 is offline
cpuidle_monitor used to assume that cpu0 is always online which is not a valid assumption on POWER machines. This patch fixes this by getting the cpu on which the current thread is running, instead of always using cpu0 for monitoring which may not be online. Signed-off-by: Abhishek Goel <huntbag@linux.vnet.ibm.com> Signed-off-by: Shuah Khan <shuahkh@osg.samsung.com>
Diffstat (limited to 'tools')
-rw-r--r--tools/power/cpupower/utils/idle_monitor/cpuidle_sysfs.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/tools/power/cpupower/utils/idle_monitor/cpuidle_sysfs.c b/tools/power/cpupower/utils/idle_monitor/cpuidle_sysfs.c
index 1b5da0066ebf..5b3205f16217 100644
--- a/tools/power/cpupower/utils/idle_monitor/cpuidle_sysfs.c
+++ b/tools/power/cpupower/utils/idle_monitor/cpuidle_sysfs.c
@@ -130,15 +130,18 @@ static struct cpuidle_monitor *cpuidle_register(void)
130{ 130{
131 int num; 131 int num;
132 char *tmp; 132 char *tmp;
133 int this_cpu;
134
135 this_cpu = sched_getcpu();
133 136
134 /* Assume idle state count is the same for all CPUs */ 137 /* Assume idle state count is the same for all CPUs */
135 cpuidle_sysfs_monitor.hw_states_num = cpuidle_state_count(0); 138 cpuidle_sysfs_monitor.hw_states_num = cpuidle_state_count(this_cpu);
136 139
137 if (cpuidle_sysfs_monitor.hw_states_num <= 0) 140 if (cpuidle_sysfs_monitor.hw_states_num <= 0)
138 return NULL; 141 return NULL;
139 142
140 for (num = 0; num < cpuidle_sysfs_monitor.hw_states_num; num++) { 143 for (num = 0; num < cpuidle_sysfs_monitor.hw_states_num; num++) {
141 tmp = cpuidle_state_name(0, num); 144 tmp = cpuidle_state_name(this_cpu, num);
142 if (tmp == NULL) 145 if (tmp == NULL)
143 continue; 146 continue;
144 147
@@ -146,7 +149,7 @@ static struct cpuidle_monitor *cpuidle_register(void)
146 strncpy(cpuidle_cstates[num].name, tmp, CSTATE_NAME_LEN - 1); 149 strncpy(cpuidle_cstates[num].name, tmp, CSTATE_NAME_LEN - 1);
147 free(tmp); 150 free(tmp);
148 151
149 tmp = cpuidle_state_desc(0, num); 152 tmp = cpuidle_state_desc(this_cpu, num);
150 if (tmp == NULL) 153 if (tmp == NULL)
151 continue; 154 continue;
152 strncpy(cpuidle_cstates[num].desc, tmp, CSTATE_DESC_LEN - 1); 155 strncpy(cpuidle_cstates[num].desc, tmp, CSTATE_DESC_LEN - 1);