tracing/ksys_tracer: misc fixes
Steven Rostedt
maintainerIngo,
Please pull the latest tip/tracing/hw-breakpoints tree, which can be found at:
git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-2.6-trace.git
tip/tracing/hw-breakpoints
Xiao Guangrong (3):
tracing/ksym_tracer: fix the output of ksym tracer tracing/ksym_tracer: fix write operation of ksym_trace_filter tracing/ksym_tracer: support quick clear for ksym_trace_filter -- v2
----
kernel/trace/trace_ksym.c | 70 +++++++++++++++++++++++++++++---------------- 1 files changed, 45 insertions(+), 25 deletions(-)
Steven Rostedt
maintainerPATCH 1/3 tracing/ksym_tracer: fix the output of ksym tracer
From: Xiao Guangrong <[email protected]>
Fix the output format of ksym tracer, make it properly aligned
Befor patch:
# tracer: ksym_tracer
#
# TASK-PID CPU# Symbol Type Function
# | | | | |
bash 1378 1 ksym_tracer_mutex W mutex_lock+0x11/0x27 bash 1378 1 ksym_filter_head W process_new_ksym_entry+0xd2/0x10c bash 1378 1 ksym_tracer_mutex W mutex_unlock+0x12/0x1b cat 1429 0 ksym_tracer_mutex W mutex_lock+0x11/0x27
After patch:
# tracer: ksym_tracer
#
# TASK-PID CPU# Symbol Type Function
# | | | | |
cat-1423 [000] ksym_tracer_mutex RW mutex_lock+0x11/0x27
cat-1423 [000] ksym_filter_head RW ksym_trace_filter_read+0x6e/0x10d
cat-1423 [000] ksym_tracer_mutex RW mutex_unlock+0x12/0x1b
cat-1423 [000] ksym_tracer_mutex RW mutex_lock+0x11/0x27
cat-1423 [000] ksym_filter_head RW ksym_trace_filter_read+0x6e/0x10d
cat-1423 [000] ksym_tracer_mutex RW mutex_unlock+0x12/0x1bLKML-Reference: <[email protected]>
--- kernel/trace/trace_ksym.c | 13 ++++++------- 1 files changed, 6 insertions(+), 7 deletions(-)
kernel/trace/trace_ksym.c +6 -7
@@ -370,13 +370,12 @@ static int ksym_trace_init(struct trace_array *tr)static void ksym_trace_print_header (struct seq_file *m) { -seq_puts (m, -"# TASK-PID CPU# Symbol Type " -"Function \n" ); +"# TASK-PID CPU# Symbol " +"Type Function\n" );seq_puts (m, -"# | | | | " -"| \n" ); +"# | | | " +" | |\n" ); }static enum print_line_t ksym_trace_output (struct trace_iterator *iter)
@@ -392,7 +391,7 @@ static enum print_line_t ksym_trace_output(struct trace_iterator *iter)trace_assign_type (field, entry); - ret =trace_seq_printf (s,"%-15s %-5d %-3d %-20s " , field->cmd, + ret =trace_seq_printf (s,"%11s-%-5d [%03d] %-30s " , field->cmd, entry->pid, iter->cpu, field->ksym_name);if (!ret)return TRACE_TYPE_PARTIAL_LINE ;
@@ -412,7 +411,7 @@ static enum print_line_t ksym_trace_output(struct trace_iterator *iter)return TRACE_TYPE_PARTIAL_LINE ;sprint_symbol (str, field->ip); - ret =trace_seq_printf (s,"%-20s\n" , str); + ret =trace_seq_printf (s,"%s\n" , str);if (!ret)return TRACE_TYPE_PARTIAL_LINE ;
Signature · 3 lines
1.6.3.3 --
Steven Rostedt
maintainerPATCH 2/3 tracing/ksym_tracer: fix write operation of ksym_trace_filter
In reply to Steven RostedtFrom: Xiao Guangrong <[email protected]>
This patch fix 2 bugs:
- fix the return value of ksym_trace_filter_write() when we want to clear symbol in ksym_trace_filter file
for example:
# echo global_trace:rw- > /debug/tracing/ksym_trace_filter # echo global_trace:--- > /debug/tracing/ksym_trace_filter -bash: echo: write error: Invalid argument # cat /debug/tracing/ksym_trace_filter # We want to clear 'global_trace' in ksym_trace_filter, it complain with "Invalid argument", but the operation is successful
- the "r--" access types is not allowed, but ksym_trace_filter file think it OK
for example:
# echo ksym_tracer_mutex:r-- > ksym_trace_filter -bash: echo: write error: Resource temporarily unavailable # dmesg ksym_tracer request failed. Try again later!!
The error occur at register_kernel_hw_breakpoint(), but It's should at access types parser
LKML-Reference: <[email protected]>
--- kernel/trace/trace_ksym.c | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-)
kernel/trace/trace_ksym.c +4 -0
@@ -135,6 +135,9 @@ static int ksym_trace_get_access_type(char *str)case 6 : access =HW_BREAKPOINT_RW ;break ; +case 4 : + access = -EINVAL ; +break ;case 2 : access =HW_BREAKPOINT_WRITE ;break ;
@@ -312,6 +315,7 @@ static ssize_t ksym_trace_filter_write(struct file *file,kfree (entry->ksym_hbp->info.name);kfree (entry->ksym_hbp);kfree (entry); + ret =0 ; goto out; }else {/* Check for malformed request: (4) */
Signature · 3 lines
1.6.3.3 --
Steven Rostedt
maintainerPATCH 3/3 tracing/ksym_tracer: support quick clear for ksym_trace_filter -- v2
In reply to Steven RostedtFrom: Xiao Guangrong <[email protected]>
It's rather boring to clear symbol one by one in ksym_trace_filter file, so, this patch will let ksym_trace_filter file support quickly clear all break points. We can write "0" to this file and it will clear all symbols
for example:
# cat ksym_trace_filter ksym_filter_head:rw- global_trace:rw- # echo 0 > ksym_trace_filter # cat ksym_trace_filter #
Changelog v1->v2:
Add other ways to clear all breakpoints by writing NULL or "*:---" to ksym_trace_filter file base on K.Prasad's suggestion
LKML-Reference: <[email protected]>
--- kernel/trace/trace_ksym.c | 53 +++++++++++++++++++++++++++++--------------- 1 files changed, 35 insertions(+), 18 deletions(-)
kernel/trace/trace_ksym.c +35 -18
@@ -163,8 +163,6 @@ static int parse_ksym_trace_str(char *input_string, char **ksymname, {int ret; -strstrip (input_string); - *ksymname =strsep (&input_string,":" ); *addr =kallsyms_lookup_name (*ksymname);
@@ -262,6 +260,25 @@ static ssize_t ksym_trace_filter_read(struct file *filp, char __user *ubuf,return cnt; } +static void __ksym_trace_reset (void ) +{ +struct trace_ksym *entry; +struct hlist_node *node, *node1; + +mutex_lock (&ksym_tracer_mutex); +hlist_for_each_entry_safe (entry, node, node1, &ksym_filter_head, + ksym_hlist) { +unregister_kernel_hw_breakpoint (entry->ksym_hbp); + ksym_filter_entry_count--; +hlist_del_rcu (&(entry->ksym_hlist)); +synchronize_rcu (); +kfree (entry->ksym_hbp->info.name); +kfree (entry->ksym_hbp); +kfree (entry); + } +mutex_unlock (&ksym_tracer_mutex); +} +static ssize_t ksym_trace_filter_write (struct file *file,const char __user *buffer,size_t count,loff_t *ppos)
@@ -282,6 +299,21 @@ static ssize_t ksym_trace_filter_write(struct file *file, } input_string[count] ='\0' ; +strstrip (input_string); + +/* +* Clear all breakpoints if: +* 1: echo > ksym_trace_filter +* 2: echo 0 > ksym_trace_filter +* 3: echo "*:---" > ksym_trace_filter +*/ +if (!input_string[0 ] || !strcmp (input_string,"0" ) || + !strcmp (input_string,"*:---" )) { +__ksym_trace_reset (); +kfree (input_string); +return count; + } + ret = op =parse_ksym_trace_str (input_string, &ksymname, &ksym_addr);if (ret <0 ) {kfree (input_string);
@@ -341,23 +373,8 @@ static const struct file_operations ksym_tracing_fops = {static void ksym_trace_reset (struct trace_array *tr) { -struct trace_ksym *entry; -struct hlist_node *node, *node1; - ksym_tracing_enabled =0 ; - -mutex_lock (&ksym_tracer_mutex); -hlist_for_each_entry_safe (entry, node, node1, &ksym_filter_head, - ksym_hlist) { -unregister_kernel_hw_breakpoint (entry->ksym_hbp); - ksym_filter_entry_count--; -hlist_del_rcu (&(entry->ksym_hlist)); -synchronize_rcu (); -kfree (entry->ksym_hbp->info.name); -kfree (entry->ksym_hbp); -kfree (entry); - } -mutex_unlock (&ksym_tracer_mutex); +__ksym_trace_reset (); }static int ksym_trace_init (struct trace_array *tr)
Signature · 3 lines
1.6.3.3 --
Quoted 8 lines · Steven Rostedt
Ingo,
Please pull the latest tip/tracing/hw-breakpoints tree, which can be found at:
git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-2.6-trace.git
tip/tracing/hw-breakpoints
Quoted 8 lines
Xiao Guangrong (3):
tracing/ksym_tracer: fix the output of ksym tracer tracing/ksym_tracer: fix write operation ofksym_trace_filtertracing/ksym_tracer: support quick clear forksym_trace_filter-- v2----
kernel/trace/trace_ksym.c | 70 +++++++++++++++++++++++++++++---------------- 1 files changed, 45 insertions(+), 25 deletions(-)
Pulled, thanks a lot Steve!
Ingo