Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit aaf045f7 authored by Steven Rostedt's avatar Steven Rostedt Committed by Frederic Weisbecker
Browse files

perf: Have perf use the new libtraceevent.a library



The event parsing code in perf was originally copied from trace-cmd
but never was kept up-to-date with the changes that was done there.
The trace-cmd libtraceevent.a code is much more mature than what is
currently in perf.

This updates the code to use wrappers to handle the calls to the
new event parsing code. The new code requires a handle to be pass
around, which removes the global event variables and allows
more than one event structure to be read from different files
(and different machines).

But perf still has the old global events and the code throughout
perf does not yet have a nice way to pass around a handle.
A global 'pevent' has been made for perf and the old calls have
been created as wrappers to the new event parsing code that uses
the global pevent.

With this change, perf can later incorporate the pevent handle into
the perf structures and allow more than one file to be read and
compared, that contains different events.

Signed-off-by: default avatarSteven Rostedt <rostedt@goodmis.org>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Arnaldo Carvalho de Melo <acme@infradead.org>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Arun Sharma <asharma@fb.com>
Cc: Namhyung Kim <namhyung.kim@lge.com>
Signed-off-by: default avatarFrederic Weisbecker <fweisbec@gmail.com>
parent 668fe01f
Loading
Loading
Loading
Loading
+13 −7
Original line number Diff line number Diff line
@@ -149,7 +149,7 @@ endif

### --- END CONFIGURATION SECTION ---

BASIC_CFLAGS = -Iutil/include -Iarch/$(ARCH)/include -I$(OUTPUT)/util -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE
BASIC_CFLAGS = -Iutil/include -Iarch/$(ARCH)/include -I$(OUTPUT)/util -I$(EVENT_PARSE_DIR) -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE
BASIC_LDFLAGS =

# Guard against environment variables
@@ -179,7 +179,15 @@ $(OUTPUT)python/perf.so: $(PYRF_OBJS) $(PYTHON_EXT_SRCS) $(PYTHON_EXT_DEPS)
SCRIPTS = $(patsubst %.sh,%,$(SCRIPT_SH))

EVENT_PARSE_DIR = ../lib/traceevent/
LIBTRACEEVENT = $(OUTPUT)$(EVENT_PARSE_DIR)libtraceevent.a

ifeq ("$(origin O)", "command line")
	EP_PATH=$(OUTPUT)/
else
	EP_PATH=$(EVENT_PARSE_DIR)/
endif

LIBPARSEVENT = $(EP_PATH)libtraceevent.a
EP_LIB := -L$(EP_PATH) -ltraceevent

#
# Single 'perf' binary right now:
@@ -295,7 +303,6 @@ LIB_H += util/hist.h
LIB_H += util/thread.h
LIB_H += util/thread_map.h
LIB_H += util/trace-event.h
LIB_H += util/trace-parse-events.h
LIB_H += util/probe-finder.h
LIB_H += util/dwarf-aux.h
LIB_H += util/probe-event.h
@@ -358,7 +365,6 @@ LIB_OBJS += $(OUTPUT)util/pmu-bison.o
LIB_OBJS += $(OUTPUT)util/trace-event-read.o
LIB_OBJS += $(OUTPUT)util/trace-event-info.o
LIB_OBJS += $(OUTPUT)util/trace-event-scripting.o
LIB_OBJS += $(OUTPUT)util/trace-parse-events.o
LIB_OBJS += $(OUTPUT)util/svghelper.o
LIB_OBJS += $(OUTPUT)util/sort.o
LIB_OBJS += $(OUTPUT)util/hist.o
@@ -402,7 +408,7 @@ BUILTIN_OBJS += $(OUTPUT)builtin-kvm.o
BUILTIN_OBJS += $(OUTPUT)builtin-test.o
BUILTIN_OBJS += $(OUTPUT)builtin-inject.o

PERFLIBS = $(LIB_FILE)
PERFLIBS = $(LIB_FILE) $(LIBPARSEVENT)

