Commit 2c6d0950 authored by Beau Belgrave's avatar Beau Belgrave Committed by Steven Rostedt (Google)

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.comSigned-off-by: default avatarBeau Belgrave <beaub@linux.microsoft.com>
Signed-off-by: default avatarSteven Rostedt (Google) <rostedt@goodmis.org>
parent cf74c59c
...@@ -14,6 +14,11 @@ Programs can view status of the events via ...@@ -14,6 +14,11 @@ Programs can view status of the events via
/sys/kernel/tracing/user_events_status and can both register and write /sys/kernel/tracing/user_events_status and can both register and write
data out via /sys/kernel/tracing/user_events_data. data out via /sys/kernel/tracing/user_events_data.
Programs can also use /sys/kernel/tracing/dynamic_events to register and
delete user based events via the u: prefix. The format of the command to
dynamic_events is the same as the ioctl with the u: prefix applied. This
requires CAP_PERFMON due to the event persisting, otherwise -EPERM is returned.
Typically programs will register a set of events that they wish to expose to Typically programs will register a set of events that they wish to expose to
tools that can read trace_events (such as ftrace and perf). The registration tools that can read trace_events (such as ftrace and perf). The registration
process tells the kernel which address and bit to reflect if any tool has process tells the kernel which address and bit to reflect if any tool has
...@@ -45,7 +50,7 @@ This command takes a packed struct user_reg as an argument:: ...@@ -45,7 +50,7 @@ This command takes a packed struct user_reg as an argument::
/* Input: Enable size in bytes at address */ /* Input: Enable size in bytes at address */
__u8 enable_size; __u8 enable_size;
/* Input: Flags for future use, set to 0 */ /* Input: Flags to use, if any */
__u16 flags; __u16 flags;
/* Input: Address to update when enabled */ /* Input: Address to update when enabled */
...@@ -69,7 +74,7 @@ The struct user_reg requires all the above inputs to be set appropriately. ...@@ -69,7 +74,7 @@ The struct user_reg requires all the above inputs to be set appropriately.
This must be 4 (32-bit) or 8 (64-bit). 64-bit values are only allowed to be This must be 4 (32-bit) or 8 (64-bit). 64-bit values are only allowed to be
used on 64-bit kernels, however, 32-bit can be used on all kernels. used on 64-bit kernels, however, 32-bit can be used on all kernels.
+ flags: The flags to use, if any. For the initial version this must be 0. + flags: The flags to use, if any.
Callers should first attempt to use flags and retry without flags to ensure Callers should first attempt to use flags and retry without flags to ensure
support for lower versions of the kernel. If a flag is not supported -EINVAL support for lower versions of the kernel. If a flag is not supported -EINVAL
is returned. is returned.
...@@ -80,6 +85,13 @@ The struct user_reg requires all the above inputs to be set appropriately. ...@@ -80,6 +85,13 @@ The struct user_reg requires all the above inputs to be set appropriately.
+ name_args: The name and arguments to describe the event, see command format + name_args: The name and arguments to describe the event, see command format
for details. for details.
The following flags are currently supported.
+ USER_EVENT_REG_PERSIST: The event will not delete upon the last reference
closing. Callers may use this if an event should exist even after the
process closes or unregisters the event. Requires CAP_PERFMON otherwise
-EPERM is returned.
Upon successful registration the following is set. Upon successful registration the following is set.
+ write_index: The index to use for this file descriptor that represents this + write_index: The index to use for this file descriptor that represents this
...@@ -141,7 +153,10 @@ event (in both user and kernel space). User programs should use a separate file ...@@ -141,7 +153,10 @@ event (in both user and kernel space). User programs should use a separate file
to request deletes than the one used for registration due to this. to request deletes than the one used for registration due to this.
**NOTE:** By default events will auto-delete when there are no references left **NOTE:** By default events will auto-delete when there are no references left
to the event. Flags in the future may change this logic. to the event. If programs do not want auto-delete, they must use the
USER_EVENT_REG_PERSIST flag when registering the event. Once that flag is used
the event exists until DIAG_IOCSDEL is invoked. Both register and delete of an
event that persists requires CAP_PERFMON, otherwise -EPERM is returned.
Unregistering Unregistering
------------- -------------
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment