aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVasily Gorbik <gor@linux.ibm.com>2018-08-06 09:17:46 -0400
committerSteven Rostedt (VMware) <rostedt@goodmis.org>2018-08-15 22:38:38 -0400
commit2f4df0017baedd535254d987c6b10f855f1fb11f (patch)
treec035a8d2357ee4c54b584a3ba4153d4673fa057f
parent07d0408120216b60625c9a5b8012d1c3a907984d (diff)
tracing: Add -mcount-nop option support
-mcount-nop gcc option generates the calls to the profiling functions as nops which allows to avoid patching mcount jump with NOP instructions initially. -mcount-nop gcc option will be activated if platform selects HAVE_NOP_MCOUNT and gcc actually supports it. In addition to that CC_USING_NOP_MCOUNT is defined and could be used by architectures to adapt ftrace patching behavior. Link: http://lkml.kernel.org/r/patch-3.thread-aa7b8d.git-e02ed2dc082b.your-ad-here.call-01533557518-ext-9465@work.hours Signed-off-by: Vasily Gorbik <gor@linux.ibm.com> Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
-rw-r--r--Makefile6
-rw-r--r--kernel/trace/Kconfig5
-rw-r--r--kernel/trace/ftrace.c2
3 files changed, 13 insertions, 0 deletions
diff --git a/Makefile b/Makefile
index 2c92ebf59a34..c5b0cd7f3c2a 100644
--- a/Makefile
+++ b/Makefile
@@ -749,6 +749,12 @@ ifdef CONFIG_FTRACE_MCOUNT_RECORD
749 CC_FLAGS_FTRACE += -mrecord-mcount 749 CC_FLAGS_FTRACE += -mrecord-mcount
750 export CC_USING_RECORD_MCOUNT := 1 750 export CC_USING_RECORD_MCOUNT := 1
751 endif 751 endif
752 ifdef CONFIG_HAVE_NOP_MCOUNT
753 ifeq ($(call cc-option-yn, -mnop-mcount),y)
754 CC_FLAGS_FTRACE += -mnop-mcount
755 CC_FLAGS_USING += -DCC_USING_NOP_MCOUNT
756 endif
757 endif
752endif 758endif
753ifdef CONFIG_HAVE_FENTRY 759ifdef CONFIG_HAVE_FENTRY
754 ifeq ($(call cc-option-yn, -mfentry),y) 760 ifeq ($(call cc-option-yn, -mfentry),y)
diff --git a/kernel/trace/Kconfig b/kernel/trace/Kconfig
index 036cec1fcd24..fd6754b88f87 100644
--- a/kernel/trace/Kconfig
+++ b/kernel/trace/Kconfig
@@ -47,6 +47,11 @@ config HAVE_FENTRY
47 help 47 help
48 Arch supports the gcc options -pg with -mfentry 48 Arch supports the gcc options -pg with -mfentry
49 49
50config HAVE_NOP_MCOUNT
51 bool
52 help
53 Arch supports the gcc options -pg with -mrecord-mcount and -nop-mcount
54
50config HAVE_C_RECORDMCOUNT 55config HAVE_C_RECORDMCOUNT
51 bool 56 bool
52 help 57 help
diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
index 48b5b466ec7a..468e8527e979 100644
--- a/kernel/trace/ftrace.c
+++ b/kernel/trace/ftrace.c
@@ -2950,12 +2950,14 @@ static int ftrace_update_code(struct module *mod, struct ftrace_page *new_pgs)
2950 p = &pg->records[i]; 2950 p = &pg->records[i];
2951 p->flags = rec_flags; 2951 p->flags = rec_flags;
2952 2952
2953#ifndef CC_USING_NOP_MCOUNT
2953 /* 2954 /*
2954 * Do the initial record conversion from mcount jump 2955 * Do the initial record conversion from mcount jump
2955 * to the NOP instructions. 2956 * to the NOP instructions.
2956 */ 2957 */
2957 if (!ftrace_code_disable(mod, p)) 2958 if (!ftrace_code_disable(mod, p))
2958 break; 2959 break;
2960#endif
2959 2961
2960 update_cnt++; 2962 update_cnt++;
2961 } 2963 }