Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

tools/power turbostat: Fix --cpu-set 0 regression on HT systems

"turbostat --cpu-set 0" appears to hang if cpu0 has an HT sibling.

This is because the initialization code recognizes that it does not
have to open perf files for the HT sibling, but the HT support
in the collection code sees the HT sibling and tries to read
from an uninitialized file descriptor, 0 (standard input).

Access HT siblings only when they are in the allowed set.

Fixes: a2b4d0f8bf07 ("tools/power turbostat: Favor cpu# over core#")
Signed-off-by: Len Brown <len.brown@intel.com>
Reported-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>

+17 -5
+17 -5
tools/power/x86/turbostat/turbostat.c
··· 2427 2427 2428 2428 int cpu_is_not_present(int cpu) 2429 2429 { 2430 + if (cpu < 0) 2431 + return 1; 2432 + 2430 2433 return !CPU_ISSET_S(cpu, cpu_present_setsize, cpu_present_set); 2431 2434 } 2432 2435 2433 2436 int cpu_is_not_allowed(int cpu) 2434 2437 { 2438 + if (cpu < 0) 2439 + return 1; 2440 + 2435 2441 return !CPU_ISSET_S(cpu, cpu_allowed_setsize, cpu_allowed_set); 2436 2442 } 2437 2443 ··· 2479 2473 int i; 2480 2474 2481 2475 for (i = MAX_HT_ID; i > 0; --i) { /* ht_id 0 is self */ 2482 - if (cpus[cpu].ht_sibling_cpu_id[i] <= 0) 2476 + int sibling_cpu_id = cpus[cpu].ht_sibling_cpu_id[i]; 2477 + 2478 + if (cpu_is_not_allowed(sibling_cpu_id)) 2483 2479 continue; 2484 - t = &thread_base[cpus[cpu].ht_sibling_cpu_id[i]]; 2480 + 2481 + t = &thread_base[sibling_cpu_id]; 2485 2482 2486 2483 retval |= func(t, c, p); 2487 2484 } ··· 6261 6252 int i; 6262 6253 6263 6254 for (i = MAX_HT_ID; i > 0; --i) { /* ht_id 0 is self */ 6264 - if (cpus[cpu].ht_sibling_cpu_id[i] <= 0) 6255 + int sibling_cpu_id = cpus[cpu].ht_sibling_cpu_id[i]; 6256 + 6257 + if (cpu_is_not_allowed(sibling_cpu_id)) 6265 6258 continue; 6266 - t = &thread_base[cpus[cpu].ht_sibling_cpu_id[i]]; 6267 - t2 = &thread_base2[cpus[cpu].ht_sibling_cpu_id[i]]; 6259 + 6260 + t = &thread_base[sibling_cpu_id]; 6261 + t2 = &thread_base2[sibling_cpu_id]; 6268 6262 6269 6263 retval |= func(t, c, p, t2, c2, p2); 6270 6264 }