Browse Source

tracing: Add ftrace_trace_stack into __trace_puts/__trace_bputs

Currently trace option stacktrace is not applicable for
trace_printk with constant string argument, the reason is
in __trace_puts/__trace_bputs ftrace_trace_stack is missing.

In contrast, when using trace_printk with non constant string
argument(will call into __trace_printk/__trace_bprintk), then
trace option stacktrace is workable, this inconstant result
will confuses users a lot.

Link: http://lkml.kernel.org/p/51E7A7C9.9040401@huawei.com

Cc: stable@vger.kernel.org # 3.10+
Signed-off-by: zhangwei(Jovi) <jovi.zhangwei@huawei.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
zhangwei(Jovi) 12 years ago
parent
commit
8abfb8727f
1 changed files with 10 additions and 2 deletions
  1. 10 2
      kernel/trace/trace.c

+ 10 - 2
kernel/trace/trace.c

@@ -466,6 +466,9 @@ int __trace_puts(unsigned long ip, const char *str, int size)
 	struct print_entry *entry;
 	struct print_entry *entry;
 	unsigned long irq_flags;
 	unsigned long irq_flags;
 	int alloc;
 	int alloc;
+	int pc;
+
+	pc = preempt_count();
 
 
 	if (unlikely(tracing_selftest_running || tracing_disabled))
 	if (unlikely(tracing_selftest_running || tracing_disabled))
 		return 0;
 		return 0;
@@ -475,7 +478,7 @@ int __trace_puts(unsigned long ip, const char *str, int size)
 	local_save_flags(irq_flags);
 	local_save_flags(irq_flags);
 	buffer = global_trace.trace_buffer.buffer;
 	buffer = global_trace.trace_buffer.buffer;
 	event = trace_buffer_lock_reserve(buffer, TRACE_PRINT, alloc, 
 	event = trace_buffer_lock_reserve(buffer, TRACE_PRINT, alloc, 
-					  irq_flags, preempt_count());
+					  irq_flags, pc);
 	if (!event)
 	if (!event)
 		return 0;
 		return 0;
 
 
@@ -492,6 +495,7 @@ int __trace_puts(unsigned long ip, const char *str, int size)
 		entry->buf[size] = '\0';
 		entry->buf[size] = '\0';
 
 
 	__buffer_unlock_commit(buffer, event);
 	__buffer_unlock_commit(buffer, event);
+	ftrace_trace_stack(buffer, irq_flags, 4, pc);
 
 
 	return size;
 	return size;
 }
 }
@@ -509,6 +513,9 @@ int __trace_bputs(unsigned long ip, const char *str)
 	struct bputs_entry *entry;
 	struct bputs_entry *entry;
 	unsigned long irq_flags;
 	unsigned long irq_flags;
 	int size = sizeof(struct bputs_entry);
 	int size = sizeof(struct bputs_entry);
+	int pc;
+
+	pc = preempt_count();
 
 
 	if (unlikely(tracing_selftest_running || tracing_disabled))
 	if (unlikely(tracing_selftest_running || tracing_disabled))
 		return 0;
 		return 0;
@@ -516,7 +523,7 @@ int __trace_bputs(unsigned long ip, const char *str)
 	local_save_flags(irq_flags);
 	local_save_flags(irq_flags);
 	buffer = global_trace.trace_buffer.buffer;
 	buffer = global_trace.trace_buffer.buffer;
 	event = trace_buffer_lock_reserve(buffer, TRACE_BPUTS, size,
 	event = trace_buffer_lock_reserve(buffer, TRACE_BPUTS, size,
-					  irq_flags, preempt_count());
+					  irq_flags, pc);
 	if (!event)
 	if (!event)
 		return 0;
 		return 0;
 
 
@@ -525,6 +532,7 @@ int __trace_bputs(unsigned long ip, const char *str)
 	entry->str			= str;
 	entry->str			= str;
 
 
 	__buffer_unlock_commit(buffer, event);
 	__buffer_unlock_commit(buffer, event);
+	ftrace_trace_stack(buffer, irq_flags, 4, pc);
 
 
 	return 1;
 	return 1;
 }
 }