]> 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)
commit897ab43828608fc8de6fa41370a371cd2e4ca044
treea193be75d817fbb94984bf6f6eb3785d49b0d276
parent322a7a18df241e4d2fcb6ed8b76356a18dc61b53
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