Re: [PATCH 0/6] tracing/ring-buffer: Fix wakeup of ring buffer waiters

From: Linus Torvalds
Date: Fri Mar 08 2024 - 16:39:39 EST


On Fri, 8 Mar 2024 at 13:33, Steven Rostedt <rostedt@xxxxxxxxxxx> wrote:
>
> There's two layers:
>
> 1) the ring buffer has the above simple producer / consumer.
> Where the wake ups can happen at the point of where the buffer has
> the amount filled that the consumer wants to start consuming with.
>
> 2) The tracing layer; Here on close of a file, the consumers need to be
> woken up and not wait again. And just take whatever was there to finish
> reading.
>
> There's also another case that the ioctl() just kicks the current
> readers out, but doesn't care about new readers.

But that's the beauty of just using the wait_event() model.

Just add that "exit" condition to the condition.

So the above "complexity" is *literally* just changing the

(new = atomic_read_acquire(&my->seq)) != old

condition to

should_exit ||
(new = atomic_read_acquire(&my->seq)) != old

(replace "should_exit" with whatever that condition is, of course) and
the wait_event() logic will take care of the rest.

Linus