]> git.baikalelectronics.ru Git - kernel.git/commit
tracing: Make trace_marker{,_raw} stream-like
authorJohn Keeping <john@metanate.com>
Tue, 7 Dec 2021 14:25:58 +0000 (14:25 +0000)
committerSteven Rostedt (VMware) <rostedt@goodmis.org>
Wed, 8 Dec 2021 03:05:49 +0000 (22:05 -0500)
commite59ee4660ffdcb65dffb9ffeb8b6708d375d4a84
treea193be75d817fbb94984bf6f6eb3785d49b0d276
parent4c749de212a934d2d01cb1caa9ae35db6fc608d5
tracing: Make trace_marker{,_raw} stream-like

The tracing marker files are write-only streams with no meaningful
concept of file position.  Using stream_open() to mark them as
stream-link indicates this and has the added advantage that a single
file descriptor can now be used from multiple threads without contention
thanks to clearing FMODE_ATOMIC_POS.

Note that this has the potential to break existing userspace by since
both lseek(2) and pwrite(2) will now return ESPIPE when previously lseek
would have updated the stored offset and pwrite would have appended to
the trace.  A survey of libtracefs and several other projects found to
use trace_marker(_raw) [1][2][3] suggests that everyone limits
themselves to calling write(2) and close(2) on these file descriptors so
there is a good chance this will go unnoticed and the benefits of
reduced overhead and lock contention seem worth the risk.

[1] https://github.com/google/perfetto
[2] https://github.com/intel/media-driver/
[3] https://w1.fi/cgit/hostap/

Link: https://lkml.kernel.org/r/20211207142558.347029-1-john@metanate.com
Signed-off-by: John Keeping <john@metanate.com>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
kernel/trace/trace.c