diff options
author | Mika Westerberg <mika.westerberg@linux.intel.com> | 2016-04-22 04:13:23 -0400 |
---|---|---|
committer | Len Brown <len.brown@intel.com> | 2016-12-01 01:33:16 -0500 |
commit | 01a67adfc5d73d24e999d9cf65b5b8a6687187b8 (patch) | |
tree | 810e3a6680f4cbe8db0c77383af18f352aca14b5 | |
parent | 3d109de23c93e9196c370fd729fbd7ecf7371701 (diff) |
tools/power turbostat: Allocate correct amount of fd and irq entries
The tool uses topo.max_cpu_num to determine number of entries needed for
fd_percpu[] and irqs_per_cpu[]. For example on a system with 4 CPUs
topo.max_cpu_num is 3 so we get too small array for holding per-CPU items.
Fix this to use right number of entries, which is topo.max_cpu_num + 1.
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
-rw-r--r-- | tools/power/x86/turbostat/turbostat.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/tools/power/x86/turbostat/turbostat.c b/tools/power/x86/turbostat/turbostat.c index be50892f27aa..741fefa2f07e 100644 --- a/tools/power/x86/turbostat/turbostat.c +++ b/tools/power/x86/turbostat/turbostat.c | |||
@@ -1618,7 +1618,7 @@ void free_fd_percpu(void) | |||
1618 | { | 1618 | { |
1619 | int i; | 1619 | int i; |
1620 | 1620 | ||
1621 | for (i = 0; i < topo.max_cpu_num; ++i) { | 1621 | for (i = 0; i < topo.max_cpu_num + 1; ++i) { |
1622 | if (fd_percpu[i] != 0) | 1622 | if (fd_percpu[i] != 0) |
1623 | close(fd_percpu[i]); | 1623 | close(fd_percpu[i]); |
1624 | } | 1624 | } |
@@ -3584,7 +3584,7 @@ void allocate_output_buffer() | |||
3584 | } | 3584 | } |
3585 | void allocate_fd_percpu(void) | 3585 | void allocate_fd_percpu(void) |
3586 | { | 3586 | { |
3587 | fd_percpu = calloc(topo.max_cpu_num, sizeof(int)); | 3587 | fd_percpu = calloc(topo.max_cpu_num + 1, sizeof(int)); |
3588 | if (fd_percpu == NULL) | 3588 | if (fd_percpu == NULL) |
3589 | err(-1, "calloc fd_percpu"); | 3589 | err(-1, "calloc fd_percpu"); |
3590 | } | 3590 | } |
@@ -3594,9 +3594,9 @@ void allocate_irq_buffers(void) | |||
3594 | if (irq_column_2_cpu == NULL) | 3594 | if (irq_column_2_cpu == NULL) |
3595 | err(-1, "calloc %d", topo.num_cpus); | 3595 | err(-1, "calloc %d", topo.num_cpus); |
3596 | 3596 | ||
3597 | irqs_per_cpu = calloc(topo.max_cpu_num, sizeof(int)); | 3597 | irqs_per_cpu = calloc(topo.max_cpu_num + 1, sizeof(int)); |
3598 | if (irqs_per_cpu == NULL) | 3598 | if (irqs_per_cpu == NULL) |
3599 | err(-1, "calloc %d", topo.max_cpu_num); | 3599 | err(-1, "calloc %d", topo.max_cpu_num + 1); |
3600 | } | 3600 | } |
3601 | void setup_all_buffers(void) | 3601 | void setup_all_buffers(void) |
3602 | { | 3602 | { |