Skip to contentSkip to conversation

tracing/trace_stack: fix the number of entries in the header

PATCH In review walimis 2 participants 9 messages Jun 3, 2009 – Jun 7, 2009 Tracing

lore
Share & tools
lore

walimis

author
#0 lore raw

PATCH 1/3 tracing/trace_stack: fix the number of entries in the header

The last entry in the stack_dump_trace is ULONG_MAX, which is not a valid entry, but max_stack_trace.nr_entries has accounted for it. So when printing the header, we should decrease it by one. Before fix, print as following, for example:

	Depth    Size   Location    (53 entries)	<--- should be 52
	-----    ----   --------

0) 3264 108 update_wall_time+0x4d5/0x9a0
...
51) 80 80 syscall_call+0x7/0xb
^^^
it's correct.

---
 kernel/trace/trace_stack.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
kernel/trace/trace_stack.c +1 -1
index 1796f00..2d7aebd 100644
@@ -265,7 +265,7 @@ static int t_show(struct seq_file *m, void *v)
 		seq_printf(m, "        Depth    Size   Location"
 			   "    (%d entries)\n"
 			   "        -----    ----   --------\n",
-			   max_stack_trace.nr_entries);
+			   max_stack_trace.nr_entries - 1);
 
 		if (!stack_tracer_enabled && !max_stack_size)
 			print_disabled(m);
Signature · 1 line
1.6.0.3
author
#1 lore raw

PATCH 2/3 tracing/events: fix output format of kernel stack

According to "events/ftrace/kernel_stack/format", output format of kernel stack should use "=>" instead of "<=".

The second problem is that we shouldn't skip the first entry in the stack, although it seems to be duplicated when used in the "function" tracer, but events also use it. If we skip the first one, we will drop the topmost entry of the stack.

The last problem is that if the last entry is ULONG_MAX(0xffffffff), we should drop it, otherwise it will print a NULL name line.

before fix:

      sh-1072  [000]   26.957239: sched_process_fork: parent sh:1072 child sh:1073
      sh-1072  [000]   26.957262:
 <= syscall_call
 <=
      sh-1072  [000]   26.957744: sched_switch: task sh:1072 [120] (R) ==> sh:1073 [120]
      sh-1072  [000]   26.957752:

<= preempt_schedule
<= wake_up_new_task
<= do_fork
<= sys_clone
<= syscall_call
<=

After fix:

      sh-1075  [000]    39.791848: sched_process_fork: parent sh:1075  child sh:1076
      sh-1075  [000]    39.791871:
 => sys_clone
 => syscall_call
      sh-1075  [000]    39.792713: sched_switch: task sh:1075 [120] (R) ==> sh:1076 [120]
      sh-1075  [000]    39.792722:

=> schedule
=> preempt_schedule
=> wake_up_new_task
=> do_fork
=> sys_clone
=> syscall_call

---
 kernel/trace/trace_output.c |   14 +++++++-------
 1 files changed, 7 insertions(+), 7 deletions(-)
