提交 0285b968 编写于 作者: S Srinivas Pandruvada 提交者: Caspar Zhang

tools/power/x86/intel-speed-select: Max CPU count calculation when CPU0 is offline

task #29499913

commit 864dc09e692f55fc7a5a87c7411da0a348ac1094 upstream

Currently /sys/devices/system/cpu/cpu0/topology/thread_siblings is used to
get the max CPU count. But when CPU0 is offline, then this file will be
absent.

So add processing so that we can get count from any first CPU in the
system. which is online.
Signed-off-by: NSrinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Signed-off-by: NAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: NErwei Deng <erwei@linux.alibaba.com>
Reviewed-by: NArtie Ding <artie.ding@linux.alibaba.com>
上级 b7339039
......@@ -316,10 +316,24 @@ static void set_max_cpu_num(void)
{
FILE *filep;
unsigned long dummy;
int i;
topo_max_cpus = 0;
filep = fopen_or_exit(
"/sys/devices/system/cpu/cpu0/topology/thread_siblings", "r");
for (i = 0; i < 256; ++i) {
char path[256];
snprintf(path, sizeof(path),
"/sys/devices/system/cpu/cpu%d/topology/thread_siblings", i);
filep = fopen(path, "r");
if (filep)
break;
}
if (!filep) {
fprintf(stderr, "Can't get max cpu number\n");
exit(0);
}
while (fscanf(filep, "%lx,", &dummy) == 1)
topo_max_cpus += BITMASK_SIZE;
fclose(filep);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册