Skip to content

Commit 5f7fb89

Browse files
committed
function_graph: Everyone uses HAVE_FUNCTION_GRAPH_RET_ADDR_PTR, remove it
All architectures that implement function graph also implements HAVE_FUNCTION_GRAPH_RET_ADDR_PTR. Remove it, as it is no longer a differentiator. Link: https://lore.kernel.org/linux-trace-kernel/[email protected] Cc: Masami Hiramatsu <[email protected]> Cc: Mark Rutland <[email protected]> Cc: Mathieu Desnoyers <[email protected]> Cc: Jonathan Corbet <[email protected]> Cc: Catalin Marinas <[email protected]> Cc: Will Deacon <[email protected]> Cc: Guo Ren <[email protected]> Cc: Huacai Chen <[email protected]> Cc: WANG Xuerui <[email protected]> Cc: Michael Ellerman <[email protected]> Cc: Nicholas Piggin <[email protected]> Cc: Christophe Leroy <[email protected]> Cc: "Naveen N. Rao" <[email protected]> Cc: Paul Walmsley <[email protected]> Cc: Palmer Dabbelt <[email protected]> Cc: Albert Ou <[email protected]> Cc: Heiko Carstens <[email protected]> Cc: Vasily Gorbik <[email protected]> Cc: Alexander Gordeev <[email protected]> Cc: Christian Borntraeger <[email protected]> Cc: Sven Schnelle <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: Borislav Petkov <[email protected]> Cc: Dave Hansen <[email protected]> Cc: "H. Peter Anvin" <[email protected]> Signed-off-by: Steven Rostedt (Google) <[email protected]>
1 parent 29c1c24 commit 5f7fb89

File tree

10 files changed

+1
-68
lines changed

10 files changed

+1
-68
lines changed

Documentation/trace/ftrace-design.rst

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -217,18 +217,6 @@ along to ftrace_push_return_trace() instead of a stub value of 0.
217217

218218
Similarly, when you call ftrace_return_to_handler(), pass it the frame pointer.
219219

220-
HAVE_FUNCTION_GRAPH_RET_ADDR_PTR
221-
--------------------------------
222-
223-
An arch may pass in a pointer to the return address on the stack. This
224-
prevents potential stack unwinding issues where the unwinder gets out of
225-
sync with ret_stack and the wrong addresses are reported by
226-
ftrace_graph_ret_addr().
227-
228-
Adding support for it is easy: just define the macro in asm/ftrace.h and
229-
pass the return address pointer as the 'retp' argument to
230-
ftrace_push_return_trace().
231-
232220
HAVE_SYSCALL_TRACEPOINTS
233221
------------------------
234222

arch/arm64/include/asm/ftrace.h

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,6 @@
1212

1313
#define HAVE_FUNCTION_GRAPH_FP_TEST
1414

15-
/*
16-
* HAVE_FUNCTION_GRAPH_RET_ADDR_PTR means that the architecture can provide a
17-
* "return address pointer" which can be used to uniquely identify a return
18-
* address which has been overwritten.
19-
*
20-
* On arm64 we use the address of the caller's frame record, which remains the
21-
* same for the lifetime of the instrumented function, unlike the return
22-
* address in the LR.
23-
*/
24-
#define HAVE_FUNCTION_GRAPH_RET_ADDR_PTR
25-
2615
#ifdef CONFIG_DYNAMIC_FTRACE_WITH_ARGS
2716
#define ARCH_SUPPORTS_FTRACE_OPS 1
2817
#else

arch/csky/include/asm/ftrace.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77

88
#define HAVE_FUNCTION_GRAPH_FP_TEST
99

10-
#define HAVE_FUNCTION_GRAPH_RET_ADDR_PTR
11-
1210
#define ARCH_SUPPORTS_FTRACE_OPS 1
1311

1412
#define MCOUNT_ADDR ((unsigned long)_mcount)

arch/loongarch/include/asm/ftrace.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ struct dyn_ftrace;
2828
struct dyn_arch_ftrace { };
2929

3030
#define ARCH_SUPPORTS_FTRACE_OPS 1
31-
#define HAVE_FUNCTION_GRAPH_RET_ADDR_PTR
3231

3332
#define ftrace_init_nop ftrace_init_nop
3433
int ftrace_init_nop(struct module *mod, struct dyn_ftrace *rec);

arch/powerpc/include/asm/ftrace.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
#define MCOUNT_ADDR ((unsigned long)(_mcount))
99
#define MCOUNT_INSN_SIZE 4 /* sizeof mcount call */
1010

