All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/3] tracing/ksym_tracer: fix the output of ksym tracer
@ 2009-07-22  3:21 Xiao Guangrong
  2009-07-22  3:23 ` [PATCH 2/3] tracing/ksym_tracer: fix write operation of ksym_trace_filter Xiao Guangrong
                   ` (2 more replies)
  0 siblings, 3 replies; 14+ messages in thread
From: Xiao Guangrong @ 2009-07-22  3:21 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: K.Prasad, Alan Stern, Frederic Weisbecker, Steven Rostedt, LKML

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

Signed-off-by: Xiao Guangrong <xiaoguangrong@cn.fujitsu.com>
---
 kernel/trace/trace_ksym.c |   13 ++++++-------
 1 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/kernel/trace/trace_ksym.c b/kernel/trace/trace_ksym.c
index 1256a6e..fbf3a8e 100644
--- a/kernel/trace/trace_ksym.c
+++ b/kernel/trace/trace_ksym.c
@@ -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;
 
-- 
1.6.1.2



^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 2/3] tracing/ksym_tracer: fix write operation of ksym_trace_filter
  2009-07-22  3:21 [PATCH 1/3] tracing/ksym_tracer: fix the output of ksym tracer Xiao Guangrong
@ 2009-07-22  3:23 ` Xiao Guangrong
  2009-11-21 13:35   ` [tip:perf/core] " tip-bot for Xiao Guangrong
  2009-07-22  3:25 ` [PATCH 3/3] tracing/ksym_tracer: support quick clear for ksym_trace_filter Xiao Guangrong
  2009-11-21 13:35 ` [tip:perf/core] tracing/ksym_tracer: fix the output of ksym tracer tip-bot for Xiao Guangrong
  2 siblings, 1 reply; 14+ messages in thread
From: Xiao Guangrong @ 2009-07-22  3:23 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: K.Prasad, Alan Stern, Frederic Weisbecker, Steven Rostedt, LKML

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

Signed-off-by: Xiao Guangrong <xiaoguangrong@cn.fujitsu.com>
---
 kernel/trace/trace_ksym.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/kernel/trace/trace_ksym.c b/kernel/trace/trace_ksym.c
index fbf3a8e..cd5cb65 100644
--- a/kernel/trace/trace_ksym.c
+++ b/kernel/trace/trace_ksym.c
@@ -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) */
-- 
1.6.1.2


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 3/3] tracing/ksym_tracer: support quick clear for ksym_trace_filter
  2009-07-22  3:21 [PATCH 1/3] tracing/ksym_tracer: fix the output of ksym tracer Xiao Guangrong
  2009-07-22  3:23 ` [PATCH 2/3] tracing/ksym_tracer: fix write operation of ksym_trace_filter Xiao Guangrong
@ 2009-07-22  3:25 ` Xiao Guangrong
  2009-07-22  5:06   ` K.Prasad
  2009-07-23  4:01   ` [PATCH 3/3] tracing/ksym_tracer: support quick clear for ksym_trace_filter -- v2 Xiao Guangrong
  2009-11-21 13:35 ` [tip:perf/core] tracing/ksym_tracer: fix the output of ksym tracer tip-bot for Xiao Guangrong
  2 siblings, 2 replies; 14+ messages in thread
From: Xiao Guangrong @ 2009-07-22  3:25 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: K.Prasad, Alan Stern, Frederic Weisbecker, Steven Rostedt, LKML

It'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
 #

Signed-off-by: Xiao Guangrong <xiaoguangrong@cn.fujitsu.com>
---
 kernel/trace/trace_ksym.c |   45 +++++++++++++++++++++++++++------------------
 1 files changed, 27 insertions(+), 18 deletions(-)

diff --git a/kernel/trace/trace_ksym.c b/kernel/trace/trace_ksym.c
index cd5cb65..96b9e19 100644
--- a/kernel/trace/trace_ksym.c
+++ b/kernel/trace/trace_ksym.c
@@ -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)
-- 
1.6.1.2


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* Re: [PATCH 3/3] tracing/ksym_tracer: support quick clear for ksym_trace_filter
  2009-07-22  3:25 ` [PATCH 3/3] tracing/ksym_tracer: support quick clear for ksym_trace_filter Xiao Guangrong
@ 2009-07-22  5:06   ` K.Prasad
  2009-07-22  9:56     ` Xiao Guangrong
  2009-07-23  4:01   ` [PATCH 3/3] tracing/ksym_tracer: support quick clear for ksym_trace_filter -- v2 Xiao Guangrong
  1 sibling, 1 reply; 14+ messages in thread
From: K.Prasad @ 2009-07-22  5:06 UTC (permalink / raw)
  To: Xiao Guangrong
  Cc: Ingo Molnar, Alan Stern, Frederic Weisbecker, Steven Rostedt,
	LKML

On Wed, Jul 22, 2009 at 11:25:14AM +0800, Xiao Guangrong wrote:
> It'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
>  #
>

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


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 3/3] tracing/ksym_tracer: support quick clear for ksym_trace_filter
  2009-07-22  5:06   ` K.Prasad
@ 2009-07-22  9:56     ` Xiao Guangrong
  2009-07-22 15:17       ` K.Prasad
  0 siblings, 1 reply; 14+ messages in thread
From: Xiao Guangrong @ 2009-07-22  9:56 UTC (permalink / raw)
  To: prasad; +Cc: Ingo Molnar, Alan Stern, Frederic Weisbecker, Steven Rostedt,
	LKML



K.Prasad wrote:
> On Wed, Jul 22, 2009 at 11:25:14AM +0800, Xiao Guangrong wrote:
>> It'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
>>  #
>>
> 
> 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

> 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
> 
> 
> 

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 3/3] tracing/ksym_tracer: support quick clear for ksym_trace_filter
  2009-07-22  9:56     ` Xiao Guangrong
@ 2009-07-22 15:17       ` K.Prasad
  2009-07-23  0:50         ` Xiao Guangrong
  0 siblings, 1 reply; 14+ messages in thread
From: K.Prasad @ 2009-07-22 15:17 UTC (permalink / raw)
  To: Xiao Guangrong, Ingo Molnar
  Cc: Alan Stern, Frederic Weisbecker, Steven Rostedt, LKML

On Wed, Jul 22, 2009 at 05:56:49PM +0800, Xiao Guangrong wrote:
> 
> 
> K.Prasad wrote:
> > On Wed, Jul 22, 2009 at 11:25:14AM +0800, Xiao Guangrong wrote:
> >> It'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
> >>  #
> >>
> > 
> > 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
>

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


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 3/3] tracing/ksym_tracer: support quick clear for ksym_trace_filter
  2009-07-22 15:17       ` K.Prasad
@ 2009-07-23  0:50         ` Xiao Guangrong
  0 siblings, 0 replies; 14+ messages in thread
From: Xiao Guangrong @ 2009-07-23  0:50 UTC (permalink / raw)
  To: prasad; +Cc: Ingo Molnar, Alan Stern, Frederic Weisbecker, Steven Rostedt,
	LKML



K.Prasad wrote:

> 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.
> 

OK, I'll fix 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;
> +	}
> 

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

> 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 majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/
> 
> 

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH 3/3] tracing/ksym_tracer: support quick clear for ksym_trace_filter -- v2
  2009-07-22  3:25 ` [PATCH 3/3] tracing/ksym_tracer: support quick clear for ksym_trace_filter Xiao Guangrong
  2009-07-22  5:06   ` K.Prasad
@ 2009-07-23  4:01   ` Xiao Guangrong
  2009-07-24  0:46     ` Steven Rostedt
  2009-11-21 13:35     ` [tip:perf/core] " tip-bot for Xiao Guangrong
  1 sibling, 2 replies; 14+ messages in thread
From: Xiao Guangrong @ 2009-07-23  4:01 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: K.Prasad, Alan Stern, Frederic Weisbecker, Steven Rostedt, LKML

It'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

Signed-off-by: Xiao Guangrong <xiaoguangrong@cn.fujitsu.com>
---
 kernel/trace/trace_ksym.c |   53 +++++++++++++++++++++++++++++---------------
 1 files changed, 35 insertions(+), 18 deletions(-)

diff --git a/kernel/trace/trace_ksym.c b/kernel/trace/trace_ksym.c
index cd5cb65..2fde875 100644
--- a/kernel/trace/trace_ksym.c
+++ b/kernel/trace/trace_ksym.c
@@ -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)
-- 
1.6.1.2



^ permalink raw reply related	[flat|nested] 14+ messages in thread

