linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [for-next][PATCH 0/7] tracing: Some last updates for 4.8
@ 2016-07-16  7:16 Steven Rostedt
  2016-07-16  7:16 ` [for-next][PATCH 1/7] tracing: Using for_each_set_bit() to simplify trace_pid_write() Steven Rostedt
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: Steven Rostedt @ 2016-07-16  7:16 UTC (permalink / raw)
  To: linux-kernel; +Cc: Ingo Molnar, Andrew Morton

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

Head SHA1: 78aebca2c955c1c5aeb48e12645e13fe3c3461f2


Daniel Bristot de Oliveira (4):
      tracing: Use outer () on __get_str() definition
      tracing, RAS: Cleanup on __get_str() usage
      tracing: Use __get_str() when manipulating strings
      printk, tracing: Avoiding unneeded blank lines

Namhyung Kim (1):
      ftrace: Reduce size of function graph entries

Tom Zanussi (1):
      tracing: Have HIST_TRIGGERS select TRACING

Wei Yongjun (1):
      tracing: Using for_each_set_bit() to simplify trace_pid_write()

----
 fs/nfs/nfs4trace.h            |  4 ++--
 fs/nfs/nfstrace.h             |  4 ++--
 include/linux/ftrace.h        | 12 ++++++++----
 include/ras/ras_event.h       |  4 ++--
 include/trace/events/printk.h | 12 ++++++++++--
 include/trace/perf.h          |  2 +-
 include/trace/trace_events.h  |  2 +-
 kernel/trace/Kconfig          |  1 +
 kernel/trace/trace.c          |  8 ++------
 kernel/trace/trace.h          | 11 +++++++++++
 kernel/trace/trace_entries.h  |  4 ++--
 11 files changed, 42 insertions(+), 22 deletions(-)

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

* [for-next][PATCH 1/7] tracing: Using for_each_set_bit() to simplify trace_pid_write()
  2016-07-16  7:16 [for-next][PATCH 0/7] tracing: Some last updates for 4.8 Steven Rostedt
@ 2016-07-16  7:16 ` Steven Rostedt
  2016-07-16  7:16 ` [for-next][PATCH 2/7] tracing: Have HIST_TRIGGERS select TRACING Steven Rostedt
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Steven Rostedt @ 2016-07-16  7:16 UTC (permalink / raw)
  To: linux-kernel; +Cc: Ingo Molnar, Andrew Morton, Wei Yongjun

[-- Attachment #1: 0001-tracing-Using-for_each_set_bit-to-simplify-trace_pid.patch --]
[-- Type: text/plain, Size: 1050 bytes --]

From: Wei Yongjun <yongjun_wei@trendmicro.com.cn>

Using for_each_set_bit() to simplify the code.

Link: http://lkml.kernel.org/r/1467645004-11169-1-git-send-email-weiyj_lk@163.com

Signed-off-by: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
 kernel/trace/trace.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index 5fd53a7847bc..dade4c9559cc 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -517,13 +517,9 @@ int trace_pid_write(struct trace_pid_list *filtered_pids,
 
 	if (filtered_pids) {
 		/* copy the current bits to the new max */
-		pid = find_first_bit(filtered_pids->pids,
-				     filtered_pids->pid_max);
-		while (pid < filtered_pids->pid_max) {
+		for_each_set_bit(pid, filtered_pids->pids,
+				 filtered_pids->pid_max) {
 			set_bit(pid, pid_list->pids);
-			pid = find_next_bit(filtered_pids->pids,
-					    filtered_pids->pid_max,
-					    pid + 1);
 			nr_pids++;
 		}
 	}
-- 
2.8.1

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

* [for-next][PATCH 2/7] tracing: Have HIST_TRIGGERS select TRACING
  2016-07-16  7:16 [for-next][PATCH 0/7] tracing: Some last updates for 4.8 Steven Rostedt
  2016-07-16  7:16 ` [for-next][PATCH 1/7] tracing: Using for_each_set_bit() to simplify trace_pid_write() Steven Rostedt
@ 2016-07-16  7:16 ` Steven Rostedt
  2016-07-16  7:16 ` [for-next][PATCH 3/7] ftrace: Reduce size of function graph entries Steven Rostedt
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Steven Rostedt @ 2016-07-16  7:16 UTC (permalink / raw)
  To: linux-kernel; +Cc: Ingo Molnar, Andrew Morton, kbuild test robot, Tom Zanussi