kernel/trace/trace_output.c +7 -7
index 0fe3b22..64596a5 100644
@@ -975,16 +975,16 @@ static enum print_line_t trace_stack_print(struct trace_iterator *iter,
 
 	trace_assign_type(field, iter->ent);
 
+	if (!trace_seq_puts(s, "\n"))
+		goto partial;
 	for (i = 0; i < FTRACE_STACK_ENTRIES; i++) {
-		if (!field->caller[i])
+		if (!field->caller[i] || (field->caller[i] == ULONG_MAX))
 			break;
-		if (i) {
-			if (!trace_seq_puts(s, " <= "))
-				goto partial;
+		if (!trace_seq_puts(s, " => "))
+			goto partial;
 
-			if (!seq_print_ip_sym(s, field->caller[i], flags))
-				goto partial;
-		}
+		if (!seq_print_ip_sym(s, field->caller[i], flags))
+			goto partial;
 		if (!trace_seq_puts(s, "\n"))
 			goto partial;
 	}
Signature · 1 line
1.6.0.3
author
#2 lore raw

PATCH 3/3 tracing/events: fix output format of user stack

According to "events/ftrace/user_stack/format", fix the output of user stack.

before fix:

sh-1073 [000] 31.137561: <b7f274fe> <- <0804e33c> <- <080835c1>

after fix:

sh-1072 [000] 37.039329:

 =>  <b7f8a4fe>
 =>  <0804e33c>
 =>  <080835c1>
---
 kernel/trace/trace_output.c |   11 +++++++----
 1 files changed, 7 insertions(+), 4 deletions(-)
kernel/trace/trace_output.c +7 -4
index 64596a5..8dadbbb 100644
@@ -389,17 +389,20 @@ seq_print_userip_objs(const struct userstack_entry *entry, struct trace_seq *s,
 
 		if (ip == ULONG_MAX || !ret)
 			break;
-		if (i && ret)
-			ret = trace_seq_puts(s, " <- ");
+		if (ret)
+			ret = trace_seq_puts(s, " => ");
 		if (!ip) {
 			if (ret)
 				ret = trace_seq_puts(s, "??");
+			if (ret)
+				ret = trace_seq_puts(s, "\n");
 			continue;
 		}
 		if (!ret)
 			break;
 		if (ret)
 			ret = seq_print_user_ip(s, mm, ip, sym_flags);
+		ret = trace_seq_puts(s, "\n");
 	}
 
 	if (mm)
@@ -1012,10 +1015,10 @@ static enum print_line_t trace_user_stack_print(struct trace_iterator *iter,
 
 	trace_assign_type(field, iter->ent);
 
-	if (!seq_print_userip_objs(field, s, flags))
+	if (!trace_seq_putc(s, '\n'))
 		goto partial;
 
-	if (!trace_seq_putc(s, '\n'))
+	if (!seq_print_userip_objs(field, s, flags))
 		goto partial;
 
 	return TRACE_TYPE_HANDLED;
Signature · 1 line
1.6.0.3
maintainer
#3 lore raw

Re: [PATCH 3/3] tracing/events: fix output format of user stack

Quoted 7 lines · walimis

According to "events/ftrace/user_stack/format", fix the output of user stack.

before fix:

sh-1073 [000] 31.137561: <b7f274fe> <- <0804e33c> <- <080835c1>

Quoted 8 lines

after fix:

sh-1072 [000] 37.039329:

 =>  <b7f8a4fe>
 =>  <0804e33c>
 =>  <080835c1>

I'll queue this too, Thanks!

-- Steve

#4 lore raw

[tip:tracing/core] tracing/events: fix output format of user stack

In reply to walimis
Commit-ID:  048dc50c5e7eada19ebabbad70b7966d14283d41
Gitweb:     http://git.kernel.org/tip/048dc50c5e7eada19ebabbad70b7966d14283d41
Author:     walimis <[email protected]>
AuthorDate: Wed, 3 Jun 2009 16:01:30 +0800
Committer:  Steven Rostedt <[email protected]>
CommitDate: Wed, 3 Jun 2009 10:25:30 -0400

tracing/events: fix output format of user stack

According to "events/ftrace/user_stack/format", fix the output of user stack.

before fix:

sh-1073 [000] 31.137561: <b7f274fe> <- <0804e33c> <- <080835c1>

after fix:

sh-1072 [000] 37.039329:

 =>  <b7f8a4fe>
 =>  <0804e33c>
 =>  <080835c1>

LKML-Reference: <[email protected]>

---
 kernel/trace/trace_output.c |   11 +++++++----
 1 files changed, 7 insertions(+), 4 deletions(-)
kernel/trace/trace_output.c +7 -4
index 64596a5..8dadbbb 100644
@@ -389,17 +389,20 @@ seq_print_userip_objs(const struct userstack_entry *entry, struct trace_seq *s,
 
 		if (ip == ULONG_MAX || !ret)
 			break;
-		if (i && ret)
-			ret = trace_seq_puts(s, " <- ");
+		if (ret)
+			ret = trace_seq_puts(s, " => ");
 		if (!ip) {
 			if (ret)
 				ret = trace_seq_puts(s, "??");
+			if (ret)
+				ret = trace_seq_puts(s, "\n");
 			continue;
 		}
 		if (!ret)
 			break;
 		if (ret)
 			ret = seq_print_user_ip(s, mm, ip, sym_flags);
+		ret = trace_seq_puts(s, "\n");
 	}
 
 	if (mm)
@@ -1012,10 +1015,10 @@ static enum print_line_t trace_user_stack_print(struct trace_iterator *iter,
 
 	trace_assign_type(field, iter->ent);
 
-	if (!seq_print_userip_objs(field, s, flags))
+	if (!trace_seq_putc(s, '\n'))
 		goto partial;
 
-	if (!trace_seq_putc(s, '\n'))
+	if (!seq_print_userip_objs(field, s, flags))
 		goto partial;
 
 	return TRACE_TYPE_HANDLED;
maintainer
#5 lore raw

Re: [PATCH 2/3] tracing/events: fix output format of kernel stack

In reply to walimis
Quoted 34 lines · walimis

According to "events/ftrace/kernel_stack/format", output format of kernel stack should use "=>" instead of "<=".

The second problem is that we shouldn't skip the first entry in the stack, although it seems to be duplicated when used in the "function" tracer, but events also use it. If we skip the first one, we will drop the topmost entry of the stack.

The last problem is that if the last entry is ULONG_MAX(0xffffffff), we should drop it, otherwise it will print a NULL name line.

before fix:

      sh-1072  [000]   26.957239: sched_process_fork: parent sh:1072 child sh:1073
      sh-1072  [000]   26.957262:
 <= syscall_call
 <=
      sh-1072  [000]   26.957744: sched_switch: task sh:1072 [120] (R) ==> sh:1073 [120]
      sh-1072  [000]   26.957752:

<= preempt_schedule
<= wake_up_new_task
<= do_fork
<= sys_clone
<= syscall_call
<=

After fix:

      sh-1075  [000]    39.791848: sched_process_fork: parent sh:1075  child sh:1076
      sh-1075  [000]    39.791871:
 => sys_clone
 => syscall_call
      sh-1075  [000]    39.792713: sched_switch: task sh:1075 [120] (R) ==> sh:1076 [120]
      sh-1075  [000]    39.792722:
Quoted 8 lines

=> schedule
=> preempt_schedule
=> wake_up_new_task
=> do_fork
=> sys_clone
=> syscall_call

I'll queue this up. Thanks!

-- Steve

#6 lore raw

[tip:tracing/core] tracing/events: fix output format of kernel stack

In reply to walimis
Commit-ID:  f11b3f4e2932bfdcfc458ab8d1ece62724ceabfc
Gitweb:     http://git.kernel.org/tip/f11b3f4e2932bfdcfc458ab8d1ece62724ceabfc
Author:     walimis <[email protected]>
AuthorDate: Wed, 3 Jun 2009 16:01:29 +0800
Committer:  Steven Rostedt <[email protected]>
CommitDate: Wed, 3 Jun 2009 10:25:15 -0400

tracing/events: fix output format of kernel stack

According to "events/ftrace/kernel_stack/format", output format of kernel stack should use "=>" instead of "<=".

The second problem is that we shouldn't skip the first entry in the stack, although it seems to be duplicated when used in the "function" tracer, but events also use it. If we skip the first one, we will drop the topmost entry of the stack.

The last problem is that if the last entry is ULONG_MAX(0xffffffff), we should drop it, otherwise it will print a NULL name line.

before fix:

      sh-1072  [000]   26.957239: sched_process_fork: parent sh:1072 child sh:1073
      sh-1072  [000]   26.957262:
 <= syscall_call
 <=
      sh-1072  [000]   26.957744: sched_switch: task sh:1072 [120] (R) ==> sh:1073 [120]
      sh-1072  [000]   26.957752:

<= preempt_schedule
<= wake_up_new_task
<= do_fork
<= sys_clone
<= syscall_call
<=

After fix:

      sh-1075  [000]    39.791848: sched_process_fork: parent sh:1075  child sh:1076
      sh-1075  [000]    39.791871:
 => sys_clone
 => syscall_call
      sh-1075  [000]    39.792713: sched_switch: task sh:1075 [120] (R) ==> sh:1076 [120]
      sh-1075  [000]    39.792722:

=> schedule
=> preempt_schedule
=> wake_up_new_task
=> do_fork
=> sys_clone
=> syscall_call

LKML-Reference: <[email protected]>

---
 kernel/trace/trace_output.c |   14 +++++++-------
 1 files changed, 7 insertions(+), 7 deletions(-)
kernel/trace/trace_output.c +7 -7
index 0fe3b22..64596a5 100644
@@ -975,16 +975,16 @@ static enum print_line_t trace_stack_print(struct trace_iterator *iter,
 
 	trace_assign_type(field, iter->ent);
 
+	if (!trace_seq_puts(s, "\n"))
+		goto partial;
 	for (i = 0; i < FTRACE_STACK_ENTRIES; i++) {
-		if (!field->caller[i])
+		if (!field->caller[i] || (field->caller[i] == ULONG_MAX))
 			break;
-		if (i) {
-			if (!trace_seq_puts(s, " <= "))
-				goto partial;
+		if (!trace_seq_puts(s, " => "))
+			goto partial;
 
-			if (!seq_print_ip_sym(s, field->caller[i], flags))
-				goto partial;
-		}
+		if (!seq_print_ip_sym(s, field->caller[i], flags))
+			goto partial;
 		if (!trace_seq_puts(s, "\n"))
 			goto partial;
 	}
maintainer
#7 lore raw
In reply to walimis
Quoted 7 lines · walimis

The last entry in the stack_dump_trace is ULONG_MAX, which is not a valid entry, but max_stack_trace.nr_entries has accounted for it. So when printing the header, we should decrease it by one. Before fix, print as following, for example:

	Depth    Size   Location    (53 entries)	<--- should be 52
	-----    ----   --------
Quoted 7 lines

0) 3264 108 update_wall_time+0x4d5/0x9a0
...
51) 80 80 syscall_call+0x7/0xb
^^^
it's correct.

This is one of those bugs I've been meaning to fix for a long time, but never got around to actually doing it. Thanks!

I'll queue this up.

-- Steve

Quoted 21 lines
---
 kernel/trace/trace_stack.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
kernel/trace/trace_stack.c +1 -1
index 1796f00..2d7aebd 100644
@@ -265,7 +265,7 @@ static int t_show(struct seq_file *m, void *v)
 		seq_printf(m, "        Depth    Size   Location"
 			   "    (%d entries)\n"
 			   "        -----    ----   --------\n",
-			   max_stack_trace.nr_entries);
+			   max_stack_trace.nr_entries - 1);
 
 		if (!stack_tracer_enabled && !max_stack_size)
 			print_disabled(m);
Signature · 1 line
1.6.0.3
#8 lore raw
In reply to walimis
Commit-ID:  083a63b48e4dd0a6a2d44216720076dc81ebb255
Gitweb:     http://git.kernel.org/tip/083a63b48e4dd0a6a2d44216720076dc81ebb255
Author:     walimis <[email protected]>
AuthorDate: Wed, 3 Jun 2009 16:01:28 +0800
Committer:  Steven Rostedt <[email protected]>
CommitDate: Wed, 3 Jun 2009 10:24:44 -0400

tracing/trace_stack: fix the number of entries in the header

The last entry in the stack_dump_trace is ULONG_MAX, which is not a valid entry, but max_stack_trace.nr_entries has accounted for it. So when printing the header, we should decrease it by one. Before fix, print as following, for example:

	Depth    Size   Location    (53 entries)	<--- should be 52
	-----    ----   --------

0) 3264 108 update_wall_time+0x4d5/0x9a0
...
51) 80 80 syscall_call+0x7/0xb
^^^
it's correct.

LKML-Reference: <[email protected]>

---
 kernel/trace/trace_stack.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
kernel/trace/trace_stack.c +1 -1
index 1796f00..2d7aebd 100644
@@ -265,7 +265,7 @@ static int t_show(struct seq_file *m, void *v)
 		seq_printf(m, "        Depth    Size   Location"
 			   "    (%d entries)\n"
 			   "        -----    ----   --------\n",
-			   max_stack_trace.nr_entries);
+			   max_stack_trace.nr_entries - 1);
 
 		if (!stack_tracer_enabled && !max_stack_size)
 			print_disabled(m);