linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] [GIT PULL] tracing: A couple more small fixes for 4.15
@ 2018-01-19 17:41 Steven Rostedt
  2018-01-19 17:41 ` [PATCH 1/2] ring-buffer: Fix duplicate results in mapping context to bits in recursive lock Steven Rostedt
  2018-01-19 17:41 ` [PATCH 2/2] tracing: Fix converting enums from the map in trace_event_eval_update() Steven Rostedt
  0 siblings, 2 replies; 3+ messages in thread
From: Steven Rostedt @ 2018-01-19 17:41 UTC (permalink / raw)
  To: linux-kernel; +Cc: Linus Torvalds, Ingo Molnar, Andrew Morton


Linus,

Two more small fixes

 - The conversion of enums into their actual numbers to display
   in the event format file had an off-by-one bug, that could cause
   an enum not to be converted, and break user space parsing tools.

 - A fix to a previous fix to bring back the context recursion checks.
   The interrupt case checks for NMI, IRQ and softirq, but the softirq
   returned the same number regardless if it was set or not, although
   the logic would force it to be set if it were hit.

Please pull the latest trace-v4.15-rc4-3 tree, which can be found at:


  git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace.git
trace-v4.15-rc4-3

Tag SHA1: 731752ff22e86fd5a139de2f1a300cd9746ac870
Head SHA1: 1ebe1eaf2f02784921759992ae1fde1a9bec8fd0


Steven Rostedt (VMware) (2):
      ring-buffer: Fix duplicate results in mapping context to bits in recursive lock
      tracing: Fix converting enum's from the map in trace_event_eval_update()

----
 kernel/trace/ring_buffer.c  |  3 +--
 kernel/trace/trace_events.c | 16 +++++++++++++++-
 2 files changed, 16 insertions(+), 3 deletions(-)

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

* [PATCH 1/2] ring-buffer: Fix duplicate results in mapping context to bits in recursive lock
  2018-01-19 17:41 [PATCH 0/2] [GIT PULL] tracing: A couple more small fixes for 4.15 Steven Rostedt
@ 2018-01-19 17:41 ` Steven Rostedt
  2018-01-19 17:41 ` [PATCH 2/2] tracing: Fix converting enums from the map in trace_event_eval_update() Steven Rostedt
  1 sibling, 0 replies; 3+ messages in thread
From: Steven Rostedt @ 2018-01-19 17:41 UTC (permalink / raw)
  To: linux-kernel; +Cc: Linus Torvalds, Ingo Molnar, Andrew Morton

