Re: [PATCH] ring-buffer: Fix slowpath of interrupted event

From: Steven Rostedt
Date: Tue Dec 19 2023 - 10:52:54 EST


On Tue, 19 Dec 2023 10:36:13 -0500
Steven Rostedt <rostedt@xxxxxxxxxxx> wrote:

> |-- interrupt event --|-- normal context event --|-- interrupt event --|
>
> ^ ^ ^
> | | |
> ts is before before_stamp | |
> our before_stamp |
> absolute value
>
> We just need to make our delta not go beyond the absolute value. So:
>
> ts of first event + (absolute value - our before_stamp)
>
> Should not be greater than the absolute value.

Hmm, this isn't good enough either. Because we could have had the interrupt
happen *after* the before_stamp update, and leave the write_stamp not equal
to the before_stamp (like the original patch is fixing).

That is, in the case of finding an absolute value, there's still no way to
know what delta to use without walking the sub-buffer. Hmm, since this is
so rare, we could do that :-/

Anyway, for now, it's just going to be delta = 0, and we could do the
sub-buffer walk if it becomes an issue (which it hasn't for the last decade
or more).

-- Steve