Re: [PATCH] riscv: ftrace: Properly acquire text_mutex to fix a race condition

From: Palmer Dabbelt
Date: Wed Jul 16 2025 - 11:25:11 EST


On Wed, 09 Jul 2025 09:45:36 PDT (-0700), rostedt@xxxxxxxxxxx wrote:
On Wed, 09 Jul 2025 07:12:47 -0700 (PDT)
Palmer Dabbelt <palmer@xxxxxxxxxxx> wrote:

> #ifdef CONFIG_DYNAMIC_FTRACE
> +void ftrace_arch_code_modify_prepare(void)
> +{
> + mutex_lock(&text_mutex);
> +}
> +
> +void ftrace_arch_code_modify_post_process(void)
> +{
> + mutex_unlock(&text_mutex);
> +}

IIRC there's a reason we don't do it this way, we had (or had tried to)
have it before. It's been a while, though, and I'm just having some a
coffee so may I'm just wrong...

Yes, because it caused issues with stop machine[1], but if you are no
longer using stop machine, this should be what you should do now.

[1] https://lore.kernel.org/all/20220310045454.672097-1-changbin.du@xxxxxxxxx/

Thanks. The v2 staged for the tester, should show up on fixes soon.


-- Steve