Re: [PATCH 1/2] tracing: Simplify and fix "buffered event" synchronization

From: Petr Pavlu
Date: Tue Dec 05 2023 - 11:16:23 EST


On 12/1/23 15:46, Steven Rostedt wrote:
> On Fri, 1 Dec 2023 15:17:35 +0100
> Petr Pavlu <petr.pavlu@xxxxxxxx> wrote:
>
>> Ok, keeping the current approach, my plan for v2 is to prepare the
>> following patches:
>>
>> [...]
>> * Fix the potential race between trace_buffered_event_enable() and
>> trace_event_buffer_lock_reserve() where the latter might already see
>> a valid trace_buffered_event pointer but not all initialization yet.
>>
>> I think this might be actually best to address by using the same
>> maintenance exclusion as is implemented in
>> trace_buffered_event_disable(). It would make both maintenance
>> operations consistent but for the cost of making the enable operation
>> somewhat slower.
>
> I wouldn't do them the same just to make them consistent. I think the
> smp_wmb() is sufficient. Don't you think?

Looking at this again, I think it is actually a non-issue. Function
trace_buffered_event_enable() only writes the header part of
ring_buffer_event but that is never written nor read by the actual users
which obtain the buffer from trace_event_buffer_lock_reserve().

No change is then needed, it is left out in v2 of the series.

-- Petr