Skip to contentSkip to conversation

ftrace: Add initialization check in trace_printk for *puts paths

PATCH Superseded Jiri Olsa 3 participants 5 messages Aug 12, 2013 Tracing

lore
Share & tools
lore

Jiri Olsa

author
#0 lore raw

PATCH 1/1 ftrace: Add initialization check in trace_printk for *puts paths

Adding initialization check in trace_printk for *puts paths, plus unifying the check for all related cases.

Cc Steven Rostedt <[email protected]>
Cc Frederic Weisbecker <[email protected]>
Cc Ingo Molnar <[email protected]>
---
 kernel/trace/trace.c | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)
kernel/trace/trace.c +12 -3
index 882ec1d..cb7cf96 100644
@@ -126,6 +126,9 @@ static char *default_bootup_tracer;
 
 static bool allocate_snapshot;
 
+#define TRACE_PRINTK_DENIED \
+	unlikely(tracing_selftest_running || tracing_disabled)
+
 static int __init set_cmdline_ftrace(char *str)
 {
 	strlcpy(bootup_tracer_buf, str, MAX_TRACER_SIZE);
@@ -430,6 +433,9 @@ int __trace_puts(unsigned long ip, const char *str, int size)
 	unsigned long irq_flags;
 	int alloc;
 
+	if (TRACE_PRINTK_DENIED)
+		return 0;
+
 	alloc = sizeof(*entry) + size + 2; /* possible \n added */
 
 	local_save_flags(irq_flags);
@@ -470,6 +476,9 @@ int __trace_bputs(unsigned long ip, const char *str)
 	unsigned long irq_flags;
 	int size = sizeof(struct bputs_entry);
 
+	if (TRACE_PRINTK_DENIED)
+		return 0;
+
 	local_save_flags(irq_flags);
 	buffer = global_trace.trace_buffer.buffer;
 	event = trace_buffer_lock_reserve(buffer, TRACE_BPUTS, size,
@@ -1757,7 +1766,7 @@ void trace_dump_stack(int skip)
 {
 	unsigned long flags;
 
-	if (tracing_disabled || tracing_selftest_running)
+	if (TRACE_PRINTK_DENIED)
 		return;
 
 	local_save_flags(flags);
@@ -1976,7 +1985,7 @@ int trace_vbprintk(unsigned long ip, const char *fmt, va_list args)
 	char *tbuffer;
 	int len = 0, size, pc;
 
-	if (unlikely(tracing_selftest_running || tracing_disabled))
+	if (TRACE_PRINTK_DENIED)
 		return 0;
 
 	/* Don't pollute graph traces with trace_vprintk internals */
@@ -2032,7 +2041,7 @@ __trace_array_vprintk(struct ring_buffer *buffer,
 	unsigned long flags;
 	char *tbuffer;
 
-	if (tracing_disabled || tracing_selftest_running)
+	if (TRACE_PRINTK_DENIED)
 		return 0;
 
 	/* Don't pollute graph traces with trace_vprintk internals */
Signature · 1 line
1.7.11.7
#1 lore raw
Quoted 7 lines · Jiri Olsa

Adding initialization check in trace_printk for *puts paths, plus unifying the check for all related cases.

Cc Steven Rostedt <[email protected]>
Cc Frederic Weisbecker <[email protected]>
Cc Ingo Molnar <[email protected]>

---

Missed Signed-off-by tag?

Quoted 65 lines
 kernel/trace/trace.c | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)
kernel/trace/trace.c +12 -3
index 882ec1d..cb7cf96 100644
@@ -126,6 +126,9 @@ static char *default_bootup_tracer;
 
 static bool allocate_snapshot;
 
+#define TRACE_PRINTK_DENIED \
+	unlikely(tracing_selftest_running || tracing_disabled)
+
 static int __init set_cmdline_ftrace(char *str)
 {
 	strlcpy(bootup_tracer_buf, str, MAX_TRACER_SIZE);
@@ -430,6 +433,9 @@ int __trace_puts(unsigned long ip, const char *str, int size)
 	unsigned long irq_flags;
 	int alloc;
 
+	if (TRACE_PRINTK_DENIED)
+		return 0;
+
 	alloc = sizeof(*entry) + size + 2; /* possible \n added */
 
 	local_save_flags(irq_flags);
@@ -470,6 +476,9 @@ int __trace_bputs(unsigned long ip, const char *str)
 	unsigned long irq_flags;
 	int size = sizeof(struct bputs_entry);
 
+	if (TRACE_PRINTK_DENIED)
+		return 0;
+
 	local_save_flags(irq_flags);
 	buffer = global_trace.trace_buffer.buffer;
 	event = trace_buffer_lock_reserve(buffer, TRACE_BPUTS, size,
@@ -1757,7 +1766,7 @@ void trace_dump_stack(int skip)
 {
 	unsigned long flags;
 
-	if (tracing_disabled || tracing_selftest_running)
+	if (TRACE_PRINTK_DENIED)
 		return;
 
 	local_save_flags(flags);
@@ -1976,7 +1985,7 @@ int trace_vbprintk(unsigned long ip, const char *fmt, va_list args)
 	char *tbuffer;
 	int len = 0, size, pc;
 
-	if (unlikely(tracing_selftest_running || tracing_disabled))
+	if (TRACE_PRINTK_DENIED)
 		return 0;
 
 	/* Don't pollute graph traces with trace_vprintk internals */
@@ -2032,7 +2041,7 @@ __trace_array_vprintk(struct ring_buffer *buffer,
 	unsigned long flags;
 	char *tbuffer;
 
-	if (tracing_disabled || tracing_selftest_running)
+	if (TRACE_PRINTK_DENIED)
 		return 0;
 
 	/* Don't pollute graph traces with trace_vprintk internals */
maintainer
#3 lore raw
In reply to Jiri Olsa
Quoted 15 lines · On Mon, 12 Aug 2013 11:34:05 +0200 Jiri Olsa <[email protected]> wrote:

Adding initialization check in trace_printk for *puts paths, plus unifying the check for all related cases.

Cc Steven Rostedt <[email protected]>
Cc Frederic Weisbecker <[email protected]>
Cc Ingo Molnar <[email protected]>
---
 kernel/trace/trace.c | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)
kernel/trace/trace.c +0 -0
index 882ec1d..cb7cf96 100644

kernel/trace/trace.c static char *default_bootup_tracer; · line 129

Quoted 4 lines
kernel/trace/trace.c +1 -0
@@ -126,6 +126,9 @@ static char *default_bootup_tracer;
 
 static bool allocate_snapshot;
 
+#define TRACE_PRINTK_DENIED \

s/TRACE_PRINTK_DENIED/TRACE_PRINTK_DISABLED/

-- Steve

Quoted 6 lines
kernel/trace/trace.c +2 -0
+	unlikely(tracing_selftest_running || tracing_disabled)
+
 static int __init set_cmdline_ftrace(char *str)
 {
 	strlcpy(bootup_tracer_buf, str, MAX_TRACER_SIZE);
author
#4 lore raw

PATCH v2 1/1 ftrace: Add initialization check in trace_printk for *puts paths

On Mon, Aug 12, 2013 at 09:07:58AM -0400, Steven Rostedt wrote:

SNIP

Quoted 7 lines
Quoted 3 lines

static bool allocate_snapshot;

+#define TRACE_PRINTK_DENIED \

s/TRACE_PRINTK_DENIED/TRACE_PRINTK_DISABLED/

Quoted 8 lines

-- Steve

Review

Quoted 6 lines
(quoted diff) +2 -0
+	unlikely(tracing_selftest_running || tracing_disabled)
+
 static int __init set_cmdline_ftrace(char *str)
 {
 	strlcpy(bootup_tracer_buf, str, MAX_TRACER_SIZE);

v2 attached, thanks
jirka

---
Adding initialization check in trace_printk for *puts paths, plus unifying the check for all related cases.

Cc Steven Rostedt <[email protected]>
Cc Frederic Weisbecker <[email protected]>
Cc Ingo Molnar <[email protected]>
---
 kernel/trace/trace.c | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)
kernel/trace/trace.c +12 -3
index 496f94d..cef7e55 100644
@@ -126,6 +126,9 @@ static char *default_bootup_tracer;
 
 static bool allocate_snapshot;
 
+#define TRACE_PRINTK_DISABLED \
+	unlikely(tracing_selftest_running || tracing_disabled)
+
 static int __init set_cmdline_ftrace(char *str)
 {
 	strlcpy(bootup_tracer_buf, str, MAX_TRACER_SIZE);
@@ -435,6 +438,9 @@ int __trace_puts(unsigned long ip, const char *str, int size)
 	unsigned long irq_flags;
 	int alloc;
 
+	if (TRACE_PRINTK_DISABLED)
+		return 0;
+
 	alloc = sizeof(*entry) + size + 2; /* possible \n added */
 
 	local_save_flags(irq_flags);
@@ -475,6 +481,9 @@ int __trace_bputs(unsigned long ip, const char *str)
 	unsigned long irq_flags;
 	int size = sizeof(struct bputs_entry);
 
+	if (TRACE_PRINTK_DISABLED)
+		return 0;
+
 	local_save_flags(irq_flags);
 	buffer = global_trace.trace_buffer.buffer;
 	event = trace_buffer_lock_reserve(buffer, TRACE_BPUTS, size,
@@ -1757,7 +1766,7 @@ void trace_dump_stack(int skip)
 {
 	unsigned long flags;
 
-	if (tracing_disabled || tracing_selftest_running)
+	if (TRACE_PRINTK_DISABLED)
 		return;
 
 	local_save_flags(flags);
@@ -1976,7 +1985,7 @@ int trace_vbprintk(unsigned long ip, const char *fmt, va_list args)
 	char *tbuffer;
 	int len = 0, size, pc;
 
-	if (unlikely(tracing_selftest_running || tracing_disabled))
+	if (TRACE_PRINTK_DISABLED)
 		return 0;
 
 	/* Don't pollute graph traces with trace_vprintk internals */
@@ -2032,7 +2041,7 @@ __trace_array_vprintk(struct ring_buffer *buffer,
 	unsigned long flags;
 	char *tbuffer;
 
-	if (tracing_disabled || tracing_selftest_running)
+	if (TRACE_PRINTK_DISABLED)
 		return 0;
 
 	/* Don't pollute graph traces with trace_vprintk internals */
Signature · 1 line
1.7.11.7