Re: [RFC PATCH] LTTng relay buffer allocation, read, write

Steven Rostedt
2008-09-29T19:55:17Z

On Mon, 29 Sep 2008, Steven Rostedt wrote:
> We do not need to worry about SMP for writes.
> That is, if you reserve data and atomically push the head forward
> if the head goes past the end of page, One, you check if your
> start of head (head - length) is still on the page. If it is
> you add your padding (you already reserved it), then you atomically
> push the head forward. Then you start the process again.
> If the start of the head (head - length) is not on the page, that
> means that an IRQ or NMI came in and pushed it before you.

I forgot to mention one important detail. The "head" index will stay
on the page frame. That way we do not need to figure out which
head_page we are on. We grab the head_page, we atomically
(local_inc_return) the head pointer on that page. If the return value is
still on the page, we succeeded. We can also increment a value on this
page frame that will prevent recording if we somehow overflowed the buffer
before relinquishing the stack.

That is

reserve_event()

IRQ->
reserve_event();

[...]

IRQ->reserve_event() came back to original head!

Here we do not have a big enough buffer, and this is just stupid ;-)
We would drop packets in this case, and should drop the guy on his
head who came up with the too small buffer.

-- Steve