# Re: \[PATCH v3 1/2\] ftrace: disable preemption between ftrace\_test\_recursion\_trylock/unlock()

- From: Steven Rostedt \<rostedt@goodmis.org\>
- Date: 2021-10-15 03:39:17 
- List: linuxppc-dev
- Page: https://ratatoskr.run/linuxppc-dev/2021/10/1542716
- Thread: https://ratatoskr.run/linuxppc-dev/2021/10/1540082/t.md

```text
On Thu, 14 Oct 2021 17:14:07 +0200
Petr Mladek [ref] wrote:

>   /**
>    * ftrace_test_recursion_trylock - tests for recursion in same context
>    *
>    * Use this for ftrace callbacks. This will detect if the function
>    * tracing recursed in the same context (normal vs interrupt),
>    *
>    * Returns: -1 if a recursion happened.
> -  *           >= 0 if no recursion
> +  *           >= 0 if no recursion (success)
> +  *
> +  * Disables the preemption on success. It is just for a convenience.
> +  * Current users needed to disable the preemtion for some reasons.
>    */

I started replying to this explaining the difference between bit not
zero and a bit zero, and I think I found a design flaw that can allow
unwanted recursion.

It's late and I'm about to go to bed, but I may have a new patch to fix
this before this gets added, as the fix will conflict with this patch,
and the fix will likely need to go to stable.

Stay tuned.

-- Steve
```
