All instances of the function ftrace_arch_modify_prepare() and ftrace_arch_modify_post_process() return zero. There's no point in checking their return value. Just have them be void functions. Link: https://lkml.kernel.org/r/20220518023639.4065-1-kunyu@nfschina.com
Unified · Split
| @@ -79,16 +79,14 @@ static unsigned long __ref adjust_address(struct dyn_ftrace *rec, · 78 unmodified lines | |||
| 79 | return (unsigned long)&ftrace_regs_caller_from_init; | 79 | return (unsigned long)&ftrace_regs_caller_from_init; |
| 80 | } | 80 | } |
| 81 | 81 | ||
| 82 | int ftrace_arch_code_modify_prepare(void) | 82 | void ftrace_arch_code_modify_prepare(void) |
| 83 | { | 83 | { |
| 84 | return 0; | ||
| 85 | } | 84 | } |
| 86 | 85 | ||
| 87 | int ftrace_arch_code_modify_post_process(void) | 86 | void ftrace_arch_code_modify_post_process(void) |
| 88 | { | 87 | { |
| 89 | /* Make sure any TLB misses during machine stop are cleared. */ | 88 | /* Make sure any TLB misses during machine stop are cleared. */ |
| 90 | flush_tlb_all(); | 89 | flush_tlb_all(); |
| 91 | return 0; | ||
| 92 | } | 90 | } |
| 93 | 91 | ||
| 94 | static unsigned long ftrace_call_replace(unsigned long pc, unsigned long addr, | 92 | static unsigned long ftrace_call_replace(unsigned long pc, unsigned long addr, |
| @@ -12,16 +12,14 @@ · 11 unmodified lines | |||
| 12 | #include <asm/patch.h> | 12 | #include <asm/patch.h> |
| 13 | 13 | ||
| 14 | #ifdef CONFIG_DYNAMIC_FTRACE | 14 | #ifdef CONFIG_DYNAMIC_FTRACE |
| 15 | int ftrace_arch_code_modify_prepare(void) __acquires(&text_mutex) | 15 | void ftrace_arch_code_modify_prepare(void) __acquires(&text_mutex) |
| 16 | { | 16 | { |
| 17 | mutex_lock(&text_mutex); | 17 | mutex_lock(&text_mutex); |
| 18 | return 0; | ||
| 19 | } | 18 | } |
| 20 | 19 | ||
| 21 | int ftrace_arch_code_modify_post_process(void) __releases(&text_mutex) | 20 | void ftrace_arch_code_modify_post_process(void) __releases(&text_mutex) |
| 22 | { | 21 | { |
| 23 | mutex_unlock(&text_mutex); | 22 | mutex_unlock(&text_mutex); |
| 24 | return 0; | ||
| 25 | } | 23 | } |
| 26 | 24 | ||
| 27 | static int ftrace_check_current_call(unsigned long hook_pos, | 25 | static int ftrace_check_current_call(unsigned long hook_pos, |
| @@ -225,14 +225,13 @@ void arch_ftrace_update_code(int command) · 224 unmodified lines | |||
| 225 | ftrace_modify_all_code(command); | 225 | ftrace_modify_all_code(command); |
| 226 | } | 226 | } |
| 227 | 227 | ||
| 228 | int ftrace_arch_code_modify_post_process(void) | 228 | void ftrace_arch_code_modify_post_process(void) |
| 229 | { | 229 | { |
| 230 | /* | 230 | /* |
| 231 | * Flush any pre-fetched instructions on all | 231 | * Flush any pre-fetched instructions on all |
| 232 | * CPUs to make the new code visible. | 232 | * CPUs to make the new code visible. |
| 233 | */ | 233 | */ |
| 234 | text_poke_sync_lock(); | 234 | text_poke_sync_lock(); |
| 235 | return 0; | ||
| 236 | } | 235 | } |
| 237 | 236 | ||
| 238 | #ifdef CONFIG_MODULES | 237 | #ifdef CONFIG_MODULES |
| @@ -37,7 +37,7 @@ · 36 unmodified lines | |||
| 37 | 37 | ||
| 38 | static int ftrace_poke_late = 0; | 38 | static int ftrace_poke_late = 0; |
| 39 | 39 | ||
| 40 | int ftrace_arch_code_modify_prepare(void) | 40 | void ftrace_arch_code_modify_prepare(void) |
| 41 | __acquires(&text_mutex) | 41 | __acquires(&text_mutex) |
| 42 | { | 42 | { |
| 43 | /* | 43 | /* |
| @@ -47,10 +47,9 @@ int ftrace_arch_code_modify_prepare(void) · 3 unmodified lines | |||
| 47 | */ | 47 | */ |
| 48 | mutex_lock(&text_mutex); | 48 | mutex_lock(&text_mutex); |
| 49 | ftrace_poke_late = 1; | 49 | ftrace_poke_late = 1; |
| 50 | return 0; | ||
| 51 | } | 50 | } |
| 52 | 51 | ||
| 53 | int ftrace_arch_code_modify_post_process(void) | 52 | void ftrace_arch_code_modify_post_process(void) |
| 54 | __releases(&text_mutex) | 53 | __releases(&text_mutex) |
| 55 | { | 54 | { |
| 56 | /* | 55 | /* |
| @@ -61,7 +60,6 @@ int ftrace_arch_code_modify_post_process(void) · 4 unmodified lines | |||
| 61 | text_poke_finish(); | 60 | text_poke_finish(); |
| 62 | ftrace_poke_late = 0; | 61 | ftrace_poke_late = 0; |
| 63 | mutex_unlock(&text_mutex); | 62 | mutex_unlock(&text_mutex); |
| 64 | return 0; | ||
| 65 | } | 63 | } |
| 66 | 64 | ||
| 67 | static const char *ftrace_nop_replace(void) | 65 | static const char *ftrace_nop_replace(void) |
| @@ -449,8 +449,8 @@ static inline void stack_tracer_enable(void) { } · 448 unmodified lines | |||
| 449 | 449 | ||
| 450 | #ifdef CONFIG_DYNAMIC_FTRACE | 450 | #ifdef CONFIG_DYNAMIC_FTRACE |
| 451 | 451 | ||
| 452 | int ftrace_arch_code_modify_prepare(void); | 452 | void ftrace_arch_code_modify_prepare(void); |
| 453 | int ftrace_arch_code_modify_post_process(void); | 453 | void ftrace_arch_code_modify_post_process(void); |
| 454 | 454 | ||
| 455 | enum ftrace_bug_type { | 455 | enum ftrace_bug_type { |
| 456 | FTRACE_BUG_UNKNOWN, | 456 | FTRACE_BUG_UNKNOWN, |
| @@ -2704,18 +2704,16 @@ ftrace_nop_initialize(struct module *mod, struct dyn_ftrace *rec) · 2703 unmodified lines | |||
| 2704 | * archs can override this function if they must do something | 2704 | * archs can override this function if they must do something |
| 2705 | * before the modifying code is performed. | 2705 | * before the modifying code is performed. |
| 2706 | */ | 2706 | */ |
| 2707 | int __weak ftrace_arch_code_modify_prepare(void) | 2707 | void __weak ftrace_arch_code_modify_prepare(void) |
| 2708 | { | 2708 | { |
| 2709 | return 0; | ||
| 2710 | } | 2709 | } |
| 2711 | 2710 | ||
| 2712 | /* | 2711 | /* |
| 2713 | * archs can override this function if they must do something | 2712 | * archs can override this function if they must do something |
| 2714 | * after the modifying code is performed. | 2713 | * after the modifying code is performed. |
| 2715 | */ | 2714 | */ |
| 2716 | int __weak ftrace_arch_code_modify_post_process(void) | 2715 | void __weak ftrace_arch_code_modify_post_process(void) |
| 2717 | { | 2716 | { |
| 2718 | return 0; | ||
| 2719 | } | 2717 | } |
| 2720 | 2718 | ||
| 2721 | void ftrace_modify_all_code(int command) | 2719 | void ftrace_modify_all_code(int command) |
| @@ -2801,12 +2799,7 @@ void __weak arch_ftrace_update_code(int command) · 79 unmodified lines | |||
| 2801 | 2799 | ||
| 2802 | static void ftrace_run_update_code(int command) | 2800 | static void ftrace_run_update_code(int command) |
| 2803 | { | 2801 | { |
| 2804 | int ret; | 2802 | ftrace_arch_code_modify_prepare(); |
| 2805 | |||
| 2806 | ret = ftrace_arch_code_modify_prepare(); | ||
| 2807 | FTRACE_WARN_ON(ret); | ||
| 2808 | if (ret) | ||
| 2809 | return; | ||
| 2810 | 2803 | ||
| 2811 | /* | 2804 | /* |
| 2812 | * By default we use stop_machine() to modify the code. | 2805 | * By default we use stop_machine() to modify the code. |
| @@ -2816,8 +2809,7 @@ static void ftrace_run_update_code(int command) · 3 unmodified lines | |||
| 2816 | */ | 2809 | */ |
| 2817 | arch_ftrace_update_code(command); | 2810 | arch_ftrace_update_code(command); |
| 2818 | 2811 | ||
| 2819 | ret = ftrace_arch_code_modify_post_process(); | 2812 | ftrace_arch_code_modify_post_process(); |
| 2820 | FTRACE_WARN_ON(ret); | ||
| 2821 | } | 2813 | } |
| 2822 | 2814 | ||
| 2823 | static void ftrace_run_modify_code(struct ftrace_ops *ops, int command, | 2815 | static void ftrace_run_modify_code(struct ftrace_ops *ops, int command, |