Commit d05cdb25d80f06f77aa6bddb53cd1390d4d91a0b

Authored by Steven Rostedt
Committed by Thomas Gleixner
1 parent 06fa75ab56

ftrace: fix dynamic ftrace selftest

With the adding of the configuration changes in the Makefile to prevent
tracing of functions in the ftrace code, all tracing of all the ftrace
code has been removed. Unfortunately, one of the selftests, relied on
a function to be traced. With the new change, the function was no longer
traced and the test failed.

This patch separates out the test function into its own file so that
we can add the "-pg" flag to the compilation of that function and the
adding of the mcount call to that function.

Signed-off-by: Steven Rostedt <srostedt@redhat.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>

Showing 4 changed files with 13 additions and 6 deletions Side-by-side Diff

kernel/trace/Makefile
... ... @@ -4,6 +4,10 @@
4 4 ifdef CONFIG_FTRACE
5 5 ORIG_CFLAGS := $(KBUILD_CFLAGS)
6 6 KBUILD_CFLAGS = $(subst -pg,,$(ORIG_CFLAGS))
  7 +
  8 +# selftest needs instrumentation
  9 +CFLAGS_trace_selftest_dynamic.o = -pg
  10 +obj-y += trace_selftest_dynamic.o
7 11 endif
8 12  
9 13 obj-$(CONFIG_FTRACE) += libftrace.o
kernel/trace/trace.h
... ... @@ -244,6 +244,8 @@
244 244  
245 245 #ifdef CONFIG_DYNAMIC_FTRACE
246 246 extern unsigned long ftrace_update_tot_cnt;
  247 +#define DYN_FTRACE_TEST_NAME trace_selftest_dynamic_test_func
  248 +extern int DYN_FTRACE_TEST_NAME(void);
247 249 #endif
248 250  
249 251 #ifdef CONFIG_FTRACE_STARTUP_TEST
kernel/trace/trace_selftest.c
... ... @@ -107,14 +107,8 @@
107 107  
108 108 #ifdef CONFIG_DYNAMIC_FTRACE
109 109  
110   -#define DYN_FTRACE_TEST_NAME trace_selftest_dynamic_test_func
111 110 #define __STR(x) #x
112 111 #define STR(x) __STR(x)
113   -static int DYN_FTRACE_TEST_NAME(void)
114   -{
115   - /* used to call mcount */
116   - return 0;
117   -}
118 112  
119 113 /* Test dynamic code modification and ftrace filters */
120 114 int trace_selftest_startup_dynamic_tracing(struct tracer *trace,
kernel/trace/trace_selftest_dynamic.c
  1 +#include "trace.h"
  2 +
  3 +int DYN_FTRACE_TEST_NAME(void)
  4 +{
  5 + /* used to call mcount */
  6 + return 0;
  7 +}