[-- Attachment #1: 0002-tracing-Have-HIST_TRIGGERS-select-TRACING.patch --]
[-- Type: text/plain, Size: 1019 bytes --]

From: Tom Zanussi <tom.zanussi@linux.intel.com>

The kbuild test robot reported a compile error if HIST_TRIGGERS was
enabled but nothing else that selected TRACING was configured in.

HIST_TRIGGERS should directly select it and not rely on anything else
to do it.

Link: http://lkml.kernel.org/r/57791866.8080505@linux.intel.com

Reported-by: kbuild test robot <fennguang.wu@intel.com>
Fixes: 7ef224d1d0e3a ("tracing: Add 'hist' event trigger command")
Signed-off-by: Tom Zanussi <tom.zanussi@linux.intel.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
 kernel/trace/Kconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/kernel/trace/Kconfig b/kernel/trace/Kconfig
index fafeaf803bd0..f4b86e8ca1e7 100644
--- a/kernel/trace/Kconfig
+++ b/kernel/trace/Kconfig
@@ -542,6 +542,7 @@ config HIST_TRIGGERS
 	bool "Histogram triggers"
 	depends on ARCH_HAVE_NMI_SAFE_CMPXCHG
 	select TRACING_MAP
+	select TRACING
 	default n
 	help
 	  Hist triggers allow one or more arbitrary trace event fields
-- 
2.8.1

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

* [for-next][PATCH 3/7] ftrace: Reduce size of function graph entries
  2016-07-16  7:16 [for-next][PATCH 0/7] tracing: Some last updates for 4.8 Steven Rostedt
  2016-07-16  7:16 ` [for-next][PATCH 1/7] tracing: Using for_each_set_bit() to simplify trace_pid_write() Steven Rostedt
  2016-07-16  7:16 ` [for-next][PATCH 2/7] tracing: Have HIST_TRIGGERS select TRACING Steven Rostedt
@ 2016-07-16  7:16 ` Steven Rostedt
  2016-07-16  7:16 ` [for-next][PATCH 4/7] tracing: Use outer () on __get_str() definition Steven Rostedt
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Steven Rostedt @ 2016-07-16  7:16 UTC (permalink / raw)
  To: linux-kernel; +Cc: Ingo Molnar, Andrew Morton, linux-arch, Namhyung Kim

[-- Attachment #1: 0003-ftrace-Reduce-size-of-function-graph-entries.patch --]
[-- Type: text/plain, Size: 3925 bytes --]

From: Namhyung Kim <namhyung@kernel.org>

Currently ftrace_graph_ent{,_entry} and ftrace_graph_ret{,_entry} struct
can have padding bytes at the end due to alignment in 64-bit data type.
As these data are recorded so frequently, those paddings waste
non-negligible space.  As the ring buffer maintains alignment properly
for each architecture, just to remove the extra padding using 'packed'
attribute.

  ftrace_graph_ent_entry:  24 -> 20
  ftrace_graph_ret_entry:  48 -> 44

Also I moved the 'overrun' field in struct ftrace_graph_ret to minimize
the padding in the middle.

Tested on x86_64 only.

Link: http://lkml.kernel.org/r/1467197808-13578-1-git-send-email-namhyung@kernel.org

Cc: Ingo Molnar <mingo@kernel.org>
Cc: linux-arch@vger.kernel.org
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
 include/linux/ftrace.h       | 12 ++++++++----
 kernel/trace/trace.h         | 11 +++++++++++
 kernel/trace/trace_entries.h |  4 ++--
 3 files changed, 21 insertions(+), 6 deletions(-)

diff --git a/include/linux/ftrace.h b/include/linux/ftrace.h
index 66a36a815f0a..7d565afe35d2 100644
--- a/include/linux/ftrace.h
+++ b/include/linux/ftrace.h
@@ -754,23 +754,27 @@ static inline void ftrace_init(void) { }
 
 /*
  * Structure that defines an entry function trace.
+ * It's already packed but the attribute "packed" is needed
+ * to remove extra padding at the end.
  */
 struct ftrace_graph_ent {
 	unsigned long func; /* Current function */
 	int depth;
-};
+} __packed;
 
 /*
  * Structure that defines a return function trace.
+ * It's already packed but the attribute "packed" is needed
+ * to remove extra padding at the end.
  */
 struct ftrace_graph_ret {
 	unsigned long func; /* Current function */
-	unsigned long long calltime;
-	unsigned long long rettime;
 	/* Number of functions that overran the depth limit for current task */
 	unsigned long overrun;
+	unsigned long long calltime;
+	unsigned long long rettime;
 	int depth;
-};
+} __packed;
 
 /* Type of the callback handlers for tracing function graph*/
 typedef void (*trace_func_graph_ret_t)(struct ftrace_graph_ret *); /* return */
diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h
index c1de3f493cd3..f783df416726 100644
--- a/kernel/trace/trace.h
+++ b/kernel/trace/trace.h
@@ -80,6 +80,12 @@ enum trace_type {
 	FTRACE_ENTRY(name, struct_name, id, PARAMS(tstruct), PARAMS(print), \
 		     filter)
 
+#undef FTRACE_ENTRY_PACKED
+#define FTRACE_ENTRY_PACKED(name, struct_name, id, tstruct, print,	\
+			    filter)					\
+	FTRACE_ENTRY(name, struct_name, id, PARAMS(tstruct), PARAMS(print), \
+		     filter) __packed
+
 #include "trace_entries.h"
 
 /*
@@ -1625,6 +1631,11 @@ int set_tracer_flag(struct trace_array *tr, unsigned int mask, int enabled);
 #define FTRACE_ENTRY_DUP(call, struct_name, id, tstruct, print, filter)	\
 	FTRACE_ENTRY(call, struct_name, id, PARAMS(tstruct), PARAMS(print), \
 		     filter)
+#undef FTRACE_ENTRY_PACKED
+#define FTRACE_ENTRY_PACKED(call, struct_name, id, tstruct, print, filter) \
+	FTRACE_ENTRY(call, struct_name, id, PARAMS(tstruct), PARAMS(print), \
+		     filter)
+
 #include "trace_entries.h"
 
 #if defined(CONFIG_PERF_EVENTS) && defined(CONFIG_FUNCTION_TRACER)
diff --git a/kernel/trace/trace_entries.h b/kernel/trace/trace_entries.h
index ee7b94a4810a..5c30efcda5e6 100644
--- a/kernel/trace/trace_entries.h
+++ b/kernel/trace/trace_entries.h
@@ -72,7 +72,7 @@ FTRACE_ENTRY_REG(function, ftrace_entry,
 );
 
 /* Function call entry */
