Skip to contentSkip to conversation

tracing: some important fixes

GIT PULL New Steven Rostedt 1 participant 4 messages Oct 8, 2009

Subsystems (2)
lore
Share & tools
lore

Steven Rostedt

author maintainer
#0 lore raw

Ingo,

The last two patches also need to go into the stable release.

Please pull the latest tip/tracing/urgent tree, which can be found at:

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

Steven Rostedt (2):
tracing: fix transposed numbers of lock_depth and preempt_count
ftrace: check for failure for all conversions

[email protected] (1):
tracing: correct module boundaries for ftrace_release

----

 include/linux/ftrace.h      |    2 +-
 kernel/trace/ftrace.c       |   23 +++++++----------------
 kernel/trace/trace_output.c |   14 ++++++++------
 3 files changed, 16 insertions(+), 23 deletions(-)
author maintainer
#1 lore raw

PATCH 1/3 tracing: fix transposed numbers of lock_depth and preempt_count

From: Steven Rostedt <[email protected]>

The lock_depth and preempt_count numbers in the latency format is transposed.

---
 kernel/trace/trace_output.c |   14 ++++++++------
 1 files changed, 8 insertions(+), 6 deletions(-)
kernel/trace/trace_output.c +8 -6
index cda766f..ed17565 100644
@@ -486,16 +486,18 @@ int trace_print_lat_fmt(struct trace_seq *s, struct trace_entry *entry)
 				hardirq ? 'h' : softirq ? 's' : '.'))
 		return 0;
 
-	if (entry->lock_depth < 0)
-		ret = trace_seq_putc(s, '.');
+	if (entry->preempt_count)
+		ret = trace_seq_printf(s, "%x", entry->preempt_count);
 	else
-		ret = trace_seq_printf(s, "%d", entry->lock_depth);
+		ret = trace_seq_putc(s, '.');
+
 	if (!ret)
 		return 0;
 
-	if (entry->preempt_count)
-		return trace_seq_printf(s, "%x", entry->preempt_count);
-	return trace_seq_putc(s, '.');
+	if (entry->lock_depth < 0)
+		return trace_seq_putc(s, '.');
+
+	return trace_seq_printf(s, "%d", entry->lock_depth);
 }
 
 static int
Signature · 1 line
1.6.3.3
author maintainer
#2 lore raw

PATCH 2/3 tracing: correct module boundaries for ftrace_release

In reply to Steven Rostedt

From: [email protected] <[email protected]>

When the module is about the unload we release its call records. The ftrace_release function was given wrong values representing the module core boundaries, thus not releasing its call records.

Plus making ftrace_release function module specific.

LKML-Reference: <[email protected]>

---
 include/linux/ftrace.h |    2 +-
 kernel/trace/ftrace.c  |   12 ++++--------
 2 files changed, 5 insertions(+), 9 deletions(-)
include/linux/ftrace.h +1 -1
index cd3d2ab..0b4f97d 100644
@@ -241,7 +241,7 @@ extern void ftrace_enable_daemon(void);
 # define ftrace_set_filter(buf, len, reset)	do { } while (0)
 # define ftrace_disable_daemon()		do { } while (0)
 # define ftrace_enable_daemon()			do { } while (0)
-static inline void ftrace_release(void *start, unsigned long size) { }
+static inline void ftrace_release_mod(struct module *mod) {}
 static inline int register_ftrace_command(struct ftrace_func_command *cmd)
 {
 	return -EINVAL;
kernel/trace/ftrace.c +4 -8
index 46592fe..c701476 100644
@@ -2658,19 +2658,17 @@ static int ftrace_convert_nops(struct module *mod,
 }
 
 #ifdef CONFIG_MODULES
-void ftrace_release(void *start, void *end)
+void ftrace_release_mod(struct module *mod)
 {
 	struct dyn_ftrace *rec;
 	struct ftrace_page *pg;
-	unsigned long s = (unsigned long)start;
-	unsigned long e = (unsigned long)end;
 
-	if (ftrace_disabled || !start || start == end)
+	if (ftrace_disabled)
 		return;
 
 	mutex_lock(&ftrace_lock);
 	do_for_each_ftrace_rec(pg, rec) {
-		if ((rec->ip >= s) && (rec->ip < e)) {
+		if (within_module_core(rec->ip, mod)) {
 			/*
 			 * rec->ip is changed in ftrace_free_rec()
 			 * It should not between s and e if record was freed.
@@ -2702,9 +2700,7 @@ static int ftrace_module_notify(struct notifier_block *self,
 				   mod->num_ftrace_callsites);
 		break;
 	case MODULE_STATE_GOING:
-		ftrace_release(mod->ftrace_callsites,
-			       mod->ftrace_callsites +
-			       mod->num_ftrace_callsites);
+		ftrace_release_mod(mod);
 		break;
 	}
 
Signature · 1 line
1.6.3.3
author maintainer
#3 lore raw

PATCH 3/3 ftrace: check for failure for all conversions

In reply to Steven Rostedt

From: Steven Rostedt <[email protected]>

Due to legacy code from back when the dynamic tracer used a daemon, only core kernel code was checking for failures. This is no longer the case. We must check for failures any time we perform text modifications.

---
 kernel/trace/ftrace.c |   11 +++--------
 1 files changed, 3 insertions(+), 8 deletions(-)
kernel/trace/ftrace.c +3 -8
index c701476..f136fe5 100644
@@ -1074,14 +1074,9 @@ static void ftrace_replace_code(int enable)
 		failed = __ftrace_replace_code(rec, enable);
 		if (failed) {
 			rec->flags |= FTRACE_FL_FAILED;
-			if ((system_state == SYSTEM_BOOTING) ||
-			    !core_kernel_text(rec->ip)) {
-				ftrace_free_rec(rec);
-				} else {
-				ftrace_bug(failed, rec->ip);
-					/* Stop processing */
-					return;
-				}
+			ftrace_bug(failed, rec->ip);
+			/* Stop processing */
+			return;
 		}
 	} while_for_each_ftrace_rec();
 }
Signature · 1 line
1.6.3.3