11-
#define HAVE_FUNCTION_GRAPH_RET_ADDR_PTR
12-
1311
/* Ignore unused weak functions which will have larger offsets */
1412
#if defined(CONFIG_MPROFILE_KERNEL) || defined(CONFIG_ARCH_USING_PATCHABLE_FUNCTION_ENTRY)
1513
#define FTRACE_MCOUNT_MAX_OFFSET 16

arch/riscv/include/asm/ftrace.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
#if defined(CONFIG_FUNCTION_GRAPH_TRACER) && defined(CONFIG_FRAME_POINTER)
1212
#define HAVE_FUNCTION_GRAPH_FP_TEST
1313
#endif
14-
#define HAVE_FUNCTION_GRAPH_RET_ADDR_PTR
1514

1615
#define ARCH_SUPPORTS_FTRACE_OPS 1
1716
#ifndef __ASSEMBLY__

arch/s390/include/asm/ftrace.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
#ifndef _ASM_S390_FTRACE_H
33
#define _ASM_S390_FTRACE_H
44

5-
#define HAVE_FUNCTION_GRAPH_RET_ADDR_PTR
65
#define ARCH_SUPPORTS_FTRACE_OPS 1
76
#define MCOUNT_INSN_SIZE 6
87

arch/x86/include/asm/ftrace.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@
2020
#define ARCH_SUPPORTS_FTRACE_OPS 1
2121
#endif
2222

23-
#define HAVE_FUNCTION_GRAPH_RET_ADDR_PTR
24-
2523
#ifndef __ASSEMBLY__
2624
extern void __fentry__(void);
2725

include/linux/ftrace.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1071,9 +1071,7 @@ struct ftrace_ret_stack {
10711071
#ifdef HAVE_FUNCTION_GRAPH_FP_TEST
10721072
unsigned long fp;
10731073
#endif
1074-
#ifdef HAVE_FUNCTION_GRAPH_RET_ADDR_PTR
10751074
unsigned long *retp;
1076-
#endif
10771075
};
10781076

10791077
/*

kernel/trace/fgraph.c

Lines changed: 1 addition & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -593,9 +593,7 @@ ftrace_push_return_trace(unsigned long ret, unsigned long func,
593593
#ifdef HAVE_FUNCTION_GRAPH_FP_TEST
594594
ret_stack->fp = frame_pointer;
595595
#endif
596-
#ifdef HAVE_FUNCTION_GRAPH_RET_ADDR_PTR
597596
ret_stack->retp = retp;
598-
#endif
599597
return offset;
600598
}
601599

@@ -887,10 +885,8 @@ ftrace_graph_get_ret_stack(struct task_struct *task, int idx)
887885
* will be assigned that location so that if called again, it will continue
888886
* where it left off.
889887
*
890-
* @retp is a pointer to the return address on the stack. It's ignored if
891-
* the arch doesn't have HAVE_FUNCTION_GRAPH_RET_ADDR_PTR defined.
888+
* @retp is a pointer to the return address on the stack.
892889
*/
893-
#ifdef HAVE_FUNCTION_GRAPH_RET_ADDR_PTR
894890
unsigned long ftrace_graph_ret_addr(struct task_struct *task, int *idx,
895891
unsigned long ret, unsigned long *retp)
896892
{
@@ -926,35 +922,6 @@ unsigned long ftrace_graph_ret_addr(struct task_struct *task, int *idx,
926922

927923
return ret;
928924
}
929-
#else /* !HAVE_FUNCTION_GRAPH_RET_ADDR_PTR */
930-
unsigned long ftrace_graph_ret_addr(struct task_struct *task, int *idx,
931-
unsigned long ret, unsigned long *retp)
932-
{
933-
struct ftrace_ret_stack *ret_stack;
934-
unsigned long return_handler = (unsigned long)dereference_kernel_function_descriptor(return_to_handler);
935-
int offset = task->curr_ret_stack;
936-
int i;
937-
938-
if (ret != return_handler)
939-
return ret;
940-
941-
if (!idx)
942-
return ret;
943-
944-
i = *idx;
945-
do {
946-
ret_stack = get_ret_stack(task, offset, &offset);
947-
if (ret_stack && ret_stack->ret == return_handler)
948-
continue;
949-
i--;
950-
} while (i >= 0 && ret_stack);
951-
952-
if (ret_stack)
953-
return ret_stack->ret;
954-
955-
return ret;
956-
}
957-
#endif /* HAVE_FUNCTION_GRAPH_RET_ADDR_PTR */
958925

959926
static struct ftrace_ops graph_ops = {
960927
.func = ftrace_graph_func,

0 commit comments

Comments
 (0)