All of lore.kernel.org
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: linux-kernel@vger.kernel.org
Cc: Ingo Molnar <mingo@kernel.org>,
	Andrew Morton <akpm@linux-foundation.org>
Subject: [for-next][PATCH 15/25] tracing: Do not create function tracer options when not compiled in
Date: Thu, 01 Oct 2015 07:55:39 -0400	[thread overview]
Message-ID: <20151001115638.586772817@goodmis.org> (raw)
In-Reply-To: 20151001115524.066462793@goodmis.org

[-- Attachment #1: 0015-tracing-Do-not-create-function-tracer-options-when-n.patch --]
[-- Type: text/plain, Size: 8211 bytes --]

From: "Steven Rostedt (Red Hat)" <rostedt@goodmis.org>

When the function tracer is not compiled in, do not create the option files
for it.

Fix up both the sched_wakeup and irqsoff tracers to handle the change.

Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
 kernel/trace/trace.c              |  4 ++--
 kernel/trace/trace.h              | 11 +++++++++-
 kernel/trace/trace_irqsoff.c      | 28 +++++++++++++++++++++-----
 kernel/trace/trace_sched_wakeup.c | 42 ++++++++++++++++++++++++++-------------
 4 files changed, 63 insertions(+), 22 deletions(-)

diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index 68fcb40fc764..cb223ad51cdf 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -490,11 +490,11 @@ static inline void ftrace_trace_stack(struct ring_buffer *buffer,
 
 /* trace_flags holds trace_options default values */
 unsigned long trace_flags =
-	FUNCTION_GRAPH_DEFAULT_FLAGS |
+	FUNCTION_DEFAULT_FLAGS | FUNCTION_GRAPH_DEFAULT_FLAGS |
 	TRACE_ITER_PRINT_PARENT | TRACE_ITER_PRINTK |
 	TRACE_ITER_ANNOTATE | TRACE_ITER_CONTEXT_INFO |
 	TRACE_ITER_RECORD_CMD | TRACE_ITER_OVERWRITE |
-	TRACE_ITER_IRQ_INFO | TRACE_ITER_MARKERS | TRACE_ITER_FUNCTION
+	TRACE_ITER_IRQ_INFO | TRACE_ITER_MARKERS
 	;
 
 static void tracer_tracing_on(struct trace_array *tr)
diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h
index 3f1cc45b7007..b389d409b952 100644
--- a/kernel/trace/trace.h
+++ b/kernel/trace/trace.h
@@ -902,6 +902,15 @@ extern int trace_get_user(struct trace_parser *parser, const char __user *ubuf,
 # define BRANCH_FLAGS
 #endif
 
+#ifdef CONFIG_FUNCTION_TRACER
+# define FUNCTION_FLAGS						\
+		C(FUNCTION,		"function-trace"),
+# define FUNCTION_DEFAULT_FLAGS		TRACE_ITER_FUNCTION
+#else
+# define FUNCTION_FLAGS
+# define FUNCTION_DEFAULT_FLAGS		0UL
+#endif
+
 /*
  * trace_iterator_flags is an enumeration that defines bit
  * positions into trace_flags that controls the output.
@@ -931,7 +940,7 @@ extern int trace_get_user(struct trace_parser *parser, const char __user *ubuf,
 		C(STOP_ON_FREE,		"disable_on_free"),	\
 		C(IRQ_INFO,		"irq-info"),		\
 		C(MARKERS,		"markers"),		\
-		C(FUNCTION,		"function-trace"),	\
+		FUNCTION_FLAGS					\
 		FGRAPH_FLAGS					\
 		BRANCH_FLAGS
 
diff --git a/kernel/trace/trace_irqsoff.c b/kernel/trace/trace_irqsoff.c
index bd9cd0e2c13c..c834b95cbe0b 100644
--- a/kernel/trace/trace_irqsoff.c
+++ b/kernel/trace/trace_irqsoff.c
@@ -31,7 +31,6 @@ enum {
 static int trace_type __read_mostly;
 
 static int save_flags;
-static bool function_enabled;
 
 static void stop_irqsoff_tracer(struct trace_array *tr, int graph);
 static int start_irqsoff_tracer(struct trace_array *tr, int graph);
@@ -249,21 +248,23 @@ __trace_function(struct trace_array *tr,
 #else
 #define __trace_function trace_function
 
+#ifdef CONFIG_FUNCTION_TRACER
 static int irqsoff_graph_entry(struct ftrace_graph_ent *trace)
 {
 	return -1;
 }
+#endif
 
 static enum print_line_t irqsoff_print_line(struct trace_iterator *iter)
 {
 	return TRACE_TYPE_UNHANDLED;
 }
 
-static void irqsoff_graph_return(struct ftrace_graph_ret *trace) { }
 static void irqsoff_trace_open(struct trace_iterator *iter) { }
 static void irqsoff_trace_close(struct trace_iterator *iter) { }
 
 #ifdef CONFIG_FUNCTION_TRACER
+static void irqsoff_graph_return(struct ftrace_graph_ret *trace) { }
 static void irqsoff_print_header(struct seq_file *s)
 {
 	trace_default_header(s);
@@ -507,6 +508,9 @@ void trace_preempt_off(unsigned long a0, unsigned long a1)
 }
 #endif /* CONFIG_PREEMPT_TRACER */
 
+#ifdef CONFIG_FUNCTION_TRACER
+static bool function_enabled;
+
 static int register_irqsoff_function(struct trace_array *tr, int graph, int set)
 {
 	int ret;
@@ -540,21 +544,35 @@ static void unregister_irqsoff_function(struct trace_array *tr, int graph)
 	function_enabled = false;
 }
 
-static int irqsoff_function_set(struct trace_array *tr, int set)
+static int irqsoff_function_set(struct trace_array *tr, u32 mask, int set)
 {
+	if (!(mask & TRACE_ITER_FUNCTION))
+		return 0;
+
 	if (set)
 		register_irqsoff_function(tr, is_graph(), 1);
 	else
 		unregister_irqsoff_function(tr, is_graph());
+	return 1;
+}
+#else
+static int register_irqsoff_function(struct trace_array *tr, int graph, int set)
+{
 	return 0;
 }
+static void unregister_irqsoff_function(struct trace_array *tr, int graph) { }
+static inline int irqsoff_function_set(struct trace_array *tr, u32 mask, int set)
+{
+	return 0;
+}
+#endif /* CONFIG_FUNCTION_TRACER */
 
 static int irqsoff_flag_changed(struct trace_array *tr, u32 mask, int set)
 {
 	struct tracer *tracer = tr->current_trace;
 
-	if (mask & TRACE_ITER_FUNCTION)
-		return irqsoff_function_set(tr, set);
+	if (irqsoff_function_set(tr, mask, set))
+		return 0;
 
 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
 	if (mask & TRACE_ITER_DISPLAY_GRAPH)
diff --git a/kernel/trace/trace_sched_wakeup.c b/kernel/trace/trace_sched_wakeup.c
index a6c350c681cc..4a20f61274d1 100644
--- a/kernel/trace/trace_sched_wakeup.c
+++ b/kernel/trace/trace_sched_wakeup.c
@@ -34,11 +34,8 @@ static arch_spinlock_t wakeup_lock =
 
 static void wakeup_reset(struct trace_array *tr);
 static void __wakeup_reset(struct trace_array *tr);
-static int wakeup_graph_entry(struct ftrace_graph_ent *trace);
-static void wakeup_graph_return(struct ftrace_graph_ret *trace);
 
 static int save_flags;
-static bool function_enabled;
 
 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
 static int wakeup_display_graph(struct trace_array *tr, int set);
@@ -46,7 +43,7 @@ static int wakeup_display_graph(struct trace_array *tr, int set);
 #else
 static inline int wakeup_display_graph(struct trace_array *tr, int set)
 {
-	return -EINVAL;
+	return 0;
 }
 # define is_graph() false
 #endif
@@ -54,6 +51,11 @@ static inline int wakeup_display_graph(struct trace_array *tr, int set)
 
 #ifdef CONFIG_FUNCTION_TRACER
 
+static int wakeup_graph_entry(struct ftrace_graph_ent *trace);
+static void wakeup_graph_return(struct ftrace_graph_ret *trace);
+
+static bool function_enabled;
+
 /*
  * Prologue for the wakeup function tracers.
  *
@@ -123,7 +125,6 @@ wakeup_tracer_call(unsigned long ip, unsigned long parent_ip,
 	atomic_dec(&data->disabled);
 	preempt_enable_notrace();
 }
-#endif /* CONFIG_FUNCTION_TRACER */
 
 static int register_wakeup_function(struct trace_array *tr, int graph, int set)
 {
@@ -158,21 +159,35 @@ static void unregister_wakeup_function(struct trace_array *tr, int graph)
 	function_enabled = false;
 }
 
-static int wakeup_function_set(struct trace_array *tr, int set)
+static int wakeup_function_set(struct trace_array *tr, u32 mask, int set)
 {
+	if (!(mask & TRACE_ITER_FUNCTION))
+		return 0;
+
 	if (set)
 		register_wakeup_function(tr, is_graph(), 1);
 	else
 		unregister_wakeup_function(tr, is_graph());
+	return 1;
+}
+#else
+static int register_wakeup_function(struct trace_array *tr, int graph, int set)
+{
 	return 0;
 }
+static void unregister_wakeup_function(struct trace_array *tr, int graph) { }
+static int wakeup_function_set(struct trace_array *tr, u32 mask, int set)
+{
+	return 0;
+}
+#endif /* CONFIG_FUNCTION_TRACER */
 
 static int wakeup_flag_changed(struct trace_array *tr, u32 mask, int set)
 {
 	struct tracer *tracer = tr->current_trace;
 
-	if (mask & TRACE_ITER_FUNCTION)
-		return wakeup_function_set(tr, set);
+	if (wakeup_function_set(tr, mask, set))
+		return 0;
 
 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
 	if (mask & TRACE_ITER_DISPLAY_GRAPH)
@@ -302,21 +317,20 @@ __trace_function(struct trace_array *tr,
 #else
 #define __trace_function trace_function
 
-static int wakeup_graph_entry(struct ftrace_graph_ent *trace)
-{
-	return -1;
-}
-
 static enum print_line_t wakeup_print_line(struct trace_iterator *iter)
 {
 	return TRACE_TYPE_UNHANDLED;
 }
 
-static void wakeup_graph_return(struct ftrace_graph_ret *trace) { }
 static void wakeup_trace_open(struct trace_iterator *iter) { }
 static void wakeup_trace_close(struct trace_iterator *iter) { }
 
 #ifdef CONFIG_FUNCTION_TRACER
+static int wakeup_graph_entry(struct ftrace_graph_ent *trace)
+{
+	return -1;
+}
+static void wakeup_graph_return(struct ftrace_graph_ret *trace) { }
 static void wakeup_print_header(struct seq_file *s)
 {
 	trace_default_header(s);
-- 
2.5.1



  parent reply	other threads:[~2015-10-01 12:01 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-01 11:55 [for-next][PATCH 00/25] tracing: Have instances have their own options + clean ups Steven Rostedt
2015-10-01 11:55 ` [for-next][PATCH 01/25] kernel/trace_probe: is_good_name can be boolean Steven Rostedt
2015-10-01 11:55 ` [for-next][PATCH 02/25] tracing: Move non perf code out of perf.h Steven Rostedt
2015-10-01 11:55 ` [for-next][PATCH 03/25] tracing: Remove ftrace_trace_stack_regs() Steven Rostedt
2015-10-01 11:55 ` [for-next][PATCH 04/25] tracing: Remove unused function trace_current_buffer_lock_reserve() Steven Rostedt
2015-10-01 11:55 ` [for-next][PATCH 05/25] tracing: Pass trace_array into trace_buffer_unlock_commit() Steven Rostedt
2015-10-01 11:55 ` [for-next][PATCH 06/25] tracing: Make ftrace_trace_stack() static Steven Rostedt
2015-10-01 11:55 ` [for-next][PATCH 07/25] tracing: Inject seq_print_userip_objs() into its only user Steven Rostedt
2015-10-01 11:55 ` [for-next][PATCH 08/25] tracing: Turn seq_print_user_ip() into a static function Steven Rostedt
2015-10-01 11:55 ` [for-next][PATCH 09/25] tracing: Move "display-graph" option to main options Steven Rostedt
2015-10-01 11:55 ` [for-next][PATCH 10/25] tracing: Remove unused tracing option "ftrace_preempt" Steven Rostedt
2015-10-01 11:55 ` [for-next][PATCH 11/25] tracing: Use enums instead of hard coded bitmasks for TRACE_ITER flags Steven Rostedt
2015-10-01 11:55 ` [for-next][PATCH 12/25] tracing: Use TRACE_FLAGS macro to keep enums and strings matched Steven Rostedt
2015-10-01 11:55 ` [for-next][PATCH 13/25] tracing: Only create function graph options when it is compiled in Steven Rostedt
2015-10-01 11:55 ` [for-next][PATCH 14/25] tracing: Only create branch tracer options when " Steven Rostedt
2015-10-01 11:55 ` Steven Rostedt [this message]
2015-10-01 11:55 ` [for-next][PATCH 16/25] tracing: Only create stacktrace option when STACKTRACE is configured Steven Rostedt
2015-10-01 11:55 ` [for-next][PATCH 17/25] tracing: Always show all tracer options in the options directory Steven Rostedt
2015-10-01 11:55 ` [for-next][PATCH 18/25] tracing: Add build bug if we have more trace_flags than bits Steven Rostedt
2015-10-01 11:55 ` [for-next][PATCH 19/25] tracing: Remove access to trace_flags in trace_printk.c Steven Rostedt
2015-10-01 11:55 ` [for-next][PATCH 20/25] tracing: Move sleep-time and graph-time options out of the core trace_flags Steven Rostedt
2015-10-01 11:55 ` [for-next][PATCH 21/25] tracing: Move trace_flags from global to a trace_array field Steven Rostedt
2015-10-01 11:55 ` [for-next][PATCH 22/25] tracing: Add a method to pass in trace_array descriptor to option files Steven Rostedt
2015-10-01 11:55 ` [for-next][PATCH 23/25] tracing: Make ftrace_trace_stack() depend on general trace_array flag Steven Rostedt
2015-10-01 11:55 ` [for-next][PATCH 24/25] tracing: Add trace options for core options to instances Steven Rostedt
2015-10-01 11:55 ` [for-next][PATCH 25/25] tracing: Add trace options for tracer " Steven Rostedt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20151001115638.586772817@goodmis.org \
    --to=rostedt@goodmis.org \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.