* Re: [PATCH 3/3] tracing/ksym_tracer: support quick clear for ksym_trace_filter -- v2
  2009-07-23  4:01   ` [PATCH 3/3] tracing/ksym_tracer: support quick clear for ksym_trace_filter -- v2 Xiao Guangrong
@ 2009-07-24  0:46     ` Steven Rostedt
  2009-07-24  2:06       ` Xiao Guangrong
  2009-11-21 13:35     ` [tip:perf/core] " tip-bot for Xiao Guangrong
  1 sibling, 1 reply; 14+ messages in thread
From: Steven Rostedt @ 2009-07-24  0:46 UTC (permalink / raw)
  To: Xiao Guangrong
  Cc: Ingo Molnar, K.Prasad, Alan Stern, Frederic Weisbecker, LKML



On Thu, 23 Jul 2009, Xiao Guangrong wrote:

> It'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

Thanks guys, I'll go ahead and queue this up for 32.

-- Steve


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 3/3] tracing/ksym_tracer: support quick clear for ksym_trace_filter -- v2
  2009-07-24  0:46     ` Steven Rostedt
@ 2009-07-24  2:06       ` Xiao Guangrong
  2009-07-24  2:11         ` Steven Rostedt
  0 siblings, 1 reply; 14+ messages in thread
From: Xiao Guangrong @ 2009-07-24  2:06 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: Ingo Molnar, K.Prasad, Alan Stern, Frederic Weisbecker, LKML



Steven Rostedt wrote:
> 
> On Thu, 23 Jul 2009, Xiao Guangrong wrote:
> 
>> It'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
> 
> Thanks 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

> -- Steve
> 
> 
> 

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 3/3] tracing/ksym_tracer: support quick clear for ksym_trace_filter -- v2
  2009-07-24  2:06       ` Xiao Guangrong
@ 2009-07-24  2:11         ` Steven Rostedt
  0 siblings, 0 replies; 14+ messages in thread
From: Steven Rostedt @ 2009-07-24  2:11 UTC (permalink / raw)
  To: Xiao Guangrong
  Cc: Ingo Molnar, K.Prasad, Alan Stern, Frederic Weisbecker, LKML


On Fri, 24 Jul 2009, Xiao Guangrong wrote:
> Steven Rostedt wrote:
> > 
> > On Thu, 23 Jul 2009, Xiao Guangrong wrote:
> > 
> >> It'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
> > 
> > Thanks 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.

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


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [tip:perf/core] tracing/ksym_tracer: fix the output of ksym tracer
  2009-07-22  3:21 [PATCH 1/3] tracing/ksym_tracer: fix the output of ksym tracer Xiao Guangrong
  2009-07-22  3:23 ` [PATCH 2/3] tracing/ksym_tracer: fix write operation of ksym_trace_filter Xiao Guangrong
  2009-07-22  3:25 ` [PATCH 3/3] tracing/ksym_tracer: support quick clear for ksym_trace_filter Xiao Guangrong
@ 2009-11-21 13:35 ` tip-bot for Xiao Guangrong
  2 siblings, 0 replies; 14+ messages in thread
From: tip-bot for Xiao Guangrong @ 2009-11-21 13:35 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: linux-kernel, hpa, mingo, rostedt, xiaoguangrong, tglx

Commit-ID:  d857ace143df3884954887e1899a65831ca72ece
Gitweb:     http://git.kernel.org/tip/d857ace143df3884954887e1899a65831ca72ece
Author:     Xiao Guangrong <xiaoguangrong@cn.fujitsu.com>
AuthorDate: Wed, 22 Jul 2009 11:21:31 +0800
Committer:  Steven Rostedt <rostedt@goodmis.org>
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/0x1b

Signed-off-by: Xiao Guangrong <xiaoguangrong@cn.fujitsu.com>
LKML-Reference: <4A6685BB.2090809@cn.fujitsu.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
 kernel/trace/trace_ksym.c |   13 ++++++-------
 1 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/kernel/trace/trace_ksym.c b/kernel/trace/trace_ksym.c
index 1256a6e..fbf3a8e 100644
--- a/kernel/trace/trace_ksym.c
+++ b/kernel/trace/trace_ksym.c
@@ -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;
 

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [tip:perf/core] tracing/ksym_tracer: fix write operation of ksym_trace_filter
  2009-07-22  3:23 ` [PATCH 2/3] tracing/ksym_tracer: fix write operation of ksym_trace_filter Xiao Guangrong
@ 2009-11-21 13:35   ` tip-bot for Xiao Guangrong
  0 siblings, 0 replies; 14+ messages in thread
