Skip to content

Commit caf7f96

Browse files
John Garryacmel
authored andcommitted
perf jevents: Fix event code for events referencing std arch events
The event code for events referencing std arch events is incorrectly evaluated in json_events(). The issue is that je.event is evaluated properly from try_fixup(), but later NULLified from the real_event() call, as "event" may be NULL. Fix by setting "event" same je.event in try_fixup(). Also remove support for overwriting event code for events using std arch events, as it is not used. Signed-off-by: John Garry <john.garry@huawei.com> Reviewed-By: Kajol Jain<kjain@linux.ibm.com> Acked-by: Jiri Olsa <jolsa@redhat.com> Link: https://lore.kernel.org/r/1602170368-11892-1-git-send-email-john.garry@huawei.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
1 parent 2a09a84 commit caf7f96

1 file changed

Lines changed: 3 additions & 8 deletions

File tree

tools/perf/pmu-events/jevents.c

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -505,20 +505,15 @@ static char *real_event(const char *name, char *event)
505505
}
506506

507507
static int
508-
try_fixup(const char *fn, char *arch_std, unsigned long long eventcode,
509-
struct json_event *je)
508+
try_fixup(const char *fn, char *arch_std, struct json_event *je, char **event)
510509
{
511510
/* try to find matching event from arch standard values */
512511
struct event_struct *es;
513512

514513
list_for_each_entry(es, &arch_std_events, list) {
515514
if (!strcmp(arch_std, es->name)) {
516-
if (!eventcode && es->event) {
517-
/* allow EventCode to be overridden */
518-
free(je->event);
519-
je->event = NULL;
520-
}
521515
FOR_ALL_EVENT_STRUCT_FIELDS(TRY_FIXUP_FIELD);
516+
*event = je->event;
522517
return 0;
523518
}
524519
}
@@ -678,7 +673,7 @@ static int json_events(const char *fn,
678673
* An arch standard event is referenced, so try to
679674
* fixup any unassigned values.
680675
*/
681-
err = try_fixup(fn, arch_std, eventcode, &je);
676+
err = try_fixup(fn, arch_std, &je, &event);
682677
if (err)
683678
goto free_strings;
684679
}

0 commit comments

Comments
 (0)