-FTRACE_ENTRY(funcgraph_entry, ftrace_graph_ent_entry,
+FTRACE_ENTRY_PACKED(funcgraph_entry, ftrace_graph_ent_entry,
 
 	TRACE_GRAPH_ENT,
 
@@ -88,7 +88,7 @@ FTRACE_ENTRY(funcgraph_entry, ftrace_graph_ent_entry,
 );
 
 /* Function return entry */
-FTRACE_ENTRY(funcgraph_exit, ftrace_graph_ret_entry,
+FTRACE_ENTRY_PACKED(funcgraph_exit, ftrace_graph_ret_entry,
 
 	TRACE_GRAPH_RET,
 
-- 
2.8.1

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

* [for-next][PATCH 4/7] tracing: Use outer () on __get_str() definition
  2016-07-16  7:16 [for-next][PATCH 0/7] tracing: Some last updates for 4.8 Steven Rostedt
                   ` (2 preceding siblings ...)
  2016-07-16  7:16 ` [for-next][PATCH 3/7] ftrace: Reduce size of function graph entries Steven Rostedt
@ 2016-07-16  7:16 ` Steven Rostedt
  2016-07-16  7:16 ` [for-next][PATCH 5/7] tracing, RAS: Cleanup on __get_str() usage Steven Rostedt
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Steven Rostedt @ 2016-07-16  7:16 UTC (permalink / raw)
  To: linux-kernel
  Cc: Ingo Molnar, Andrew Morton, Trond Myklebust, Anna Schumaker,
	Ingo Molnar, Daniel Bristot de Oliveira

[-- Attachment #1: 0004-tracing-Use-outer-on-__get_str-definition.patch --]
[-- Type: text/plain, Size: 1776 bytes --]

From: Daniel Bristot de Oliveira <bristot@redhat.com>

__get_str(str)'s definition includes a (char *) operator
overloading that is not protected with outer ().

This patch adds () around __get_str()'s definition, enabling
some code cleanup.

Link: http://lkml.kernel.org/r/20ac1a10c2ec4ccd23e4a8ef34101fb6e4157d37.1467407618.git.bristot@redhat.com

Cc: Trond Myklebust <trond.myklebust@primarydata.com>
Cc: Anna Schumaker <anna.schumaker@netapp.com>
Cc: Ingo Molnar <mingo@redhat.com>
Suggested-by: Steven Rostedt <rostedt@goodmis.org>
Reviewed-by: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Daniel Bristot de Oliveira <bristot@redhat.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
 include/trace/perf.h         | 2 +-
 include/trace/trace_events.h | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/trace/perf.h b/include/trace/perf.h
index 88de5c205e86..04fe68bbe767 100644
--- a/include/trace/perf.h
+++ b/include/trace/perf.h
@@ -15,7 +15,7 @@
 		((__entry->__data_loc_##field >> 16) & 0xffff)
 
 #undef __get_str
-#define __get_str(field) (char *)__get_dynamic_array(field)
+#define __get_str(field) ((char *)__get_dynamic_array(field))
 
 #undef __get_bitmask
 #define __get_bitmask(field) (char *)__get_dynamic_array(field)
diff --git a/include/trace/trace_events.h b/include/trace/trace_events.h
index 80679a9fae65..467e12f780d8 100644
--- a/include/trace/trace_events.h
+++ b/include/trace/trace_events.h
@@ -256,7 +256,7 @@ TRACE_MAKE_SYSTEM_STR();
 		((__entry->__data_loc_##field >> 16) & 0xffff)
 
 #undef __get_str
-#define __get_str(field) (char *)__get_dynamic_array(field)
+#define __get_str(field) ((char *)__get_dynamic_array(field))
 
 #undef __get_bitmask
 #define __get_bitmask(field)						\
-- 
2.8.1

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

* [for-next][PATCH 5/7] tracing, RAS: Cleanup on __get_str() usage
  2016-07-16  7:16 [for-next][PATCH 0/7] tracing: Some last updates for 4.8 Steven Rostedt
                   ` (3 preceding siblings ...)
  2016-07-16  7:16 ` [for-next][PATCH 4/7] tracing: Use outer () on __get_str() definition Steven Rostedt
@ 2016-07-16  7:16 ` Steven Rostedt
  2016-07-16  7:16 ` [for-next][PATCH 6/7] tracing: Use __get_str() when manipulating strings Steven Rostedt
  2016-07-16  7:16 ` [for-next][PATCH 7/7] printk, tracing: Avoiding unneeded blank lines Steven Rostedt
  6 siblings, 0 replies; 8+ messages in thread
From: Steven Rostedt @ 2016-07-16  7:16 UTC (permalink / raw)
  To: linux-kernel
  Cc: Ingo Molnar, Andrew Morton, Trond Myklebust, Anna Schumaker,
	Ingo Molnar, Daniel Bristot de Oliveira

[-- Attachment #1: 0005-tracing-RAS-Cleanup-on-__get_str-usage.patch --]
[-- Type: text/plain, Size: 1518 bytes --]

From: Daniel Bristot de Oliveira <bristot@redhat.com>

__get_str(msg) does not need (char *) operator overloading to access
mgs's elements anymore. This patch substitutes
((char *)__get_str(msg))[0] usage to __get_str(msg)[0].

It is just a code cleanup, no changes on tracepoint ABI.

Link: http://lkml.kernel.org/r/6f2db5be7705da2cb483923320c91283d7c712a7.1467407618.git.bristot@redhat.com

Cc: Trond Myklebust <trond.myklebust@primarydata.com>
Cc: Anna Schumaker <anna.schumaker@netapp.com>
Cc: Ingo Molnar <mingo@redhat.com>
Reviewed-by: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Daniel Bristot de Oliveira <bristot@redhat.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
 include/ras/ras_event.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/ras/ras_event.h b/include/ras/ras_event.h
index 1443d79e4fe6..1791a12cfa85 100644
--- a/include/ras/ras_event.h
+++ b/include/ras/ras_event.h
@@ -147,7 +147,7 @@ TRACE_EVENT(mc_event,
 		  __entry->error_count,
 		  mc_event_error_type(__entry->error_type),
 		  __entry->error_count > 1 ? "s" : "",
-		  ((char *)__get_str(msg))[0] ? " " : "",
+		  __get_str(msg)[0] ? " " : "",
 		  __get_str(msg),
 		  __get_str(label),
 		  __entry->mc_index,
@@ -157,7 +157,7 @@ TRACE_EVENT(mc_event,
 		  __entry->address,
 		  1 << __entry->grain_bits,
 		  __entry->syndrome,
-		  ((char *)__get_str(driver_detail))[0] ? " " : "",
+		  __get_str(driver_detail)[0] ? " " : "",
 		  __get_str(driver_detail))
 );
 
-- 
2.8.1

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

* [for-next][PATCH 6/7] tracing: Use __get_str() when manipulating strings
  2016-07-16  7:16 [for-next][PATCH 0/7] tracing: Some last updates for 4.8 Steven Rostedt
                   ` (4 preceding siblings ...)
  2016-07-16  7:16 ` [for-next][PATCH 5/7] tracing, RAS: Cleanup on __get_str() usage Steven Rostedt
@ 2016-07-16  7:16 ` Steven Rostedt
  2016-07-16  7:16 ` [for-next][PATCH 7/7] printk, tracing: Avoiding unneeded blank lines Steven Rostedt
  6 siblings, 0 replies; 8+ messages in thread
From: Steven Rostedt @ 2016-07-16  7:16 UTC (permalink / raw)
  To: linux-kernel
  Cc: Ingo Molnar, Andrew Morton, Trond Myklebust, Anna Schumaker,
	Ingo Molnar, linux-nfs, Daniel Bristot de Oliveira

[-- Attachment #1: 0006-tracing-Use-__get_str-when-manipulating-strings.patch --]
[-- Type: text/plain, Size: 2298 bytes --]

From: Daniel Bristot de Oliveira <bristot@redhat.com>

Use __get_str(str) rather than __get_dynamic_array(str) when
deadling with strings.

It is just a code cleanup, no changes on tracepoint ABI.

Link: http://lkml.kernel.org/r/ea260df91817411cca2a1f3db2abd88860094788.1467407618.git.bristot@redhat.com

Cc: Trond Myklebust <trond.myklebust@primarydata.com>
Cc: Anna Schumaker <anna.schumaker@netapp.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: linux-nfs@vger.kernel.org
Suggested-by: Steven Rostedt <rostedt@goodmis.org>
Reviewed-by: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Daniel Bristot de Oliveira <bristot@redhat.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
 fs/nfs/nfs4trace.h            | 4 ++--
 fs/nfs/nfstrace.h             | 4 ++--
 include/trace/events/printk.h | 4 ++--
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/fs/nfs/nfs4trace.h b/fs/nfs/nfs4trace.h
index 9c150b153782..cfb8f7ce5cf6 100644
--- a/fs/nfs/nfs4trace.h
+++ b/fs/nfs/nfs4trace.h
@@ -1235,8 +1235,8 @@ DECLARE_EVENT_CLASS(nfs4_idmap_event,
 				len = 0;
 			__entry->error = error < 0 ? error : 0;
 			__entry->id = id;
-			memcpy(__get_dynamic_array(name), name, len);
-			((char *)__get_dynamic_array(name))[len] = 0;
+			memcpy(__get_str(name), name, len);
+			__get_str(name)[len] = 0;
 		),
 
 		TP_printk(
diff --git a/fs/nfs/nfstrace.h b/fs/nfs/nfstrace.h
index 0b9e5cc9a747..31c7763b94d5 100644
--- a/fs/nfs/nfstrace.h
+++ b/fs/nfs/nfstrace.h
@@ -707,9 +707,9 @@ TRACE_EVENT(nfs_sillyrename_unlink,
 			__entry->dev = dir->i_sb->s_dev;
 			__entry->dir = NFS_FILEID(dir);
 			__entry->error = error;
-			memcpy(__get_dynamic_array(name),
+			memcpy(__get_str(name),
 				data->args.name.name, len);
-			((char *)__get_dynamic_array(name))[len] = 0;
+			__get_str(name)[len] = 0;
 		),
 
 		TP_printk(
diff --git a/include/trace/events/printk.h b/include/trace/events/printk.h
index c008bc99f9fa..542a7558154a 100644
--- a/include/trace/events/printk.h
+++ b/include/trace/events/printk.h
@@ -16,8 +16,8 @@ TRACE_EVENT(console,
 	),
 
 	TP_fast_assign(
-		memcpy(__get_dynamic_array(msg), text, len);
-		((char *)__get_dynamic_array(msg))[len] = 0;
+		memcpy(__get_str(msg), text, len);
+		__get_str(msg)[len] = 0;
 	),
 
 	TP_printk("%s", __get_str(msg))
-- 
2.8.1

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

* [for-next][PATCH 7/7] printk, tracing: Avoiding unneeded blank lines
  2016-07-16  7:16 [for-next][PATCH 0/7] tracing: Some last updates for 4.8 Steven Rostedt
                   ` (5 preceding siblings ...)
  2016-07-16  7:16 ` [for-next][PATCH 6/7] tracing: Use __get_str() when manipulating strings Steven Rostedt
@ 2016-07-16  7:16 ` Steven Rostedt
  6 siblings, 0 replies; 8+ messages in thread
From: Steven Rostedt @ 2016-07-16  7:16 UTC (permalink / raw)
  To: linux-kernel
  Cc: Ingo Molnar, Andrew Morton, Trond Myklebust, Anna Schumaker,
	Ingo Molnar, Daniel Bristot de Oliveira

[-- Attachment #1: 0007-printk-tracing-Avoiding-unneeded-blank-lines.patch --]
[-- Type: text/plain, Size: 2297 bytes --]

From: Daniel Bristot de Oliveira <bristot@redhat.com>

Printk messages often finish with '\n' to cause a new line.
But as each tracepoint is already printed in a new line,
printk messages that finish with '\n' ends up adding a blank
line to the trace output. For example:

     kworker/0:1-86    [000] d...    46.006949: console: [   46.006946] usb 1-3: USB disconnect, device number 3

     kworker/2:2-374   [002] d...    48.699342: console: [   48.699339] usb 1-3: new high-speed USB device number 4 using ehci-pci

     kworker/2:2-374   [002] d...    49.041450: console: [   49.041448] usb 1-3: New USB device found, idVendor=5986, idProduct=0

To avoid unneeded blank lines, this patch checks if the printk
message finishes with '\n', if so, it cut is off the '\n' to
avoid blank lines.

In a patched kernel, the same messages are printed without
extra blank lines. For example:

     kworker/0:4-185   [000] d...    23.641738: console: [   23.641736] usb 1-3: USB disconnect, device number 3
     kworker/0:4-185   [000] d...    24.918703: console: [   24.918700] usb 1-3: new high-speed USB device number 4 using ehci-pci
     kworker/0:4-185   [000] d...    25.228308: console: [   25.228306] usb 1-3: New USB device found, idVendor=5986, idProduct=02d5

Link: http://lkml.kernel.org/r/c350fb2521baaf681a1b4d67981ca0e900108e8e.1467407618.git.bristot@redhat.com

Cc: Trond Myklebust <trond.myklebust@primarydata.com>
Cc: Anna Schumaker <anna.schumaker@netapp.com>
Cc: Ingo Molnar <mingo@redhat.com>
Reviewed-by: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Daniel Bristot de Oliveira <bristot@redhat.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
 include/trace/events/printk.h | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/include/trace/events/printk.h b/include/trace/events/printk.h
index 542a7558154a..f350170059c6 100644
--- a/include/trace/events/printk.h
+++ b/include/trace/events/printk.h
@@ -16,6 +16,14 @@ TRACE_EVENT(console,
 	),
 
 	TP_fast_assign(
+		/*
+		 * Each trace entry is printed in a new line.
+		 * If the msg finishes with '\n', cut it off
+		 * to avoid blank lines in the trace.
+		 */
+		if ((len > 0) && (text[len-1] == '\n'))
+			len -= 1;
+
 		memcpy(__get_str(msg), text, len);
 		__get_str(msg)[len] = 0;
 	),
-- 
2.8.1

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

end of thread, other threads:[~2016-07-16  7:17 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-07-16  7:16 [for-next][PATCH 0/7] tracing: Some last updates for 4.8 Steven Rostedt
2016-07-16  7:16 ` [for-next][PATCH 1/7] tracing: Using for_each_set_bit() to simplify trace_pid_write() Steven Rostedt
2016-07-16  7:16 ` [for-next][PATCH 2/7] tracing: Have HIST_TRIGGERS select TRACING Steven Rostedt
2016-07-16  7:16 ` [for-next][PATCH 3/7] ftrace: Reduce size of function graph entries Steven Rostedt
2016-07-16  7:16 ` [for-next][PATCH 4/7] tracing: Use outer () on __get_str() definition Steven Rostedt
2016-07-16  7:16 ` [for-next][PATCH 5/7] tracing, RAS: Cleanup on __get_str() usage Steven Rostedt
2016-07-16  7:16 ` [for-next][PATCH 6/7] tracing: Use __get_str() when manipulating strings Steven Rostedt
2016-07-16  7:16 ` [for-next][PATCH 7/7] printk, tracing: Avoiding unneeded blank lines Steven Rostedt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).