]> 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)
commit0ee98e6f7b9797dd81d2f7dad2f7a686d3723392
tree63f49ec8f535ab4ca9a8d31a65317b23240a2ebe
parentc07d16b77bab88d657b7e9d9ae630bb39815bef6
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