Re: [PATCH] tracing: Have all levels of checks prevent recursion
From: Petr Mladek <pmladek@suse.com>
Date: 2021-10-19 06:41:32
Also in:
linux-riscv, live-patching, lkml
On Mon 2021-10-18 22:02:03, Steven Rostedt wrote:
quoted hunk ↗ jump to hunk
On Mon, 18 Oct 2021 12:19:20 +0200 Petr Mladek [off-list ref] wrote:quoted
quoted
- bit = trace_get_context_bit() + start; if (unlikely(val & (1 << bit))) { /* * It could be that preempt_count has not been updated during * a switch between contexts. Allow for a single recursion. */ - bit = TRACE_TRANSITION_BIT; + bit = TRACE_CTX_TRANSITION + start;[..]quoted
Could we please update the comment? I mean to say if it is a race or if we trace a function that should not get traced.What do you think of this change?diff --git a/include/linux/trace_recursion.h b/include/linux/trace_recursion.h index 1d8cce02c3fb..24f284eb55a7 100644 --- a/include/linux/trace_recursion.h +++ b/include/linux/trace_recursion.h@@ -168,8 +168,12 @@ static __always_inline int trace_test_and_set_recursion(unsigned long ip, unsign bit = trace_get_context_bit() + start; if (unlikely(val & (1 << bit))) { /* - * It could be that preempt_count has not been updated during - * a switch between contexts. Allow for a single recursion. + * If an interrupt occurs during a trace, and another trace + * happens in that interrupt but before the preempt_count is + * updated to reflect the new interrupt context, then this + * will think a recursion occurred, and the event will be dropped. + * Let a single instance happen via the TRANSITION_BIT to + * not drop those events. */ bit = TRACE_TRANSITION_BIT; if (val & (1 << bit)) {
Looks good to me. Thanks for the update. Feel free to postpone this change. I do not want to complicate upstreaming the fix for stable. I am sorry if I already complicated it. Best Regards, Petr