Skip to contentSkip to conversation

perf: Tracepoint collection support

RFC PATCH In review Peter Zijlstra 2 participants 4 messages Nov 22, 2010 – Nov 23, 2010 1 message not in the archive

Subsystems (4)
lore
Share & tools
lore

Peter Zijlstra

author maintainer
#0 lore raw

RFC PATCH 1/1 perf: Tracepoint collection support

Due to popular request this implements a tracepoint collection event { .type = PERF_TYPE_TRACEPOINT, .config = ~0ULL }. by default it contains no tracepoints, but tracepoints can be added using:
ioctl(fd, PERF_EVENT_IOC_ADD_TP, tp_id);

In order to provide a dense ID space for tracepoints replace the tracepoint ID generation with an IDR tree.

Furthermore, replace the whole trace-event <-> perf infrastructure with multiple IDR trees.

We keep an IDR tree per perf_event, this tree collects all the tracepoints the perf_event is interested in and stores the corresponding 'node'. This tree manages the node life-time.

Then we keep an IDR tree per task and per CPU. Both of these trees are accumulation trees, they're the union of all events of that particular task/CPU. It stores a list of 'node's.

Then, when a trace-event happens, we look for it in both the CPU tree as well as the current task tree. For both, if present we iterate the node list and deliver the event to the corresponding perf_events.

We manage the IDR trees on perf_event creation/destruction and ioctl(ADD_TP) time. This mean that pmu::{add,remove} are empty ops, the per-task stat is taken care of in the per-task tree after all.

The patch is lightly tested and wants some serious testing/review before merging.

Also, it has a number of open points, like the breakpoint much it suffers from the pmu::event_init() vs context-attach inversion, and the whole fancy inherited context avoid switch logic needs a fix.

---
 include/linux/ftrace_event.h    |    9 
 include/linux/perf_event.h      |    9 
 include/linux/sched.h           |    9 
 include/trace/ftrace.h          |    4 
 kernel/perf_event.c             |  389 ++++++++++++++++++++++++++++++++++++++--
 kernel/trace/trace_event_perf.c |   95 ++++-----
 kernel/trace/trace_kprobe.c     |   10 -
 kernel/trace/trace_output.c     |   77 +------
 kernel/trace/trace_syscalls.c   |    8 
 9 files changed, 459 insertions(+), 151 deletions(-)
