diff options
author | Nathan Ciobanu <nathan.d.ciobanu@linux.intel.com> | 2018-06-08 18:15:12 -0400 |
---|---|---|
committer | Len Brown <len.brown@intel.com> | 2018-06-20 13:55:04 -0400 |
commit | 42dd45209201edb222de5f9eadc1c8f93700ef28 (patch) | |
tree | 6932027a3b20fd4ff1bfabe3656397b0abe7d0dc /tools | |
parent | 4c2122d42116ebaa1665ad0fbef2c558fdc0e3c6 (diff) |
tools/power turbostat: fix segfault on 'no node' machines
Running turbostat on machines that don't expose nodes
in sysfs (no /sys/bus/node) causes a segfault or a -nan
value diesplayed in the log. This is caused by
physical_node_id being reported as -1 and logical_node_id
being calculated as a negative number resulting in the new
GET_THREAD/GET_CORE returning an incorrect address.
Signed-off-by: Nathan Ciobanu <nathan.d.ciobanu@linux.intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/power/x86/turbostat/turbostat.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/tools/power/x86/turbostat/turbostat.c b/tools/power/x86/turbostat/turbostat.c index 3bc2c9d94739..97cc00a9c763 100644 --- a/tools/power/x86/turbostat/turbostat.c +++ b/tools/power/x86/turbostat/turbostat.c | |||
@@ -2492,6 +2492,12 @@ void set_node_data(void) | |||
2492 | if (pni[pkg].count > topo.nodes_per_pkg) | 2492 | if (pni[pkg].count > topo.nodes_per_pkg) |
2493 | topo.nodes_per_pkg = pni[0].count; | 2493 | topo.nodes_per_pkg = pni[0].count; |
2494 | 2494 | ||
2495 | /* Fake 1 node per pkg for machines that don't | ||
2496 | * expose nodes and thus avoid -nan results | ||
2497 | */ | ||
2498 | if (topo.nodes_per_pkg == 0) | ||
2499 | topo.nodes_per_pkg = 1; | ||
2500 | |||
2495 | for (cpu = 0; cpu < topo.num_cpus; cpu++) { | 2501 | for (cpu = 0; cpu < topo.num_cpus; cpu++) { |
2496 | pkg = cpus[cpu].physical_package_id; | 2502 | pkg = cpus[cpu].physical_package_id; |
2497 | node = cpus[cpu].physical_node_id; | 2503 | node = cpus[cpu].physical_node_id; |
@@ -4904,6 +4910,13 @@ void init_counter(struct thread_data *thread_base, struct core_data *core_base, | |||
4904 | struct core_data *c; | 4910 | struct core_data *c; |
4905 | struct pkg_data *p; | 4911 | struct pkg_data *p; |
4906 | 4912 | ||
4913 | |||
4914 | /* Workaround for systems where physical_node_id==-1 | ||
4915 | * and logical_node_id==(-1 - topo.num_cpus) | ||
4916 | */ | ||
4917 | if (node_id < 0) | ||
4918 | node_id = 0; | ||
4919 | |||
4907 | t = GET_THREAD(thread_base, thread_id, core_id, node_id, pkg_id); | 4920 | t = GET_THREAD(thread_base, thread_id, core_id, node_id, pkg_id); |
4908 | c = GET_CORE(core_base, core_id, node_id, pkg_id); | 4921 | c = GET_CORE(core_base, core_id, node_id, pkg_id); |
4909 | p = GET_PKG(pkg_base, pkg_id); | 4922 | p = GET_PKG(pkg_base, pkg_id); |