[PATCH 2/4] s390/ftrace: Serialize text patching with text_mutex
From: Heiko Carstens
Date: Mon Oct 26 2026 - 08:10:23 EST
Add ftrace_arch_code_modify_prepare() and extend
ftrace_arch_code_modify_post_process() to acquire and release text_mutex
around the ftrace code modification pass. This way s390 uses text_mutex
like e.g. x86 and riscv.
This is a prereq for removing the spinlock in __s390_kernel_write().
Signed-off-by: Heiko Carstens <hca@xxxxxxxxxxxxx>
---
arch/s390/kernel/ftrace.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/arch/s390/kernel/ftrace.c b/arch/s390/kernel/ftrace.c
index e94bb98f5231..772dbdcc51f2 100644
--- a/arch/s390/kernel/ftrace.c
+++ b/arch/s390/kernel/ftrace.c
@@ -8,6 +8,7 @@
*/
#include <linux/hardirq.h>
+#include <linux/memory.h>
#include <linux/uaccess.h>
#include <linux/ftrace.h>
#include <linux/kernel.h>
@@ -247,13 +248,21 @@ int ftrace_update_ftrace_func(ftrace_func_t func)
return 0;
}
+void ftrace_arch_code_modify_prepare(void)
+ __acquires(&text_mutex)
+{
+ mutex_lock(&text_mutex);
+}
+
void arch_ftrace_update_code(int command)
{
ftrace_modify_all_code(command);
}
void ftrace_arch_code_modify_post_process(void)
+ __releases(&text_mutex)
{
+ mutex_unlock(&text_mutex);
/*
* Flush any pre-fetched instructions on all
* CPUs to make the new code visible.
--
2.53.0