Skip to content

Commit 0f42c1a

Browse files
committed
x86/ftrace: Get rid of function_hook
History lesson courtesy of Steve: "When ftrace first was introduced to the kernel, it used gcc's mcount profiling mechanism. The mcount mechanism would add a call to "mcount" at the start of every function but after the stack frame was set up. Later, in gcc 4.6, gcc introduced -mfentry, that would create a call to "__fentry__" instead of "mcount", before the stack frame was set up. In order to handle both cases, ftrace defined a macro "function_hook" that would be either "mcount" or "__fentry__" depending on which one was being used. The Linux kernel no longer supports the "mcount" method, thus there's no reason to keep the "function_hook" define around. Simply use "__fentry__", as there is no ambiguity to the name anymore." Drop it everywhere. Signed-off-by: Borislav Petkov <[email protected]> Acked-by: Jiri Slaby <[email protected]> Cc: "H. Peter Anvin" <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: Jonathan Corbet <[email protected]> Cc: Josh Poimboeuf <[email protected]> Cc: [email protected] Cc: [email protected] Cc: Peter Zijlstra <[email protected]> Cc: "Steven Rostedt (VMware)" <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: [email protected] Link: http://lkml.kernel.org/r/[email protected]
1 parent 13fbe78 commit 0f42c1a

File tree

3 files changed

+11
-14
lines changed

3 files changed

+11
-14
lines changed

Documentation/asm-annotations.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,9 @@ This section covers ``SYM_FUNC_*`` and ``SYM_CODE_*`` enumerated above.
117117
So in most cases, developers should write something like in the following
118118
example, having some asm instructions in between the macros, of course::
119119

120-
SYM_FUNC_START(function_hook)
120+
SYM_FUNC_START(memset)
121121
... asm insns ...
122-
SYM_FUNC_END(function_hook)
122+
SYM_FUNC_END(memset)
123123

124124
In fact, this kind of annotation corresponds to the now deprecated ``ENTRY``
125125
and ``ENDPROC`` macros.

arch/x86/kernel/ftrace_32.S

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,16 @@
1212
#include <asm/frame.h>
1313
#include <asm/asm-offsets.h>
1414

15-
# define function_hook __fentry__
16-
EXPORT_SYMBOL(__fentry__)
17-
1815
#ifdef CONFIG_FRAME_POINTER
1916
# define MCOUNT_FRAME 1 /* using frame = true */
2017
#else
2118
# define MCOUNT_FRAME 0 /* using frame = false */
2219
#endif
2320

24-
SYM_FUNC_START(function_hook)
21+
SYM_FUNC_START(__fentry__)
2522
ret
26-
SYM_FUNC_END(function_hook)
23+
SYM_FUNC_END(__fentry__)
24+
EXPORT_SYMBOL(__fentry__)
2725

2826
SYM_CODE_START(ftrace_caller)
2927

arch/x86/kernel/ftrace_64.S

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@
1414
.code64
1515
.section .entry.text, "ax"
1616

17-
# define function_hook __fentry__
18-
EXPORT_SYMBOL(__fentry__)
19-
2017
#ifdef CONFIG_FRAME_POINTER
2118
/* Save parent and function stack frames (rip and rbp) */
2219
# define MCOUNT_FRAME_SIZE (8+16*2)
@@ -132,9 +129,10 @@ EXPORT_SYMBOL(__fentry__)
132129

133130
#ifdef CONFIG_DYNAMIC_FTRACE
134131

135-
SYM_FUNC_START(function_hook)
132+
SYM_FUNC_START(__fentry__)
136133
retq
137-
SYM_FUNC_END(function_hook)
134+
SYM_FUNC_END(__fentry__)
135+
EXPORT_SYMBOL(__fentry__)
138136

139137
SYM_FUNC_START(ftrace_caller)
140138
/* save_mcount_regs fills in first two parameters */
@@ -248,7 +246,7 @@ SYM_FUNC_END(ftrace_regs_caller)
248246

249247
#else /* ! CONFIG_DYNAMIC_FTRACE */
250248

251-
SYM_FUNC_START(function_hook)
249+
SYM_FUNC_START(__fentry__)
252250
cmpq $ftrace_stub, ftrace_trace_function
253251
jnz trace
254252

@@ -279,7 +277,8 @@ trace:
279277
restore_mcount_regs
280278

281279
jmp fgraph_trace
282-
SYM_FUNC_END(function_hook)
280+
SYM_FUNC_END(__fentry__)
281+
EXPORT_SYMBOL(__fentry__)
283282
#endif /* CONFIG_DYNAMIC_FTRACE */
284283

285284
#ifdef CONFIG_FUNCTION_GRAPH_TRACER

0 commit comments

Comments
 (0)