Skip to contentSkip to conversation

perf top: update event name when falling back to cpu-clock

PATCH In review David Ahern 1 participant 2 messages May 8, 2012 – May 11, 2012 perf events

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 perf top: update event name when falling back to cpu-clock

perf-top falls back to cpu-clock if the H/W cycles event is not supported, but the event name is not updated leading to a misleading header:

PerfTop: 8 irqs/sec kernel:75.0% exact: 0.0% [1000Hz cycles], ...

Update the event name when the event type is changed so that the header displays correctly:

PerfTop: 794 irqs/sec kernel:100.0% exact: 0.0% [1000Hz cpu-clock], ...

---
 tools/perf/builtin-top.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)
tools/perf/builtin-top.c +5 -0
index c53cdab..79481c1 100644
@@ -948,6 +948,11 @@ try_again:
 
 				attr->type = PERF_TYPE_SOFTWARE;
 				attr->config = PERF_COUNT_SW_CPU_CLOCK;
+				if (counter->name) {
+					free(counter->name);
+					counter->name = NULL;
+					counter->name = strdup(event_name(counter));
+				}
 				goto try_again;
 			}
 
Signature · 1 line
1.7.5.4
#1 lore raw

[tip:perf/core] perf top: Update event name when falling back to cpu-clock

Commit-ID:  40491eaa46a693e8c6ef94102350a747c63e584d
Gitweb:     http://git.kernel.org/tip/40491eaa46a693e8c6ef94102350a747c63e584d
Author:     David Ahern <[email protected]>
AuthorDate: Tue, 8 May 2012 10:49:49 -0600
Committer:  Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Wed, 9 May 2012 12:01:57 -0300

perf top: Update event name when falling back to cpu-clock

The 'perf top' command falls back to cpu-clock if the H/W cycles event is not supported, but the event name is not updated leading to a misleading header:

PerfTop: 8 irqs/sec kernel:75.0% exact: 0.0% [1000Hz cycles], ...

Update the event name when the event type is changed so that the header displays correctly:

PerfTop: 794 irqs/sec kernel:100.0% exact: 0.0% [1000Hz cpu-clock], ...

---
 tools/perf/builtin-top.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
tools/perf/builtin-top.c +4 -0
index c53cdab..4eb6171 100644
@@ -948,6 +948,10 @@ try_again:
 
 				attr->type = PERF_TYPE_SOFTWARE;
 				attr->config = PERF_COUNT_SW_CPU_CLOCK;
+				if (counter->name) {
+					free(counter->name);
+					counter->name = strdup(event_name(counter));
+				}
 				goto try_again;
 			}