Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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/20240611031737.982047614@goodmis.org

Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Cc: Jonathan Corbet <corbet@lwn.net>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Will Deacon <will@kernel.org>
Cc: Guo Ren <guoren@kernel.org>
Cc: Huacai Chen <chenhuacai@kernel.org>
Cc: WANG Xuerui <kernel@xen0n.name>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Nicholas Piggin <npiggin@gmail.com>
Cc: Christophe Leroy <christophe.leroy@csgroup.eu>
Cc: "Naveen N. Rao" <naveen.n.rao@linux.ibm.com>
Cc: Paul Walmsley <paul.walmsley@sifive.com>
Cc: Palmer Dabbelt <palmer@dabbelt.com>
Cc: Albert Ou <aou@eecs.berkeley.edu>
Cc: Heiko Carstens <hca@linux.ibm.com>
Cc: Vasily Gorbik <gor@linux.ibm.com>
Cc: Alexander Gordeev <agordeev@linux.ibm.com>
Cc: Christian Borntraeger <borntraeger@linux.ibm.com>
Cc: Sven Schnelle <svens@linux.ibm.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>

+1 -68
-12
Documentation/trace/ftrace-design.rst
··· 217 217 218 218 Similarly, when you call ftrace_return_to_handler(), pass it the frame pointer. 219 219 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 - 232 220 HAVE_SYSCALL_TRACEPOINTS 233 221 ------------------------ 234 222
-11
arch/arm64/include/asm/ftrace.h
··· 12 12 13 13 #define HAVE_FUNCTION_GRAPH_FP_TEST 14 14 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 - 26 15 #ifdef CONFIG_DYNAMIC_FTRACE_WITH_ARGS 27 16 #define ARCH_SUPPORTS_FTRACE_OPS 1 28 17 #else
-2
arch/csky/include/asm/ftrace.h
··· 7 7 8 8 #define HAVE_FUNCTION_GRAPH_FP_TEST 9 9 10 - #define HAVE_FUNCTION_GRAPH_RET_ADDR_PTR 11 - 12 10 #define ARCH_SUPPORTS_FTRACE_OPS 1 13 11 14 12 #define MCOUNT_ADDR ((unsigned long)_mcount)
-1
arch/loongarch/include/asm/ftrace.h
··· 28 28 struct dyn_arch_ftrace { }; 29 29 30 30 #define ARCH_SUPPORTS_FTRACE_OPS 1 31 - #define HAVE_FUNCTION_GRAPH_RET_ADDR_PTR 32 31 33 32 #define ftrace_init_nop ftrace_init_nop 34 33 int ftrace_init_nop(struct module *mod, struct dyn_ftrace *rec);
-2
arch/powerpc/include/asm/ftrace.h
··· 8 8 #define MCOUNT_ADDR ((unsigned long)(_mcount)) 9 9 #define MCOUNT_INSN_SIZE 4 /* sizeof mcount call */ 10 10 11 - #define HAVE_FUNCTION_GRAPH_RET_ADDR_PTR 12 - 13 11 /* Ignore unused weak functions which will have larger offsets */ 14 12 #if defined(CONFIG_MPROFILE_KERNEL) || defined(CONFIG_ARCH_USING_PATCHABLE_FUNCTION_ENTRY) 15 13 #define FTRACE_MCOUNT_MAX_OFFSET 16
-1
arch/riscv/include/asm/ftrace.h
··· 11 11 #if defined(CONFIG_FUNCTION_GRAPH_TRACER) && defined(CONFIG_FRAME_POINTER) 12 12 #define HAVE_FUNCTION_GRAPH_FP_TEST 13 13 #endif 14 - #define HAVE_FUNCTION_GRAPH_RET_ADDR_PTR 15 14 16 15 #define ARCH_SUPPORTS_FTRACE_OPS 1 17 16 #ifndef __ASSEMBLY__
-1
arch/s390/include/asm/ftrace.h
··· 2 2 #ifndef _ASM_S390_FTRACE_H 3 3 #define _ASM_S390_FTRACE_H 4 4 5 - #define HAVE_FUNCTION_GRAPH_RET_ADDR_PTR 6 5 #define ARCH_SUPPORTS_FTRACE_OPS 1 7 6 #define MCOUNT_INSN_SIZE 6 8 7
-2
arch/x86/include/asm/ftrace.h
··· 20 20 #define ARCH_SUPPORTS_FTRACE_OPS 1 21 21 #endif 22 22 23 - #define HAVE_FUNCTION_GRAPH_RET_ADDR_PTR 24 - 25 23 #ifndef __ASSEMBLY__ 26 24 extern void __fentry__(void); 27 25
-2
include/linux/ftrace.h
··· 1071 1071 #ifdef HAVE_FUNCTION_GRAPH_FP_TEST 1072 1072 unsigned long fp; 1073 1073 #endif 1074 - #ifdef HAVE_FUNCTION_GRAPH_RET_ADDR_PTR 1075 1074 unsigned long *retp; 1076 - #endif 1077 1075 }; 1078 1076 1079 1077 /*
+1 -34
kernel/trace/fgraph.c
··· 593 593 #ifdef HAVE_FUNCTION_GRAPH_FP_TEST 594 594 ret_stack->fp = frame_pointer; 595 595 #endif 596 - #ifdef HAVE_FUNCTION_GRAPH_RET_ADDR_PTR 597 596 ret_stack->retp = retp; 598 - #endif 599 597 return offset; 600 598 } 601 599 ··· 885 887 * will be assigned that location so that if called again, it will continue 886 888 * where it left off. 887 889 * 888 - * @retp is a pointer to the return address on the stack. It's ignored if 889 - * the arch doesn't have HAVE_FUNCTION_GRAPH_RET_ADDR_PTR defined. 890 + * @retp is a pointer to the return address on the stack. 890 891 */ 891 - #ifdef HAVE_FUNCTION_GRAPH_RET_ADDR_PTR 892 892 unsigned long ftrace_graph_ret_addr(struct task_struct *task, int *idx, 893 893 unsigned long ret, unsigned long *retp) 894 894 { ··· 922 926 923 927 return ret; 924 928 } 925 - #else /* !HAVE_FUNCTION_GRAPH_RET_ADDR_PTR */ 926 - unsigned long ftrace_graph_ret_addr(struct task_struct *task, int *idx, 927 - unsigned long ret, unsigned long *retp) 928 - { 929 - struct ftrace_ret_stack *ret_stack; 930 - unsigned long return_handler = (unsigned long)dereference_kernel_function_descriptor(return_to_handler); 931 - int offset = task->curr_ret_stack; 932 - int i; 933 - 934 - if (ret != return_handler) 935 - return ret; 936 - 937 - if (!idx) 938 - return ret; 939 - 940 - i = *idx; 941 - do { 942 - ret_stack = get_ret_stack(task, offset, &offset); 943 - if (ret_stack && ret_stack->ret == return_handler) 944 - continue; 945 - i--; 946 - } while (i >= 0 && ret_stack); 947 - 948 - if (ret_stack) 949 - return ret_stack->ret; 950 - 951 - return ret; 952 - } 953 - #endif /* HAVE_FUNCTION_GRAPH_RET_ADDR_PTR */ 954 929 955 930 static struct ftrace_ops graph_ops = { 956 931 .func = ftrace_graph_func,