perf values: Fix thread index bug
authorJiri Olsa <[email protected]>
Thu, 24 Aug 2017 16:27:33 +0000 (18:27 +0200)
committerArnaldo Carvalho de Melo <[email protected]>
Mon, 28 Aug 2017 19:44:42 +0000 (16:44 -0300)
We are taking wrong index (+1) for first thread, which leaves thread
with index 0 unused and uninitialized.

Signed-off-by: Jiri Olsa <[email protected]>
Cc: Alexander Shishkin <[email protected]>
Cc: Andi Kleen <[email protected]>
Cc: David Ahern <[email protected]>
Cc: Mark Rutland <[email protected]>
Cc: Namhyung Kim <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
tools/perf/util/values.c

index 5de2e15e2eda9c343246431caf0ba68d9559e614..9ac36bf2c438900b478ee68c0b40287102b636d0 100644 (file)
@@ -98,7 +98,7 @@ static int perf_read_values__findnew_thread(struct perf_read_values *values,
                        return i;
        }
 
-       i = values->threads + 1;
+       i = values->threads;
        values->value[i] = malloc(values->counters_max * sizeof(**values->value));
        if (!values->value[i]) {
                pr_debug("failed to allocate read_values counters array");
@@ -106,7 +106,7 @@ static int perf_read_values__findnew_thread(struct perf_read_values *values,
        }
        values->pid[i] = pid;
        values->tid[i] = tid;
-       values->threads = i;
+       values->threads = i + 1;
 
        return i;
 }