diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2012-05-25 13:49:51 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2012-05-25 13:59:37 -0400 |
commit | 895d97663c83f8ed7a3386e912009155524fe7dd (patch) | |
tree | e782ad8cf7b1c460e3756d94c3d873e98add448d /tools | |
parent | e8cdd947776300f962d5b699c34087af45a8aea7 (diff) |
perf top: Fix counter name fixup when fallbacking to cpu-clock
In 40491eaa "perf top: Update event name when falling back to cpu-clock"
we freed counter->name but didn't reset it to NULL, then when setting it
to the result of event_name(), event_name() would use the cached value,
which by now was overwritten and thus we got garbage or a zero lenght
string.
Fix it by just freeing and setting counter->name to NULL, this way
event_name() when called afterwards, will find the right counter name
and cache it again.
Found while trying 'cycles:pp' on a machine were :pp couldn't be
honoured. Probably the best fallback here is to tell the user that that
level of precision is not available on the PMU and then go removing 'p',
levels of precision till we get to play 'cycles' and if even that fails,
_then_ get to 'cpu-clock'.
But that is the matter for another patch, this one just needs to fix the
caching issue, which in the end will show 'cpu-clock' when tools ask for
the event name being used, which clarifies things for the user, that
will see that 'cycles:pp' or whatever not support event is not being
used, some sort of fallback happened.
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Namhyung Kim <namhyung@gmail.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/n/tip-w1neie2dqli89we1bzwkf4id@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/perf/builtin-top.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c index 6031dce0429f..d4a5f9b7f4f9 100644 --- a/tools/perf/builtin-top.c +++ b/tools/perf/builtin-top.c | |||
@@ -953,7 +953,7 @@ try_again: | |||
953 | attr->config = PERF_COUNT_SW_CPU_CLOCK; | 953 | attr->config = PERF_COUNT_SW_CPU_CLOCK; |
954 | if (counter->name) { | 954 | if (counter->name) { |
955 | free(counter->name); | 955 | free(counter->name); |
956 | counter->name = strdup(event_name(counter)); | 956 | counter->name = NULL; |
957 | } | 957 | } |
958 | goto try_again; | 958 | goto try_again; |
959 | } | 959 | } |