Skip to content

Commit 5b158d0

Browse files
rostedtgregkh
authored andcommitted
ring-buffer: Always check to put back before stamp when crossing pages
commit 68e10d5 upstream. The current ring buffer logic checks to see if the updating of the event buffer was interrupted, and if it is, it will try to fix up the before stamp with the write stamp to make them equal again. This logic is flawed, because if it is not interrupted, the two are guaranteed to be different, as the current event just updated the before stamp before allocation. This guarantees that the next event (this one or another interrupting one) will think it interrupted the time updates of a previous event and inject an absolute time stamp to compensate. The correct logic is to always update the timestamps when traversing to a new sub buffer. Cc: stable@vger.kernel.org Fixes: a389d86 ("ring-buffer: Have nested events still record running time stamp") Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 68e17e0 commit 5b158d0

1 file changed

Lines changed: 6 additions & 8 deletions

File tree

‎kernel/trace/ring_buffer.c‎

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3234,14 +3234,12 @@ __rb_reserve_next(struct ring_buffer_per_cpu *cpu_buffer,
32343234

32353235
/* See if we shot pass the end of this buffer page */
32363236
if (unlikely(write > BUF_PAGE_SIZE)) {
3237-
if (tail != w) {
3238-
/* before and after may now different, fix it up*/
3239-
b_ok = rb_time_read(&cpu_buffer->before_stamp, &info->before);
3240-
a_ok = rb_time_read(&cpu_buffer->write_stamp, &info->after);
3241-
if (a_ok && b_ok && info->before != info->after)
3242-
(void)rb_time_cmpxchg(&cpu_buffer->before_stamp,
3243-
info->before, info->after);
3244-
}
3237+
/* before and after may now different, fix it up*/
3238+
b_ok = rb_time_read(&cpu_buffer->before_stamp, &info->before);
3239+
a_ok = rb_time_read(&cpu_buffer->write_stamp, &info->after);
3240+
if (a_ok && b_ok && info->before != info->after)
3241+
(void)rb_time_cmpxchg(&cpu_buffer->before_stamp,
3242+
info->before, info->after);
32453243
return rb_move_tail(cpu_buffer, tail, info);
32463244
}
32473245

0 commit comments

Comments
 (0)