mbox series

[0/3] libtracefs: Updates to trace_marker functions

Message ID 20210409151604.2224578-1-rostedt@goodmis.org (mailing list archive)
Headers show
Series libtracefs: Updates to trace_marker functions | expand

Message

Steven Rostedt April 9, 2021, 3:16 p.m. UTC
From: "Steven Rostedt (VMware)" <rostedt@goodmis.org>

[
  This is on top of:
  https://lore.kernel.org/linux-trace-devel/20210409042739.3179257-1-tz.stoyanov@gmail.com/
]

This is some updates to the tracefs_print*() and tracefs_binary*()
functions. The first patch does some clean ups, the second adds a helper
function to find the right pthread mutex to use, and the last patch adds
a pthread mutex around the modifications of the file descriptors used
for writing to the file.

Note, the lock only protects against the modification of the file
descriptor (opening and closing it). It does not protect against writing
to it (a write updates the file the file descriptor points to, but the
value of the file descriptor - the number - is left unchanged).

It is now safe to use tracefs_v?print() and tracefs_binary_write() along
with tracefs_print_init() and tracefs_binary_init(), where it will
open the file descriptor if it is not open yet, and return it if it is
already opened.

The writes are not safe to use against tracefs_print_close() or
tracefs_binary_close(), and that is up to the application to protect.


Steven Rostedt (VMware) (3):
  libtracefs: Do some cleanups to the trace_marker.c code
  libtracefs: Add helper function trace_get_lock()
  libtracefs: Add lock around modifying the trace_marker file descriptor

 include/tracefs-local.h |  5 +++++
 src/tracefs-marker.c    | 44 +++++++++++++++++++++++++++++++----------
 src/tracefs-tools.c     |  2 +-
 3 files changed, 40 insertions(+), 11 deletions(-)