Commit 8785f51a authored by Andrea Righi's avatar Andrea Righi Committed by Steven Rostedt (VMware)

ring-buffer: Set the right timestamp in the slow path of __rb_reserve_next()

In the slow path of __rb_reserve_next() a nested event(s) can happen
between evaluating the timestamp delta of the current event and updating
write_stamp via local_cmpxchg(); in this case the delta is not valid
anymore and it should be set to 0 (same timestamp as the interrupting
event), since the event that we are currently processing is not the last
event in the buffer.

Link: https://lkml.kernel.org/r/X8IVJcp1gRE+FJCJ@xps-13-7390

Cc: Ingo Molnar <mingo@redhat.com>
Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: stable@vger.kernel.org
Link: https://lwn.net/Articles/831207
Fixes: a389d86f ("ring-buffer: Have nested events still record running time stamp")
Signed-off-by: default avatarAndrea Righi <andrea.righi@canonical.com>
Signed-off-by: default avatarSteven Rostedt (VMware) <rostedt@goodmis.org>
parent 55ea4cf4
...@@ -3287,11 +3287,11 @@ __rb_reserve_next(struct ring_buffer_per_cpu *cpu_buffer, ...@@ -3287,11 +3287,11 @@ __rb_reserve_next(struct ring_buffer_per_cpu *cpu_buffer,
ts = rb_time_stamp(cpu_buffer->buffer); ts = rb_time_stamp(cpu_buffer->buffer);
barrier(); barrier();
/*E*/ if (write == (local_read(&tail_page->write) & RB_WRITE_MASK) && /*E*/ if (write == (local_read(&tail_page->write) & RB_WRITE_MASK) &&
info->after < ts) { info->after < ts &&
rb_time_cmpxchg(&cpu_buffer->write_stamp,
info->after, ts)) {
/* Nothing came after this event between C and E */ /* Nothing came after this event between C and E */
info->delta = ts - info->after; info->delta = ts - info->after;
(void)rb_time_cmpxchg(&cpu_buffer->write_stamp,
info->after, ts);
info->ts = ts; info->ts = ts;
} else { } else {
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment