Skip to content

Commit 54ecbc8

Browse files
AndybnACTpalmer-dabbelt
authored andcommitted
riscv: ftrace factor out code defined by !WITH_ARG
DYNAMIC_FTRACE selects DYNAMIC_FTRACE_WITH_ARGS and mcount-dyn.S in riscv, so we can remove ifdef jargons of WITH_ARG when it is known that DYNAMIC_FTRACE is true. Signed-off-by: Andy Chiu <andybnac@gmail.com> Link: https://lore.kernel.org/r/20250407180838.42877-2-andybnac@gmail.com Signed-off-by: Alexandre Ghiti <alexghiti@rivosinc.com> Signed-off-by: Palmer Dabbelt <palmer@dabbelt.com>
1 parent f8693f6 commit 54ecbc8

File tree

2 files changed

+0
-49
lines changed

2 files changed

+0
-49
lines changed

arch/riscv/kernel/ftrace.c

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,6 @@ void prepare_ftrace_return(unsigned long *parent, unsigned long self_addr,
210210
}
211211

212212
#ifdef CONFIG_DYNAMIC_FTRACE
213-
#ifdef CONFIG_DYNAMIC_FTRACE_WITH_ARGS
214213
void ftrace_graph_func(unsigned long ip, unsigned long parent_ip,
215214
struct ftrace_ops *op, struct ftrace_regs *fregs)
216215
{
@@ -231,19 +230,5 @@ void ftrace_graph_func(unsigned long ip, unsigned long parent_ip,
231230
if (!function_graph_enter_regs(old, ip, frame_pointer, parent, fregs))
232231
*parent = return_hooker;
233232
}
234-
#else /* CONFIG_DYNAMIC_FTRACE_WITH_ARGS */
235-
extern void ftrace_graph_call(void);
236-
int ftrace_enable_ftrace_graph_caller(void)
237-
{
238-
return __ftrace_modify_call((unsigned long)&ftrace_graph_call,
239-
(unsigned long)&prepare_ftrace_return, true, true);
240-
}
241-
242-
int ftrace_disable_ftrace_graph_caller(void)
243-
{
244-
return __ftrace_modify_call((unsigned long)&ftrace_graph_call,
245-
(unsigned long)&prepare_ftrace_return, false, true);
246-
}
247-
#endif /* CONFIG_DYNAMIC_FTRACE_WITH_ARGS */
248233
#endif /* CONFIG_DYNAMIC_FTRACE */
249234
#endif /* CONFIG_FUNCTION_GRAPH_TRACER */

arch/riscv/kernel/mcount-dyn.S

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,6 @@
5656
addi sp, sp, ABI_SIZE_ON_STACK
5757
.endm
5858

59-
#ifdef CONFIG_DYNAMIC_FTRACE_WITH_ARGS
60-
6159
/**
6260
* SAVE_ABI_REGS - save regs against the ftrace_regs struct
6361
*
@@ -149,36 +147,6 @@
149147
mv a3, sp
150148
.endm
151149

152-
#endif /* CONFIG_DYNAMIC_FTRACE_WITH_ARGS */
153-
154-
#ifndef CONFIG_DYNAMIC_FTRACE_WITH_ARGS
155-
SYM_FUNC_START(ftrace_caller)
156-
SAVE_ABI
157-
158-
addi a0, t0, -FENTRY_RA_OFFSET
159-
la a1, function_trace_op
160-
REG_L a2, 0(a1)
161-
mv a1, ra
162-
mv a3, sp
163-
164-
SYM_INNER_LABEL(ftrace_call, SYM_L_GLOBAL)
165-
call ftrace_stub
166-
167-
#ifdef CONFIG_FUNCTION_GRAPH_TRACER
168-
addi a0, sp, ABI_RA
169-
REG_L a1, ABI_T0(sp)
170-
addi a1, a1, -FENTRY_RA_OFFSET
171-
#ifdef HAVE_FUNCTION_GRAPH_FP_TEST
172-
mv a2, s0
173-
#endif
174-
SYM_INNER_LABEL(ftrace_graph_call, SYM_L_GLOBAL)
175-
call ftrace_stub
176-
#endif
177-
RESTORE_ABI
178-
jr t0
179-
SYM_FUNC_END(ftrace_caller)
180-
181-
#else /* CONFIG_DYNAMIC_FTRACE_WITH_ARGS */
182150
SYM_FUNC_START(ftrace_caller)
183151
mv t1, zero
184152
SAVE_ABI_REGS
@@ -194,8 +162,6 @@ SYM_INNER_LABEL(ftrace_call, SYM_L_GLOBAL)
194162
jr t1
195163
SYM_FUNC_END(ftrace_caller)
196164

197-
#endif /* CONFIG_DYNAMIC_FTRACE_WITH_ARGS */
198-
199165
#ifdef CONFIG_DYNAMIC_FTRACE_WITH_DIRECT_CALLS
200166
SYM_CODE_START(ftrace_stub_direct_tramp)
201167
jr t0

0 commit comments

Comments
 (0)