[PATCH] perf, tool: Add modifiers to be part of the event name

From: Jiri Olsa
Date: Fri May 11 2012 - 06:30:18 EST


On Thu, May 10, 2012 at 05:17:48PM -0700, Andi Kleen wrote:
> From: Andi Kleen <ak@xxxxxxxxxxxxxxx>
>
> We need to save the original string for perf stat output,
> otherwise :t and :c are invisible.

right, the modifier got lost

We need to fix the name once modifier is detected and final
event name is assigned (e.g. there could be "*?" in the tracepoint
event name, causing the name to be unwinded..).

Please check attached patch.

I'll add some testcases later, since there's patchset
waiting in Arnaldo's queue that would need to be rebased.

thanks,
jirka


---
We lost modifier as part of the event name after event parser
refactoring. Adding it back so it could be properly displayed
in perf stat output.

If there's a modifier specified for the event we fix the event
name to include it.

Signed-off-by: Jiri Olsa <jolsa@xxxxxxxxxx>
---
tools/perf/util/parse-events.c | 16 ++++++++++++++++
1 files changed, 16 insertions(+), 0 deletions(-)

diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c
index 5b3a0ef..6125f5e 100644
--- a/tools/perf/util/parse-events.c
+++ b/tools/perf/util/parse-events.c
@@ -684,11 +684,24 @@ void parse_events_update_lists(struct list_head *list_event,
INIT_LIST_HEAD(list_event);
}

+static int update_event_name(struct perf_evsel *evsel, char *mod)
+{
+ char name[MAX_NAME_LEN];
+
+ /* Each event should have a name defined at this point. */
+ BUG_ON(!evsel->name);
+ snprintf(name, MAX_NAME_LEN, "%s:%s", evsel->name, mod);
+ free(evsel->name);
+ evsel->name = strdup(name);
+ return evsel->name ? 0 : -ENOMEM;
+}
+
int parse_events_modifier(struct list_head *list, char *str)
{
struct perf_evsel *evsel;
int exclude = 0, exclude_GH = 0;
int eu = 0, ek = 0, eh = 0, eH = 0, eG = 0, precise = 0;
+ char *mod = str;

if (str == NULL)
return 0;
@@ -742,6 +755,9 @@ int parse_events_modifier(struct list_head *list, char *str)
evsel->attr.precise_ip = precise;
evsel->attr.exclude_host = eH;
evsel->attr.exclude_guest = eG;
+
+ if (update_event_name(evsel, mod))
+ return -ENOMEM;
}

return 0;
--
1.7.7.6

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/