# Files needed for the python binding, perf.so
# pyrf is just an internal name needed for all those wrappers.
@@ -699,7 +705,7 @@ $(OUTPUT)perf.o: perf.c $(OUTPUT)common-cmds.h $(OUTPUT)PERF-CFLAGS
		'-DPERF_HTML_PATH="$(htmldir_SQ)"' \
		$(ALL_CFLAGS) -c $(filter %.c,$^) -o $@

$(OUTPUT)perf: $(OUTPUT)perf.o $(BUILTIN_OBJS) $(PERFLIBS) $(LIBTRACEEVENT)
$(OUTPUT)perf: $(OUTPUT)perf.o $(BUILTIN_OBJS) $(PERFLIBS)
	$(QUIET_LINK)$(CC) $(ALL_CFLAGS) $(ALL_LDFLAGS) $(OUTPUT)perf.o \
               $(BUILTIN_OBJS) $(LIBS) -o $@

@@ -806,7 +812,7 @@ $(LIB_FILE): $(LIB_OBJS)
	$(QUIET_AR)$(RM) $@ && $(AR) rcs $@ $(LIB_OBJS)

# libparsevent.a
$(LIBTRACEEVENT):
$(LIBPARSEVENT):
	make -C $(EVENT_PARSE_DIR) $(COMMAND_O) libtraceevent.a

help:
+3 −3
Original line number Diff line number Diff line
@@ -192,7 +192,7 @@ static void insert_caller_stat(unsigned long call_site,
}

