Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

tracing/user_events: Document multi-format flag

User programs can now ask user_events to handle the synchronization of
multiple different formats for an event with the same name via the new
USER_EVENT_REG_MULTI_FORMAT flag.

Add a section for USER_EVENT_REG_MULTI_FORMAT that explains the intended
purpose and caveats of using it. Explain how deletion works in these
cases and how to use /sys/kernel/tracing/dynamic_events for per-version
deletion.

Link: https://lore.kernel.org/linux-trace-kernel/20240222001807.1463-5-beaub@linux.microsoft.com

Signed-off-by: Beau Belgrave <beaub@linux.microsoft.com>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>

authored by

Beau Belgrave and committed by
Steven Rostedt (Google)
3727db1c bcb7bdcc

+26 -1
+26 -1
Documentation/trace/user_events.rst
··· 92 92 process closes or unregisters the event. Requires CAP_PERFMON otherwise 93 93 -EPERM is returned. 94 94 95 + + USER_EVENT_REG_MULTI_FORMAT: The event can contain multiple formats. This 96 + allows programs to prevent themselves from being blocked when their event 97 + format changes and they wish to use the same name. When this flag is used the 98 + tracepoint name will be in the new format of "name.unique_id" vs the older 99 + format of "name". A tracepoint will be created for each unique pair of name 100 + and format. This means if several processes use the same name and format, 101 + they will use the same tracepoint. If yet another process uses the same name, 102 + but a different format than the other processes, it will use a different 103 + tracepoint with a new unique id. Recording programs need to scan tracefs for 104 + the various different formats of the event name they are interested in 105 + recording. The system name of the tracepoint will also use "user_events_multi" 106 + instead of "user_events". This prevents single-format event names conflicting 107 + with any multi-format event names within tracefs. The unique_id is output as 108 + a hex string. Recording programs should ensure the tracepoint name starts with 109 + the event name they registered and has a suffix that starts with . and only 110 + has hex characters. For example to find all versions of the event "test" you 111 + can use the regex "^test\.[0-9a-fA-F]+$". 112 + 95 113 Upon successful registration the following is set. 96 114 97 115 + write_index: The index to use for this file descriptor that represents this ··· 124 106 **NOTE:** The event subsystem name by default is "user_events". Callers should 125 107 not assume it will always be "user_events". Operators reserve the right in the 126 108 future to change the subsystem name per-process to accommodate event isolation. 109 + In addition if the USER_EVENT_REG_MULTI_FORMAT flag is used the tracepoint name 110 + will have a unique id appended to it and the system name will be 111 + "user_events_multi" as described above. 127 112 128 113 Command Format 129 114 ^^^^^^^^^^^^^^ ··· 177 156 to the event. If programs do not want auto-delete, they must use the 178 157 USER_EVENT_REG_PERSIST flag when registering the event. Once that flag is used 179 158 the event exists until DIAG_IOCSDEL is invoked. Both register and delete of an 180 - event that persists requires CAP_PERFMON, otherwise -EPERM is returned. 159 + event that persists requires CAP_PERFMON, otherwise -EPERM is returned. When 160 + there are multiple formats of the same event name, all events with the same 161 + name will be attempted to be deleted. If only a specific version is wanted to 162 + be deleted then the /sys/kernel/tracing/dynamic_events file should be used for 163 + that specific format of the event. 181 164 182 165 Unregistering 183 166 -------------