From nobody Thu Feb 12 14:09:22 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 86A2D1CD16 for ; Tue, 11 Jun 2024 20:46:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718138772; cv=none; b=JurthEzRb86ajNDgrAkV9ja23P04KfJ4fWOaVwNz17N2XJ+65+aTA2Den9sse7e5+0BSeMRGlge/pbCo7qbMIfPMzuwBjDnJ2Qxy1KD1x79Ef5avih/kLt8HSvyaNNc8LPonveIdxPa62QJ+ah89XCJBUNOSte06p255X7g4LnA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718138772; c=relaxed/simple; bh=ImQ9KOd+2hjVgtXx/dfloG4fYodqkEbfTCz8zH9mw/k=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=B21iehOElCmiyuZ6OJNxOQ7fiieie01Bj8rZ4QVktKZc01O26sOojMxkCuUAZ2AEx57+wTZDifIFeE6JEhSjVQMaKuO+8Zrfx4aqAVM2CsJB3VDXOJlRR6qQaaD6YNQA8Jd5MsSdxGBR7FhVGITIqDXzt/Jp/JWz5lBJGc+wQns= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 130A1C4AF1C; Tue, 11 Jun 2024 20:46:12 +0000 (UTC) Received: from rostedt by gandalf with local (Exim 4.97) (envelope-from ) id 1sH8Nw-00000001V2e-2eUr; Tue, 11 Jun 2024 16:46:28 -0400 Message-ID: <20240611204628.489153002@goodmis.org> User-Agent: quilt/0.68 Date: Tue, 11 Jun 2024 16:45:55 -0400 From: Steven Rostedt To: linux-kernel@vger.kernel.org Cc: Masami Hiramatsu , Mark Rutland , Mathieu Desnoyers , Andrew Morton , kernel test robot Subject: [for-next][PATCH 1/4] function_graph: Make fgraph_update_pid_func() a stub for !DYNAMIC_FTRACE References: <20240611204554.092271761@goodmis.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: "Steven Rostedt (Google)" When CONFIG_DYNAMIC_FTRACE is not set, the function fgraph_update_pid_func() doesn't do anything. Currently, most of its logic is within a "#ifdef CONFIG_DYNAMIC_FTRACE" block, but its variables were declared outside that, and when DYNAMIC_FTRACE is not set, it produces unused variable warnings. Instead, just place it (and the helper function fgraph_pid_func()) within the #ifdef block and have the header file use a empty stub function for when DYNAMIC_FTRACE is not defined. Link: https://lore.kernel.org/linux-trace-kernel/20240607094833.6a787d73@ro= rschach.local.home Cc: Masami Hiramatsu Cc: Mark Rutland Cc: Mathieu Desnoyers Reported-by: kernel test robot Closes: https://lore.kernel.org/oe-kbuild-all/202406071806.BRjaC5FF-lkp@int= el.com/ Signed-off-by: Steven Rostedt (Google) --- kernel/trace/fgraph.c | 4 ++-- kernel/trace/ftrace_internal.h | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/kernel/trace/fgraph.c b/kernel/trace/fgraph.c index a13551a023aa..63d0c2f84ce1 100644 --- a/kernel/trace/fgraph.c +++ b/kernel/trace/fgraph.c @@ -1138,6 +1138,7 @@ void ftrace_graph_exit_task(struct task_struct *t) kfree(ret_stack); } =20 +#ifdef CONFIG_DYNAMIC_FTRACE static int fgraph_pid_func(struct ftrace_graph_ent *trace, struct fgraph_ops *gops) { @@ -1164,7 +1165,6 @@ void fgraph_update_pid_func(void) if (!(graph_ops.flags & FTRACE_OPS_FL_INITIALIZED)) return; =20 -#ifdef CONFIG_DYNAMIC_FTRACE list_for_each_entry(op, &graph_ops.subop_list, list) { if (op->flags & FTRACE_OPS_FL_PID) { gops =3D container_of(op, struct fgraph_ops, ops); @@ -1174,8 +1174,8 @@ void fgraph_update_pid_func(void) static_call_update(fgraph_func, gops->entryfunc); } } -#endif } +#endif =20 /* Allocate a return stack for each task */ static int start_graph_tracing(void) diff --git a/kernel/trace/ftrace_internal.h b/kernel/trace/ftrace_internal.h index 4bb1e881154a..3235470e61b3 100644 --- a/kernel/trace/ftrace_internal.h +++ b/kernel/trace/ftrace_internal.h @@ -52,7 +52,11 @@ static inline int ftrace_shutdown_subops(struct ftrace_o= ps *ops, struct ftrace_o =20 #ifdef CONFIG_FUNCTION_GRAPH_TRACER extern int ftrace_graph_active; +# ifdef CONFIG_DYNAMIC_FTRACE extern void fgraph_update_pid_func(void); +# else +static inline void fgraph_update_pid_func(void) {} +# endif #else /* !CONFIG_FUNCTION_GRAPH_TRACER */ # define ftrace_graph_active 0 static inline void fgraph_update_pid_func(void) {} --=20 2.43.0 From nobody Thu Feb 12 14:09:22 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 869C38488 for ; Tue, 11 Jun 2024 20:46:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718138772; cv=none; b=F2VN4aW3kyf/k55n8hbBIk5me9/xmOtS/54XRoN7Wn2nwSonSak4E8HH5Rrd1I29ji6OnnKnW51LXlf0BTSvYsYzdfEYf94PpwM8zqId9CueMUEYKW7vCXYTNDWgdJ1JJgABgitq+TwExqStsHtdG0CoYJe9HbclLVQAK/JT2yI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718138772; c=relaxed/simple; bh=+6gP8t0w01bewNTXjkKuZ7tRG/S6J++weKA38nZj6JM=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=RqhYN6OKNbcBnnS+x3RKbiiYqV1FzU45K2kkKu+WxCNReS+O1tX2Ifvb0qkYCsu9jhehcTuze22QBT5Dk8MdkBvku6gjlBQh6ODwGdN4Z+OibFKz6d4INisqghBNZhKYnjS5L52DPyWwmgx4OuBoMIQviypURJ5q+CMIqQN00Cw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3026FC4AF4D; Tue, 11 Jun 2024 20:46:12 +0000 (UTC) Received: from rostedt by gandalf with local (Exim 4.97) (envelope-from ) id 1sH8Nw-00000001V39-3J5g; Tue, 11 Jun 2024 16:46:28 -0400 Message-ID: <20240611204628.651616294@goodmis.org> User-Agent: quilt/0.68 Date: Tue, 11 Jun 2024 16:45:56 -0400 From: Steven Rostedt To: linux-kernel@vger.kernel.org Cc: Masami Hiramatsu , Mark Rutland , Mathieu Desnoyers , Andrew Morton , Jonathan Corbet , Catalin Marinas , Will Deacon , Guo Ren , Huacai Chen , WANG Xuerui , Michael Ellerman , Nicholas Piggin , Christophe Leroy , "Naveen N. Rao" , Paul Walmsley , Palmer Dabbelt , Albert Ou , Heiko Carstens , Vasily Gorbik , Alexander Gordeev , Christian Borntraeger , Sven Schnelle , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" , Yang Li Subject: [for-next][PATCH 2/4] function_graph: Fix up ftrace_graph_ret_addr() References: <20240611204554.092271761@goodmis.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: "Steven Rostedt (Google)" Yang Li sent a patch to fix the kerneldoc of ftrace_graph_ret_addr(). While reviewing it, I realized that the comments in the entire function header needed a rewrite. When doing that, I realized that @idx parameter was being ignored. Every time this was called by the unwinder, it would start the loop at the top of the shadow stack and look for the matching stack pointer. When it found it, it would return it. When the unwinder asked for the next function, it would search from the beginning again. In reality, it should start from where it left off. That was the reason for the @idx parameter in the first place. The first time the unwinder calls this function, the @idx pointer would contain zero. That would mean to start from the top of the stack. The function was supposed to update the @idx with the index where it found the return address, so that the next time the unwinder calls this function it doesn't have to search through the previous addresses it found (making it O(n^2)!). This speeds up the unwinder's use of ftrace_graph_ret_addr() by an order of magnitude. Link: https://lore.kernel.org/linux-trace-kernel/20240610181746.656e3759@ga= ndalf.local.home/ Link: https://lore.kernel.org/linux-trace-kernel/20240611031737.821995106@g= oodmis.org Cc: Masami Hiramatsu Cc: Mark Rutland Cc: Mathieu Desnoyers Cc: Jonathan Corbet Cc: Catalin Marinas Cc: Will Deacon Cc: Guo Ren Cc: Huacai Chen Cc: WANG Xuerui Cc: Michael Ellerman Cc: Nicholas Piggin Cc: Christophe Leroy Cc: "Naveen N. Rao" Cc: Paul Walmsley Cc: Palmer Dabbelt Cc: Albert Ou Cc: Heiko Carstens Cc: Vasily Gorbik Cc: Alexander Gordeev Cc: Christian Borntraeger Cc: Sven Schnelle Cc: Thomas Gleixner Cc: Ingo Molnar Cc: Borislav Petkov Cc: Dave Hansen Cc: "H. Peter Anvin" Reported-by: Yang Li Fixes: 7aa1eaef9f428 ("function_graph: Allow multiple users to attach to fu= nction graph") Signed-off-by: Steven Rostedt (Google) --- kernel/trace/fgraph.c | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/kernel/trace/fgraph.c b/kernel/trace/fgraph.c index 63d0c2f84ce1..91f1eef256af 100644 --- a/kernel/trace/fgraph.c +++ b/kernel/trace/fgraph.c @@ -870,18 +870,24 @@ ftrace_graph_get_ret_stack(struct task_struct *task, = int idx) } =20 /** - * ftrace_graph_ret_addr - convert a potentially modified stack return add= ress - * to its original value + * ftrace_graph_ret_addr - return the original value of the return address + * @task: The task the unwinder is being executed on + * @idx: An initialized pointer to the next stack index to use + * @ret: The current return address (likely pointing to return_handler) + * @retp: The address on the stack of the current return location * * This function can be called by stack unwinding code to convert a found = stack - * return address ('ret') to its original value, in case the function graph + * return address (@ret) to its original value, in case the function graph * tracer has modified it to be 'return_to_handler'. If the address hasn't - * been modified, the unchanged value of 'ret' is returned. + * been modified, the unchanged value of @ret is returned. * - * 'idx' is a state variable which should be initialized by the caller to = zero - * before the first call. + * @idx holds the last index used to know where to start from. It should be + * initialized to zero for the first iteration as that will mean to start + * at the top of the shadow stack. If the location is found, this pointer + * will be assigned that location so that if called again, it will continue + * where it left off. * - * 'retp' is a pointer to the return address on the stack. It's ignored if + * @retp is a pointer to the return address on the stack. It's ignored if * the arch doesn't have HAVE_FUNCTION_GRAPH_RET_ADDR_PTR defined. */ #ifdef HAVE_FUNCTION_GRAPH_RET_ADDR_PTR @@ -895,6 +901,10 @@ unsigned long ftrace_graph_ret_addr(struct task_struct= *task, int *idx, if (ret !=3D return_handler) return ret; =20 + if (!idx) + return ret; + + i =3D *idx ? : task->curr_ret_stack; while (i > 0) { ret_stack =3D get_ret_stack(current, i, &i); if (!ret_stack) @@ -908,8 +918,10 @@ unsigned long ftrace_graph_ret_addr(struct task_struct= *task, int *idx, * Thus we will continue to find real return address. */ if (ret_stack->retp =3D=3D retp && - ret_stack->ret !=3D return_handler) + ret_stack->ret !=3D return_handler) { + *idx =3D i; return ret_stack->ret; + } } =20 return ret; --=20 2.43.0 From nobody Thu Feb 12 14:09:22 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AF14484A21 for ; Tue, 11 Jun 2024 20:46:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718138772; cv=none; b=ZB3LhkhB5kU4eI0uiEWj82UNnVOnomupbbl8dTv3PL+mIK6ddnFvairECO8NvU0ERh6Xs2x60w45hcVziMo3XX1J0t3EmVqtUDrxD41LreZY+lhpahjpcsDbrzDQm40GHxVUzubsJOotbqIcDLZiwX2HhO37Ak45TC/7PFLvAsM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718138772; c=relaxed/simple; bh=NLn3FypQGVT0OqUHI0W5V8u523q/O3WxpepNIZOFktE=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=oK4Fu70PjePYhiuWE1PBas6HD23cQztUvCE+ONt2UUpVvtt4vjQfskA4z9kTflqQQruKHAZ3qRCHfkMwrZSicW9iq0UlN1mXBhInus9nrrh4+3izqEH0dUcYOEpjU3QlUnG6EaGeIlAqD5rDyWgnzLCcL39PEePZdmPM/P97DBE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4B9E9C4AF52; Tue, 11 Jun 2024 20:46:12 +0000 (UTC) Received: from rostedt by gandalf with local (Exim 4.97) (envelope-from ) id 1sH8Nw-00000001V3d-3zE0; Tue, 11 Jun 2024 16:46:28 -0400 Message-ID: <20240611204628.808810560@goodmis.org> User-Agent: quilt/0.68 Date: Tue, 11 Jun 2024 16:45:57 -0400 From: Steven Rostedt To: linux-kernel@vger.kernel.org Cc: Masami Hiramatsu , Mark Rutland , Mathieu Desnoyers , Andrew Morton , Jonathan Corbet , Catalin Marinas , Will Deacon , Guo Ren , Huacai Chen , WANG Xuerui , Michael Ellerman , Nicholas Piggin , Christophe Leroy , "Naveen N. Rao" , Paul Walmsley , Palmer Dabbelt , Albert Ou , Heiko Carstens , Vasily Gorbik , Alexander Gordeev , Christian Borntraeger , Sven Schnelle , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" Subject: [for-next][PATCH 3/4] function_graph: Everyone uses HAVE_FUNCTION_GRAPH_RET_ADDR_PTR, remove it References: <20240611204554.092271761@goodmis.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: "Steven Rostedt (Google)" 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@g= oodmis.org Cc: Masami Hiramatsu Cc: Mark Rutland Cc: Mathieu Desnoyers Cc: Jonathan Corbet Cc: Catalin Marinas Cc: Will Deacon Cc: Guo Ren Cc: Huacai Chen Cc: WANG Xuerui Cc: Michael Ellerman Cc: Nicholas Piggin Cc: Christophe Leroy Cc: "Naveen N. Rao" Cc: Paul Walmsley Cc: Palmer Dabbelt Cc: Albert Ou Cc: Heiko Carstens Cc: Vasily Gorbik Cc: Alexander Gordeev Cc: Christian Borntraeger Cc: Sven Schnelle Cc: Thomas Gleixner Cc: Ingo Molnar Cc: Borislav Petkov Cc: Dave Hansen Cc: "H. Peter Anvin" Signed-off-by: Steven Rostedt (Google) --- Documentation/trace/ftrace-design.rst | 12 --------- arch/arm64/include/asm/ftrace.h | 11 --------- arch/csky/include/asm/ftrace.h | 2 -- arch/loongarch/include/asm/ftrace.h | 1 - arch/powerpc/include/asm/ftrace.h | 2 -- arch/riscv/include/asm/ftrace.h | 1 - arch/s390/include/asm/ftrace.h | 1 - arch/x86/include/asm/ftrace.h | 2 -- include/linux/ftrace.h | 2 -- kernel/trace/fgraph.c | 35 +-------------------------- 10 files changed, 1 insertion(+), 68 deletions(-) diff --git a/Documentation/trace/ftrace-design.rst b/Documentation/trace/ft= race-design.rst index 6893399157f0..dc82d64b3a44 100644 --- a/Documentation/trace/ftrace-design.rst +++ b/Documentation/trace/ftrace-design.rst @@ -217,18 +217,6 @@ along to ftrace_push_return_trace() instead of a stub = value of 0. =20 Similarly, when you call ftrace_return_to_handler(), pass it the frame poi= nter. =20 -HAVE_FUNCTION_GRAPH_RET_ADDR_PTR --------------------------------- - -An arch may pass in a pointer to the return address on the stack. This -prevents potential stack unwinding issues where the unwinder gets out of -sync with ret_stack and the wrong addresses are reported by -ftrace_graph_ret_addr(). - -Adding support for it is easy: just define the macro in asm/ftrace.h and -pass the return address pointer as the 'retp' argument to -ftrace_push_return_trace(). - HAVE_SYSCALL_TRACEPOINTS ------------------------ =20 diff --git a/arch/arm64/include/asm/ftrace.h b/arch/arm64/include/asm/ftrac= e.h index ab158196480c..dc9cf0bd2a4c 100644 --- a/arch/arm64/include/asm/ftrace.h +++ b/arch/arm64/include/asm/ftrace.h @@ -12,17 +12,6 @@ =20 #define HAVE_FUNCTION_GRAPH_FP_TEST =20 -/* - * HAVE_FUNCTION_GRAPH_RET_ADDR_PTR means that the architecture can provid= e a - * "return address pointer" which can be used to uniquely identify a return - * address which has been overwritten. - * - * On arm64 we use the address of the caller's frame record, which remains= the - * same for the lifetime of the instrumented function, unlike the return - * address in the LR. - */ -#define HAVE_FUNCTION_GRAPH_RET_ADDR_PTR - #ifdef CONFIG_DYNAMIC_FTRACE_WITH_ARGS #define ARCH_SUPPORTS_FTRACE_OPS 1 #else diff --git a/arch/csky/include/asm/ftrace.h b/arch/csky/include/asm/ftrace.h index fd215c38ef27..00f9f7647e3f 100644 --- a/arch/csky/include/asm/ftrace.h +++ b/arch/csky/include/asm/ftrace.h @@ -7,8 +7,6 @@ =20 #define HAVE_FUNCTION_GRAPH_FP_TEST =20 -#define HAVE_FUNCTION_GRAPH_RET_ADDR_PTR - #define ARCH_SUPPORTS_FTRACE_OPS 1 =20 #define MCOUNT_ADDR ((unsigned long)_mcount) diff --git a/arch/loongarch/include/asm/ftrace.h b/arch/loongarch/include/a= sm/ftrace.h index de891c2c83d4..c0a682808e07 100644 --- a/arch/loongarch/include/asm/ftrace.h +++ b/arch/loongarch/include/asm/ftrace.h @@ -28,7 +28,6 @@ struct dyn_ftrace; struct dyn_arch_ftrace { }; =20 #define ARCH_SUPPORTS_FTRACE_OPS 1 -#define HAVE_FUNCTION_GRAPH_RET_ADDR_PTR =20 #define ftrace_init_nop ftrace_init_nop int ftrace_init_nop(struct module *mod, struct dyn_ftrace *rec); diff --git a/arch/powerpc/include/asm/ftrace.h b/arch/powerpc/include/asm/f= trace.h index 107fc5a48456..559560286e6d 100644 --- a/arch/powerpc/include/asm/ftrace.h +++ b/arch/powerpc/include/asm/ftrace.h @@ -8,8 +8,6 @@ #define MCOUNT_ADDR ((unsigned long)(_mcount)) #define MCOUNT_INSN_SIZE 4 /* sizeof mcount call */ =20 -#define HAVE_FUNCTION_GRAPH_RET_ADDR_PTR - /* Ignore unused weak functions which will have larger offsets */ #if defined(CONFIG_MPROFILE_KERNEL) || defined(CONFIG_ARCH_USING_PATCHABLE= _FUNCTION_ENTRY) #define FTRACE_MCOUNT_MAX_OFFSET 16 diff --git a/arch/riscv/include/asm/ftrace.h b/arch/riscv/include/asm/ftrac= e.h index 9eb31a7ea0aa..2cddd79ff21b 100644 --- a/arch/riscv/include/asm/ftrace.h +++ b/arch/riscv/include/asm/ftrace.h @@ -11,7 +11,6 @@ #if defined(CONFIG_FUNCTION_GRAPH_TRACER) && defined(CONFIG_FRAME_POINTER) #define HAVE_FUNCTION_GRAPH_FP_TEST #endif -#define HAVE_FUNCTION_GRAPH_RET_ADDR_PTR =20 #define ARCH_SUPPORTS_FTRACE_OPS 1 #ifndef __ASSEMBLY__ diff --git a/arch/s390/include/asm/ftrace.h b/arch/s390/include/asm/ftrace.h index 77e479d44f1e..fbadca645af7 100644 --- a/arch/s390/include/asm/ftrace.h +++ b/arch/s390/include/asm/ftrace.h @@ -2,7 +2,6 @@ #ifndef _ASM_S390_FTRACE_H #define _ASM_S390_FTRACE_H =20 -#define HAVE_FUNCTION_GRAPH_RET_ADDR_PTR #define ARCH_SUPPORTS_FTRACE_OPS 1 #define MCOUNT_INSN_SIZE 6 =20 diff --git a/arch/x86/include/asm/ftrace.h b/arch/x86/include/asm/ftrace.h index 897cf02c20b1..0152a81d9b4a 100644 --- a/arch/x86/include/asm/ftrace.h +++ b/arch/x86/include/asm/ftrace.h @@ -20,8 +20,6 @@ #define ARCH_SUPPORTS_FTRACE_OPS 1 #endif =20 -#define HAVE_FUNCTION_GRAPH_RET_ADDR_PTR - #ifndef __ASSEMBLY__ extern void __fentry__(void); =20 diff --git a/include/linux/ftrace.h b/include/linux/ftrace.h index 4135dc171447..845c2ab0bc1c 100644 --- a/include/linux/ftrace.h +++ b/include/linux/ftrace.h @@ -1071,9 +1071,7 @@ struct ftrace_ret_stack { #ifdef HAVE_FUNCTION_GRAPH_FP_TEST unsigned long fp; #endif -#ifdef HAVE_FUNCTION_GRAPH_RET_ADDR_PTR unsigned long *retp; -#endif }; =20 /* diff --git a/kernel/trace/fgraph.c b/kernel/trace/fgraph.c index 91f1eef256af..8317d1a7f43a 100644 --- a/kernel/trace/fgraph.c +++ b/kernel/trace/fgraph.c @@ -593,9 +593,7 @@ ftrace_push_return_trace(unsigned long ret, unsigned lo= ng func, #ifdef HAVE_FUNCTION_GRAPH_FP_TEST ret_stack->fp =3D frame_pointer; #endif -#ifdef HAVE_FUNCTION_GRAPH_RET_ADDR_PTR ret_stack->retp =3D retp; -#endif return offset; } =20 @@ -887,10 +885,8 @@ ftrace_graph_get_ret_stack(struct task_struct *task, i= nt idx) * will be assigned that location so that if called again, it will continue * where it left off. * - * @retp is a pointer to the return address on the stack. It's ignored if - * the arch doesn't have HAVE_FUNCTION_GRAPH_RET_ADDR_PTR defined. + * @retp is a pointer to the return address on the stack. */ -#ifdef HAVE_FUNCTION_GRAPH_RET_ADDR_PTR unsigned long ftrace_graph_ret_addr(struct task_struct *task, int *idx, unsigned long ret, unsigned long *retp) { @@ -926,35 +922,6 @@ unsigned long ftrace_graph_ret_addr(struct task_struct= *task, int *idx, =20 return ret; } -#else /* !HAVE_FUNCTION_GRAPH_RET_ADDR_PTR */ -unsigned long ftrace_graph_ret_addr(struct task_struct *task, int *idx, - unsigned long ret, unsigned long *retp) -{ - struct ftrace_ret_stack *ret_stack; - unsigned long return_handler =3D (unsigned long)dereference_kernel_functi= on_descriptor(return_to_handler); - int offset =3D task->curr_ret_stack; - int i; - - if (ret !=3D return_handler) - return ret; - - if (!idx) - return ret; - - i =3D *idx; - do { - ret_stack =3D get_ret_stack(task, offset, &offset); - if (ret_stack && ret_stack->ret =3D=3D return_handler) - continue; - i--; - } while (i >=3D 0 && ret_stack); - - if (ret_stack) - return ret_stack->ret; - - return ret; -} -#endif /* HAVE_FUNCTION_GRAPH_RET_ADDR_PTR */ =20 static struct ftrace_ops graph_ops =3D { .func =3D ftrace_graph_func, --=20 2.43.0 From nobody Thu Feb 12 14:09:22 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DA9F615278E for ; Tue, 11 Jun 2024 20:46:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718138772; cv=none; b=X9XqT9CKGR3nOfGmJkh6XIz0q3nce3FA1L0bfxq7tmm2bLLc5+QaVE+XLkZmvd/PXNKznWq6nafwi7kUuIvtZVydyPRpwa4IjdltoKykX9NUC8KCSpG/pZR2Pb+goKerJR9Vy/eubMquo/HHEnC99lvD58JSCm1AB9SIY5jNlDc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718138772; c=relaxed/simple; bh=mlfoC7wSjNFUGkvrNFnurpR22N9Qil8iNTgQKZPwB0s=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=uYvH7O8bVeRhVAR50RL4D+w1yBddTSlKrTrhuKUIHCKlrFEluJsI5VEeUUomIxqPQj8wKJm0fqRJcdrRjIEAZeLFC/plgheeBzMSzyu2QAIYP4WTmqGU+W9v9BERnGzvZtVC4gohPvBjMVQ7YBSoB0pCckwbVcSDXmZ4/sgyVa0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6D21EC4AF55; Tue, 11 Jun 2024 20:46:12 +0000 (UTC) Received: from rostedt by gandalf with local (Exim 4.97) (envelope-from ) id 1sH8Nx-00000001V47-0RxS; Tue, 11 Jun 2024 16:46:29 -0400 Message-ID: <20240611204628.970422788@goodmis.org> User-Agent: quilt/0.68 Date: Tue, 11 Jun 2024 16:45:58 -0400 From: Steven Rostedt To: linux-kernel@vger.kernel.org Cc: Masami Hiramatsu , Mark Rutland , Mathieu Desnoyers , Andrew Morton , Shuah Khan , Javier Carrasco , Marilene A Garcia Subject: [for-next][PATCH 4/4] ftrace: Add missing kerneldoc parameters to unregister_ftrace_direct() References: <20240611204554.092271761@goodmis.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Marilene A Garcia Add the description to the parameters addr and free_filters of the function unregister_ftrace_direct(). Link: https://lore.kernel.org/linux-trace-kernel/20240606132520.1397567-1-m= arilene.agarcia@gmail.com Cc: Masami Hiramatsu Cc: Mark Rutland Cc: Mathieu Desnoyers Cc: Shuah Khan Cc: Javier Carrasco Signed-off-by: Marilene A Garcia Signed-off-by: Steven Rostedt (Google) --- kernel/trace/ftrace.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c index 4aeb1183ea9f..f44229294e9d 100644 --- a/kernel/trace/ftrace.c +++ b/kernel/trace/ftrace.c @@ -5988,6 +5988,8 @@ EXPORT_SYMBOL_GPL(register_ftrace_direct); * unregister_ftrace_direct - Remove calls to custom trampoline * previously registered by register_ftrace_direct for @ops object. * @ops: The address of the struct ftrace_ops object + * @addr: The address of the direct function that is called by the @ops fu= nctions + * @free_filters: Set to true to remove all filters for the ftrace_ops, fa= lse otherwise * * This is used to remove a direct calls to @addr from the nop locations * of the functions registered in @ops (with by ftrace_set_filter_ip --=20 2.43.0