perf_event: cleanup for event profile buffer operation
PATCH RESEND v2 1/2 perf_event: cleanup for event profile buffer operation
Introduce ftrace_perf_buf_prepare() and ftrace_perf_buf_submit() to operate event profile buffer, clean up redundant code
Changlog v1->v2:
- Rename function name address Masami and Frederic's suggestion
- Add __kprobes for ftrace_perf_buf_prepare() and make ftrace_perf_buf_submit() inline address Masami's suggestion
- Export ftrace_perf_buf_prepare since module will use it
--- include/linux/ftrace_event.h | 18 ++++++- include/trace/ftrace.h | 48 +++----------------- kernel/trace/trace_event_profile.c | 52 +++++++++++++++++++-- kernel/trace/trace_kprobe.c | 86 ++++------------------------------- kernel/trace/trace_syscalls.c | 71 ++++------------------------- 5 files changed, 88 insertions(+), 187 deletions(-)
include/linux/ftrace_event.h +15 -3
@@ -5,6 +5,7 @@#include <linux/trace_seq.h> #include <linux/percpu.h> #include <linux/hardirq.h> +#include <linux/perf_event.h> struct trace_array ;struct tracer ;
@@ -137,9 +138,6 @@ struct ftrace_event_call {#define FTRACE_MAX_PROFILE_SIZE 2048 -extern char *perf_trace_buf; -extern char *perf_trace_buf_nmi; -#define MAX_FILTER_PRED 32#define MAX_FILTER_STR_VAL 256/* Should handle KSYM_SYMBOL_LEN */
@@ -194,6 +192,20 @@ extern void ftrace_profile_disable(int event_id);extern int ftrace_profile_set_filter (struct perf_event *event,int event_id,char *filter_str);extern void ftrace_profile_free_filter (struct perf_event *event); +extern void * +ftrace_perf_buf_prepare (int size,unsigned short type,int *rctxp, +unsigned long *irq_flags); + +static inline void +ftrace_perf_buf_submit (void *raw_data,int size,int rctx,u64 addr, +u64 count,unsigned long irq_flags) +{ +struct trace_entry *entry = raw_data; + +perf_tp_event (entry->type, addr, count, raw_data, size); +perf_swevent_put_recursion_context (rctx); +local_irq_restore (irq_flags); +}#endif #endif /* _LINUX_FTRACE_EVENT_H */
include/trace/ftrace.h +6 -42
70 lines not on this page · raw message
kernel/trace/trace_event_profile.c +47 -5
64 lines not on this page · raw message
kernel/trace/trace_kprobe.c +10 -76
129 lines not on this page · raw message
kernel/trace/trace_syscalls.c +10 -61
108 lines not on this page · raw message
Signature · 1 line
1.6.1.2
PATCH RESEND v2 2/2 tracing/kprobe: cleanup unused return value of function
Those function's return value is meaningless
--- kernel/trace/trace_kprobe.c | 28 ++++++++++++++-------------- 1 files changed, 14 insertions(+), 14 deletions(-)
kernel/trace/trace_kprobe.c +14 -14
@@ -942,7 +942,7 @@ static const struct file_operations kprobe_profile_ops = { };/* Kprobe handler */ -static __kprobes int kprobe_trace_func (struct kprobe *kp,struct pt_regs *regs) +static __kprobes void kprobe_trace_func (struct kprobe *kp,struct pt_regs *regs) { struct trace_probe *tp = container_of(kp, struct trace_probe, rp.kp);struct kprobe_trace_entry *entry;
@@ -962,7 +962,7 @@ static __kprobes int kprobe_trace_func(struct kprobe *kp, struct pt_regs *regs) event =trace_current_buffer_lock_reserve (&buffer, call->id, size, irq_flags, pc);if (!event) -return 0 ; +return ; entry =ring_buffer_event_data (event); entry->nargs = tp->nr_args;
@@ -972,11 +972,11 @@ static __kprobes int kprobe_trace_func(struct kprobe *kp, struct pt_regs *regs)if (!filter_current_check_discard (buffer, call, entry, event))trace_nowake_buffer_unlock_commit (buffer, event, irq_flags, pc); -return 0 ; +return ; }/* Kretprobe handler */ -static __kprobes int kretprobe_trace_func (struct kretprobe_instance *ri, +static __kprobes void kretprobe_trace_func (struct kretprobe_instance *ri,struct pt_regs *regs) { struct trace_probe *tp = container_of(ri->rp, struct trace_probe, rp);
@@ -995,7 +995,7 @@ static __kprobes int kretprobe_trace_func(struct kretprobe_instance *ri, event =trace_current_buffer_lock_reserve (&buffer, call->id, size, irq_flags, pc);if (!event) -return 0 ; +return ; entry =ring_buffer_event_data (event); entry->nargs = tp->nr_args;
@@ -1007,7 +1007,7 @@ static __kprobes int kretprobe_trace_func(struct kretprobe_instance *ri,if (!filter_current_check_discard (buffer, call, entry, event))trace_nowake_buffer_unlock_commit (buffer, event, irq_flags, pc); -return 0 ; +return ; }/* Event entry printers */
@@ -1217,7 +1217,7 @@ static int set_print_fmt(struct trace_probe *tp)#ifdef CONFIG_PERF_EVENTS /* Kprobe profile handler */ -static __kprobes int kprobe_profile_func (struct kprobe *kp, +static __kprobes void kprobe_profile_func (struct kprobe *kp,struct pt_regs *regs) { struct trace_probe *tp = container_of(kp, struct trace_probe, rp.kp);
@@ -1232,11 +1232,11 @@ static __kprobes int kprobe_profile_func(struct kprobe *kp, size -=sizeof (u32);if (WARN_ONCE (size >FTRACE_MAX_PROFILE_SIZE ,"profile buffer not large enough" )) -return 0 ; +return ; entry =ftrace_perf_buf_prepare (size, call->id, &rctx, &irq_flags);if (!entry) -return 0 ; +return ; entry->nargs = tp->nr_args; entry->ip = (unsigned long )kp->addr;
@@ -1245,11 +1245,11 @@ static __kprobes int kprobe_profile_func(struct kprobe *kp,ftrace_perf_buf_submit (entry, size, rctx, entry->ip,1 , irq_flags); -return 0 ; +return ; }/* Kretprobe profile handler */ -static __kprobes int kretprobe_profile_func (struct kretprobe_instance *ri, +static __kprobes void kretprobe_profile_func (struct kretprobe_instance *ri,struct pt_regs *regs) { struct trace_probe *tp = container_of(ri->rp, struct trace_probe, rp);
@@ -1264,11 +1264,11 @@ static __kprobes int kretprobe_profile_func(struct kretprobe_instance *ri, size -=sizeof (u32);if (WARN_ONCE (size >FTRACE_MAX_PROFILE_SIZE ,"profile buffer not large enough" )) -return 0 ; +return ; entry =ftrace_perf_buf_prepare (size, call->id, &rctx, &irq_flags);if (!entry) -return 0 ; +return ; entry->nargs = tp->nr_args; entry->func = (unsigned long )tp->rp.kp.addr;
@@ -1278,7 +1278,7 @@ static __kprobes int kretprobe_profile_func(struct kretprobe_instance *ri,ftrace_perf_buf_submit (entry, size, rctx, entry->ret_ip,1 , irq_flags); -return 0 ; +return ; }static int probe_profile_enable (struct ftrace_event_call *call)
Signature · 1 line
1.6.1.2
[tip:perf/core] tracing/kprobe: Cleanup unused return value of tracing functions
Commit-ID: 1e12a4a7a3a78bc9c3aaf3486dde3b8ab1cdf465 Gitweb: http://git.kernel.org/tip/1e12a4a7a3a78bc9c3aaf3486dde3b8ab1cdf465 Author: Xiao Guangrong <[email protected]> AuthorDate: Thu, 28 Jan 2010 09:34:27 +0800 Committer: Frederic Weisbecker <[email protected]> CommitDate: Fri, 29 Jan 2010 02:14:40 +0100
tracing/kprobe: Cleanup unused return value of tracing functions
The return values of the kprobe's tracing functions are meaningless, lets remove these.
LKML-Reference: <[email protected]> [fweisbec@gmail: whitespace fixes, drop useless void returns in end of functions]
--- kernel/trace/trace_kprobe.c | 27 ++++++++++----------------- 1 files changed, 10 insertions(+), 17 deletions(-)
kernel/trace/trace_kprobe.c +10 -17
@@ -942,7 +942,7 @@ static const struct file_operations kprobe_profile_ops = { };/* Kprobe handler */ -static __kprobes int kprobe_trace_func (struct kprobe *kp,struct pt_regs *regs) +static __kprobes void kprobe_trace_func (struct kprobe *kp,struct pt_regs *regs) { struct trace_probe *tp = container_of(kp, struct trace_probe, rp.kp);struct kprobe_trace_entry *entry;
@@ -962,7 +962,7 @@ static __kprobes int kprobe_trace_func(struct kprobe *kp, struct pt_regs *regs) event =trace_current_buffer_lock_reserve (&buffer, call->id, size, irq_flags, pc);if (!event) -return 0 ; +return ; entry =ring_buffer_event_data (event); entry->nargs = tp->nr_args;
@@ -972,11 +972,10 @@ static __kprobes int kprobe_trace_func(struct kprobe *kp, struct pt_regs *regs)if (!filter_current_check_discard (buffer, call, entry, event))trace_nowake_buffer_unlock_commit (buffer, event, irq_flags, pc); -return 0 ; }/* Kretprobe handler */ -static __kprobes int kretprobe_trace_func (struct kretprobe_instance *ri, +static __kprobes void kretprobe_trace_func (struct kretprobe_instance *ri,struct pt_regs *regs) { struct trace_probe *tp = container_of(ri->rp, struct trace_probe, rp);
@@ -995,7 +994,7 @@ static __kprobes int kretprobe_trace_func(struct kretprobe_instance *ri, event =trace_current_buffer_lock_reserve (&buffer, call->id, size, irq_flags, pc);if (!event) -return 0 ; +return ; entry =ring_buffer_event_data (event); entry->nargs = tp->nr_args;
@@ -1006,8 +1005,6 @@ static __kprobes int kretprobe_trace_func(struct kretprobe_instance *ri,if (!filter_current_check_discard (buffer, call, entry, event))trace_nowake_buffer_unlock_commit (buffer, event, irq_flags, pc); - -return 0 ; }/* Event entry printers */
@@ -1237,7 +1234,7 @@ static int kretprobe_event_show_format(struct ftrace_event_call *call,#ifdef CONFIG_PERF_EVENTS /* Kprobe profile handler */ -static __kprobes int kprobe_profile_func (struct kprobe *kp, +static __kprobes void kprobe_profile_func (struct kprobe *kp,struct pt_regs *regs) { struct trace_probe *tp = container_of(kp, struct trace_probe, rp.kp);
@@ -1252,11 +1249,11 @@ static __kprobes int kprobe_profile_func(struct kprobe *kp, size -=sizeof (u32);if (WARN_ONCE (size >FTRACE_MAX_PROFILE_SIZE ,"profile buffer not large enough" )) -return 0 ; +return ; entry =ftrace_perf_buf_prepare (size, call->id, &rctx, &irq_flags);if (!entry) -return 0 ; +return ; entry->nargs = tp->nr_args; entry->ip = (unsigned long )kp->addr;
@@ -1264,12 +1261,10 @@ static __kprobes int kprobe_profile_func(struct kprobe *kp, entry->args[i] =call_fetch (&tp->args[i].fetch, regs);ftrace_perf_buf_submit (entry, size, rctx, entry->ip,1 , irq_flags); - -return 0 ; }/* Kretprobe profile handler */ -static __kprobes int kretprobe_profile_func (struct kretprobe_instance *ri, +static __kprobes void kretprobe_profile_func (struct kretprobe_instance *ri,struct pt_regs *regs) { struct trace_probe *tp = container_of(ri->rp, struct trace_probe, rp);
@@ -1284,11 +1279,11 @@ static __kprobes int kretprobe_profile_func(struct kretprobe_instance *ri, size -=sizeof (u32);if (WARN_ONCE (size >FTRACE_MAX_PROFILE_SIZE ,"profile buffer not large enough" )) -return 0 ; +return ; entry =ftrace_perf_buf_prepare (size, call->id, &rctx, &irq_flags);if (!entry) -return 0 ; +return ; entry->nargs = tp->nr_args; entry->func = (unsigned long )tp->rp.kp.addr;
@@ -1297,8 +1292,6 @@ static __kprobes int kretprobe_profile_func(struct kretprobe_instance *ri, entry->args[i] =call_fetch (&tp->args[i].fetch, regs);ftrace_perf_buf_submit (entry, size, rctx, entry->ret_ip,1 , irq_flags); - -return 0 ; }static int probe_profile_enable (struct ftrace_event_call *call)
Quoted 12 lines · Xiao Guangrong
Introduce
ftrace_perf_buf_prepare()andftrace_perf_buf_submit()to operate event profile buffer, clean up redundant codeChanglog
v1->v2:
- Rename function name address Masami and Frederic's suggestion
- Add__kprobesforftrace_perf_buf_prepare()and makeftrace_perf_buf_submit()inline address Masami's suggestion
- Exportftrace_perf_buf_preparesince module will use itAcked-by Masami Hiramatsu <[email protected]>Signed-off-by Xiao Guangrong <[email protected]>
Quoted 7 lines
--- include/linux/ftrace_event.h | 18 ++++++- include/trace/ftrace.h | 48 +++----------------- kernel/trace/trace_event_profile.c | 52 +++++++++++++++++++-- kernel/trace/trace_kprobe.c | 86 ++++------------------------------- kernel/trace/trace_syscalls.c | 71 ++++------------------------- 5 files changed, 88 insertions(+), 187 deletions(-)
I'm queuing these two patches, thanks Xiao!
[tip:perf/core] perf: Factorize trace events raw sample buffer operations
In reply to Xiao GuangrongCommit-ID: 430ad5a600a83956749307b13257c464c3826b55 Gitweb: http://git.kernel.org/tip/430ad5a600a83956749307b13257c464c3826b55 Author: Xiao Guangrong <[email protected]> AuthorDate: Thu, 28 Jan 2010 09:32:29 +0800 Committer: Frederic Weisbecker <[email protected]> CommitDate: Fri, 29 Jan 2010 02:02:57 +0100
perf: Factorize trace events raw sample buffer operations
Introduce ftrace_perf_buf_prepare() and ftrace_perf_buf_submit() to gather the common code that operates on raw events sampling buffer. This cleans up redundant code between regular trace events, syscall events and kprobe events.
Changelog v1->v2:
- Rename function name as per Masami and Frederic's suggestion
- Add __kprobes for ftrace_perf_buf_prepare() and make ftrace_perf_buf_submit() inline as per Masami's suggestion
- Export ftrace_perf_buf_prepare since modules will use it
LKML-Reference: <[email protected]>
--- include/linux/ftrace_event.h | 18 ++++++- include/trace/ftrace.h | 48 +++----------------- kernel/trace/trace_event_profile.c | 52 +++++++++++++++++++-- kernel/trace/trace_kprobe.c | 86 ++++------------------------------- kernel/trace/trace_syscalls.c | 71 ++++------------------------- 5 files changed, 88 insertions(+), 187 deletions(-)
include/linux/ftrace_event.h +15 -3
@@ -5,6 +5,7 @@#include <linux/trace_seq.h> #include <linux/percpu.h> #include <linux/hardirq.h> +#include <linux/perf_event.h> struct trace_array ;struct tracer ;
@@ -138,9 +139,6 @@ struct ftrace_event_call {#define FTRACE_MAX_PROFILE_SIZE 2048 -extern char *perf_trace_buf; -extern char *perf_trace_buf_nmi; -#define MAX_FILTER_PRED 32#define MAX_FILTER_STR_VAL 256/* Should handle KSYM_SYMBOL_LEN */
@@ -195,6 +193,20 @@ extern void ftrace_profile_disable(int event_id);extern int ftrace_profile_set_filter (struct perf_event *event,int event_id,char *filter_str);extern void ftrace_profile_free_filter (struct perf_event *event); +extern void * +ftrace_perf_buf_prepare (int size,unsigned short type,int *rctxp, +unsigned long *irq_flags); + +static inline void +ftrace_perf_buf_submit (void *raw_data,int size,int rctx,u64 addr, +u64 count,unsigned long irq_flags) +{ +struct trace_entry *entry = raw_data; + +perf_tp_event (entry->type, addr, count, raw_data, size); +perf_swevent_put_recursion_context (rctx); +local_irq_restore (irq_flags); +}#endif #endif /* _LINUX_FTRACE_EVENT_H */
include/trace/ftrace.h +6 -42
70 lines not on this page · raw message
kernel/trace/trace_event_profile.c +47 -5
64 lines not on this page · raw message
kernel/trace/trace_kprobe.c +10 -76
129 lines not on this page · raw message
kernel/trace/trace_syscalls.c +10 -61
108 lines not on this page · raw message