Skip to contentSkip to conversation

ftrace: Therapy updates

PATCH New Steven Rostedt 1 participant 3 messages Sep 13, 2014

Subsystems (2)
lore
Share & tools
lore

Steven Rostedt

author maintainer
#0 lore raw

cover ftrace: Therapy updates

What? Me working? Um, no! This is just, um, my physical therapy. Yeah, that's it. Part of my therapy is to stare at a monitor and randomly raise and lower my fingers on top of a keyboard.

Alright, alright, you caught me :-p Please don't tell my wife!!!!

(me cleaning things up for more work to come, when I'm better)

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

Head SHA1: 3ddee63a099ebbdc8f84697fe46730b58240c09d

Steven Rostedt (Red Hat) (2):
ftrace: Add sanity check when unregistering last ftrace_ops
ftrace: Only disable ftrace_enabled to test buffer in selftest

----

 kernel/trace/ftrace.c         | 15 +++++++++++++++
 kernel/trace/trace_selftest.c |  4 ++++
 2 files changed, 19 insertions(+)
author maintainer
#1 lore raw

PATCH 1/2 ftrace: Add sanity check when unregistering last ftrace_ops

From: "Steven Rostedt (Red Hat)" <[email protected]>

When the last ftrace_ops is unregistered, all the function records should have a zeroed flags value. Make sure that is the case when the last ftrace_ops is unregistered.

---
 kernel/trace/ftrace.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
kernel/trace/ftrace.c +15 -0
index d325a1e76554..fb186b9ddf51 100644
@@ -2416,6 +2416,21 @@ static int ftrace_shutdown(struct ftrace_ops *ops, int command)
 
 	ftrace_run_update_code(command);
 
+	/*
+	 * If there's no more ops registered with ftrace, run a
+	 * sanity check to make sure all rec flags are cleared.
+	 */
+	if (ftrace_ops_list == &ftrace_list_end) {
+		struct ftrace_page *pg;
+		struct dyn_ftrace *rec;
+
+		do_for_each_ftrace_rec(pg, rec) {
+			if (FTRACE_WARN_ON_ONCE(rec->flags))
+				pr_warn("  %pS flags:%lx\n",
+					(void *)rec->ip, rec->flags);
+		} while_for_each_ftrace_rec();
+	}
+
 	ops->old_hash.filter_hash = NULL;
 	ops->old_hash.notrace_hash = NULL;
 
Signature · 1 line
2.0.1
author maintainer
#2 lore raw

PATCH 2/2 ftrace: Only disable ftrace_enabled to test buffer in selftest

In reply to Steven Rostedt

From: "Steven Rostedt (Red Hat)" <[email protected]>

The ftrace_enabled variable is set to zero in the self tests to keep delayed functions from being traced and messing with the checks. This only needs to be done when the checks are being performed, otherwise, if ftrace_enabled is off when calls back to the utility that is being tested, it can cause errors to happen and the tests can fail with false positives.

---
 kernel/trace/trace_selftest.c | 4 ++++
 1 file changed, 4 insertions(+)
kernel/trace/trace_selftest.c +4 -0
index 5ef60499dc8e..61a6acd6025d 100644
@@ -382,6 +382,8 @@ static int trace_selftest_startup_dynamic_tracing(struct tracer *trace,
 
 	/* check the trace buffer */
 	ret = trace_test_buffer(&tr->trace_buffer, &count);
+
+	ftrace_enabled = 1;
 	tracing_start();
 
 	/* we should only have one item */
@@ -679,6 +681,8 @@ trace_selftest_startup_function(struct tracer *trace, struct trace_array *tr)
 
 	/* check the trace buffer */
 	ret = trace_test_buffer(&tr->trace_buffer, &count);
+
+	ftrace_enabled = 1;
 	trace->reset(tr);
 	tracing_start();
 
Signature · 1 line
2.0.1