From: tip-bot for Xiao Guangrong @ 2009-11-21 13:35 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: linux-kernel, hpa, mingo, rostedt, xiaoguangrong, tglx

Commit-ID:  8e068542a8d9efec55126284d2f5cb32f003d507
Gitweb:     http://git.kernel.org/tip/8e068542a8d9efec55126284d2f5cb32f003d507
Author:     Xiao Guangrong <xiaoguangrong@cn.fujitsu.com>
AuthorDate: Wed, 22 Jul 2009 11:23:41 +0800
Committer:  Steven Rostedt <rostedt@goodmis.org>
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

Signed-off-by: Xiao Guangrong <xiaoguangrong@cn.fujitsu.com>
LKML-Reference: <4A66863D.5090802@cn.fujitsu.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
 kernel/trace/trace_ksym.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/kernel/trace/trace_ksym.c b/kernel/trace/trace_ksym.c
index fbf3a8e..cd5cb65 100644
--- a/kernel/trace/trace_ksym.c
+++ b/kernel/trace/trace_ksym.c
@@ -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) */

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [tip:perf/core] tracing/ksym_tracer: support quick clear for ksym_trace_filter -- v2
  2009-07-23  4:01   ` [PATCH 3/3] tracing/ksym_tracer: support quick clear for ksym_trace_filter -- v2 Xiao Guangrong
  2009-07-24  0:46     ` Steven Rostedt
@ 2009-11-21 13:35     ` tip-bot for Xiao Guangrong
  1 sibling, 0 replies; 14+ messages in thread
From: tip-bot for Xiao Guangrong @ 2009-11-21 13:35 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: linux-kernel, hpa, mingo, rostedt, xiaoguangrong, tglx

Commit-ID:  75e33751ca8bbb72dd6f1a74d2810ddc8cbe4bdf
Gitweb:     http://git.kernel.org/tip/75e33751ca8bbb72dd6f1a74d2810ddc8cbe4bdf
Author:     Xiao Guangrong <xiaoguangrong@cn.fujitsu.com>
AuthorDate: Thu, 23 Jul 2009 12:01:22 +0800
Committer:  Steven Rostedt <rostedt@goodmis.org>
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

Signed-off-by: Xiao Guangrong <xiaoguangrong@cn.fujitsu.com>
LKML-Reference: <4A67E092.3080202@cn.fujitsu.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
 kernel/trace/trace_ksym.c |   53 +++++++++++++++++++++++++++++---------------
 1 files changed, 35 insertions(+), 18 deletions(-)

diff --git a/kernel/trace/trace_ksym.c b/kernel/trace/trace_ksym.c
index cd5cb65..2fde875 100644
--- a/kernel/trace/trace_ksym.c
+++ b/kernel/trace/trace_ksym.c
@@ -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)

^ permalink raw reply related	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2009-11-21 13:36 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-07-22  3:21 [PATCH 1/3] tracing/ksym_tracer: fix the output of ksym tracer Xiao Guangrong
2009-07-22  3:23 ` [PATCH 2/3] tracing/ksym_tracer: fix write operation of ksym_trace_filter Xiao Guangrong
2009-11-21 13:35   ` [tip:perf/core] " tip-bot for Xiao Guangrong
2009-07-22  3:25 ` [PATCH 3/3] tracing/ksym_tracer: support quick clear for ksym_trace_filter Xiao Guangrong
2009-07-22  5:06   ` K.Prasad
2009-07-22  9:56     ` Xiao Guangrong
2009-07-22 15:17       ` K.Prasad
2009-07-23  0:50         ` Xiao Guangrong
2009-07-23  4:01   ` [PATCH 3/3] tracing/ksym_tracer: support quick clear for ksym_trace_filter -- v2 Xiao Guangrong
2009-07-24  0:46     ` Steven Rostedt
2009-07-24  2:06       ` Xiao Guangrong
2009-07-24  2:11         ` Steven Rostedt
2009-11-21 13:35     ` [tip:perf/core] " tip-bot for Xiao Guangrong
2009-11-21 13:35 ` [tip:perf/core] tracing/ksym_tracer: fix the output of ksym tracer tip-bot for Xiao Guangrong

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.