public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/6] ftrace: more updates to tip
@ 2009-01-16  4:53 Steven Rostedt
  2009-01-16  4:53 ` [PATCH 1/6] ftrace: move function tracer functions out of trace.c Steven Rostedt
                   ` (6 more replies)
  0 siblings, 7 replies; 11+ messages in thread
From: Steven Rostedt @ 2009-01-16  4:53 UTC (permalink / raw)
  To: linux-kernel; +Cc: Ingo Molnar, Andrew Morton, Frederic Weisbecker

Ingo,

The following patches are in:

  git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-2.6-trace.git

    branch: tip/devel


Steven Rostedt (6):
      ftrace: move function tracer functions out of trace.c
      trace: add gcc printf check to trace_seq_printf
      trace: clean up format errors in calls to trace_seq_printf
      ftrace: combine stack trace in function call
      ftrace: remove static from function tracer functions
      trace: set max latency variable to zero on default

----
 kernel/trace/kmemtrace.c          |    4 +-
 kernel/trace/trace.c              |   89 +----------------------------
 kernel/trace/trace.h              |   10 ---
 kernel/trace/trace_functions.c    |  115 ++++++++++++++++++++++++++++++++++---
 kernel/trace/trace_irqsoff.c      |    1 +
 kernel/trace/trace_mmiotrace.c    |   13 ++--
 kernel/trace/trace_output.c       |    2 +-
 kernel/trace/trace_output.h       |    3 +-
 kernel/trace/trace_sched_wakeup.c |    1 +
 9 files changed, 122 insertions(+), 116 deletions(-)

-- 

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

* [PATCH 1/6] ftrace: move function tracer functions out of trace.c
  2009-01-16  4:53 [PATCH 0/6] ftrace: more updates to tip Steven Rostedt
@ 2009-01-16  4:53 ` Steven Rostedt
  2009-01-16  6:49   ` Andrew Morton
  2009-01-16  4:53 ` [PATCH 2/6] trace: add gcc printf check to trace_seq_printf Steven Rostedt
                   ` (5 subsequent siblings)
  6 siblings, 1 reply; 11+ messages in thread
From: Steven Rostedt @ 2009-01-16  4:53 UTC (permalink / raw)
  To: linux-kernel
  Cc: Ingo Molnar, Andrew Morton, Frederic Weisbecker, Steven Rostedt

[-- Attachment #1: 0001-ftrace-move-function-tracer-functions-out-of-trace.patch --]
[-- Type: text/plain, Size: 5959 bytes --]

From: Steven Rostedt <srostedt@redhat.com>

Impact: clean up of trace.c

The function tracer functions were put in trace.c because it needed
to share static variables that were in trace.c.  Since then, those
variables have become global for various reasons. This patch moves
the function tracer functions into trace_function.c where they belong.

Signed-off-by: Steven Rostedt <srostedt@redhat.com>
---
 kernel/trace/trace.c           |   84 ----------------------------------------
 kernel/trace/trace_functions.c |   84 +++++++++++++++++++++++++++++++++++++++-
 2 files changed, 83 insertions(+), 85 deletions(-)

diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index 3c54cb1..2585ffb 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -1046,65 +1046,6 @@ ftrace_special(unsigned long arg1, unsigned long arg2, unsigned long arg3)
 	local_irq_restore(flags);
 }
 
-#ifdef CONFIG_FUNCTION_TRACER
-static void
-function_trace_call_preempt_only(unsigned long ip, unsigned long parent_ip)
-{
-	struct trace_array *tr = &global_trace;
-	struct trace_array_cpu *data;
-	unsigned long flags;
-	long disabled;
-	int cpu, resched;
-	int pc;
-
-	if (unlikely(!ftrace_function_enabled))
-		return;
-
-	pc = preempt_count();
-	resched = ftrace_preempt_disable();
-	local_save_flags(flags);
-	cpu = raw_smp_processor_id();
-	data = tr->data[cpu];
-	disabled = atomic_inc_return(&data->disabled);
-
-	if (likely(disabled == 1))
-		trace_function(tr, data, ip, parent_ip, flags, pc);
-
-	atomic_dec(&data->disabled);
-	ftrace_preempt_enable(resched);
-}
-
-static void
-function_trace_call(unsigned long ip, unsigned long parent_ip)
-{
-	struct trace_array *tr = &global_trace;
-	struct trace_array_cpu *data;
-	unsigned long flags;
-	long disabled;
-	int cpu;
-	int pc;
-
-	if (unlikely(!ftrace_function_enabled))
-		return;
-
-	/*
-	 * Need to use raw, since this must be called before the
-	 * recursive protection is performed.
-	 */
-	local_irq_save(flags);
-	cpu = raw_smp_processor_id();
-	data = tr->data[cpu];
-	disabled = atomic_inc_return(&data->disabled);
-
-	if (likely(disabled == 1)) {
-		pc = preempt_count();
-		trace_function(tr, data, ip, parent_ip, flags, pc);
-	}
-
-	atomic_dec(&data->disabled);
-	local_irq_restore(flags);
-}
-
 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
 int trace_graph_entry(struct ftrace_graph_ent *trace)
 {
@@ -1162,31 +1103,6 @@ void trace_graph_return(struct ftrace_graph_ret *trace)
 }
 #endif /* CONFIG_FUNCTION_GRAPH_TRACER */
 
-static struct ftrace_ops trace_ops __read_mostly =
-{
-	.func = function_trace_call,
-};
-
-void tracing_start_function_trace(void)
-{
-	ftrace_function_enabled = 0;
-
-	if (trace_flags & TRACE_ITER_PREEMPTONLY)
-		trace_ops.func = function_trace_call_preempt_only;
-	else
-		trace_ops.func = function_trace_call;
-
-	register_ftrace_function(&trace_ops);
-	ftrace_function_enabled = 1;
-}
-
-void tracing_stop_function_trace(void)
-{
-	ftrace_function_enabled = 0;
-	unregister_ftrace_function(&trace_ops);
-}
-#endif
-
 enum trace_file_type {
 	TRACE_FILE_LAT_FMT	= 1,
 	TRACE_FILE_ANNOTATE	= 2,
diff --git a/kernel/trace/trace_functions.c b/kernel/trace/trace_functions.c
index 3a5fa08..2dce3c7 100644
--- a/kernel/trace/trace_functions.c
+++ b/kernel/trace/trace_functions.c
@@ -20,6 +20,7 @@ static struct trace_array	*func_trace;
 
 static void start_function_trace(struct trace_array *tr)
 {
+	func_trace = tr;
 	tr->cpu = get_cpu();
 	tracing_reset_online_cpus(tr);
 	put_cpu();
@@ -36,7 +37,6 @@ static void stop_function_trace(struct trace_array *tr)
 
 static int function_trace_init(struct trace_array *tr)
 {
-	func_trace = tr;
 	start_function_trace(tr);
 	return 0;
 }
@@ -52,6 +52,64 @@ static void function_trace_start(struct trace_array *tr)
 }
 
 static void
+function_trace_call_preempt_only(unsigned long ip, unsigned long parent_ip)
+{
+	struct trace_array *tr = func_trace;
+	struct trace_array_cpu *data;
+	unsigned long flags;
+	long disabled;
+	int cpu, resched;
+	int pc;
+
+	if (unlikely(!ftrace_function_enabled))
+		return;
+
+	pc = preempt_count();
+	resched = ftrace_preempt_disable();
+	local_save_flags(flags);
+	cpu = raw_smp_processor_id();
+	data = tr->data[cpu];
+	disabled = atomic_inc_return(&data->disabled);
+
+	if (likely(disabled == 1))
+		trace_function(tr, data, ip, parent_ip, flags, pc);
+
+	atomic_dec(&data->disabled);
+	ftrace_preempt_enable(resched);
+}
+
+static void
+function_trace_call(unsigned long ip, unsigned long parent_ip)
+{
+	struct trace_array *tr = func_trace;
+	struct trace_array_cpu *data;
+	unsigned long flags;
+	long disabled;
+	int cpu;
+	int pc;
+
+	if (unlikely(!ftrace_function_enabled))
+		return;
+
+	/*
+	 * Need to use raw, since this must be called before the
+	 * recursive protection is performed.
+	 */
+	local_irq_save(flags);
+	cpu = raw_smp_processor_id();
+	data = tr->data[cpu];
+	disabled = atomic_inc_return(&data->disabled);
+
+	if (likely(disabled == 1)) {
+		pc = preempt_count();
+		trace_function(tr, data, ip, parent_ip, flags, pc);
+	}
+
+	atomic_dec(&data->disabled);
+	local_irq_restore(flags);
+}
+
+static void
 function_stack_trace_call(unsigned long ip, unsigned long parent_ip)
 {
 	struct trace_array *tr = func_trace;
@@ -90,6 +148,30 @@ function_stack_trace_call(unsigned long ip, unsigned long parent_ip)
 	local_irq_restore(flags);
 }
 
+
+static struct ftrace_ops trace_ops __read_mostly =
+{
+	.func = function_trace_call,
+};
+
+void tracing_start_function_trace(void)
+{
+	ftrace_function_enabled = 0;
+
+	if (trace_flags & TRACE_ITER_PREEMPTONLY)
+		trace_ops.func = function_trace_call_preempt_only;
+	else
+		trace_ops.func = function_trace_call;
+
+	register_ftrace_function(&trace_ops);
+	ftrace_function_enabled = 1;
+}
+
+void tracing_stop_function_trace(void)
+{
+	ftrace_function_enabled = 0;
+	unregister_ftrace_function(&trace_ops);
+}
 static struct ftrace_ops trace_stack_ops __read_mostly =
 {
 	.func = function_stack_trace_call,
-- 
1.5.6.5

-- 

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

* [PATCH 2/6] trace: add gcc printf check to trace_seq_printf
  2009-01-16  4:53 [PATCH 0/6] ftrace: more updates to tip Steven Rostedt
  2009-01-16  4:53 ` [PATCH 1/6] ftrace: move function tracer functions out of trace.c Steven Rostedt
@ 2009-01-16  4:53 ` Steven Rostedt
  2009-01-16  4:53 ` [PATCH 3/6] trace: clean up format errors in calls " Steven Rostedt
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 11+ messages in thread
From: Steven Rostedt @ 2009-01-16  4:53 UTC (permalink / raw)
  To: linux-kernel
  Cc: Ingo Molnar, Andrew Morton, Frederic Weisbecker, Steven Rostedt

[-- Attachment #1: 0002-trace-add-gcc-printf-check-to-trace_seq_printf.patch --]
[-- Type: text/plain, Size: 875 bytes --]

From: Steven Rostedt <srostedt@redhat.com>

Andrew Morton suggested adding a printf checker to trace_seq_printf
since there are a number of users that have improper format arguments.

Signed-off-by: Steven Rostedt <srostedt@redhat.com>
---
 kernel/trace/trace_output.h |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/kernel/trace/trace_output.h b/kernel/trace/trace_output.h
index b2c1461..1cbab5e 100644
--- a/kernel/trace/trace_output.h
+++ b/kernel/trace/trace_output.h
@@ -16,7 +16,8 @@ struct trace_event {
 	trace_print_func	binary;
 };
 
-extern int trace_seq_printf(struct trace_seq *s, const char *fmt, ...);
+extern int trace_seq_printf(struct trace_seq *s, const char *fmt, ...)
+	__attribute__ ((format (printf, 2, 3)));
 extern int
 seq_print_ip_sym(struct trace_seq *s, unsigned long ip,
 		unsigned long sym_flags);
-- 
1.5.6.5

-- 

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

* [PATCH 3/6] trace: clean up format errors in calls to trace_seq_printf
  2009-01-16  4:53 [PATCH 0/6] ftrace: more updates to tip Steven Rostedt
  2009-01-16  4:53 ` [PATCH 1/6] ftrace: move function tracer functions out of trace.c Steven Rostedt
  2009-01-16  4:53 ` [PATCH 2/6] trace: add gcc printf check to trace_seq_printf Steven Rostedt
@ 2009-01-16  4:53 ` Steven Rostedt
  2009-01-16  4:53 ` [PATCH 4/6] ftrace: combine stack trace in function call Steven Rostedt
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 11+ messages in thread
From: Steven Rostedt @ 2009-01-16  4:53 UTC (permalink / raw)
  To: linux-kernel
  Cc: Ingo Molnar, Andrew Morton, Frederic Weisbecker, Steven Rostedt

[-- Attachment #1: 0003-trace-clean-up-format-errors-in-calls-to-trace_seq_.patch --]
[-- Type: text/plain, Size: 3555 bytes --]

From: Steven Rostedt <srostedt@redhat.com>

After adding the printf format checking for trace_seq_printf, several
warnings now show up. This patch cleans them up.

Signed-off-by: Steven Rostedt <srostedt@redhat.com>
---
 kernel/trace/kmemtrace.c       |    4 ++--
 kernel/trace/trace_mmiotrace.c |   13 +++++++------
 kernel/trace/trace_output.c    |    2 +-
 3 files changed, 10 insertions(+), 9 deletions(-)

diff --git a/kernel/trace/kmemtrace.c b/kernel/trace/kmemtrace.c
index faaa5ae..7ebc58c 100644
--- a/kernel/trace/kmemtrace.c
+++ b/kernel/trace/kmemtrace.c
@@ -139,12 +139,12 @@ kmemtrace_print_alloc_compress(struct trace_iterator *iter,
 		return TRACE_TYPE_PARTIAL_LINE;
 
 	/* Requested */
-	ret = trace_seq_printf(s, "%4d   ", entry->bytes_req);
+	ret = trace_seq_printf(s, "%4ld   ", entry->bytes_req);
 	if (!ret)
 		return TRACE_TYPE_PARTIAL_LINE;
 
 	/* Allocated */
-	ret = trace_seq_printf(s, "%4d   ", entry->bytes_alloc);
+	ret = trace_seq_printf(s, "%4ld   ", entry->bytes_alloc);
 	if (!ret)
 		return TRACE_TYPE_PARTIAL_LINE;
 
diff --git a/kernel/trace/trace_mmiotrace.c b/kernel/trace/trace_mmiotrace.c
index 621c8c3..ec78e24 100644
--- a/kernel/trace/trace_mmiotrace.c
+++ b/kernel/trace/trace_mmiotrace.c
@@ -184,21 +184,22 @@ static enum print_line_t mmio_print_rw(struct trace_iterator *iter)
 	switch (rw->opcode) {
 	case MMIO_READ:
 		ret = trace_seq_printf(s,
-			"R %d %lu.%06lu %d 0x%llx 0x%lx 0x%lx %d\n",
+			"R %d %u.%06lu %d 0x%llx 0x%lx 0x%lx %d\n",
 			rw->width, secs, usec_rem, rw->map_id,
 			(unsigned long long)rw->phys,
 			rw->value, rw->pc, 0);
 		break;
 	case MMIO_WRITE:
 		ret = trace_seq_printf(s,
-			"W %d %lu.%06lu %d 0x%llx 0x%lx 0x%lx %d\n",
+			"W %d %u.%06lu %d 0x%llx 0x%lx 0x%lx %d\n",
 			rw->width, secs, usec_rem, rw->map_id,
 			(unsigned long long)rw->phys,
 			rw->value, rw->pc, 0);
 		break;
 	case MMIO_UNKNOWN_OP:
 		ret = trace_seq_printf(s,
-			"UNKNOWN %lu.%06lu %d 0x%llx %02x,%02x,%02x 0x%lx %d\n",
+			"UNKNOWN %u.%06lu %d 0x%llx %02lx,%02lx,"
+			"%02lx 0x%lx %d\n",
 			secs, usec_rem, rw->map_id,
 			(unsigned long long)rw->phys,
 			(rw->value >> 16) & 0xff, (rw->value >> 8) & 0xff,
@@ -230,14 +231,14 @@ static enum print_line_t mmio_print_map(struct trace_iterator *iter)
 	switch (m->opcode) {
 	case MMIO_PROBE:
 		ret = trace_seq_printf(s,
-			"MAP %lu.%06lu %d 0x%llx 0x%lx 0x%lx 0x%lx %d\n",
+			"MAP %u.%06lu %d 0x%llx 0x%lx 0x%lx 0x%lx %d\n",
 			secs, usec_rem, m->map_id,
 			(unsigned long long)m->phys, m->virt, m->len,
 			0UL, 0);
 		break;
 	case MMIO_UNPROBE:
 		ret = trace_seq_printf(s,
-			"UNMAP %lu.%06lu %d 0x%lx %d\n",
+			"UNMAP %u.%06lu %d 0x%lx %d\n",
 			secs, usec_rem, m->map_id, 0UL, 0);
 		break;
 	default:
@@ -261,7 +262,7 @@ static enum print_line_t mmio_print_mark(struct trace_iterator *iter)
 	int ret;
 
 	/* The trailing newline must be in the message. */
-	ret = trace_seq_printf(s, "MARK %lu.%06lu %s", secs, usec_rem, msg);
+	ret = trace_seq_printf(s, "MARK %u.%06lu %s", secs, usec_rem, msg);
 	if (!ret)
 		return TRACE_TYPE_PARTIAL_LINE;
 
diff --git a/kernel/trace/trace_output.c b/kernel/trace/trace_output.c
index 4e3ad36..1a4e144 100644
--- a/kernel/trace/trace_output.c
+++ b/kernel/trace/trace_output.c
@@ -440,7 +440,7 @@ trace_fn_raw(struct trace_seq *s, struct trace_entry *entry, int flags)
 
 	trace_assign_type(field, entry);
 
-	if (!trace_seq_printf(s, "%x %x\n",
+	if (!trace_seq_printf(s, "%lx %lx\n",
 			      field->ip,
 			      field->parent_ip))
 		return TRACE_TYPE_PARTIAL_LINE;
-- 
1.5.6.5

-- 

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

* [PATCH 4/6] ftrace: combine stack trace in function call
  2009-01-16  4:53 [PATCH 0/6] ftrace: more updates to tip Steven Rostedt
                   ` (2 preceding siblings ...)
  2009-01-16  4:53 ` [PATCH 3/6] trace: clean up format errors in calls " Steven Rostedt
@ 2009-01-16  4:53 ` Steven Rostedt
  2009-01-16  4:53 ` [PATCH 5/6] ftrace: remove static from function tracer functions Steven Rostedt
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 11+ messages in thread
From: Steven Rostedt @ 2009-01-16  4:53 UTC (permalink / raw)
  To: linux-kernel
  Cc: Ingo Molnar, Andrew Morton, Frederic Weisbecker, Steven Rostedt

[-- Attachment #1: 0004-ftrace-combine-stack-trace-in-function-call.patch --]
[-- Type: text/plain, Size: 3424 bytes --]

From: Steven Rostedt <srostedt@redhat.com>

Impact: less likely to interleave function and stack traces

This patch does replaces the separate stack trace on function with
a record function and stack trace together. This will switch between
the function only recording to a function and stack recording.

Also some whitespace fix ups as well.

Signed-off-by: Steven Rostedt <srostedt@redhat.com>
---
 kernel/trace/trace_functions.c |   61 +++++++++++++++++++++++----------------
 1 files changed, 36 insertions(+), 25 deletions(-)

diff --git a/kernel/trace/trace_functions.c b/kernel/trace/trace_functions.c
index 2dce3c7..61d0b73 100644
--- a/kernel/trace/trace_functions.c
+++ b/kernel/trace/trace_functions.c
@@ -133,6 +133,7 @@ function_stack_trace_call(unsigned long ip, unsigned long parent_ip)
 
 	if (likely(disabled == 1)) {
 		pc = preempt_count();
+		trace_function(tr, data, ip, parent_ip, flags, pc);
 		/*
 		 * skip over 5 funcs:
 		 *    __ftrace_trace_stack,
@@ -154,24 +155,6 @@ static struct ftrace_ops trace_ops __read_mostly =
 	.func = function_trace_call,
 };
 
-void tracing_start_function_trace(void)
-{
-	ftrace_function_enabled = 0;
-
-	if (trace_flags & TRACE_ITER_PREEMPTONLY)
-		trace_ops.func = function_trace_call_preempt_only;
-	else
-		trace_ops.func = function_trace_call;
-
-	register_ftrace_function(&trace_ops);
-	ftrace_function_enabled = 1;
-}
-
-void tracing_stop_function_trace(void)
-{
-	ftrace_function_enabled = 0;
-	unregister_ftrace_function(&trace_ops);
-}
 static struct ftrace_ops trace_stack_ops __read_mostly =
 {
 	.func = function_stack_trace_call,
@@ -194,6 +177,31 @@ static struct tracer_flags func_flags = {
 	.opts = func_opts
 };
 
+void tracing_start_function_trace(void)
+{
+	ftrace_function_enabled = 0;
+
+	if (trace_flags & TRACE_ITER_PREEMPTONLY)
+		trace_ops.func = function_trace_call_preempt_only;
+	else
+		trace_ops.func = function_trace_call;
+
+	if (func_flags.val & TRACE_FUNC_OPT_STACK)
+		register_ftrace_function(&trace_stack_ops);
+	else
+		register_ftrace_function(&trace_ops);
+
+	ftrace_function_enabled = 1;
+}
+
+void tracing_stop_function_trace(void)
+{
+	ftrace_function_enabled = 0;
+	/* OK if they are not registered */
+	unregister_ftrace_function(&trace_stack_ops);
+	unregister_ftrace_function(&trace_ops);
+}
+
 static int func_set_flag(u32 old_flags, u32 bit, int set)
 {
 	if (bit == TRACE_FUNC_OPT_STACK) {
@@ -201,10 +209,13 @@ static int func_set_flag(u32 old_flags, u32 bit, int set)
 		if (!!set == !!(func_flags.val & TRACE_FUNC_OPT_STACK))
 			return 0;
 
-		if (set)
+		if (set) {
+			unregister_ftrace_function(&trace_ops);
 			register_ftrace_function(&trace_stack_ops);
-		else
+		} else {
 			unregister_ftrace_function(&trace_stack_ops);
+			register_ftrace_function(&trace_ops);
+		}
 
 		return 0;
 	}
@@ -214,14 +225,14 @@ static int func_set_flag(u32 old_flags, u32 bit, int set)
 
 static struct tracer function_trace __read_mostly =
 {
-	.name	     = "function",
-	.init	     = function_trace_init,
-	.reset	     = function_trace_reset,
-	.start	     = function_trace_start,
+	.name		= "function",
+	.init		= function_trace_init,
+	.reset		= function_trace_reset,
+	.start		= function_trace_start,
 	.flags		= &func_flags,
 	.set_flag	= func_set_flag,
 #ifdef CONFIG_FTRACE_SELFTEST
-	.selftest    = trace_selftest_startup_function,
+	.selftest	= trace_selftest_startup_function,
 #endif
 };
 
-- 
1.5.6.5

-- 

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

* [PATCH 5/6] ftrace: remove static from function tracer functions
  2009-01-16  4:53 [PATCH 0/6] ftrace: more updates to tip Steven Rostedt
                   ` (3 preceding siblings ...)
  2009-01-16  4:53 ` [PATCH 4/6] ftrace: combine stack trace in function call Steven Rostedt
@ 2009-01-16  4:53 ` Steven Rostedt
  2009-01-16  4:53 ` [PATCH 6/6] trace: set max latency variable to zero on default Steven Rostedt
  2009-01-16 11:25 ` [PATCH 0/6] ftrace: more updates to tip Ingo Molnar
  6 siblings, 0 replies; 11+ messages in thread
From: Steven Rostedt @ 2009-01-16  4:53 UTC (permalink / raw)
  To: linux-kernel
  Cc: Ingo Molnar, Andrew Morton, Frederic Weisbecker, Steven Rostedt

[-- Attachment #1: 0005-ftrace-remove-static-from-function-tracer-functions.patch --]
[-- Type: text/plain, Size: 2524 bytes --]

From: Steven Rostedt <srostedt@redhat.com>

Impact: clean up

After reorganizing the functions in trace.c and trace_function.c,
they no longer need to be in global context. This patch makes the
functions and one variable into static.

Signed-off-by: Steven Rostedt <srostedt@redhat.com>
---
 kernel/trace/trace.c           |    3 ---
 kernel/trace/trace.h           |   10 ----------
 kernel/trace/trace_functions.c |   10 ++++++++--
 3 files changed, 8 insertions(+), 15 deletions(-)

diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index 2585ffb..7de6a94 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -187,9 +187,6 @@ int tracing_is_enabled(void)
 	return tracer_enabled;
 }
 
-/* function tracing enabled */
-int				ftrace_function_enabled;
-
 /*
  * trace_buf_size is the size in bytes that is allocated
  * for a buffer. Note, the number of bytes is always rounded
diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h
index bf39a36..54b7278 100644
--- a/kernel/trace/trace.h
+++ b/kernel/trace/trace.h
@@ -464,16 +464,6 @@ void __trace_stack(struct trace_array *tr,
 
 extern cycle_t ftrace_now(int cpu);
 
-#ifdef CONFIG_FUNCTION_TRACER
-void tracing_start_function_trace(void);
-void tracing_stop_function_trace(void);
-#else
-# define tracing_start_function_trace()		do { } while (0)
-# define tracing_stop_function_trace()		do { } while (0)
-#endif
-
-extern int ftrace_function_enabled;
-
 #ifdef CONFIG_CONTEXT_SWITCH_TRACER
 typedef void
 (*tracer_switch_func_t)(void *private,
diff --git a/kernel/trace/trace_functions.c b/kernel/trace/trace_functions.c
index 61d0b73..b3a320f 100644
--- a/kernel/trace/trace_functions.c
+++ b/kernel/trace/trace_functions.c
@@ -16,8 +16,14 @@
 
 #include "trace.h"
 
+/* function tracing enabled */
+static int			ftrace_function_enabled;
+
 static struct trace_array	*func_trace;
 
+static void tracing_start_function_trace(void);
+static void tracing_stop_function_trace(void);
+
 static void start_function_trace(struct trace_array *tr)
 {
 	func_trace = tr;
@@ -177,7 +183,7 @@ static struct tracer_flags func_flags = {
 	.opts = func_opts
 };
 
-void tracing_start_function_trace(void)
+static void tracing_start_function_trace(void)
 {
 	ftrace_function_enabled = 0;
 
@@ -194,7 +200,7 @@ void tracing_start_function_trace(void)
 	ftrace_function_enabled = 1;
 }
 
-void tracing_stop_function_trace(void)
+static void tracing_stop_function_trace(void)
 {
 	ftrace_function_enabled = 0;
 	/* OK if they are not registered */
-- 
1.5.6.5

-- 

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

* [PATCH 6/6] trace: set max latency variable to zero on default
  2009-01-16  4:53 [PATCH 0/6] ftrace: more updates to tip Steven Rostedt
                   ` (4 preceding siblings ...)
  2009-01-16  4:53 ` [PATCH 5/6] ftrace: remove static from function tracer functions Steven Rostedt
@ 2009-01-16  4:53 ` Steven Rostedt
  2009-01-16 11:25 ` [PATCH 0/6] ftrace: more updates to tip Ingo Molnar
  6 siblings, 0 replies; 11+ messages in thread
From: Steven Rostedt @ 2009-01-16  4:53 UTC (permalink / raw)
  To: linux-kernel
  Cc: Ingo Molnar, Andrew Morton, Frederic Weisbecker, Steven Rostedt

[-- Attachment #1: 0006-trace-set-max-latency-variable-to-zero-on-default.patch --]
[-- Type: text/plain, Size: 1971 bytes --]

From: Steven Rostedt <srostedt@redhat.com>

Impact: trace max latencies on start of latency tracing

This patch sets the max latency to zero whenever one of the
irq variant tracers or the wakeup tracer is set to current tracer.

Most developers expect to see output when starting up a latency
tracer. But since the max_latency is already set to max, and
it takes a latency greater than max_latency to be recorded, there
is no trace. This is not the expected behavior and has even confused
myself.

Signed-off-by: Steven Rostedt <srostedt@redhat.com>
---
 kernel/trace/trace.c              |    2 +-
 kernel/trace/trace_irqsoff.c      |    1 +
 kernel/trace/trace_sched_wakeup.c |    1 +
 3 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index 7de6a94..220c264 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -41,7 +41,7 @@
 
 #define TRACE_BUFFER_FLAGS	(RB_FL_OVERWRITE)
 
-unsigned long __read_mostly	tracing_max_latency = (cycle_t)ULONG_MAX;
+unsigned long __read_mostly	tracing_max_latency;
 unsigned long __read_mostly	tracing_thresh;
 
 /*
diff --git a/kernel/trace/trace_irqsoff.c b/kernel/trace/trace_irqsoff.c
index 7c2e326..62a78d9 100644
--- a/kernel/trace/trace_irqsoff.c
+++ b/kernel/trace/trace_irqsoff.c
@@ -380,6 +380,7 @@ static void stop_irqsoff_tracer(struct trace_array *tr)
 
 static void __irqsoff_tracer_init(struct trace_array *tr)
 {
+	tracing_max_latency = 0;
 	irqsoff_trace = tr;
 	/* make sure that the tracer is visible */
 	smp_wmb();
diff --git a/kernel/trace/trace_sched_wakeup.c b/kernel/trace/trace_sched_wakeup.c
index 43586b6..42ae1e7 100644
--- a/kernel/trace/trace_sched_wakeup.c
+++ b/kernel/trace/trace_sched_wakeup.c
@@ -333,6 +333,7 @@ static void stop_wakeup_tracer(struct trace_array *tr)
 
 static int wakeup_tracer_init(struct trace_array *tr)
 {
+	tracing_max_latency = 0;
 	wakeup_trace = tr;
 	start_wakeup_tracer(tr);
 	return 0;
-- 
1.5.6.5

-- 

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

* Re: [PATCH 1/6] ftrace: move function tracer functions out of trace.c
  2009-01-16  4:53 ` [PATCH 1/6] ftrace: move function tracer functions out of trace.c Steven Rostedt
@ 2009-01-16  6:49   ` Andrew Morton
  2009-01-16 11:12     ` Ingo Molnar
  2009-01-16 13:13     ` Steven Rostedt
  0 siblings, 2 replies; 11+ messages in thread
From: Andrew Morton @ 2009-01-16  6:49 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: linux-kernel, Ingo Molnar, Frederic Weisbecker, Steven Rostedt

On Thu, 15 Jan 2009 23:53:43 -0500 Steven Rostedt <rostedt@goodmis.org> wrote:

>  static void
> +function_trace_call_preempt_only(unsigned long ip, unsigned long parent_ip)
> +{
> +	struct trace_array *tr = func_trace;
> +	struct trace_array_cpu *data;
> +	unsigned long flags;
> +	long disabled;
> +	int cpu, resched;
> +	int pc;
> +
> +	if (unlikely(!ftrace_function_enabled))
> +		return;

We're optimizing for the tracing-is-enabled case.  What's the thinking
here?

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

* Re: [PATCH 1/6] ftrace: move function tracer functions out of trace.c
  2009-01-16  6:49   ` Andrew Morton
@ 2009-01-16 11:12     ` Ingo Molnar
  2009-01-16 13:13     ` Steven Rostedt
  1 sibling, 0 replies; 11+ messages in thread
From: Ingo Molnar @ 2009-01-16 11:12 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Steven Rostedt, linux-kernel, Frederic Weisbecker, Steven Rostedt


* Andrew Morton <akpm@linux-foundation.org> wrote:

> On Thu, 15 Jan 2009 23:53:43 -0500 Steven Rostedt <rostedt@goodmis.org> wrote:
> 
> >  static void
> > +function_trace_call_preempt_only(unsigned long ip, unsigned long parent_ip)
> > +{
> > +	struct trace_array *tr = func_trace;
> > +	struct trace_array_cpu *data;
> > +	unsigned long flags;
> > +	long disabled;
> > +	int cpu, resched;
> > +	int pc;
> > +
> > +	if (unlikely(!ftrace_function_enabled))
> > +		return;
> 
> We're optimizing for the tracing-is-enabled case.  What's the thinking 
> here?

There's two levels here: first the patched in callsites. Those are NOPs in 
the usual case - there's no overhead for the default 'function tracing is 
built in but not enabled' case.

There's a second level: a /debug/tracing/tracing_enabled lightweight 
dynamic flag to flip tracing on/off while the tracer is enabled. _That_ 
one, if it ever matters to a codepath, is default-enabled.

I.e. the above code sequence is correct.

Thanks,

	Ingo

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

* Re: [PATCH 0/6] ftrace: more updates to tip
  2009-01-16  4:53 [PATCH 0/6] ftrace: more updates to tip Steven Rostedt
                   ` (5 preceding siblings ...)
  2009-01-16  4:53 ` [PATCH 6/6] trace: set max latency variable to zero on default Steven Rostedt
@ 2009-01-16 11:25 ` Ingo Molnar
  6 siblings, 0 replies; 11+ messages in thread
From: Ingo Molnar @ 2009-01-16 11:25 UTC (permalink / raw)
  To: Steven Rostedt; +Cc: linux-kernel, Andrew Morton, Frederic Weisbecker


* Steven Rostedt <rostedt@goodmis.org> wrote:

> Ingo,
> 
> The following patches are in:
> 
>   git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-2.6-trace.git
> 
>     branch: tip/devel
> 
> 
> Steven Rostedt (6):
>       ftrace: move function tracer functions out of trace.c
>       trace: add gcc printf check to trace_seq_printf
>       trace: clean up format errors in calls to trace_seq_printf
>       ftrace: combine stack trace in function call
>       ftrace: remove static from function tracer functions
>       trace: set max latency variable to zero on default
> 
> ----
>  kernel/trace/kmemtrace.c          |    4 +-
>  kernel/trace/trace.c              |   89 +----------------------------
>  kernel/trace/trace.h              |   10 ---
>  kernel/trace/trace_functions.c    |  115 ++++++++++++++++++++++++++++++++++---
>  kernel/trace/trace_irqsoff.c      |    1 +
>  kernel/trace/trace_mmiotrace.c    |   13 ++--
>  kernel/trace/trace_output.c       |    2 +-
>  kernel/trace/trace_output.h       |    3 +-
>  kernel/trace/trace_sched_wakeup.c |    1 +
>  9 files changed, 122 insertions(+), 116 deletions(-)

Pulled into tip/tracing/ftrace, thanks Steve!

	Ingo

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

* Re: [PATCH 1/6] ftrace: move function tracer functions out of trace.c
  2009-01-16  6:49   ` Andrew Morton
  2009-01-16 11:12     ` Ingo Molnar
@ 2009-01-16 13:13     ` Steven Rostedt
  1 sibling, 0 replies; 11+ messages in thread
From: Steven Rostedt @ 2009-01-16 13:13 UTC (permalink / raw)
  To: Andrew Morton
  Cc: linux-kernel, Ingo Molnar, Frederic Weisbecker, Steven Rostedt


On Thu, 15 Jan 2009, Andrew Morton wrote:

> On Thu, 15 Jan 2009 23:53:43 -0500 Steven Rostedt <rostedt@goodmis.org> wrote:
> 
> >  static void
> > +function_trace_call_preempt_only(unsigned long ip, unsigned long parent_ip)
> > +{
> > +	struct trace_array *tr = func_trace;
> > +	struct trace_array_cpu *data;
> > +	unsigned long flags;
> > +	long disabled;
> > +	int cpu, resched;
> > +	int pc;
> > +
> > +	if (unlikely(!ftrace_function_enabled))
> > +		return;
> 
> We're optimizing for the tracing-is-enabled case.  What's the thinking
> here?

This is called only when tracing _is_ enabled :-) Either it was enabled by 
the dynamic ftrace system, or there's another variable tested before 
jumping to the functions. This function must be register, and when it is, 
tracing is expected to run.

The reason for the "ftrace_function_enabled" variable is to prevent 
tracing to start before the stop_machine finishes. It is local to this one 
tracer. Without it, you get a lot of garbage on the start up of the 
tracer.

-- Steve


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

end of thread, other threads:[~2009-01-16 13:13 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-01-16  4:53 [PATCH 0/6] ftrace: more updates to tip Steven Rostedt
2009-01-16  4:53 ` [PATCH 1/6] ftrace: move function tracer functions out of trace.c Steven Rostedt
2009-01-16  6:49   ` Andrew Morton
2009-01-16 11:12     ` Ingo Molnar
2009-01-16 13:13     ` Steven Rostedt
2009-01-16  4:53 ` [PATCH 2/6] trace: add gcc printf check to trace_seq_printf Steven Rostedt
2009-01-16  4:53 ` [PATCH 3/6] trace: clean up format errors in calls " Steven Rostedt
2009-01-16  4:53 ` [PATCH 4/6] ftrace: combine stack trace in function call Steven Rostedt
2009-01-16  4:53 ` [PATCH 5/6] ftrace: remove static from function tracer functions Steven Rostedt
2009-01-16  4:53 ` [PATCH 6/6] trace: set max latency variable to zero on default Steven Rostedt
2009-01-16 11:25 ` [PATCH 0/6] ftrace: more updates to tip Ingo Molnar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox