All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] perf jevents: Fix event code for events referencing std arch events
@ 2020-10-08 15:19 John Garry
  2020-10-09 11:26 ` kajoljain
  2020-10-12 10:54 ` Jiri Olsa
  0 siblings, 2 replies; 15+ messages in thread
From: John Garry @ 2020-10-08 15:19 UTC (permalink / raw)
  To: peterz, mingo, acme, mark.rutland, alexander.shishkin, jolsa,
	namhyung, kjain, irogers, yao.jin, yeyunfeng
  Cc: linux-kernel, linuxarm, =linux-arm-kernel, John Garry

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>

diff --git a/tools/perf/pmu-events/jevents.c b/tools/perf/pmu-events/jevents.c
index 99df41a9543d..e47644cab3fa 100644
--- a/tools/perf/pmu-events/jevents.c
+++ b/tools/perf/pmu-events/jevents.c
@@ -505,20 +505,15 @@ static char *real_event(const char *name, char *event)
 }
 
 static int
-try_fixup(const char *fn, char *arch_std, unsigned long long eventcode,
-	  struct json_event *je)
+try_fixup(const char *fn, char *arch_std, struct json_event *je, char **event)
 {
 	/* try to find matching event from arch standard values */
 	struct event_struct *es;
 
 	list_for_each_entry(es, &arch_std_events, list) {
 		if (!strcmp(arch_std, es->name)) {
-			if (!eventcode && es->event) {
-				/* allow EventCode to be overridden */
-				free(je->event);
-				je->event = NULL;
-			}
 			FOR_ALL_EVENT_STRUCT_FIELDS(TRY_FIXUP_FIELD);
+			*event = je->event;
 			return 0;
 		}
 	}
@@ -678,7 +673,7 @@ static int json_events(const char *fn,
 			 * An arch standard event is referenced, so try to
 			 * fixup any unassigned values.
 			 */
-			err = try_fixup(fn, arch_std, eventcode, &je);
+			err = try_fixup(fn, arch_std, &je, &event);
 			if (err)
 				goto free_strings;
 		}
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2020-10-15 15:47 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-08 15:19 [PATCH] perf jevents: Fix event code for events referencing std arch events John Garry
2020-10-09 11:26 ` kajoljain
2020-10-09 11:38   ` John Garry
2020-10-09 11:38     ` John Garry
2020-10-12 10:54 ` Jiri Olsa
2020-10-12 11:15   ` John Garry
2020-10-12 11:24     ` Jiri Olsa
2020-10-13  8:41       ` John Garry
2020-10-13  8:41         ` John Garry
2020-10-14 16:49       ` Arnaldo Carvalho de Melo
2020-10-14 17:46         ` John Garry
2020-10-15 12:25           ` Arnaldo Carvalho de Melo
2020-10-15 12:25             ` Arnaldo Carvalho de Melo
2020-10-15 15:42             ` John Garry
2020-10-15 15:42               ` John Garry

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.