Commit cf9f0f7
tracing: Allow user-space mapping of the ring-buffer
Currently, user-space extracts data from the ring-buffer via splice,
which is handy for storage or network sharing. However, due to splice
limitations, it is imposible to do real-time analysis without a copy.
A solution for that problem is to let the user-space map the ring-buffer
directly.
The mapping is exposed via the per-CPU file trace_pipe_raw. The first
element of the mapping is the meta-page. It is followed by each
subbuffer constituting the ring-buffer, ordered by their unique page ID:
* Meta-page -- include/uapi/linux/trace_mmap.h for a description
* Subbuf ID 0
* Subbuf ID 1
...
It is therefore easy to translate a subbuf ID into an offset in the
mapping:
reader_id = meta->reader->id;
reader_offset = meta->meta_page_size + reader_id * meta->subbuf_size;
When new data is available, the mapper must call a newly introduced ioctl:
TRACE_MMAP_IOCTL_GET_READER. This will update the Meta-page reader ID to
point to the next reader containing unread data.
Mapping will prevent snapshot and buffer size modifications.
Link: https://lore.kernel.org/linux-trace-kernel/[email protected]
CC: <[email protected]>
Signed-off-by: Vincent Donnefort <[email protected]>
Signed-off-by: Steven Rostedt (Google) <[email protected]>1 parent 117c392 commit cf9f0f7
3 files changed
+102
-5
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
| 46 | + | |
| 47 | + | |
46 | 48 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1191 | 1191 | | |
1192 | 1192 | | |
1193 | 1193 | | |
| 1194 | + | |
| 1195 | + | |
| 1196 | + | |
| 1197 | + | |
| 1198 | + | |
| 1199 | + | |
1194 | 1200 | | |
1195 | 1201 | | |
1196 | 1202 | | |
| |||
1323 | 1329 | | |
1324 | 1330 | | |
1325 | 1331 | | |
1326 | | - | |
| 1332 | + | |
1327 | 1333 | | |
1328 | 1334 | | |
1329 | 1335 | | |
| |||
6068 | 6074 | | |
6069 | 6075 | | |
6070 | 6076 | | |
6071 | | - | |
| 6077 | + | |
6072 | 6078 | | |
6073 | 6079 | | |
6074 | 6080 | | |
| |||
8194 | 8200 | | |
8195 | 8201 | | |
8196 | 8202 | | |
8197 | | - | |
8198 | 8203 | | |
8199 | 8204 | | |
8200 | 8205 | | |
8201 | 8206 | | |
| 8207 | + | |
| 8208 | + | |
| 8209 | + | |
| 8210 | + | |
| 8211 | + | |
| 8212 | + | |
| 8213 | + | |
| 8214 | + | |
| 8215 | + | |
| 8216 | + | |
| 8217 | + | |
8202 | 8218 | | |
8203 | | - | |
8204 | | - | |
| 8219 | + | |
| 8220 | + | |
| 8221 | + | |
| 8222 | + | |
| 8223 | + | |
8205 | 8224 | | |
| 8225 | + | |
| 8226 | + | |
| 8227 | + | |
| 8228 | + | |
8206 | 8229 | | |
8207 | 8230 | | |
8208 | 8231 | | |
| |||
8214 | 8237 | | |
8215 | 8238 | | |
8216 | 8239 | | |
| 8240 | + | |
| 8241 | + | |
| 8242 | + | |
| 8243 | + | |
| 8244 | + | |
| 8245 | + | |
| 8246 | + | |
| 8247 | + | |
| 8248 | + | |
| 8249 | + | |
| 8250 | + | |
| 8251 | + | |
| 8252 | + | |
| 8253 | + | |
| 8254 | + | |
| 8255 | + | |
| 8256 | + | |
| 8257 | + | |
| 8258 | + | |
| 8259 | + | |
| 8260 | + | |
| 8261 | + | |
| 8262 | + | |
| 8263 | + | |
| 8264 | + | |
| 8265 | + | |
| 8266 | + | |
| 8267 | + | |
| 8268 | + | |
| 8269 | + | |
| 8270 | + | |
| 8271 | + | |
| 8272 | + | |
| 8273 | + | |
| 8274 | + | |
| 8275 | + | |
| 8276 | + | |
| 8277 | + | |
| 8278 | + | |
| 8279 | + | |
| 8280 | + | |
| 8281 | + | |
| 8282 | + | |
| 8283 | + | |
| 8284 | + | |
| 8285 | + | |
| 8286 | + | |
| 8287 | + | |
| 8288 | + | |
| 8289 | + | |
| 8290 | + | |
| 8291 | + | |
| 8292 | + | |
| 8293 | + | |
| 8294 | + | |
| 8295 | + | |
| 8296 | + | |
| 8297 | + | |
| 8298 | + | |
| 8299 | + | |
| 8300 | + | |
| 8301 | + | |
| 8302 | + | |
| 8303 | + | |
| 8304 | + | |
| 8305 | + | |
| 8306 | + | |
| 8307 | + | |
| 8308 | + | |
| 8309 | + | |
8217 | 8310 | | |
8218 | 8311 | | |
8219 | 8312 | | |
| |||
8223 | 8316 | | |
8224 | 8317 | | |
8225 | 8318 | | |
| 8319 | + | |
8226 | 8320 | | |
8227 | 8321 | | |
8228 | 8322 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
336 | 336 | | |
337 | 337 | | |
338 | 338 | | |
| 339 | + | |
339 | 340 | | |
340 | 341 | | |
341 | 342 | | |
| |||
0 commit comments