static void process_alloc_event(void *data,
				struct event *event,
				struct event_format *event,
				int cpu,
				u64 timestamp __used,
				struct thread *thread __used,
@@ -253,7 +253,7 @@ static struct alloc_stat *search_alloc_stat(unsigned long ptr,
}

static void process_free_event(void *data,
			       struct event *event,
			       struct event_format *event,
			       int cpu,
			       u64 timestamp __used,
			       struct thread *thread __used)
@@ -281,7 +281,7 @@ static void process_free_event(void *data,
static void process_raw_event(union perf_event *raw_event __used, void *data,
			      int cpu, u64 timestamp, struct thread *thread)
{
	struct event *event;
	struct event_format *event;
	int type;

	type = trace_parse_common_type(data);
+13 −13
Original line number Diff line number Diff line
@@ -356,25 +356,25 @@ struct trace_release_event {

struct trace_lock_handler {
	void (*acquire_event)(struct trace_acquire_event *,
			      struct event *,
			      struct event_format *,
			      int cpu,
			      u64 timestamp,
			      struct thread *thread);

	void (*acquired_event)(struct trace_acquired_event *,
			       struct event *,
			       struct event_format *,
			       int cpu,
			       u64 timestamp,
			       struct thread *thread);

	void (*contended_event)(struct trace_contended_event *,
				struct event *,
				struct event_format *,
				int cpu,
				u64 timestamp,
				struct thread *thread);

	void (*release_event)(struct trace_release_event *,
			      struct event *,
			      struct event_format *,
			      int cpu,
			      u64 timestamp,
			      struct thread *thread);
@@ -416,7 +416,7 @@ enum acquire_flags {

static void
report_lock_acquire_event(struct trace_acquire_event *acquire_event,
			struct event *__event __used,
			struct event_format *__event __used,
			int cpu __used,
			u64 timestamp __used,
			struct thread *thread __used)
@@ -480,7 +480,7 @@ end:

static void
report_lock_acquired_event(struct trace_acquired_event *acquired_event,
			 struct event *__event __used,
			 struct event_format *__event __used,
			 int cpu __used,
			 u64 timestamp __used,
			 struct thread *thread __used)
@@ -536,7 +536,7 @@ end:

static void
report_lock_contended_event(struct trace_contended_event *contended_event,
			  struct event *__event __used,
			  struct event_format *__event __used,
			  int cpu __used,
			  u64 timestamp __used,
			  struct thread *thread __used)
@@ -583,7 +583,7 @@ end:

static void
report_lock_release_event(struct trace_release_event *release_event,
			struct event *__event __used,
			struct event_format *__event __used,
			int cpu __used,
			u64 timestamp __used,
			struct thread *thread __used)
@@ -647,7 +647,7 @@ static struct trace_lock_handler *trace_handler;

static void
process_lock_acquire_event(void *data,
			   struct event *event __used,
			   struct event_format *event __used,
			   int cpu __used,
			   u64 timestamp __used,
			   struct thread *thread __used)
@@ -666,7 +666,7 @@ process_lock_acquire_event(void *data,

static void
process_lock_acquired_event(void *data,
			    struct event *event __used,
			    struct event_format *event __used,
			    int cpu __used,
			    u64 timestamp __used,
			    struct thread *thread __used)
@@ -684,7 +684,7 @@ process_lock_acquired_event(void *data,

static void
process_lock_contended_event(void *data,
			     struct event *event __used,
			     struct event_format *event __used,
			     int cpu __used,
			     u64 timestamp __used,
			     struct thread *thread __used)
@@ -702,7 +702,7 @@ process_lock_contended_event(void *data,

static void
process_lock_release_event(void *data,
			   struct event *event __used,
			   struct event_format *event __used,
			   int cpu __used,
			   u64 timestamp __used,
			   struct thread *thread __used)
@@ -721,7 +721,7 @@ process_lock_release_event(void *data,
static void
process_raw_event(void *data, int cpu, u64 timestamp, struct thread *thread)
{
	struct event *event;
	struct event_format *event;
	int type;

	type = trace_parse_common_type(data);
+21 −21
Original line number Diff line number Diff line
@@ -728,34 +728,34 @@ struct trace_migrate_task_event {
struct trace_sched_handler {
	void (*switch_event)(struct trace_switch_event *,
			     struct machine *,
			     struct event *,
			     struct event_format *,
			     int cpu,
			     u64 timestamp,
			     struct thread *thread);

	void (*runtime_event)(struct trace_runtime_event *,
			      struct machine *,
			      struct event *,
			      struct event_format *,
			      int cpu,
			      u64 timestamp,
			      struct thread *thread);

	void (*wakeup_event)(struct trace_wakeup_event *,
			     struct machine *,
			     struct event *,
			     struct event_format *,
			     int cpu,
			     u64 timestamp,
			     struct thread *thread);

	void (*fork_event)(struct trace_fork_event *,
			   struct event *,
			   struct event_format *,
			   int cpu,
			   u64 timestamp,
			   struct thread *thread);

	void (*migrate_task_event)(struct trace_migrate_task_event *,
			   struct machine *machine,
			   struct event *,
			   struct event_format *,
			   int cpu,
			   u64 timestamp,
			   struct thread *thread);
@@ -765,7 +765,7 @@ struct trace_sched_handler {
static void
replay_wakeup_event(struct trace_wakeup_event *wakeup_event,
		    struct machine *machine __used,
		    struct event *event,
		    struct event_format *event,
		    int cpu __used,
		    u64 timestamp __used,
		    struct thread *thread __used)
@@ -792,7 +792,7 @@ static u64 cpu_last_switched[MAX_CPUS];
static void
replay_switch_event(struct trace_switch_event *switch_event,
		    struct machine *machine __used,
		    struct event *event,
		    struct event_format *event,
		    int cpu,
		    u64 timestamp,
		    struct thread *thread __used)
@@ -835,7 +835,7 @@ replay_switch_event(struct trace_switch_event *switch_event,

static void
replay_fork_event(struct trace_fork_event *fork_event,
		  struct event *event,
		  struct event_format *event,
		  int cpu __used,
		  u64 timestamp __used,
		  struct thread *thread __used)
@@ -944,7 +944,7 @@ static void thread_atoms_insert(struct thread *thread)

static void
latency_fork_event(struct trace_fork_event *fork_event __used,
		   struct event *event __used,
		   struct event_format *event __used,
		   int cpu __used,
		   u64 timestamp __used,
		   struct thread *thread __used)
@@ -1026,7 +1026,7 @@ add_sched_in_event(struct work_atoms *atoms, u64 timestamp)
static void
latency_switch_event(struct trace_switch_event *switch_event,
		     struct machine *machine,
		     struct event *event __used,
		     struct event_format *event __used,
		     int cpu,
		     u64 timestamp,
		     struct thread *thread __used)
@@ -1079,7 +1079,7 @@ latency_switch_event(struct trace_switch_event *switch_event,
static void
latency_runtime_event(struct trace_runtime_event *runtime_event,
		     struct machine *machine,
		     struct event *event __used,
		     struct event_format *event __used,
		     int cpu,
		     u64 timestamp,
		     struct thread *this_thread __used)
@@ -1102,7 +1102,7 @@ latency_runtime_event(struct trace_runtime_event *runtime_event,
static void
latency_wakeup_event(struct trace_wakeup_event *wakeup_event,
		     struct machine *machine,
		     struct event *__event __used,
		     struct event_format *__event __used,
		     int cpu __used,
		     u64 timestamp,
		     struct thread *thread __used)
@@ -1150,7 +1150,7 @@ latency_wakeup_event(struct trace_wakeup_event *wakeup_event,
static void
latency_migrate_task_event(struct trace_migrate_task_event *migrate_task_event,
		     struct machine *machine,
		     struct event *__event __used,
		     struct event_format *__event __used,
		     int cpu __used,
		     u64 timestamp,
		     struct thread *thread __used)
@@ -1361,7 +1361,7 @@ static struct trace_sched_handler *trace_handler;

static void
process_sched_wakeup_event(struct perf_tool *tool __used,
			   struct event *event,
			   struct event_format *event,
			   struct perf_sample *sample,
			   struct machine *machine,
			   struct thread *thread)
@@ -1398,7 +1398,7 @@ static char next_shortname2 = '0';
static void
map_switch_event(struct trace_switch_event *switch_event,
		 struct machine *machine,
		 struct event *event __used,
		 struct event_format *event __used,
		 int this_cpu,
		 u64 timestamp,
		 struct thread *thread __used)
@@ -1476,7 +1476,7 @@ map_switch_event(struct trace_switch_event *switch_event,

static void
process_sched_switch_event(struct perf_tool *tool __used,
			   struct event *event,
			   struct event_format *event,
			   struct perf_sample *sample,
			   struct machine *machine,
			   struct thread *thread)
@@ -1512,7 +1512,7 @@ process_sched_switch_event(struct perf_tool *tool __used,

static void
process_sched_runtime_event(struct perf_tool *tool __used,
			    struct event *event,
			    struct event_format *event,
			    struct perf_sample *sample,
			    struct machine *machine,
			    struct thread *thread)
@@ -1532,7 +1532,7 @@ process_sched_runtime_event(struct perf_tool *tool __used,

static void
process_sched_fork_event(struct perf_tool *tool __used,
			 struct event *event,
			 struct event_format *event,
			 struct perf_sample *sample,
			 struct machine *machine __used,
			 struct thread *thread)
@@ -1554,7 +1554,7 @@ process_sched_fork_event(struct perf_tool *tool __used,

static void
process_sched_exit_event(struct perf_tool *tool __used,
			 struct event *event,
			 struct event_format *event,
			 struct perf_sample *sample __used,
			 struct machine *machine __used,
			 struct thread *thread __used)
@@ -1565,7 +1565,7 @@ process_sched_exit_event(struct perf_tool *tool __used,

static void
process_sched_migrate_task_event(struct perf_tool *tool __used,
				 struct event *event,
				 struct event_format *event,
				 struct perf_sample *sample,
				 struct machine *machine,
				 struct thread *thread)
@@ -1586,7 +1586,7 @@ process_sched_migrate_task_event(struct perf_tool *tool __used,
						  sample->time, thread);
}

typedef void (*tracepoint_handler)(struct perf_tool *tool, struct event *event,
typedef void (*tracepoint_handler)(struct perf_tool *tool, struct event_format *event,
				   struct perf_sample *sample,
				   struct machine *machine,
				   struct thread *thread);
+1 −1
Original line number Diff line number Diff line
@@ -261,7 +261,7 @@ static void print_sample_start(struct perf_sample *sample,
			       struct perf_event_attr *attr)
{
	int type;
	struct event *event;
	struct event_format *event;
	const char *evname = NULL;
	unsigned long secs;
	unsigned long usecs;
Loading