.. | .. |
---|
| 1 | +.. SPDX-License-Identifier: GPL-2.0 |
---|
| 2 | + |
---|
1 | 3 | =================== |
---|
2 | 4 | System Trace Module |
---|
3 | 5 | =================== |
---|
.. | .. |
---|
31 | 33 | have a name (string identifier) and a range of masters and channels |
---|
32 | 34 | associated with it, located in "stp-policy" subsystem directory in |
---|
33 | 35 | configfs. The topmost directory's name (the policy) is formatted as |
---|
34 | | -the STM device name to which this policy applies and and arbitrary |
---|
35 | | -string identifier separated by a stop. From the examle above, a rule |
---|
| 36 | +the STM device name to which this policy applies and an arbitrary |
---|
| 37 | +string identifier separated by a stop. From the example above, a rule |
---|
36 | 38 | may look like this:: |
---|
37 | 39 | |
---|
38 | 40 | $ ls /config/stp-policy/dummy_stm.my-policy/user |
---|
.. | .. |
---|
53 | 55 | be used for trace sources with the id string of "user/dummy". |
---|
54 | 56 | |
---|
55 | 57 | Trace sources have to open the stm class device's node and write their |
---|
56 | | -trace data into its file descriptor. In order to identify themselves |
---|
57 | | -to the policy, they need to do a STP_POLICY_ID_SET ioctl on this file |
---|
58 | | -descriptor providing their id string. Otherwise, they will be |
---|
59 | | -automatically allocated a master/channel pair upon first write to this |
---|
60 | | -file descriptor according to the "default" rule of the policy, if such |
---|
61 | | -exists. |
---|
| 58 | +trace data into its file descriptor. |
---|
| 59 | + |
---|
| 60 | +In order to find an appropriate policy node for a given trace source, |
---|
| 61 | +several mechanisms can be used. First, a trace source can explicitly |
---|
| 62 | +identify itself by calling an STP_POLICY_ID_SET ioctl on the character |
---|
| 63 | +device's file descriptor, providing their id string, before they write |
---|
| 64 | +any data there. Secondly, if they chose not to perform the explicit |
---|
| 65 | +identification (because you may not want to patch existing software |
---|
| 66 | +to do this), they can just start writing the data, at which point the |
---|
| 67 | +stm core will try to find a policy node with the name matching the |
---|
| 68 | +task's name (e.g., "syslogd") and if one exists, it will be used. |
---|
| 69 | +Thirdly, if the task name can't be found among the policy nodes, the |
---|
| 70 | +catch-all entry "default" will be used, if it exists. This entry also |
---|
| 71 | +needs to be created and configured by the system administrator or |
---|
| 72 | +whatever tools are taking care of the policy configuration. Finally, |
---|
| 73 | +if all the above steps failed, the write() to an stm file descriptor |
---|
| 74 | +will return a error (EINVAL). |
---|
| 75 | + |
---|
| 76 | +Previously, if no policy nodes were found for a trace source, the stm |
---|
| 77 | +class would silently fall back to allocating the first available |
---|
| 78 | +contiguous range of master/channels from the beginning of the device's |
---|
| 79 | +master/channel range. The new requirement for a policy node to exist |
---|
| 80 | +will help programmers and sysadmins identify gaps in configuration |
---|
| 81 | +and have better control over the un-identified sources. |
---|
62 | 82 | |
---|
63 | 83 | Some STM devices may allow direct mapping of the channel mmio regions |
---|
64 | 84 | to userspace for zero-copy writing. One mappable page (in terms of |
---|
.. | .. |
---|
92 | 112 | there's a node in the root of the policy directory that matches the |
---|
93 | 113 | stm_source device's name (for example, "console"), this node will be |
---|
94 | 114 | used to allocate master and channel numbers. If there's no such policy |
---|
95 | | -node, the stm core will pick the first contiguous chunk of channels |
---|
96 | | -within the first available master. Note that the node must exist |
---|
97 | | -before the stm_source device is connected to its stm device. |
---|
| 115 | +node, the stm core will use the catch-all entry "default", if one |
---|
| 116 | +exists. If neither policy nodes exist, the write() to stm_source_link |
---|
| 117 | +will return an error. |
---|
98 | 118 | |
---|
99 | 119 | stm_console |
---|
100 | 120 | =========== |
---|