[3.9] tracing: various updates
Subsystems (2)
Steven Rostedt
maintainerIngo,
Please pull the latest tip/perf/core tree, which can be found at:
git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace.git
tip/perf/core
Head SHA1: 8a18d22f0b00530e66e7d7c78d3b58f9d789ed7b
Fengguang Wu (1):
tracing/syscalls: Make local functions static
Jovi Zhang (1):
tracing: Verify target file before registering a uprobe event
Shan Wei (1):
tracing: Use this_cpu_ptr per-cpu helper
----
kernel/trace/blktrace.c | 2 +- kernel/trace/trace.c | 5 +---- kernel/trace/trace_syscalls.c | 18 +++++++++--------- kernel/trace/trace_uprobe.c | 6 +++++- 4 files changed, 16 insertions(+), 15 deletions(-)
Steven Rostedt
maintainerPATCH 1/3 tracing: Use this_cpu_ptr per-cpu helper
From: Shan Wei <[email protected]>
typeof(&buffer) is a pointer to array of 1024 char, or char (*)[1024].
But, typeof(&buffer[0]) is a pointer to char which match the return type of get_trace_buf(). As well-known, the value of &buffer is equal to &buffer[0].
so return this_cpu_ptr(&percpu_buffer->buffer[0]) can avoid type cast.
--- kernel/trace/blktrace.c | 2 +- kernel/trace/trace.c | 5 +---- 2 files changed, 2 insertions(+), 5 deletions(-)
kernel/trace/blktrace.c +1 -1
@@ -147,7 +147,7 @@ void __trace_note_message(struct blk_trace *bt, const char *fmt, ...)return ;local_irq_save (flags); - buf =per_cpu_ptr (bt->msg_data,smp_processor_id ()); + buf =this_cpu_ptr (bt->msg_data);va_start (args, fmt); n =vscnprintf (buf,BLK_TN_MAX_MSG , fmt, args);va_end (args);
kernel/trace/trace.c +1 -4
@@ -1517,7 +1517,6 @@ static struct trace_buffer_struct *trace_percpu_nmi_buffer;static char *get_trace_buf (void ) {struct trace_buffer_struct *percpu_buffer; -struct trace_buffer_struct *buffer;/* * If we have allocated per cpu buffers, then we do not
@@ -1535,9 +1534,7 @@ static char *get_trace_buf(void)if (!percpu_buffer)return NULL ; - buffer =per_cpu_ptr (percpu_buffer,smp_processor_id ()); - -return buffer->buffer; +return this_cpu_ptr (&percpu_buffer->buffer[0 ]); }static int alloc_percpu_trace_buffer (void )
Signature · 1 line
1.7.10.4
Steven Rostedt
maintainerPATCH 2/3 tracing: Verify target file before registering a uprobe event
In reply to Steven RostedtFrom: Jovi Zhang <[email protected]>
Without this patch, we can register a uprobe event for a directory. Enabling such a uprobe event would anyway fail.
Example:
$ echo 'p /bin:0x4245c0' > /sys/kernel/debug/tracing/uprobe_events
However dirctories cannot be valid targets for uprobe. Hence verify if the target is a regular file during the probe registration.
--- kernel/trace/trace_uprobe.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
kernel/trace/trace_uprobe.c +5 -1
@@ -257,6 +257,10 @@ static int create_trace_uprobe(int argc, char **argv) goto fail_address_parse; inode =igrab (path.dentry->d_inode); +if (!S_ISREG (inode->i_mode) ||S_ISDIR (inode->i_mode)) { + ret = -EINVAL ; + goto fail_address_parse; + } argc -=2 ; argv +=2 ;
@@ -356,7 +360,7 @@ fail_address_parse:if (inode)iput (inode); -pr_info ("Failed to parse address.\n" ); +pr_info ("Failed to parse address or file.\n" );return ret; }
Signature · 1 line
1.7.10.4
Steven Rostedt
maintainerPATCH 3/3 tracing/syscalls: Make local functions static
In reply to Steven RostedtFrom: Fengguang Wu <[email protected]>
Some functions in the syscall tracing is used only locally to the file, but they are labeled global. Convert them to static functions.
--- kernel/trace/trace_syscalls.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-)
kernel/trace/trace_syscalls.c +9 -9
@@ -77,7 +77,7 @@ static struct syscall_metadata *syscall_nr_to_meta(int nr)return syscalls_metadata[nr]; } -enum print_line_t +static enum print_line_t print_syscall_enter (struct trace_iterator *iter,int flags,struct trace_event *event) {
@@ -130,7 +130,7 @@ end:return TRACE_TYPE_HANDLED ; } -enum print_line_t +static enum print_line_t print_syscall_exit (struct trace_iterator *iter,int flags,struct trace_event *event) {
@@ -270,7 +270,7 @@ static int syscall_exit_define_fields(struct ftrace_event_call *call)return ret; } -void ftrace_syscall_enter (void *ignore,struct pt_regs *regs,long id) +static void ftrace_syscall_enter (void *ignore,struct pt_regs *regs,long id) {struct syscall_trace_enter *entry;struct syscall_metadata *sys_data;
@@ -305,7 +305,7 @@ void ftrace_syscall_enter(void *ignore, struct pt_regs *regs, long id)trace_current_buffer_unlock_commit (buffer, event,0 ,0 ); } -void ftrace_syscall_exit (void *ignore,struct pt_regs *regs,long ret) +static void ftrace_syscall_exit (void *ignore,struct pt_regs *regs,long ret) {struct syscall_trace_exit *entry;struct syscall_metadata *sys_data;
@@ -337,7 +337,7 @@ void ftrace_syscall_exit(void *ignore, struct pt_regs *regs, long ret)trace_current_buffer_unlock_commit (buffer, event,0 ,0 ); } -int reg_event_syscall_enter (struct ftrace_event_call *call) +static int reg_event_syscall_enter (struct ftrace_event_call *call) {int ret =0 ;int num;
@@ -356,7 +356,7 @@ int reg_event_syscall_enter(struct ftrace_event_call *call)return ret; } -void unreg_event_syscall_enter (struct ftrace_event_call *call) +static void unreg_event_syscall_enter (struct ftrace_event_call *call) {int num;
@@ -371,7 +371,7 @@ void unreg_event_syscall_enter(struct ftrace_event_call *call)mutex_unlock (&syscall_trace_lock); } -int reg_event_syscall_exit (struct ftrace_event_call *call) +static int reg_event_syscall_exit (struct ftrace_event_call *call) {int ret =0 ;int num;
@@ -390,7 +390,7 @@ int reg_event_syscall_exit(struct ftrace_event_call *call)return ret; } -void unreg_event_syscall_exit (struct ftrace_event_call *call) +static void unreg_event_syscall_exit (struct ftrace_event_call *call) {int num;
@@ -459,7 +459,7 @@ unsigned long __init __weak arch_syscall_addr(int nr)return (unsigned long )sys_call_table[nr]; } -int __init init_ftrace_syscalls (void ) +static int __init init_ftrace_syscalls (void ) {struct syscall_metadata *meta;unsigned long addr;
Signature · 1 line
1.7.10.4