14
14
#include <asm/text-patching.h>
15
15
16
16
#ifdef CONFIG_DYNAMIC_FTRACE
17
+ void ftrace_arch_code_modify_prepare (void )
18
+ __acquires (& text_mutex )
19
+ {
20
+ mutex_lock (& text_mutex );
21
+ }
22
+
23
+ void ftrace_arch_code_modify_post_process (void )
24
+ __releases (& text_mutex )
25
+ {
26
+ mutex_unlock (& text_mutex );
27
+ }
28
+
17
29
unsigned long ftrace_call_adjust (unsigned long addr )
18
30
{
19
31
if (IS_ENABLED (CONFIG_DYNAMIC_FTRACE_WITH_CALL_OPS ))
@@ -29,10 +41,8 @@ unsigned long arch_ftrace_get_symaddr(unsigned long fentry_ip)
29
41
30
42
void arch_ftrace_update_code (int command )
31
43
{
32
- mutex_lock (& text_mutex );
33
44
command |= FTRACE_MAY_SLEEP ;
34
45
ftrace_modify_all_code (command );
35
- mutex_unlock (& text_mutex );
36
46
flush_icache_all ();
37
47
}
38
48
@@ -149,6 +159,8 @@ int ftrace_init_nop(struct module *mod, struct dyn_ftrace *rec)
149
159
unsigned int nops [2 ], offset ;
150
160
int ret ;
151
161
162
+ guard (mutex )(& text_mutex );
163
+
152
164
ret = ftrace_rec_set_nop_ops (rec );
153
165
if (ret )
154
166
return ret ;
@@ -157,9 +169,7 @@ int ftrace_init_nop(struct module *mod, struct dyn_ftrace *rec)
157
169
nops [0 ] = to_auipc_t0 (offset );
158
170
nops [1 ] = RISCV_INSN_NOP4 ;
159
171
160
- mutex_lock (& text_mutex );
161
172
ret = patch_insn_write ((void * )pc , nops , 2 * MCOUNT_INSN_SIZE );
162
- mutex_unlock (& text_mutex );
163
173
164
174
return ret ;
165
175
}
0 commit comments