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

tracing/user_events: Document persist event flags

Users need to know how to make events persist now that we allow for
that. We also now allow the dynamic_events file to create events by
utilizing the persist flag during event register.

Add back in to documentation how /sys/kernel/tracing/dynamic_events can
be used to create persistent user_events. Add a section under registering
for the currently supported flags (USER_EVENT_REG_PERSIST) and the
required permissions. Add a note under deleting that deleting a
persistent event also requires sufficient permission.

Link: https://lkml.kernel.org/r/20230912180704.1284-4-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)
2c6d0950 cf74c59c

+18 -3
+18 -3
Documentation/trace/user_events.rst
··· 14 14 /sys/kernel/tracing/user_events_status and can both register and write 15 15 data out via /sys/kernel/tracing/user_events_data. 16 16 17 + Programs can also use /sys/kernel/tracing/dynamic_events to register and 18 + delete user based events via the u: prefix. The format of the command to 19 + dynamic_events is the same as the ioctl with the u: prefix applied. This 20 + requires CAP_PERFMON due to the event persisting, otherwise -EPERM is returned. 21 + 17 22 Typically programs will register a set of events that they wish to expose to 18 23 tools that can read trace_events (such as ftrace and perf). The registration 19 24 process tells the kernel which address and bit to reflect if any tool has ··· 50 45 /* Input: Enable size in bytes at address */ 51 46 __u8 enable_size; 52 47 53 - /* Input: Flags for future use, set to 0 */ 48 + /* Input: Flags to use, if any */ 54 49 __u16 flags; 55 50 56 51 /* Input: Address to update when enabled */ ··· 74 69 This must be 4 (32-bit) or 8 (64-bit). 64-bit values are only allowed to be 75 70 used on 64-bit kernels, however, 32-bit can be used on all kernels. 76 71 77 - + flags: The flags to use, if any. For the initial version this must be 0. 72 + + flags: The flags to use, if any. 78 73 Callers should first attempt to use flags and retry without flags to ensure 79 74 support for lower versions of the kernel. If a flag is not supported -EINVAL 80 75 is returned. ··· 84 79 85 80 + name_args: The name and arguments to describe the event, see command format 86 81 for details. 82 + 83 + The following flags are currently supported. 84 + 85 + + USER_EVENT_REG_PERSIST: The event will not delete upon the last reference 86 + closing. Callers may use this if an event should exist even after the 87 + process closes or unregisters the event. Requires CAP_PERFMON otherwise 88 + -EPERM is returned. 87 89 88 90 Upon successful registration the following is set. 89 91 ··· 153 141 to request deletes than the one used for registration due to this. 154 142 155 143 **NOTE:** By default events will auto-delete when there are no references left 156 - to the event. Flags in the future may change this logic. 144 + to the event. If programs do not want auto-delete, they must use the 145 + USER_EVENT_REG_PERSIST flag when registering the event. Once that flag is used 146 + the event exists until DIAG_IOCSDEL is invoked. Both register and delete of an 147 + event that persists requires CAP_PERFMON, otherwise -EPERM is returned. 157 148 158 149 Unregistering 159 150 -------------