]> git.baikalelectronics.ru Git - kernel.git/commit
ring-buffer: Force before_stamp and write_stamp to be different on discard
authorSteven Rostedt (VMware) <rostedt@goodmis.org>
Wed, 3 Mar 2021 23:03:52 +0000 (18:03 -0500)
committerSteven Rostedt (VMware) <rostedt@goodmis.org>
Thu, 4 Mar 2021 14:45:17 +0000 (09:45 -0500)
commitb3c8c84d44cafdb2830c95ab4dbabc9dfec0c3c1
tree94187d9daa84bcc433c7f234cd4ff2df195e0301
parent6503aa1e1763ba27e8ce175ce130fbe23f063f85
ring-buffer: Force before_stamp and write_stamp to be different on discard

Part of the logic of the new time stamp code depends on the before_stamp and
the write_stamp to be different if the write_stamp does not match the last
event on the buffer, as it will be used to calculate the delta of the next
event written on the buffer.

The discard logic depends on this, as the next event to come in needs to
inject a full timestamp as it can not rely on the last event timestamp in
the buffer because it is unknown due to events after it being discarded. But
by changing the write_stamp back to the time before it, it forces the next
event to use a full time stamp, instead of relying on it.

The issue came when a full time stamp was used for the event, and
rb_time_delta() returns zero in that case. The update to the write_stamp
(which subtracts delta) made it not change. Then when the event is removed
from the buffer, because the before_stamp and write_stamp still match, the
next event written would calculate its delta from the write_stamp, but that
would be wrong as the write_stamp is of the time of the event that was
discarded.

In the case that the delta change being made to write_stamp is zero, set the
before_stamp to zero as well, and this will force the next event to inject a
full timestamp and not use the current write_stamp.

Cc: stable@vger.kernel.org
Fixes: e6cc5f23410ef ("ring-buffer: Have nested events still record running time stamp")
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
kernel/trace/ring_buffer.c