[PATCH v2 1/4] perf/trace: Add function to find event type by name
From: Takao Indoh
Date: Tue Sep 08 2015 - 01:50:05 EST
This patch adds function to find struct trace_event by event name like
"sched_switch" , and return its type so that Intel PT logger can enable
the trace event in kernel. Intel PT logger needs this because it needs
sched_switch tracing to collect side-band data.
Signed-off-by: Takao Indoh <indou.takao@xxxxxxxxxxxxxx>
---
include/linux/trace_events.h | 2 ++
kernel/trace/trace_event_perf.c | 22 ++++++++++++++++++++++
2 files changed, 24 insertions(+), 0 deletions(-)
diff --git a/include/linux/trace_events.h b/include/linux/trace_events.h
index ed27917..d3cae4b 100644
--- a/include/linux/trace_events.h
+++ b/include/linux/trace_events.h
@@ -616,6 +616,8 @@ perf_trace_buf_submit(void *raw_data, int size, int rctx, u64 addr,
{
perf_tp_event(addr, count, raw_data, size, regs, head, rctx, task);
}
+
+int perf_trace_event_get_type_by_name(char *system, char *name);
#endif
#endif /* _LINUX_TRACE_EVENT_H */
diff --git a/kernel/trace/trace_event_perf.c b/kernel/trace/trace_event_perf.c
index abfc903..1a851d5 100644
--- a/kernel/trace/trace_event_perf.c
+++ b/kernel/trace/trace_event_perf.c
@@ -21,6 +21,28 @@ typedef typeof(unsigned long [PERF_MAX_TRACE_SIZE / sizeof(unsigned long)])
/* Count the events in use (per event id, not per instance) */
static int total_ref_count;
+int perf_trace_event_get_type_by_name(char *system, char *name)
+{
+ struct trace_event_call *tp_event;
+ int ret = 0;
+ /*
+ * All type is larger than __TRACE_LAST_TYPE + 1. Therefore return zero
+ * as a invalid type if not found.
+ */
+
+ mutex_lock(&event_mutex);
+ list_for_each_entry(tp_event, &ftrace_events, list) {
+ if (!strcmp(tp_event->class->system, system) &&
+ !strcmp(trace_event_name(tp_event), name)) {
+ ret = tp_event->event.type;
+ break;
+ }
+ }
+ mutex_unlock(&event_mutex);
+
+ return ret;
+}
+
static int perf_trace_event_perm(struct trace_event_call *tp_event,
struct perf_event *p_event)
{
--
1.7.1
--
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/