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

Palmer Dabbelt palmer at dabbelt.com
Wed Jul 16 08:22:44 PDT 2025


On Wed, 09 Jul 2025 09:45:36 PDT (-0700), rostedt at goodmis.org wrote:
> On Wed, 09 Jul 2025 07:12:47 -0700 (PDT)
> Palmer Dabbelt <palmer at dabbelt.com> 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@gmail.com/

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

>
> -- Steve



More information about the linux-riscv mailing list