include/linux/ftrace_event.h +4 -5
Index: linux-2.6/include/linux/ftrace_event.h
===================================================================
@@ -87,7 +87,6 @@ struct trace_event_functions {
 };
 
 struct trace_event {
-	struct hlist_node		node;
 	struct list_head		list;
 	int				type;
 	struct trace_event_functions	*funcs;
@@ -194,7 +193,6 @@ struct ftrace_event_call {
 
 #ifdef CONFIG_PERF_EVENTS
 	int				perf_refcount;
-	struct hlist_head __percpu	*perf_events;
 #endif
 };
 
@@ -260,8 +258,9 @@ struct perf_event;
 
 DECLARE_PER_CPU(struct pt_regs, perf_trace_regs);
 
-extern int  perf_trace_init(struct perf_event *event);
+extern int  perf_trace_init(struct perf_event *event, int event_id);
 extern void perf_trace_destroy(struct perf_event *event);
+extern void perf_trace_destroy_id(int id);
 extern int  perf_trace_add(struct perf_event *event, int flags);
 extern void perf_trace_del(struct perf_event *event, int flags);
 extern int  ftrace_profile_set_filter(struct perf_event *event, int event_id,
@@ -272,9 +271,9 @@ extern void *perf_trace_buf_prepare(int 
 
 static inline void
 perf_trace_buf_submit(void *raw_data, int size, int rctx, u64 addr,
-		       u64 count, struct pt_regs *regs, void *head)
+		       u64 count, struct pt_regs *regs, int id)
 {
-	perf_tp_event(addr, count, raw_data, size, regs, head, rctx);
+	perf_tp_event(addr, count, raw_data, size, regs, rctx, id);
 }
 #endif
 
include/linux/perf_event.h +8 -1
Index: linux-2.6/include/linux/perf_event.h
===================================================================
@@ -238,6 +238,7 @@ struct perf_event_attr {
 #define PERF_EVENT_IOC_PERIOD		_IOW('$', 4, __u64)
 #define PERF_EVENT_IOC_SET_OUTPUT	_IO ('$', 5)
 #define PERF_EVENT_IOC_SET_FILTER	_IOW('$', 6, char *)
+#define PERF_EVENT_IOC_ADD_TP		_IO ('$', 7)
 
 enum perf_event_ioc_flags {
 	PERF_IOC_FLAG_GROUP		= 1U << 0,
@@ -545,6 +546,11 @@ struct hw_perf_event {
 			struct task_struct		*bp_target;
 		};
 #endif
+		/*
+		 * Same fudge as for breakpoints, trace-events needs
+		 * it too,.. convert the bp crap over..
+		 */
+		struct task_struct *event_target;
 	};
 	int				state;
 	local64_t			prev_count;
@@ -813,6 +819,7 @@ struct perf_event {
 #ifdef CONFIG_EVENT_TRACING
 	struct ftrace_event_call	*tp_event;
 	struct event_filter		*filter;
+	struct perf_tp_idr		tp_idr;
 #endif
 
 #endif /* CONFIG_PERF_EVENTS */
@@ -1076,7 +1083,7 @@ static inline bool perf_paranoid_kernel(
 extern void perf_event_init(void);
 extern void perf_tp_event(u64 addr, u64 count, void *record,
 			  int entry_size, struct pt_regs *regs,
-			  struct hlist_head *head, int rctx);
+			  int rctx, int id);
 extern void perf_bp_event(struct perf_event *event, void *data);
 
 #ifndef perf_misc_flags
include/linux/sched.h +9 -0
Index: linux-2.6/include/linux/sched.h
===================================================================
@@ -82,6 +82,7 @@ struct sched_param {
 #include <linux/rculist.h>
 #include <linux/rtmutex.h>
 
+#include <linux/idr.h>
 #include <linux/time.h>
 #include <linux/param.h>
 #include <linux/resource.h>
@@ -1179,6 +1180,11 @@ enum perf_event_task_context {
 	perf_nr_task_contexts,
 };
 
+struct perf_tp_idr {
+	struct mutex	lock;
+	struct idr	idr;
+};
+
 struct task_struct {
 	volatile long state;	/* -1 unrunnable, 0 runnable, >0 stopped */
 	void *stack;
@@ -1452,6 +1458,9 @@ struct task_struct {
 	struct perf_event_context *perf_event_ctxp[perf_nr_task_contexts];
 	struct mutex perf_event_mutex;
 	struct list_head perf_event_list;
+#ifdef CONFIG_EVENT_TRACING
+	struct perf_tp_idr *perf_tp_idr;
+#endif
 #endif
 #ifdef CONFIG_NUMA
 	struct mempolicy *mempolicy;	/* Protected by alloc_lock */
include/trace/ftrace.h +1 -3
Index: linux-2.6/include/trace/ftrace.h
===================================================================
@@ -700,7 +700,6 @@ perf_trace_##call(void *__data, proto)		
 	struct ftrace_raw_##call *entry;				\
 	struct pt_regs __regs;						\
 	u64 __addr = 0, __count = 1;					\
-	struct hlist_head *head;					\
 	int __entry_size;						\
 	int __data_size;						\
 	int rctx;							\
@@ -725,9 +724,8 @@ perf_trace_##call(void *__data, proto)		
 									\
 	{ assign; }							\
 									\
-	head = this_cpu_ptr(event_call->perf_events);			\
 	perf_trace_buf_submit(entry, __entry_size, rctx, __addr,	\
-		__count, &__regs, head);				\
+		__count, &__regs, event_call->event.type);		\
 }
 
 /*
kernel/perf_event.c +373 -16

557 lines not on this page · raw message

kernel/trace/trace_event_perf.c +40 -55

148 lines not on this page · raw message

kernel/trace/trace_kprobe.c +4 -6
Index: linux-2.6/kernel/trace/trace_kprobe.c
===================================================================
@@ -1559,7 +1559,6 @@ static __kprobes void kprobe_perf_func(s
 	struct trace_probe *tp = container_of(kp, struct trace_probe, rp.kp);
 	struct ftrace_event_call *call = &tp->call;
 	struct kprobe_trace_entry_head *entry;
-	struct hlist_head *head;
 	int size, __size, dsize;
 	int rctx;
 
@@ -1579,8 +1578,8 @@ static __kprobes void kprobe_perf_func(s
 	memset(&entry[1], 0, dsize);
 	store_trace_args(sizeof(*entry), tp, regs, (u8 *)&entry[1], dsize);
 
-	head = this_cpu_ptr(call->perf_events);
-	perf_trace_buf_submit(entry, size, rctx, entry->ip, 1, regs, head);
+	perf_trace_buf_submit(entry, size, rctx, entry->ip, 1, regs,
+			      call->event.type);
 }
 
 /* Kretprobe profile handler */
@@ -1590,7 +1589,6 @@ static __kprobes void kretprobe_perf_fun
 	struct trace_probe *tp = container_of(ri->rp, struct trace_probe, rp);
 	struct ftrace_event_call *call = &tp->call;
 	struct kretprobe_trace_entry_head *entry;
-	struct hlist_head *head;
 	int size, __size, dsize;
 	int rctx;
 
@@ -1610,8 +1608,8 @@ static __kprobes void kretprobe_perf_fun
 	entry->ret_ip = (unsigned long)ri->ret_addr;
 	store_trace_args(sizeof(*entry), tp, regs, (u8 *)&entry[1], dsize);
 
-	head = this_cpu_ptr(call->perf_events);
-	perf_trace_buf_submit(entry, size, rctx, entry->ret_ip, 1, regs, head);
+	perf_trace_buf_submit(entry, size, rctx, entry->ret_ip, 1,
+			      regs, call->event.type);
 }
 
 static int probe_perf_enable(struct ftrace_event_call *call)
kernel/trace/trace_output.c +18 -59

128 lines not on this page · raw message

kernel/trace/trace_syscalls.c +2 -6
Index: linux-2.6/kernel/trace/trace_syscalls.c
===================================================================
@@ -489,7 +489,6 @@ static void perf_syscall_enter(void *ign
 {
 	struct syscall_metadata *sys_data;
 	struct syscall_trace_enter *rec;
-	struct hlist_head *head;
 	int syscall_nr;
 	int rctx;
 	int size;
@@ -520,8 +519,7 @@ static void perf_syscall_enter(void *ign
 	syscall_get_arguments(current, regs, 0, sys_data->nb_args,
 			       (unsigned long *)&rec->args);
 
-	head = this_cpu_ptr(sys_data->enter_event->perf_events);
-	perf_trace_buf_submit(rec, size, rctx, 0, 1, regs, head);
+	perf_trace_buf_submit(rec, size, rctx, 0, 1, regs, rec->ent.type);
 }
 
 int perf_sysenter_enable(struct ftrace_event_call *call)
@@ -563,7 +561,6 @@ static void perf_syscall_exit(void *igno
 {
 	struct syscall_metadata *sys_data;
 	struct syscall_trace_exit *rec;
-	struct hlist_head *head;
 	int syscall_nr;
 	int rctx;
 	int size;
@@ -596,8 +593,7 @@ static void perf_syscall_exit(void *igno
 	rec->nr = syscall_nr;
 	rec->ret = syscall_get_return_value(current, regs);
 
-	head = this_cpu_ptr(sys_data->exit_event->perf_events);
-	perf_trace_buf_submit(rec, size, rctx, 0, 1, regs, head);
+	perf_trace_buf_submit(rec, size, rctx, 0, 1, regs, rec->ent.type);
 }
 
 int perf_sysexit_enable(struct ftrace_event_call *call)
author maintainer
#1 lore raw

kernel/perf_event.c static int perf_tp_event_init(struct per · line 5064

Quoted 8 lines · Peter Zijlstra
kernel/perf_event.c +8 -0
+       if (event->attr.config != ~0ULL) {
+               err = __perf_event_add_tp(event, event->attr.config);
+               if (err)
+                       return err;
+               err = perf_trace_init(event, event->attr.config);
+               if (err)
+                       return err;
+       } 

That's a double perf_trace_init() call, __perf_event_add_tp() already does that.

#3 lore raw
In reply to a message not in the archive
Quoted 56 lines

From: Peter Zijlstra <[email protected]>
Date: Tue, Nov 23, 2010 at 1:08 AM

Due to popular request this implements a tracepoint collection event { .type = PERF_TYPE_TRACEPOINT, .config = ~0ULL }. by default it contains no tracepoints, but tracepoints can be added using:
ioctl(fd, PERF_EVENT_IOC_ADD_TP, tp_id);

In order to provide a dense ID space for tracepoints replace the tracepoint ID generation with an IDR tree.

Furthermore, replace the whole trace-event <-> perf infrastructure with multiple IDR trees.

We keep an IDR tree per perf_event, this tree collects all the tracepoints the perf_event is interested in and stores the corresponding 'node'. This tree manages the node life-time.

Then we keep an IDR tree per task and per CPU. Both of these trees are accumulation trees, they're the union of all events of that particular task/CPU. It stores a list of 'node's.

Then, when a trace-event happens, we look for it in both the CPU tree as well as the current task tree. For both, if present we iterate the node list and deliver the event to the corresponding perf_events.

We manage the IDR trees on perf_event creation/destruction and ioctl(ADD_TP) time. This mean that pmu::{add,remove} are empty ops, the per-task stat is taken care of in the per-task tree after all.

The patch is lightly tested and wants some serious testing/review before merging.

Also, it has a number of open points, like the breakpoint much it suffers from the pmu::event_init() vs context-attach inversion, and the whole fancy inherited context avoid switch logic needs a fix.

---
 include/linux/ftrace_event.h    |    9
 include/linux/perf_event.h      |    9
 include/linux/sched.h           |    9
 include/trace/ftrace.h          |    4
 kernel/perf_event.c             |  389 ++++++++++++++++++++++++++++++++++++++--
 kernel/trace/trace_event_perf.c |   95 ++++-----
 kernel/trace/trace_kprobe.c     |   10 -
 kernel/trace/trace_output.c     |   77 +------
 kernel/trace/trace_syscalls.c   |    8
 9 files changed, 459 insertions(+), 151 deletions(-)

Index: linux-2.6/include/linux/ftrace_event.h
===================================================================

include/linux/ftrace_event.h struct trace_event_functions { · line 90

Quoted 5 lines
include/linux/ftrace_event.h +0 -1
@@ -87,7 +87,6 @@ struct trace_event_functions {
 };
 
 struct trace_event {
-       struct hlist_node               node;
       struct list_head                list;

Cool patch!

ftrace_event_list/trace_event::list can be deleted now.

include/linux/ftrace_event.h +0 -1
index cba21d3..f3c03ac 100644
@@ -87,7 +87,6 @@ struct trace_event_functions {
 };
 
 struct trace_event {
-	struct list_head		list;
 	int				type;
 	struct trace_event_functions	*funcs;
 };
kernel/trace/trace_output.c +0 -10
index 8f30dd3..7803022 100644
@@ -664,8 +664,6 @@ struct trace_event *ftrace_find_event(int type)
 	return idr_find(&trace_type_idr, type);
 }
 
-static LIST_HEAD(ftrace_event_list);
-
 void trace_event_read_lock(void)
 {
 	down_read(&trace_event_mutex);
@@ -703,10 +701,7 @@ int register_ftrace_event(struct trace_event *event)
 	if (WARN_ON(!event->funcs))
 		goto out;
 
-	INIT_LIST_HEAD(&event->list);
-
 	if (!event->type) {
-		struct list_head *list = NULL;
 		int type, err;
 
 		err = idr_pre_get(&trace_type_idr, GFP_KERNEL);
@@ -723,10 +718,6 @@ int register_ftrace_event(struct trace_event *event)
 		}
 
 		event->type = type;
-		list = &ftrace_event_list;
-
-		list_add_tail(&event->list, list);
-
 	} else if (event->type > __TRACE_LAST_TYPE) {
 		printk(KERN_WARNING "Need to add type to trace.h\n");
 		WARN_ON(1);
@@ -760,7 +751,6 @@ EXPORT_SYMBOL_GPL(register_ftrace_event);
 int __unregister_ftrace_event(struct trace_event *event)
 {
 	idr_remove(&trace_type_idr, event->type);
-	list_del(&event->list);
 	return 0;
 }
 

Thanks,
Lin Ming

author maintainer
#4 lore raw

RFC PATCH 1/1 perf: Tracepoint collection support -v2

In reply to Peter Zijlstra

Due to popular demand this implements a tracepoint collection event { .type = PERF_TYPE_TRACEPOINT, .config = ~0ULL }. by default it contains no tracepoints, but tracepoints can be added using:
ioctl(fd, PERF_EVENT_IOC_ADD_TP, tp_id);

In order to provide a dense ID space for tracepoints replace the tracepoint ID generation with an IDR tree.

Furthermore, replace the whole trace-event <-> perf infrastructure with multiple IDR trees.

We keep an IDR tree per perf_event, this tree collects all the tracepoints the perf_event is interested in and stores the corresponding 'node'. This tree manages the node life-time.

Then we keep an IDR tree per task and per CPU. Both of these trees are accumulation trees, they're the union of all events of that particular task/CPU. It stores a list of 'node's.

Then, when a trace-event happens, we look for it in both the CPU tree as well as the current task tree. For both, if present we iterate the node list and deliver the event to the corresponding perf_events.

We manage the IDR trees on perf_event creation/destruction and ioctl(ADD_TP) time. This mean that pmu::{add,remove} are empty ops, the per-task stat is taken care of in the per-task tree after all.

The patch got hammered by tglx, but wants some more review as well as solving the open points before merging.

The open points are:
- like the breakpoint muck it suffers from the pmu::event_init() vs context-attach inversion, and
- the whole fancy inherited context avoid switch logic needs a fix.

---

-v2
- fixed various crashes found by tglx
- merge cleanup by lin ming

 include/linux/ftrace_event.h    |   10 
 include/linux/perf_event.h      |    9 
 include/linux/sched.h           |    9 
 include/trace/ftrace.h          |    4 
 kernel/perf_event.c             |  410 ++++++++++++++++++++++++++++++++++++++--
 kernel/trace/trace_event_perf.c |   95 +++------
 kernel/trace/trace_kprobe.c     |   10 
 kernel/trace/trace_output.c     |   83 +-------
 kernel/trace/trace_syscalls.c   |    8 
 9 files changed, 477 insertions(+), 161 deletions(-)
include/linux/ftrace_event.h +4 -6
Index: linux-2.6/include/linux/ftrace_event.h
===================================================================
@@ -87,8 +87,6 @@ struct trace_event_functions {
 };
 
 struct trace_event {
-	struct hlist_node		node;
-	struct list_head		list;
 	int				type;
 	struct trace_event_functions	*funcs;
 };
@@ -194,7 +192,6 @@ struct ftrace_event_call {
 
 #ifdef CONFIG_PERF_EVENTS
 	int				perf_refcount;
-	struct hlist_head __percpu	*perf_events;
 #endif
 };
 
@@ -260,8 +257,9 @@ struct perf_event;
 
 DECLARE_PER_CPU(struct pt_regs, perf_trace_regs);
 
-extern int  perf_trace_init(struct perf_event *event);
+extern int  perf_trace_init(struct perf_event *event, int event_id);
 extern void perf_trace_destroy(struct perf_event *event);
+extern void perf_trace_destroy_id(int id);
 extern int  perf_trace_add(struct perf_event *event, int flags);
 extern void perf_trace_del(struct perf_event *event, int flags);
 extern int  ftrace_profile_set_filter(struct perf_event *event, int event_id,
@@ -272,9 +270,9 @@ extern void *perf_trace_buf_prepare(int 
 
 static inline void
 perf_trace_buf_submit(void *raw_data, int size, int rctx, u64 addr,
-		       u64 count, struct pt_regs *regs, void *head)
+		       u64 count, struct pt_regs *regs, int id)
 {
-	perf_tp_event(addr, count, raw_data, size, regs, head, rctx);
+	perf_tp_event(addr, count, raw_data, size, regs, rctx, id);
 }
 #endif
 
include/linux/perf_event.h +8 -1
Index: linux-2.6/include/linux/perf_event.h
===================================================================
@@ -238,6 +238,7 @@ struct perf_event_attr {
 #define PERF_EVENT_IOC_PERIOD		_IOW('$', 4, __u64)
 #define PERF_EVENT_IOC_SET_OUTPUT	_IO ('$', 5)
 #define PERF_EVENT_IOC_SET_FILTER	_IOW('$', 6, char *)
+#define PERF_EVENT_IOC_ADD_TP		_IO ('$', 7)
 
 enum perf_event_ioc_flags {
 	PERF_IOC_FLAG_GROUP		= 1U << 0,
@@ -545,6 +546,11 @@ struct hw_perf_event {
 			struct task_struct		*bp_target;
 		};
 #endif
+		/*
+		 * Same fudge as for breakpoints, trace-events needs
+		 * it too,.. convert the bp crap over..
+		 */
+		struct task_struct *event_target;
 	};
 	int				state;
 	local64_t			prev_count;
@@ -813,6 +819,7 @@ struct perf_event {
 #ifdef CONFIG_EVENT_TRACING
 	struct ftrace_event_call	*tp_event;
 	struct event_filter		*filter;
+	struct perf_tp_idr		tp_idr;
 #endif
 
 #endif /* CONFIG_PERF_EVENTS */
@@ -1076,7 +1083,7 @@ static inline bool perf_paranoid_kernel(
 extern void perf_event_init(void);
 extern void perf_tp_event(u64 addr, u64 count, void *record,
 			  int entry_size, struct pt_regs *regs,
-			  struct hlist_head *head, int rctx);
+			  int rctx, int id);
 extern void perf_bp_event(struct perf_event *event, void *data);
 
 #ifndef perf_misc_flags
include/linux/sched.h +9 -0
Index: linux-2.6/include/linux/sched.h
===================================================================
@@ -82,6 +82,7 @@ struct sched_param {
 #include <linux/rculist.h>
 #include <linux/rtmutex.h>
 
+#include <linux/idr.h>
 #include <linux/time.h>
 #include <linux/param.h>
 #include <linux/resource.h>
@@ -1179,6 +1180,11 @@ enum perf_event_task_context {
 	perf_nr_task_contexts,
 };
 
+struct perf_tp_idr {
+	struct mutex	lock;
+	struct idr	idr;
+};
+
 struct task_struct {
 	volatile long state;	/* -1 unrunnable, 0 runnable, >0 stopped */
 	void *stack;
@@ -1452,6 +1458,9 @@ struct task_struct {
 	struct perf_event_context *perf_event_ctxp[perf_nr_task_contexts];
 	struct mutex perf_event_mutex;
 	struct list_head perf_event_list;
+#ifdef CONFIG_EVENT_TRACING
+	struct perf_tp_idr *perf_tp_idr;
+#endif
 #endif
 #ifdef CONFIG_NUMA
 	struct mempolicy *mempolicy;	/* Protected by alloc_lock */
include/trace/ftrace.h +1 -3
Index: linux-2.6/include/trace/ftrace.h
===================================================================
@@ -700,7 +700,6 @@ perf_trace_##call(void *__data, proto)		
 	struct ftrace_raw_##call *entry;				\
 	struct pt_regs __regs;						\
 	u64 __addr = 0, __count = 1;					\
-	struct hlist_head *head;					\
 	int __entry_size;						\
 	int __data_size;						\
 	int rctx;							\
@@ -725,9 +724,8 @@ perf_trace_##call(void *__data, proto)		
 									\
 	{ assign; }							\
 									\
-	head = this_cpu_ptr(event_call->perf_events);			\
 	perf_trace_buf_submit(entry, __entry_size, rctx, __addr,	\
-		__count, &__regs, head);				\
+		__count, &__regs, event_call->event.type);		\
 }
 
 /*
kernel/perf_event.c +393 -17

583 lines not on this page · raw message

kernel/trace/trace_event_perf.c +40 -55

148 lines not on this page · raw message

kernel/trace/trace_kprobe.c +4 -6
Index: linux-2.6/kernel/trace/trace_kprobe.c
===================================================================
@@ -1559,7 +1559,6 @@ static __kprobes void kprobe_perf_func(s
 	struct trace_probe *tp = container_of(kp, struct trace_probe, rp.kp);
 	struct ftrace_event_call *call = &tp->call;
 	struct kprobe_trace_entry_head *entry;
-	struct hlist_head *head;
 	int size, __size, dsize;
 	int rctx;
 
@@ -1579,8 +1578,8 @@ static __kprobes void kprobe_perf_func(s
 	memset(&entry[1], 0, dsize);
 	store_trace_args(sizeof(*entry), tp, regs, (u8 *)&entry[1], dsize);
 
-	head = this_cpu_ptr(call->perf_events);
-	perf_trace_buf_submit(entry, size, rctx, entry->ip, 1, regs, head);
+	perf_trace_buf_submit(entry, size, rctx, entry->ip, 1, regs,
+			      call->event.type);
 }
 
 /* Kretprobe profile handler */
@@ -1590,7 +1589,6 @@ static __kprobes void kretprobe_perf_fun
 	struct trace_probe *tp = container_of(ri->rp, struct trace_probe, rp);
 	struct ftrace_event_call *call = &tp->call;
 	struct kretprobe_trace_entry_head *entry;
-	struct hlist_head *head;
 	int size, __size, dsize;
 	int rctx;
 
@@ -1610,8 +1608,8 @@ static __kprobes void kretprobe_perf_fun
 	entry->ret_ip = (unsigned long)ri->ret_addr;
 	store_trace_args(sizeof(*entry), tp, regs, (u8 *)&entry[1], dsize);
 
-	head = this_cpu_ptr(call->perf_events);
-	perf_trace_buf_submit(entry, size, rctx, entry->ret_ip, 1, regs, head);
+	perf_trace_buf_submit(entry, size, rctx, entry->ret_ip, 1,
+			      regs, call->event.type);
 }
 
 static int probe_perf_enable(struct ftrace_event_call *call)
kernel/trace/trace_output.c +16 -67

132 lines not on this page · raw message

kernel/trace/trace_syscalls.c +2 -6
Index: linux-2.6/kernel/trace/trace_syscalls.c
===================================================================
@@ -489,7 +489,6 @@ static void perf_syscall_enter(void *ign
 {
 	struct syscall_metadata *sys_data;
 	struct syscall_trace_enter *rec;
-	struct hlist_head *head;
 	int syscall_nr;
 	int rctx;
 	int size;
@@ -520,8 +519,7 @@ static void perf_syscall_enter(void *ign
 	syscall_get_arguments(current, regs, 0, sys_data->nb_args,
 			       (unsigned long *)&rec->args);
 
-	head = this_cpu_ptr(sys_data->enter_event->perf_events);
-	perf_trace_buf_submit(rec, size, rctx, 0, 1, regs, head);
+	perf_trace_buf_submit(rec, size, rctx, 0, 1, regs, rec->ent.type);
 }
 
 int perf_sysenter_enable(struct ftrace_event_call *call)
@@ -563,7 +561,6 @@ static void perf_syscall_exit(void *igno
 {
 	struct syscall_metadata *sys_data;
 	struct syscall_trace_exit *rec;
-	struct hlist_head *head;
 	int syscall_nr;
 	int rctx;
 	int size;
@@ -596,8 +593,7 @@ static void perf_syscall_exit(void *igno
 	rec->nr = syscall_nr;
 	rec->ret = syscall_get_return_value(current, regs);
 
-	head = this_cpu_ptr(sys_data->exit_event->perf_events);
-	perf_trace_buf_submit(rec, size, rctx, 0, 1, regs, head);
+	perf_trace_buf_submit(rec, size, rctx, 0, 1, regs, rec->ent.type);
 }
 
 int perf_sysexit_enable(struct ftrace_event_call *call)