[-- Attachment #1: 0001-ring-buffer-Fix-duplicate-results-in-mapping-context.patch --]
[-- Type: text/plain, Size: 1295 bytes --]

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

In bringing back the context checks, the code checks first if its normal
(non-interrupt) context, and then for NMI then IRQ then softirq. The final
check is redundant. Since the if branch is only hit if the context is one of
NMI, IRQ, or SOFTIRQ, if it's not NMI or IRQ there's no reason to check if
it is SOFTIRQ. The current code returns the same result even if its not a
SOFTIRQ. Which is confusing.

  pc & SOFTIRQ_OFFSET ? 2 : RB_CTX_SOFTIRQ

Is redundant as RB_CTX_SOFTIRQ *is* 2!

Fixes: a0e3a18f4baf ("ring-buffer: Bring back context level recursive checks")
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
---
 kernel/trace/ring_buffer.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c
index 0cddf60186da..5af2842dea96 100644
--- a/kernel/trace/ring_buffer.c
+++ b/kernel/trace/ring_buffer.c
@@ -2579,8 +2579,7 @@ trace_recursive_lock(struct ring_buffer_per_cpu *cpu_buffer)
 		bit = RB_CTX_NORMAL;
 	else
 		bit = pc & NMI_MASK ? RB_CTX_NMI :
-			pc & HARDIRQ_MASK ? RB_CTX_IRQ :
-			pc & SOFTIRQ_OFFSET ? 2 : RB_CTX_SOFTIRQ;
+			pc & HARDIRQ_MASK ? RB_CTX_IRQ : RB_CTX_SOFTIRQ;
 
 	if (unlikely(val & (1 << bit)))
 		return 1;
-- 
2.13.2

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

* [PATCH 2/2] tracing: Fix converting enums from the map in trace_event_eval_update()
  2018-01-19 17:41 [PATCH 0/2] [GIT PULL] tracing: A couple more small fixes for 4.15 Steven Rostedt
  2018-01-19 17:41 ` [PATCH 1/2] ring-buffer: Fix duplicate results in mapping context to bits in recursive lock Steven Rostedt
@ 2018-01-19 17:41 ` Steven Rostedt
  1 sibling, 0 replies; 3+ messages in thread
From: Steven Rostedt @ 2018-01-19 17:41 UTC (permalink / raw)
  To: linux-kernel
  Cc: Linus Torvalds, Ingo Molnar, Andrew Morton, stable, Chuck Lever

[-- Attachment #1: 0002-tracing-Fix-converting-enum-s-from-the-map-in-trace_.patch --]
[-- Type: text/plain, Size: 3861 bytes --]

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

Since enums do not get converted by the TRACE_EVENT macro into their values,
the event format displaces the enum name and not the value. This breaks
tools like perf and trace-cmd that need to interpret the raw binary data. To
solve this, an enum map was created to convert these enums into their actual
numbers on boot up. This is done by TRACE_EVENTS() adding a
TRACE_DEFINE_ENUM() macro.

Some enums were not being converted. This was caused by an optization that
had a bug in it.

All calls get checked against this enum map to see if it should be converted
or not, and it compares the call's system to the system that the enum map
was created under. If they match, then they call is processed.

To cut down on the number of iterations needed to find the maps with a
matching system, since calls and maps are grouped by system, when a match is
made, the index into the map array is saved, so that the next call, if it
belongs to the same system as the previous call, could start right at that
array index and not have to scan all the previous arrays.

The problem was, the saved index was used as the variable to know if this is
a call in a new system or not. If the index was zero, it was assumed that
the call is in a new system and would keep incrementing the saved index
until it found a matching system. The issue arises when the first matching
system was at index zero. The next map, if it belonged to the same system,
would then think it was the first match and increment the index to one. If
the next call belong to the same system, it would begin its search of the
maps off by one, and miss the first enum that should be converted. This left
a single enum not converted properly.

Also add a comment to describe exactly what that index was for. It took me a
bit too long to figure out what I was thinking when debugging this issue.

Link: http://lkml.kernel.org/r/717BE572-2070-4C1E-9902-9F2E0FEDA4F8@oracle.com

Cc: stable@vger.kernel.org
Fixes: 0c564a538aa93 ("tracing: Add TRACE_DEFINE_ENUM() macro to map enums to their values")
Reported-by: Chuck Lever <chuck.lever@oracle.com>
Teste-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
---
 kernel/trace/trace_events.c | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c
index ec0f9aa4e151..1b87157edbff 100644
--- a/kernel/trace/trace_events.c
+++ b/kernel/trace/trace_events.c
@@ -2213,6 +2213,7 @@ void trace_event_eval_update(struct trace_eval_map **map, int len)
 {
 	struct trace_event_call *call, *p;
 	const char *last_system = NULL;
+	bool first = false;
 	int last_i;
 	int i;
 
@@ -2220,15 +2221,28 @@ void trace_event_eval_update(struct trace_eval_map **map, int len)
 	list_for_each_entry_safe(call, p, &ftrace_events, list) {
 		/* events are usually grouped together with systems */
 		if (!last_system || call->class->system != last_system) {
+			first = true;
 			last_i = 0;
 			last_system = call->class->system;
 		}
 
+		/*
+		 * Since calls are grouped by systems, the likelyhood that the
+		 * next call in the iteration belongs to the same system as the
+		 * previous call is high. As an optimization, we skip seaching
+		 * for a map[] that matches the call's system if the last call
+		 * was from the same system. That's what last_i is for. If the
+		 * call has the same system as the previous call, then last_i
+		 * will be the index of the first map[] that has a matching
+		 * system.
+		 */
 		for (i = last_i; i < len; i++) {
 			if (call->class->system == map[i]->system) {
 				/* Save the first system if need be */
-				if (!last_i)
+				if (first) {
 					last_i = i;
+					first = false;
+				}
 				update_event_printk(call, map[i]);
 			}
 		}
-- 
2.13.2

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

end of thread, other threads:[~2018-01-19 17:42 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-01-19 17:41 [PATCH 0/2] [GIT PULL] tracing: A couple more small fixes for 4.15 Steven Rostedt
2018-01-19 17:41 ` [PATCH 1/2] ring-buffer: Fix duplicate results in mapping context to bits in recursive lock Steven Rostedt
2018-01-19 17:41 ` [PATCH 2/2] tracing: Fix converting enums from the map in trace_event_eval_update() 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).