[PATCH v4 04/12] kernel: ftrace: export ftrace_sync_ipi

From: Andy Chiu
Date: Mon Apr 07 2025 - 14:11:21 EST


The following ftrace patch for riscv uses a data store to update ftrace
function. Therefore, a romote fence is required to order it against
function_trace_op updates. The mechanism is similar to the fence between
function_trace_op and update_ftrace_func in the generic ftrace, so we
leverage the same ftrace_sync_ipi function.

Signed-off-by: Andy Chiu <andybnac@xxxxxxxxx>
---
include/linux/ftrace.h | 1 +
kernel/trace/ftrace.c | 2 +-
2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/include/linux/ftrace.h b/include/linux/ftrace.h
index fbabc3d848b3..0d4eec574707 100644
--- a/include/linux/ftrace.h
+++ b/include/linux/ftrace.h
@@ -807,6 +807,7 @@ extern void ftrace_call(void);
extern void ftrace_regs_call(void);
extern void mcount_call(void);

+void ftrace_sync_ipi(void *data);
void ftrace_modify_all_code(int command);

#ifndef FTRACE_ADDR
diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
index ee662f380b61..d06bd4a046de 100644
--- a/kernel/trace/ftrace.c
+++ b/kernel/trace/ftrace.c
@@ -188,7 +188,7 @@ static void ftrace_pid_func(unsigned long ip, unsigned long parent_ip,
op->saved_func(ip, parent_ip, op, fregs);
}

-static void ftrace_sync_ipi(void *data)
+void ftrace_sync_ipi(void *data)
{
/* Probably not needed, but do it anyway */
smp_rmb();
--
2.39.3 (Apple Git-145)