Update ring buffer and pretty print
[lttng-modules.git] / instrumentation / events / lttng-module / block.h
1 #undef TRACE_SYSTEM
2 #define TRACE_SYSTEM block
3
4 #if !defined(_TRACE_BLOCK_H) || defined(TRACE_HEADER_MULTI_READ)
5 #define _TRACE_BLOCK_H
6
7 #include <linux/blktrace_api.h>
8 #include <linux/blkdev.h>
9 #include <linux/tracepoint.h>
10 #include <linux/trace_seq.h>
11
12 #ifndef _TRACE_BLOCK_DEF_
13 #define _TRACE_BLOCK_DEF_
14
15 #define __blk_dump_cmd(cmd, len) "<unknown>"
16
17 enum {
18 RWBS_FLAG_WRITE = (1 << 0),
19 RWBS_FLAG_DISCARD = (1 << 1),
20 RWBS_FLAG_READ = (1 << 2),
21 RWBS_FLAG_RAHEAD = (1 << 3),
22 RWBS_FLAG_SYNC = (1 << 4),
23 RWBS_FLAG_META = (1 << 5),
24 RWBS_FLAG_SECURE = (1 << 6),
25 };
26
27 #endif /* _TRACE_BLOCK_DEF_ */
28
29 #define __print_rwbs_flags(rwbs) \
30 __print_flags(rwbs, "", \
31 { RWBS_FLAG_WRITE, "W" }, \
32 { RWBS_FLAG_DISCARD, "D" }, \
33 { RWBS_FLAG_READ, "R" }, \
34 { RWBS_FLAG_RAHEAD, "A" }, \
35 { RWBS_FLAG_SYNC, "S" }, \
36 { RWBS_FLAG_META, "M" }, \
37 { RWBS_FLAG_SECURE, "E" })
38
39 #define blk_fill_rwbs(rwbs, rw, bytes) \
40 tp_assign(rwbs, ((rw) & WRITE ? RWBS_FLAG_WRITE : \
41 ( (rw) & REQ_DISCARD ? RWBS_FLAG_DISCARD : \
42 ( (bytes) ? RWBS_FLAG_READ : \
43 ( 0 )))) \
44 | ((rw) & REQ_RAHEAD ? RWBS_FLAG_RAHEAD : 0) \
45 | ((rw) & REQ_SYNC ? RWBS_FLAG_SYNC : 0) \
46 | ((rw) & REQ_META ? RWBS_FLAG_META : 0) \
47 | ((rw) & REQ_SECURE ? RWBS_FLAG_SECURE : 0))
48
49 DECLARE_EVENT_CLASS(block_rq_with_error,
50
51 TP_PROTO(struct request_queue *q, struct request *rq),
52
53 TP_ARGS(q, rq),
54
55 TP_STRUCT__entry(
56 __field( dev_t, dev )
57 __field( sector_t, sector )
58 __field( unsigned int, nr_sector )
59 __field( int, errors )
60 __field( unsigned int, rwbs )
61 __dynamic_array_text( char, cmd, blk_cmd_buf_len(rq) )
62 ),
63
64 TP_fast_assign(
65 tp_assign(dev, rq->rq_disk ? disk_devt(rq->rq_disk) : 0)
66 tp_assign(sector, (rq->cmd_type == REQ_TYPE_BLOCK_PC) ?
67 0 : blk_rq_pos(rq))
68 tp_assign(nr_sector, (rq->cmd_type == REQ_TYPE_BLOCK_PC) ?
69 0 : blk_rq_sectors(rq))
70 tp_assign(errors, rq->errors)
71 blk_fill_rwbs(rwbs, rq->cmd_flags, blk_rq_bytes(rq))
72 tp_memcpy_dyn(cmd, rq->cmd, blk_cmd_buf_len(rq))
73 ),
74
75 TP_printk("%d,%d %s (%s) %llu + %u [%d]",
76 MAJOR(__entry->dev), MINOR(__entry->dev),
77 __print_rwbs_flags(__entry->rwbs),
78 __blk_dump_cmd(__get_dynamic_array(cmd),
79 __get_dynamic_array_len(cmd)),
80 (unsigned long long)__entry->sector,
81 __entry->nr_sector, __entry->errors)
82 )
83
84 /**
85 * block_rq_abort - abort block operation request
86 * @q: queue containing the block operation request
87 * @rq: block IO operation request
88 *
89 * Called immediately after pending block IO operation request @rq in
90 * queue @q is aborted. The fields in the operation request @rq
91 * can be examined to determine which device and sectors the pending
92 * operation would access.
93 */
94 DEFINE_EVENT(block_rq_with_error, block_rq_abort,
95
96 TP_PROTO(struct request_queue *q, struct request *rq),
97
98 TP_ARGS(q, rq)
99 )
100
101 /**
102 * block_rq_requeue - place block IO request back on a queue
103 * @q: queue holding operation
104 * @rq: block IO operation request
105 *
106 * The block operation request @rq is being placed back into queue
107 * @q. For some reason the request was not completed and needs to be
108 * put back in the queue.
109 */
110 DEFINE_EVENT(block_rq_with_error, block_rq_requeue,
111
112 TP_PROTO(struct request_queue *q, struct request *rq),
113
114 TP_ARGS(q, rq)
115 )
116
117 /**
118 * block_rq_complete - block IO operation completed by device driver
119 * @q: queue containing the block operation request
120 * @rq: block operations request
121 *
122 * The block_rq_complete tracepoint event indicates that some portion
123 * of operation request has been completed by the device driver. If
124 * the @rq->bio is %NULL, then there is absolutely no additional work to
125 * do for the request. If @rq->bio is non-NULL then there is
126 * additional work required to complete the request.
127 */
128 DEFINE_EVENT(block_rq_with_error, block_rq_complete,
129
130 TP_PROTO(struct request_queue *q, struct request *rq),
131
132 TP_ARGS(q, rq)
133 )
134
135 DECLARE_EVENT_CLASS(block_rq,
136
137 TP_PROTO(struct request_queue *q, struct request *rq),
138
139 TP_ARGS(q, rq),
140
141 TP_STRUCT__entry(
142 __field( dev_t, dev )
143 __field( sector_t, sector )
144 __field( unsigned int, nr_sector )
145 __field( unsigned int, bytes )
146 __field( unsigned int, rwbs )
147 __array_text( char, comm, TASK_COMM_LEN )
148 __dynamic_array_text( char, cmd, blk_cmd_buf_len(rq) )
149 ),
150
151 TP_fast_assign(
152 tp_assign(dev, rq->rq_disk ? disk_devt(rq->rq_disk) : 0)
153 tp_assign(sector, (rq->cmd_type == REQ_TYPE_BLOCK_PC) ?
154 0 : blk_rq_pos(rq))
155 tp_assign(nr_sector, (rq->cmd_type == REQ_TYPE_BLOCK_PC) ?
156 0 : blk_rq_sectors(rq))
157 tp_assign(bytes, (rq->cmd_type == REQ_TYPE_BLOCK_PC) ?
158 blk_rq_bytes(rq) : 0)
159 blk_fill_rwbs(rwbs, rq->cmd_flags, blk_rq_bytes(rq))
160 tp_memcpy_dyn(cmd, rq->cmd, blk_cmd_buf_len(rq))
161 tp_memcpy(comm, current->comm, TASK_COMM_LEN)
162 ),
163
164 TP_printk("%d,%d %s %u (%s) %llu + %u [%s]",
165 MAJOR(__entry->dev), MINOR(__entry->dev),
166 __print_rwbs_flags(__entry->rwbs),
167 __entry->bytes,
168 __blk_dump_cmd(__get_dynamic_array(cmd),
169 __get_dynamic_array_len(cmd)),
170 (unsigned long long)__entry->sector,
171 __entry->nr_sector, __entry->comm)
172 )
173
174 /**
175 * block_rq_insert - insert block operation request into queue
176 * @q: target queue
177 * @rq: block IO operation request
178 *
179 * Called immediately before block operation request @rq is inserted
180 * into queue @q. The fields in the operation request @rq struct can
181 * be examined to determine which device and sectors the pending
182 * operation would access.
183 */
184 DEFINE_EVENT(block_rq, block_rq_insert,
185
186 TP_PROTO(struct request_queue *q, struct request *rq),
187
188 TP_ARGS(q, rq)
189 )
190
191 /**
192 * block_rq_issue - issue pending block IO request operation to device driver
193 * @q: queue holding operation
194 * @rq: block IO operation operation request
195 *
196 * Called when block operation request @rq from queue @q is sent to a
197 * device driver for processing.
198 */
199 DEFINE_EVENT(block_rq, block_rq_issue,
200
201 TP_PROTO(struct request_queue *q, struct request *rq),
202
203 TP_ARGS(q, rq)
204 )
205
206 /**
207 * block_bio_bounce - used bounce buffer when processing block operation
208 * @q: queue holding the block operation
209 * @bio: block operation
210 *
211 * A bounce buffer was used to handle the block operation @bio in @q.
212 * This occurs when hardware limitations prevent a direct transfer of
213 * data between the @bio data memory area and the IO device. Use of a
214 * bounce buffer requires extra copying of data and decreases
215 * performance.
216 */
217 TRACE_EVENT(block_bio_bounce,
218
219 TP_PROTO(struct request_queue *q, struct bio *bio),
220
221 TP_ARGS(q, bio),
222
223 TP_STRUCT__entry(
224 __field( dev_t, dev )
225 __field( sector_t, sector )
226 __field( unsigned int, nr_sector )
227 __field( unsigned int, rwbs )
228 __array_text( char, comm, TASK_COMM_LEN )
229 ),
230
231 TP_fast_assign(
232 tp_assign(dev, bio->bi_bdev ?
233 bio->bi_bdev->bd_dev : 0)
234 tp_assign(sector, bio->bi_sector)
235 tp_assign(nr_sector, bio->bi_size >> 9)
236 blk_fill_rwbs(rwbs, bio->bi_rw, bio->bi_size)
237 tp_memcpy(comm, current->comm, TASK_COMM_LEN)
238 ),
239
240 TP_printk("%d,%d %s %llu + %u [%s]",
241 MAJOR(__entry->dev), MINOR(__entry->dev),
242 __print_rwbs_flags(__entry->rwbs),
243 (unsigned long long)__entry->sector,
244 __entry->nr_sector, __entry->comm)
245 )
246
247 /**
248 * block_bio_complete - completed all work on the block operation
249 * @q: queue holding the block operation
250 * @bio: block operation completed
251 * @error: io error value
252 *
253 * This tracepoint indicates there is no further work to do on this
254 * block IO operation @bio.
255 */
256 TRACE_EVENT(block_bio_complete,
257
258 TP_PROTO(struct request_queue *q, struct bio *bio, int error),
259
260 TP_ARGS(q, bio, error),
261
262 TP_STRUCT__entry(
263 __field( dev_t, dev )
264 __field( sector_t, sector )
265 __field( unsigned, nr_sector )
266 __field( int, error )
267 __field( unsigned int, rwbs )
268 ),
269
270 TP_fast_assign(
271 tp_assign(dev, bio->bi_bdev->bd_dev)
272 tp_assign(sector, bio->bi_sector)
273 tp_assign(nr_sector, bio->bi_size >> 9)
274 tp_assign(error, error)
275 blk_fill_rwbs(rwbs, bio->bi_rw, bio->bi_size)
276 ),
277
278 TP_printk("%d,%d %s %llu + %u [%d]",
279 MAJOR(__entry->dev), MINOR(__entry->dev),
280 __print_rwbs_flags(__entry->rwbs),
281 (unsigned long long)__entry->sector,
282 __entry->nr_sector, __entry->error)
283 )
284
285 DECLARE_EVENT_CLASS(block_bio,
286
287 TP_PROTO(struct request_queue *q, struct bio *bio),
288
289 TP_ARGS(q, bio),
290
291 TP_STRUCT__entry(
292 __field( dev_t, dev )
293 __field( sector_t, sector )
294 __field( unsigned int, nr_sector )
295 __field( unsigned int, rwbs )
296 __array_text( char, comm, TASK_COMM_LEN )
297 ),
298
299 TP_fast_assign(
300 tp_assign(dev, bio->bi_bdev->bd_dev)
301 tp_assign(sector, bio->bi_sector)
302 tp_assign(nr_sector, bio->bi_size >> 9)
303 blk_fill_rwbs(rwbs, bio->bi_rw, bio->bi_size)
304 tp_memcpy(comm, current->comm, TASK_COMM_LEN)
305 ),
306
307 TP_printk("%d,%d %s %llu + %u [%s]",
308 MAJOR(__entry->dev), MINOR(__entry->dev),
309 __print_rwbs_flags(__entry->rwbs),
310 (unsigned long long)__entry->sector,
311 __entry->nr_sector, __entry->comm)
312 )
313
314 /**
315 * block_bio_backmerge - merging block operation to the end of an existing operation
316 * @q: queue holding operation
317 * @bio: new block operation to merge
318 *
319 * Merging block request @bio to the end of an existing block request
320 * in queue @q.
321 */
322 DEFINE_EVENT(block_bio, block_bio_backmerge,
323
324 TP_PROTO(struct request_queue *q, struct bio *bio),
325
326 TP_ARGS(q, bio)
327 )
328
329 /**
330 * block_bio_frontmerge - merging block operation to the beginning of an existing operation
331 * @q: queue holding operation
332 * @bio: new block operation to merge
333 *
334 * Merging block IO operation @bio to the beginning of an existing block
335 * operation in queue @q.
336 */
337 DEFINE_EVENT(block_bio, block_bio_frontmerge,
338
339 TP_PROTO(struct request_queue *q, struct bio *bio),
340
341 TP_ARGS(q, bio)
342 )
343
344 /**
345 * block_bio_queue - putting new block IO operation in queue
346 * @q: queue holding operation
347 * @bio: new block operation
348 *
349 * About to place the block IO operation @bio into queue @q.
350 */
351 DEFINE_EVENT(block_bio, block_bio_queue,
352
353 TP_PROTO(struct request_queue *q, struct bio *bio),
354
355 TP_ARGS(q, bio)
356 )
357
358 DECLARE_EVENT_CLASS(block_get_rq,
359
360 TP_PROTO(struct request_queue *q, struct bio *bio, int rw),
361
362 TP_ARGS(q, bio, rw),
363
364 TP_STRUCT__entry(
365 __field( dev_t, dev )
366 __field( sector_t, sector )
367 __field( unsigned int, nr_sector )
368 __field( unsigned int, rwbs )
369 __array_text( char, comm, TASK_COMM_LEN )
370 ),
371
372 TP_fast_assign(
373 tp_assign(dev, bio ? bio->bi_bdev->bd_dev : 0)
374 tp_assign(sector, bio ? bio->bi_sector : 0)
375 tp_assign(nr_sector, bio ? bio->bi_size >> 9 : 0)
376 blk_fill_rwbs(rwbs, bio ? bio->bi_rw : 0,
377 bio ? bio->bi_size >> 9 : 0)
378 tp_memcpy(comm, current->comm, TASK_COMM_LEN)
379 ),
380
381 TP_printk("%d,%d %s %llu + %u [%s]",
382 MAJOR(__entry->dev), MINOR(__entry->dev),
383 __print_rwbs_flags(__entry->rwbs),
384 (unsigned long long)__entry->sector,
385 __entry->nr_sector, __entry->comm)
386 )
387
388 /**
389 * block_getrq - get a free request entry in queue for block IO operations
390 * @q: queue for operations
391 * @bio: pending block IO operation
392 * @rw: low bit indicates a read (%0) or a write (%1)
393 *
394 * A request struct for queue @q has been allocated to handle the
395 * block IO operation @bio.
396 */
397 DEFINE_EVENT(block_get_rq, block_getrq,
398
399 TP_PROTO(struct request_queue *q, struct bio *bio, int rw),
400
401 TP_ARGS(q, bio, rw)
402 )
403
404 /**
405 * block_sleeprq - waiting to get a free request entry in queue for block IO operation
406 * @q: queue for operation
407 * @bio: pending block IO operation
408 * @rw: low bit indicates a read (%0) or a write (%1)
409 *
410 * In the case where a request struct cannot be provided for queue @q
411 * the process needs to wait for an request struct to become
412 * available. This tracepoint event is generated each time the
413 * process goes to sleep waiting for request struct become available.
414 */
415 DEFINE_EVENT(block_get_rq, block_sleeprq,
416
417 TP_PROTO(struct request_queue *q, struct bio *bio, int rw),
418
419 TP_ARGS(q, bio, rw)
420 )
421
422 /**
423 * block_plug - keep operations requests in request queue
424 * @q: request queue to plug
425 *
426 * Plug the request queue @q. Do not allow block operation requests
427 * to be sent to the device driver. Instead, accumulate requests in
428 * the queue to improve throughput performance of the block device.
429 */
430 TRACE_EVENT(block_plug,
431
432 TP_PROTO(struct request_queue *q),
433
434 TP_ARGS(q),
435
436 TP_STRUCT__entry(
437 __array_text( char, comm, TASK_COMM_LEN )
438 ),
439
440 TP_fast_assign(
441 tp_memcpy(comm, current->comm, TASK_COMM_LEN)
442 ),
443
444 TP_printk("[%s]", __entry->comm)
445 )
446
447 DECLARE_EVENT_CLASS(block_unplug,
448
449 TP_PROTO(struct request_queue *q, unsigned int depth, bool explicit),
450
451 TP_ARGS(q, depth, explicit),
452
453 TP_STRUCT__entry(
454 __field( int, nr_rq )
455 __array_text( char, comm, TASK_COMM_LEN )
456 ),
457
458 TP_fast_assign(
459 tp_assign(nr_rq, depth)
460 tp_memcpy(comm, current->comm, TASK_COMM_LEN)
461 ),
462
463 TP_printk("[%s] %d", __entry->comm, __entry->nr_rq)
464 )
465
466 /**
467 * block_unplug - release of operations requests in request queue
468 * @q: request queue to unplug
469 * @depth: number of requests just added to the queue
470 * @explicit: whether this was an explicit unplug, or one from schedule()
471 *
472 * Unplug request queue @q because device driver is scheduled to work
473 * on elements in the request queue.
474 */
475 DEFINE_EVENT(block_unplug, block_unplug,
476
477 TP_PROTO(struct request_queue *q, unsigned int depth, bool explicit),
478
479 TP_ARGS(q, depth, explicit)
480 )
481
482 /**
483 * block_split - split a single bio struct into two bio structs
484 * @q: queue containing the bio
485 * @bio: block operation being split
486 * @new_sector: The starting sector for the new bio
487 *
488 * The bio request @bio in request queue @q needs to be split into two
489 * bio requests. The newly created @bio request starts at
490 * @new_sector. This split may be required due to hardware limitation
491 * such as operation crossing device boundaries in a RAID system.
492 */
493 TRACE_EVENT(block_split,
494
495 TP_PROTO(struct request_queue *q, struct bio *bio,
496 unsigned int new_sector),
497
498 TP_ARGS(q, bio, new_sector),
499
500 TP_STRUCT__entry(
501 __field( dev_t, dev )
502 __field( sector_t, sector )
503 __field( sector_t, new_sector )
504 __field( unsigned int, rwbs )
505 __array_text( char, comm, TASK_COMM_LEN )
506 ),
507
508 TP_fast_assign(
509 tp_assign(dev, bio->bi_bdev->bd_dev)
510 tp_assign(sector, bio->bi_sector)
511 tp_assign(new_sector, new_sector)
512 blk_fill_rwbs(rwbs, bio->bi_rw, bio->bi_size)
513 tp_memcpy(comm, current->comm, TASK_COMM_LEN)
514 ),
515
516 TP_printk("%d,%d %s %llu / %llu [%s]",
517 MAJOR(__entry->dev), MINOR(__entry->dev),
518 __print_rwbs_flags(__entry->rwbs),
519 (unsigned long long)__entry->sector,
520 (unsigned long long)__entry->new_sector,
521 __entry->comm)
522 )
523
524 /**
525 * block_bio_remap - map request for a logical device to the raw device
526 * @q: queue holding the operation
527 * @bio: revised operation
528 * @dev: device for the operation
529 * @from: original sector for the operation
530 *
531 * An operation for a logical device has been mapped to the
532 * raw block device.
533 */
534 TRACE_EVENT(block_bio_remap,
535
536 TP_PROTO(struct request_queue *q, struct bio *bio, dev_t dev,
537 sector_t from),
538
539 TP_ARGS(q, bio, dev, from),
540
541 TP_STRUCT__entry(
542 __field( dev_t, dev )
543 __field( sector_t, sector )
544 __field( unsigned int, nr_sector )
545 __field( dev_t, old_dev )
546 __field( sector_t, old_sector )
547 __field( unsigned int, rwbs )
548 ),
549
550 TP_fast_assign(
551 tp_assign(dev, bio->bi_bdev->bd_dev)
552 tp_assign(sector, bio->bi_sector)
553 tp_assign(nr_sector, bio->bi_size >> 9)
554 tp_assign(old_dev, dev)
555 tp_assign(old_sector, from)
556 blk_fill_rwbs(rwbs, bio->bi_rw, bio->bi_size)
557 ),
558
559 TP_printk("%d,%d %s %llu + %u <- (%d,%d) %llu",
560 MAJOR(__entry->dev), MINOR(__entry->dev),
561 __print_rwbs_flags(__entry->rwbs),
562 (unsigned long long)__entry->sector,
563 __entry->nr_sector,
564 MAJOR(__entry->old_dev), MINOR(__entry->old_dev),
565 (unsigned long long)__entry->old_sector)
566 )
567
568 /**
569 * block_rq_remap - map request for a block operation request
570 * @q: queue holding the operation
571 * @rq: block IO operation request
572 * @dev: device for the operation
573 * @from: original sector for the operation
574 *
575 * The block operation request @rq in @q has been remapped. The block
576 * operation request @rq holds the current information and @from hold
577 * the original sector.
578 */
579 TRACE_EVENT(block_rq_remap,
580
581 TP_PROTO(struct request_queue *q, struct request *rq, dev_t dev,
582 sector_t from),
583
584 TP_ARGS(q, rq, dev, from),
585
586 TP_STRUCT__entry(
587 __field( dev_t, dev )
588 __field( sector_t, sector )
589 __field( unsigned int, nr_sector )
590 __field( dev_t, old_dev )
591 __field( sector_t, old_sector )
592 __field( unsigned int, rwbs )
593 ),
594
595 TP_fast_assign(
596 tp_assign(dev, disk_devt(rq->rq_disk))
597 tp_assign(sector, blk_rq_pos(rq))
598 tp_assign(nr_sector, blk_rq_sectors(rq))
599 tp_assign(old_dev, dev)
600 tp_assign(old_sector, from)
601 blk_fill_rwbs(rwbs, rq->cmd_flags, blk_rq_bytes(rq))
602 ),
603
604 TP_printk("%d,%d %s %llu + %u <- (%d,%d) %llu",
605 MAJOR(__entry->dev), MINOR(__entry->dev),
606 __print_rwbs_flags(__entry->rwbs),
607 (unsigned long long)__entry->sector,
608 __entry->nr_sector,
609 MAJOR(__entry->old_dev), MINOR(__entry->old_dev),
610 (unsigned long long)__entry->old_sector)
611 )
612
613 #undef __print_rwbs_flags
614 #undef blk_fill_rwbs
615
616 #endif /* _TRACE_BLOCK_H */
617
618 /* This part must be outside protection */
619 #include "define_trace.h"
620
This page took 0.0442 seconds and 4 git commands to generate.