Skip to content

Commit 2f4df00

Browse files
Vasily Gorbikrostedt
authored andcommitted
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>
1 parent 07d0408 commit 2f4df00

3 files changed

Lines changed: 13 additions & 0 deletions

File tree

‎Makefile‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -749,6 +749,12 @@ ifdef CONFIG_FTRACE_MCOUNT_RECORD
749749
CC_FLAGS_FTRACE += -mrecord-mcount
750750
export CC_USING_RECORD_MCOUNT := 1
751751
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
752758
endif
753759
ifdef CONFIG_HAVE_FENTRY
754760
ifeq ($(call cc-option-yn, -mfentry),y)

‎kernel/trace/Kconfig‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@ config HAVE_FENTRY
4747
help
4848
Arch supports the gcc options -pg with -mfentry
4949

50+
config HAVE_NOP_MCOUNT
51+
bool
52+
help
53+
Arch supports the gcc options -pg with -mrecord-mcount and -nop-mcount
54+
5055
config HAVE_C_RECORDMCOUNT
5156
bool
5257
help

‎kernel/trace/ftrace.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2950,12 +2950,14 @@ static int ftrace_update_code(struct module *mod, struct ftrace_page *new_pgs)
29502950
p = &pg->records[i];
29512951
p->flags = rec_flags;
29522952

2953+
#ifndef CC_USING_NOP_MCOUNT
29532954
/*
29542955
* Do the initial record conversion from mcount jump
29552956
* to the NOP instructions.
29562957
*/
29572958
if (!ftrace_code_disable(mod, p))
29582959
break;
2960+
#endif
29592961

29602962
update_cnt++;
29612963
}

0 commit comments

Comments
 (0)