]> git.baikalelectronics.ru Git - kernel.git/commit
tracing: Add trace_event helper macros __string_len() and __assign_str_len()
authorSteven Rostedt (VMware) <rostedt@goodmis.org>
Sat, 17 Jul 2021 00:55:10 +0000 (20:55 -0400)
committerChuck Lever <chuck.lever@oracle.com>
Tue, 17 Aug 2021 15:47:52 +0000 (11:47 -0400)
commit522f2b34fcdcce127e76c47bf040d6a056249043
tree63f49ec8f535ab4ca9a8d31a65317b23240a2ebe
parentecfa4c2f161c44a97dafd659c312442e97da810e
tracing: Add trace_event helper macros __string_len() and __assign_str_len()

There's a few cases that a string that is to be recorded in a trace event,
does not have a terminating 'nul' character, and instead, the tracepoint
passes in the length of the string to record.

Add two helper macros to the trace event code that lets this work easier,
than tricks with "%.*s" logic.

  __string_len() which is similar to __string() for declaration, but takes a
                 length argument.

  __assign_str_len() which is similar to __assign_str() for assiging the
                 string, but it too takes a length argument.

Note, the TRACE_EVENT() macro will allocate the location on the ring
buffer to 'len + 1', that will be used to store the string into. It is a
requirement that the 'len' used for this is a most the length of the
string being recorded.

This string can still use __get_str() just like strings created with
__string() can use to retrieve the string.

Link: https://lore.kernel.org/linux-nfs/20210513105018.7539996a@gandalf.local.home/
Tested-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
include/trace/trace_events.h
samples/trace_events/trace-events-sample.h