tracing/ksym_tracer: fix the output of ksym tracer
PATCH 1/3 tracing/ksym_tracer: fix the output of ksym tracer
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/0x1b--- 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 · 1 line
1.6.1.2
PATCH 2/3 tracing/ksym_tracer: fix write operation of ksym_trace_filter
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
--- 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 · 1 line
1.6.1.2
PATCH 3/3 tracing/ksym_tracer: support quick clear for ksym_trace_filter
In reply to Xiao GuangrongIt's rather bored to clear symbol one by one in ksym_trace_filter file, so, this patch can let ksym_trace_filter file support quick clear, we can write "0" to this file, it can 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 #
--- kernel/trace/trace_ksym.c | 45 +++++++++++++++++++++++++++------------------ 1 files changed, 27 insertions(+), 18 deletions(-)
kernel/trace/trace_ksym.c +27 -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,13 @@ static ssize_t ksym_trace_filter_write(struct file *file, } input_string[count] ='\0' ; +strstrip (input_string); +if (!strcmp (input_string,"0" )) { +__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 +365,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 · 1 line
1.6.1.2
Re: [PATCH 3/3] tracing/ksym_tracer: support quick clear for ksym_trace_filter
Quoted 4 lines · Xiao Guangrong
It's rather bored to clear symbol one by one in
ksym_trace_filterfile, so, this patch can letksym_trace_filterfile support quick clear, we can write "0" to this file, it can clear all symbols
Quoted 8 lines
for example:
# cat ksym_trace_filter ksym_filter_head:rw- global_trace:rw- # echo 0 > ksym_trace_filter # cat ksym_trace_filter #
It's nice to have this feature added and the other patches fix issues in ksym tracer. Can you have this patch add the capability to clear all breakpoints in one-shot through wild-cards?
Ingo wanted something like "echo "*:---" > ksym_trace_filter". The patch I sent here: http://lkml.org/lkml/2009/6/20/73 implements the same. You may want to implement something on those lines.
Thanks,
K.Prasad
Re: [PATCH 3/3] tracing/ksym_tracer: support quick clear for ksym_trace_filter
Quoted 14 lines · K.Prasad
Quoted 4 lines · Xiao Guangrong
It's rather bored to clear symbol one by one in
ksym_trace_filterfile, so, this patch can letksym_trace_filterfile support quick clear, we can write "0" to this file, it can clear all symbolsQuoted 8 lines
for example:
# cat ksym_trace_filter ksym_filter_head:rw- global_trace:rw- # echo 0 > ksym_trace_filter # cat ksym_trace_filter #
Quoted 4 lines
It's nice to have this feature added and the other patches fix issues in ksym tracer. Can you have this patch add the capability to clear all breakpoints in one-shot through wild-cards?
It already can clear all breakpoints in one-shot by write "0" to ksym_trace_filter file, do you means that we need to support other way for it? like:
echo > ksym_trace_filter
echo "*:---" > ksym_trace_filter
IMHO, one way to clear all breakpoints is enough, no need to add more code for the same function, for example, in trace events filter, only echo 0 > filter can properly clear all filters.
Are you sure other way is necessary?
Thanks,
Xiao
Quoted 9 lines
Ingo wanted something like "echo "*:---" >
ksym_trace_filter". The patch I sent here: http://lkml.org/lkml/2009/6/20/73 implements the same. You may want to implement something on those lines.Thanks,
K.Prasad
Re: [PATCH 3/3] tracing/ksym_tracer: support quick clear for ksym_trace_filter
Quoted 29 lines · Xiao Guangrong
Quoted 14 lines · K.Prasad
Quoted 4 lines · Xiao Guangrong
It's rather bored to clear symbol one by one in
ksym_trace_filterfile, so, this patch can letksym_trace_filterfile support quick clear, we can write "0" to this file, it can clear all symbolsQuoted 8 lines
for example:
# cat ksym_trace_filter ksym_filter_head:rw- global_trace:rw- # echo 0 > ksym_trace_filter # cat ksym_trace_filter #Quoted 4 lines
It's nice to have this feature added and the other patches fix issues in ksym tracer. Can you have this patch add the capability to clear all breakpoints in one-shot through wild-cards?
It already can clear all breakpoints in one-shot by write "0" to
ksym_trace_filterfile, do you means that we need to support other way for it? like:echo >
ksym_trace_filter
echo "*:---" >ksym_trace_filter
Quoted 9 lines
IMHO, one way to clear all breakpoints is enough, no need to add more code for the same function, for example, in trace events filter, only echo 0 > filter can properly clear all filters.
Are you sure other way is necessary?
Thanks,
Xiao
As I stated before, the ability to support
echo "*:---" > ksym_trace_filter was Ingo Molnar's suggestion, so if he's not particular about having it now we may skip it.
However, given that it requires just a few lines of code in addition, say
+ /* Clear all breakpoints if echo "*:---" > ksym_trace_filter */
+ if ((strncmp(ksymname, "*", strlen("*")) == 0) && (op == 0)) {
+ ksym_trace_reset(NULL);
+ kfree(input_string);
+ return count;
+ }
in ksym_trace_filter_write(), and that the patch is already present it shouldn't be bothersome to add it.
Thanks,
K.Prasad
Re: [PATCH 3/3] tracing/ksym_tracer: support quick clear for ksym_trace_filter
Quoted 4 lines · K.Prasad
As I stated before, the ability to support
echo "*:---" >ksym_trace_filterwas Ingo Molnar's suggestion, so if he's not particular about having it now we may skip it.
OK, I'll fix it.
kernel/trace/trace_ksym.c static ssize_t ksym_trace_filter_write(struct file *file, · line 307
Quoted 10 lines
However, given that it requires just a few lines of code in addition, say
kernel/trace/trace_ksym.c +6
-0+/* Clear all breakpoints if echo "*:---" > ksym_trace_filter */ +if ((strncmp (ksymname,"*" ,strlen ("*" )) ==0 ) && (op ==0 )) { +ksym_trace_reset (NULL ); +kfree (input_string); +return count; + }
I think below way is simpler:
+ /*
+ /* Clear all breakpoints if:
+ /* 1: echo > ksym_trace_filter
+ /* 2: echo 0 > ksym_trace_filter
+ /* 3: echo "*:---" > ksym_trace_filter
+ */
+ strstrip(input_string);
+ if (!input_string[0] || !strcmp(input_string, "0") ||
+ (!strcmp(input, "*:---")) {
+ __ksym_trace_reset();
+ kfree(input_string);
+ return count;
+ }
+
I'll sent a new patch after do some test for it.
Thanks,
Xiao
Quoted 13 lines
in
ksym_trace_filter_write(), and that the patch is already present it shouldn't be bothersome to add it.Thanks,
K.Prasad--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
PATCH 3/3 tracing/ksym_tracer: support quick clear for ksym_trace_filter -- v2
In reply to Xiao GuangrongIt's rather bored to clear symbol one by one in ksym_trace_filter file, so, this patch can let ksym_trace_filter file support quick clear, we can write "0" to this file, it can 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 way to clear all breakpoints by writing NULL or "*:---" to ksym_trace_filter file base on K.Prasad's suggestion
--- 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 · 1 line
1.6.1.2
Steven Rostedt
maintainerRe: [PATCH 3/3] tracing/ksym_tracer: support quick clear for ksym_trace_filter -- v2
Quoted 12 lines · Xiao Guangrong
It's rather bored to clear symbol one by one in
ksym_trace_filterfile, so, this patch can letksym_trace_filterfile support quick clear, we can write "0" to this file, it can clear all symbolsfor example:
# cat ksym_trace_filter ksym_filter_head:rw- global_trace:rw- # echo 0 > ksym_trace_filter # cat ksym_trace_filter #
Quoted 3 lines
Changelog
v1->v2:
Add other way to clear all breakpoints by writing NULL or "*:---" toksym_trace_filterfile base on K.Prasad's suggestion
Thanks guys, I'll go ahead and queue this up for 32.
-- Steve
Re: [PATCH 3/3] tracing/ksym_tracer: support quick clear for ksym_trace_filter -- v2
Quoted 15 lines · Steven Rostedt
Quoted 12 lines · Xiao Guangrong
It's rather bored to clear symbol one by one in
ksym_trace_filterfile, so, this patch can letksym_trace_filterfile support quick clear, we can write "0" to this file, it can clear all symbolsfor example:
# cat ksym_trace_filter ksym_filter_head:rw- global_trace:rw- # echo 0 > ksym_trace_filter # cat ksym_trace_filter #
Quoted 6 lines
Quoted 3 lines
Changelog
v1->v2:
Add other way to clear all breakpoints by writing NULL or "*:---" toksym_trace_filterfile base on K.Prasad's suggestionThanks guys, I'll go ahead and queue this up for 32.
Hi Steven,
Could you have a look at other 2 patches in this series:
[PATCH 1/3] tracing/ksym_tracer: fix the output of ksym tracer [PATCH 2/3] tracing/ksym_tracer: fix write operation of ksym_trace_filter
I think those fix is valuable, and K.Prasad has no objection.
Thanks,
Xiao
Quoted 4 lines
-- Steve
Steven Rostedt
maintainerRe: [PATCH 3/3] tracing/ksym_tracer: support quick clear for ksym_trace_filter -- v2
Quoted 23 lines · Xiao Guangrong
Quoted 15 lines · Steven Rostedt
Quoted 12 lines · Xiao Guangrong
It's rather bored to clear symbol one by one in
ksym_trace_filterfile, so, this patch can letksym_trace_filterfile support quick clear, we can write "0" to this file, it can clear all symbolsfor example:
# cat ksym_trace_filter ksym_filter_head:rw- global_trace:rw- # echo 0 > ksym_trace_filter # cat ksym_trace_filter #Quoted 6 lines
Quoted 3 lines
Changelog
v1->v2:
Add other way to clear all breakpoints by writing NULL or "*:---" toksym_trace_filterfile base on K.Prasad's suggestionThanks guys, I'll go ahead and queue this up for 32.
Quoted 8 lines
Hi Steven,
Could you have a look at other 2 patches in this series:
[PATCH 1/3] tracing/ksym_tracer: fix the output of ksym tracer [PATCH 2/3] tracing/ksym_tracer: fix write operation of
ksym_trace_filterI think those fix is valuable, and K.Prasad has no objection.
Ah, sorry for the confusion. I've queued up the entire series. I'm just playing with it now, and will post a pull request shortly.
-- Steve
Commit-ID: d857ace143df3884954887e1899a65831ca72ece Gitweb: http://git.kernel.org/tip/d857ace143df3884954887e1899a65831ca72ece Author: Xiao Guangrong <[email protected]> AuthorDate: Wed, 22 Jul 2009 11:21:31 +0800 Committer: Steven Rostedt <[email protected]> CommitDate: Thu, 23 Jul 2009 20:51:35 -0400
tracing/ksym_tracer: fix the output of ksym tracer
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 ;
[tip:perf/core] tracing/ksym_tracer: fix write operation of ksym_trace_filter
In reply to Xiao GuangrongCommit-ID: 8e068542a8d9efec55126284d2f5cb32f003d507 Gitweb: http://git.kernel.org/tip/8e068542a8d9efec55126284d2f5cb32f003d507 Author: Xiao Guangrong <[email protected]> AuthorDate: Wed, 22 Jul 2009 11:23:41 +0800 Committer: Steven Rostedt <[email protected]> CommitDate: Thu, 23 Jul 2009 20:52:05 -0400
tracing/ksym_tracer: fix write operation of ksym_trace_filter
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) */
[tip:perf/core] tracing/ksym_tracer: support quick clear for ksym_trace_filter -- v2
In reply to Xiao GuangrongCommit-ID: 75e33751ca8bbb72dd6f1a74d2810ddc8cbe4bdf Gitweb: http://git.kernel.org/tip/75e33751ca8bbb72dd6f1a74d2810ddc8cbe4bdf Author: Xiao Guangrong <[email protected]> AuthorDate: Thu, 23 Jul 2009 12:01:22 +0800 Committer: Steven Rostedt <[email protected]> CommitDate: Thu, 23 Jul 2009 20:54:40 -0400
tracing/ksym_tracer: support quick clear for ksym_trace_filter -- v2
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)