Rename LTTng instrumentation macros
[lttng-modules.git] / instrumentation / events / lttng-module / block.h
1 #undef TRACE_SYSTEM
2 #define TRACE_SYSTEM block
3
4 #if !defined(LTTNG_TRACE_BLOCK_H) || defined(TRACE_HEADER_MULTI_READ)
5 #define LTTNG_TRACE_BLOCK_H
6
7 #include "../../../probes/lttng-tracepoint-event.h"
8 #include <linux/blktrace_api.h>
9 #include <linux/blkdev.h>
10 #include <linux/trace_seq.h>
11 #include <linux/version.h>
12
13 #define RWBS_LEN 8
14
15 #ifndef _TRACE_BLOCK_DEF_
16 #define _TRACE_BLOCK_DEF_
17
18 #define __blk_dump_cmd(cmd, len) "<unknown>"
19
20 enum {
21 RWBS_FLAG_WRITE = (1 << 0),
22 RWBS_FLAG_DISCARD = (1 << 1),
23 RWBS_FLAG_READ = (1 << 2),
24 RWBS_FLAG_RAHEAD = (1 << 3),
25 RWBS_FLAG_BARRIER = (1 << 4),
26 RWBS_FLAG_SYNC = (1 << 5),
27 RWBS_FLAG_META = (1 << 6),
28 RWBS_FLAG_SECURE = (1 << 7),
29 RWBS_FLAG_FLUSH = (1 << 8),
30 RWBS_FLAG_FUA = (1 << 9),
31 };
32
33 #endif /* _TRACE_BLOCK_DEF_ */
34
35 #define __print_rwbs_flags(rwbs) \
36 __print_flags(rwbs, "", \
37 { RWBS_FLAG_FLUSH, "F" }, \
38 { RWBS_FLAG_WRITE, "W" }, \
39 { RWBS_FLAG_DISCARD, "D" }, \
40 { RWBS_FLAG_READ, "R" }, \
41 { RWBS_FLAG_FUA, "F" }, \
42 { RWBS_FLAG_RAHEAD, "A" }, \
43 { RWBS_FLAG_BARRIER, "B" }, \
44 { RWBS_FLAG_SYNC, "S" }, \
45 { RWBS_FLAG_META, "M" }, \
46 { RWBS_FLAG_SECURE, "E" })
47
48 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,1,0))
49
50 #define blk_fill_rwbs(rwbs, rw, bytes) \
51 tp_assign(rwbs, ((rw) & WRITE ? RWBS_FLAG_WRITE : \
52 ( (rw) & REQ_DISCARD ? RWBS_FLAG_DISCARD : \
53 ( (bytes) ? RWBS_FLAG_READ : \
54 ( 0 )))) \
55 | ((rw) & REQ_RAHEAD ? RWBS_FLAG_RAHEAD : 0) \
56 | ((rw) & REQ_SYNC ? RWBS_FLAG_SYNC : 0) \
57 | ((rw) & REQ_META ? RWBS_FLAG_META : 0) \
58 | ((rw) & REQ_SECURE ? RWBS_FLAG_SECURE : 0) \
59 | ((rw) & REQ_FLUSH ? RWBS_FLAG_FLUSH : 0) \
60 | ((rw) & REQ_FUA ? RWBS_FLAG_FUA : 0))
61
62 #elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37))
63
64 #define blk_fill_rwbs(rwbs, rw, bytes) \
65 tp_assign(rwbs, ((rw) & WRITE ? RWBS_FLAG_WRITE : \
66 ( (rw) & REQ_DISCARD ? RWBS_FLAG_DISCARD : \
67 ( (bytes) ? RWBS_FLAG_READ : \
68 ( 0 )))) \
69 | ((rw) & REQ_RAHEAD ? RWBS_FLAG_RAHEAD : 0) \
70 | ((rw) & REQ_SYNC ? RWBS_FLAG_SYNC : 0) \
71 | ((rw) & REQ_META ? RWBS_FLAG_META : 0) \
72 | ((rw) & REQ_SECURE ? RWBS_FLAG_SECURE : 0))
73
74 #elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36))
75
76 #define blk_fill_rwbs(rwbs, rw, bytes) \
77 tp_assign(rwbs, ((rw) & WRITE ? RWBS_FLAG_WRITE : \
78 ( (rw) & REQ_DISCARD ? RWBS_FLAG_DISCARD : \
79 ( (bytes) ? RWBS_FLAG_READ : \
80 ( 0 )))) \
81 | ((rw) & REQ_RAHEAD ? RWBS_FLAG_RAHEAD : 0) \
82 | ((rw) & REQ_HARDBARRIER ? RWBS_FLAG_BARRIER : 0) \
83 | ((rw) & REQ_SYNC ? RWBS_FLAG_SYNC : 0) \
84 | ((rw) & REQ_META ? RWBS_FLAG_META : 0) \
85 | ((rw) & REQ_SECURE ? RWBS_FLAG_SECURE : 0))
86
87 #else
88
89 #define blk_fill_rwbs(rwbs, rw, bytes) \
90 tp_assign(rwbs, ((rw) & WRITE ? RWBS_FLAG_WRITE : \
91 ( (rw) & (1 << BIO_RW_DISCARD) ? RWBS_FLAG_DISCARD : \
92 ( (bytes) ? RWBS_FLAG_READ : \
93 ( 0 )))) \
94 | ((rw) & (1 << BIO_RW_AHEAD) ? RWBS_FLAG_RAHEAD : 0) \
95 | ((rw) & (1 << BIO_RW_SYNCIO) ? RWBS_FLAG_SYNC : 0) \
96 | ((rw) & (1 << BIO_RW_META) ? RWBS_FLAG_META : 0) \
97 | ((rw) & (1 << BIO_RW_BARRIER) ? RWBS_FLAG_BARRIER : 0))
98
99 #endif
100
101 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
102 LTTNG_TRACEPOINT_EVENT_CLASS(block_buffer,
103
104 TP_PROTO(struct buffer_head *bh),
105
106 TP_ARGS(bh),
107
108 TP_STRUCT__entry (
109 __field( dev_t, dev )
110 __field( sector_t, sector )
111 __field( size_t, size )
112 ),
113
114 TP_fast_assign(
115 tp_assign(dev, bh->b_bdev->bd_dev)
116 tp_assign(sector, bh->b_blocknr)
117 tp_assign(size, bh->b_size)
118 ),
119
120 TP_printk("%d,%d sector=%llu size=%zu",
121 MAJOR(__entry->dev), MINOR(__entry->dev),
122 (unsigned long long)__entry->sector, __entry->size
123 )
124 )
125
126 /**
127 * block_touch_buffer - mark a buffer accessed
128 * @bh: buffer_head being touched
129 *
130 * Called from touch_buffer().
131 */
132 LTTNG_TRACEPOINT_EVENT_INSTANCE(block_buffer, block_touch_buffer,
133
134 TP_PROTO(struct buffer_head *bh),
135
136 TP_ARGS(bh)
137 )
138
139 /**
140 * block_dirty_buffer - mark a buffer dirty
141 * @bh: buffer_head being dirtied
142 *
143 * Called from mark_buffer_dirty().
144 */
145 LTTNG_TRACEPOINT_EVENT_INSTANCE(block_buffer, block_dirty_buffer,
146
147 TP_PROTO(struct buffer_head *bh),
148
149 TP_ARGS(bh)
150 )
151 #endif
152
153 LTTNG_TRACEPOINT_EVENT_CLASS(block_rq_with_error,
154
155 TP_PROTO(struct request_queue *q, struct request *rq),
156
157 TP_ARGS(q, rq),
158
159 TP_STRUCT__entry(
160 __field( dev_t, dev )
161 __field( sector_t, sector )
162 __field( unsigned int, nr_sector )
163 __field( int, errors )
164 __field( unsigned int, rwbs )
165 __dynamic_array_hex( unsigned char, cmd,
166 (rq->cmd_type == REQ_TYPE_BLOCK_PC) ?
167 rq->cmd_len : 0)
168 ),
169
170 TP_fast_assign(
171 tp_assign(dev, rq->rq_disk ? disk_devt(rq->rq_disk) : 0)
172 tp_assign(sector, (rq->cmd_type == REQ_TYPE_BLOCK_PC) ?
173 0 : blk_rq_pos(rq))
174 tp_assign(nr_sector, (rq->cmd_type == REQ_TYPE_BLOCK_PC) ?
175 0 : blk_rq_sectors(rq))
176 tp_assign(errors, rq->errors)
177 blk_fill_rwbs(rwbs, rq->cmd_flags, blk_rq_bytes(rq))
178 tp_memcpy_dyn(cmd, (rq->cmd_type == REQ_TYPE_BLOCK_PC) ?
179 rq->cmd : NULL)
180 ),
181
182 TP_printk("%d,%d %s (%s) %llu + %u [%d]",
183 MAJOR(__entry->dev), MINOR(__entry->dev),
184 __print_rwbs_flags(__entry->rwbs),
185 __blk_dump_cmd(__get_dynamic_array(cmd),
186 __get_dynamic_array_len(cmd)),
187 (unsigned long long)__entry->sector,
188 __entry->nr_sector, __entry->errors)
189 )
190
191 /**
192 * block_rq_abort - abort block operation request
193 * @q: queue containing the block operation request
194 * @rq: block IO operation request
195 *
196 * Called immediately after pending block IO operation request @rq in
197 * queue @q is aborted. The fields in the operation request @rq
198 * can be examined to determine which device and sectors the pending
199 * operation would access.
200 */
201 LTTNG_TRACEPOINT_EVENT_INSTANCE(block_rq_with_error, block_rq_abort,
202
203 TP_PROTO(struct request_queue *q, struct request *rq),
204
205 TP_ARGS(q, rq)
206 )
207
208 /**
209 * block_rq_requeue - place block IO request back on a queue
210 * @q: queue holding operation
211 * @rq: block IO operation request
212 *
213 * The block operation request @rq is being placed back into queue
214 * @q. For some reason the request was not completed and needs to be
215 * put back in the queue.
216 */
217 LTTNG_TRACEPOINT_EVENT_INSTANCE(block_rq_with_error, block_rq_requeue,
218
219 TP_PROTO(struct request_queue *q, struct request *rq),
220
221 TP_ARGS(q, rq)
222 )
223
224 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,5) \
225 || LTTNG_KERNEL_RANGE(3,12,21, 3,13,0) \
226 || LTTNG_KERNEL_RANGE(3,10,41, 3,11,0) \
227 || LTTNG_KERNEL_RANGE(3,4,91, 3,5,0) \
228 || LTTNG_KERNEL_RANGE(3,2,58, 3,3,0))
229
230 /**
231 * block_rq_complete - block IO operation completed by device driver
232 * @q: queue containing the block operation request
233 * @rq: block operations request
234 * @nr_bytes: number of completed bytes
235 *
236 * The block_rq_complete tracepoint event indicates that some portion
237 * of operation request has been completed by the device driver. If
238 * the @rq->bio is %NULL, then there is absolutely no additional work to
239 * do for the request. If @rq->bio is non-NULL then there is
240 * additional work required to complete the request.
241 */
242 LTTNG_TRACEPOINT_EVENT(block_rq_complete,
243
244 TP_PROTO(struct request_queue *q, struct request *rq,
245 unsigned int nr_bytes),
246
247 TP_ARGS(q, rq, nr_bytes),
248
249 TP_STRUCT__entry(
250 __field( dev_t, dev )
251 __field( sector_t, sector )
252 __field( unsigned int, nr_sector )
253 __field( int, errors )
254 __field( unsigned int, rwbs )
255 __dynamic_array_hex( unsigned char, cmd,
256 (rq->cmd_type == REQ_TYPE_BLOCK_PC) ?
257 rq->cmd_len : 0)
258 ),
259
260 TP_fast_assign(
261 tp_assign(dev, rq->rq_disk ? disk_devt(rq->rq_disk) : 0)
262 tp_assign(sector, blk_rq_pos(rq))
263 tp_assign(nr_sector, nr_bytes >> 9)
264 tp_assign(errors, rq->errors)
265 blk_fill_rwbs(rwbs, rq->cmd_flags, nr_bytes)
266 tp_memcpy_dyn(cmd, (rq->cmd_type == REQ_TYPE_BLOCK_PC) ?
267 rq->cmd : NULL)
268 ),
269
270 TP_printk("%d,%d %s (%s) %llu + %u [%d]",
271 MAJOR(__entry->dev), MINOR(__entry->dev),
272 __entry->rwbs, __get_str(cmd),
273 (unsigned long long)__entry->sector,
274 __entry->nr_sector, __entry->errors)
275 )
276
277 #else /* #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,15,0)) */
278
279 /**
280 * block_rq_complete - block IO operation completed by device driver
281 * @q: queue containing the block operation request
282 * @rq: block operations request
283 *
284 * The block_rq_complete tracepoint event indicates that some portion
285 * of operation request has been completed by the device driver. If
286 * the @rq->bio is %NULL, then there is absolutely no additional work to
287 * do for the request. If @rq->bio is non-NULL then there is
288 * additional work required to complete the request.
289 */
290 LTTNG_TRACEPOINT_EVENT_INSTANCE(block_rq_with_error, block_rq_complete,
291
292 TP_PROTO(struct request_queue *q, struct request *rq),
293
294 TP_ARGS(q, rq)
295 )
296
297 #endif /* #else #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,15,0)) */
298
299 LTTNG_TRACEPOINT_EVENT_CLASS(block_rq,
300
301 TP_PROTO(struct request_queue *q, struct request *rq),
302
303 TP_ARGS(q, rq),
304
305 TP_STRUCT__entry(
306 __field( dev_t, dev )
307 __field( sector_t, sector )
308 __field( unsigned int, nr_sector )
309 __field( unsigned int, bytes )
310 __field( unsigned int, rwbs )
311 __field( pid_t, tid )
312 __array_text( char, comm, TASK_COMM_LEN )
313 __dynamic_array_hex( unsigned char, cmd,
314 (rq->cmd_type == REQ_TYPE_BLOCK_PC) ?
315 rq->cmd_len : 0)
316 ),
317
318 TP_fast_assign(
319 tp_assign(dev, rq->rq_disk ? disk_devt(rq->rq_disk) : 0)
320 tp_assign(sector, (rq->cmd_type == REQ_TYPE_BLOCK_PC) ?
321 0 : blk_rq_pos(rq))
322 tp_assign(nr_sector, (rq->cmd_type == REQ_TYPE_BLOCK_PC) ?
323 0 : blk_rq_sectors(rq))
324 tp_assign(bytes, (rq->cmd_type == REQ_TYPE_BLOCK_PC) ?
325 blk_rq_bytes(rq) : 0)
326 blk_fill_rwbs(rwbs, rq->cmd_flags, blk_rq_bytes(rq))
327 tp_memcpy_dyn(cmd, (rq->cmd_type == REQ_TYPE_BLOCK_PC) ?
328 rq->cmd : NULL)
329 tp_memcpy(comm, current->comm, TASK_COMM_LEN)
330 tp_assign(tid, current->pid)
331 ),
332
333 TP_printk("%d,%d %s %u (%s) %llu + %u [%s] %d",
334 MAJOR(__entry->dev), MINOR(__entry->dev),
335 __print_rwbs_flags(__entry->rwbs),
336 __entry->bytes,
337 __blk_dump_cmd(__get_dynamic_array(cmd),
338 __get_dynamic_array_len(cmd)),
339 (unsigned long long)__entry->sector,
340 __entry->nr_sector, __entry->comm, __entry->tid)
341 )
342
343 /**
344 * block_rq_insert - insert block operation request into queue
345 * @q: target queue
346 * @rq: block IO operation request
347 *
348 * Called immediately before block operation request @rq is inserted
349 * into queue @q. The fields in the operation request @rq struct can
350 * be examined to determine which device and sectors the pending
351 * operation would access.
352 */
353 LTTNG_TRACEPOINT_EVENT_INSTANCE(block_rq, block_rq_insert,
354
355 TP_PROTO(struct request_queue *q, struct request *rq),
356
357 TP_ARGS(q, rq)
358 )
359
360 /**
361 * block_rq_issue - issue pending block IO request operation to device driver
362 * @q: queue holding operation
363 * @rq: block IO operation operation request
364 *
365 * Called when block operation request @rq from queue @q is sent to a
366 * device driver for processing.
367 */
368 LTTNG_TRACEPOINT_EVENT_INSTANCE(block_rq, block_rq_issue,
369
370 TP_PROTO(struct request_queue *q, struct request *rq),
371
372 TP_ARGS(q, rq)
373 )
374
375 /**
376 * block_bio_bounce - used bounce buffer when processing block operation
377 * @q: queue holding the block operation
378 * @bio: block operation
379 *
380 * A bounce buffer was used to handle the block operation @bio in @q.
381 * This occurs when hardware limitations prevent a direct transfer of
382 * data between the @bio data memory area and the IO device. Use of a
383 * bounce buffer requires extra copying of data and decreases
384 * performance.
385 */
386 LTTNG_TRACEPOINT_EVENT(block_bio_bounce,
387
388 TP_PROTO(struct request_queue *q, struct bio *bio),
389
390 TP_ARGS(q, bio),
391
392 TP_STRUCT__entry(
393 __field( dev_t, dev )
394 __field( sector_t, sector )
395 __field( unsigned int, nr_sector )
396 __field( unsigned int, rwbs )
397 __field( pid_t, tid )
398 __array_text( char, comm, TASK_COMM_LEN )
399 ),
400
401 TP_fast_assign(
402 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0))
403 tp_assign(dev, bio->bi_bdev ?
404 bio->bi_bdev->bd_dev : 0)
405 tp_assign(sector, bio->bi_iter.bi_sector)
406 tp_assign(nr_sector, bio_sectors(bio))
407 blk_fill_rwbs(rwbs, bio->bi_rw, bio->bi_iter.bi_size)
408 tp_memcpy(comm, current->comm, TASK_COMM_LEN)
409 tp_assign(tid, current->pid)
410 #else /* #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0)) */
411 tp_assign(dev, bio->bi_bdev ?
412 bio->bi_bdev->bd_dev : 0)
413 tp_assign(sector, bio->bi_sector)
414 tp_assign(nr_sector, bio->bi_size >> 9)
415 blk_fill_rwbs(rwbs, bio->bi_rw, bio->bi_size)
416 tp_memcpy(comm, current->comm, TASK_COMM_LEN)
417 tp_assign(tid, current->pid)
418 #endif /* #else #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0)) */
419 ),
420
421 TP_printk("%d,%d %s %llu + %u [%s] %d",
422 MAJOR(__entry->dev), MINOR(__entry->dev),
423 __print_rwbs_flags(__entry->rwbs),
424 (unsigned long long)__entry->sector,
425 __entry->nr_sector, __entry->comm, __entry->tid)
426 )
427
428 /**
429 * block_bio_complete - completed all work on the block operation
430 * @q: queue holding the block operation
431 * @bio: block operation completed
432 * @error: io error value
433 *
434 * This tracepoint indicates there is no further work to do on this
435 * block IO operation @bio.
436 */
437 LTTNG_TRACEPOINT_EVENT(block_bio_complete,
438
439 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
440 TP_PROTO(struct request_queue *q, struct bio *bio, int error),
441
442 TP_ARGS(q, bio, error),
443 #else
444 TP_PROTO(struct request_queue *q, struct bio *bio),
445
446 TP_ARGS(q, bio),
447 #endif
448
449 TP_STRUCT__entry(
450 __field( dev_t, dev )
451 __field( sector_t, sector )
452 __field( unsigned, nr_sector )
453 __field( int, error )
454 __field( unsigned int, rwbs )
455 ),
456
457 TP_fast_assign(
458 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0))
459 tp_assign(dev, bio->bi_bdev->bd_dev)
460 tp_assign(sector, bio->bi_iter.bi_sector)
461 tp_assign(nr_sector, bio_sectors(bio))
462 tp_assign(error, error)
463 blk_fill_rwbs(rwbs, bio->bi_rw, bio->bi_iter.bi_size)
464 #else /* #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0)) */
465 tp_assign(dev, bio->bi_bdev->bd_dev)
466 tp_assign(sector, bio->bi_sector)
467 tp_assign(nr_sector, bio->bi_size >> 9)
468 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
469 tp_assign(error, error)
470 #else
471 tp_assign(error, 0)
472 #endif
473 blk_fill_rwbs(rwbs, bio->bi_rw, bio->bi_size)
474 #endif /* #else #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0)) */
475 ),
476
477 TP_printk("%d,%d %s %llu + %u [%d]",
478 MAJOR(__entry->dev), MINOR(__entry->dev),
479 __print_rwbs_flags(__entry->rwbs),
480 (unsigned long long)__entry->sector,
481 __entry->nr_sector, __entry->error)
482 )
483
484 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
485 LTTNG_TRACEPOINT_EVENT_CLASS(block_bio_merge,
486
487 TP_PROTO(struct request_queue *q, struct request *rq, struct bio *bio),
488
489 TP_ARGS(q, rq, bio),
490
491 TP_STRUCT__entry(
492 __field( dev_t, dev )
493 __field( sector_t, sector )
494 __field( unsigned int, nr_sector )
495 __field( unsigned int, rwbs )
496 __field( pid_t, tid )
497 __array_text( char, comm, TASK_COMM_LEN )
498 ),
499
500 TP_fast_assign(
501 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0))
502 tp_assign(dev, bio->bi_bdev->bd_dev)
503 tp_assign(sector, bio->bi_iter.bi_sector)
504 tp_assign(nr_sector, bio_sectors(bio))
505 blk_fill_rwbs(rwbs, bio->bi_rw, bio->bi_iter.bi_size)
506 tp_memcpy(comm, current->comm, TASK_COMM_LEN)
507 tp_assign(tid, current->pid)
508 #else /* #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0)) */
509 tp_assign(dev, bio->bi_bdev->bd_dev)
510 tp_assign(sector, bio->bi_sector)
511 tp_assign(nr_sector, bio->bi_size >> 9)
512 blk_fill_rwbs(rwbs, bio->bi_rw, bio->bi_size)
513 tp_memcpy(comm, current->comm, TASK_COMM_LEN)
514 tp_assign(tid, current->pid)
515 #endif /* #else #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0)) */
516 ),
517
518 TP_printk("%d,%d %s %llu + %u [%s] %d",
519 MAJOR(__entry->dev), MINOR(__entry->dev),
520 __print_rwbs_flags(__entry->rwbs),
521 (unsigned long long)__entry->sector,
522 __entry->nr_sector, __entry->comm, __entry->tid)
523 )
524
525 /**
526 * block_bio_backmerge - merging block operation to the end of an existing operation
527 * @q: queue holding operation
528 * @bio: new block operation to merge
529 *
530 * Merging block request @bio to the end of an existing block request
531 * in queue @q.
532 */
533 LTTNG_TRACEPOINT_EVENT_INSTANCE(block_bio_merge, block_bio_backmerge,
534
535 TP_PROTO(struct request_queue *q, struct request *rq, struct bio *bio),
536
537 TP_ARGS(q, rq, bio)
538 )
539
540 /**
541 * block_bio_frontmerge - merging block operation to the beginning of an existing operation
542 * @q: queue holding operation
543 * @bio: new block operation to merge
544 *
545 * Merging block IO operation @bio to the beginning of an existing block
546 * operation in queue @q.
547 */
548 LTTNG_TRACEPOINT_EVENT_INSTANCE(block_bio_merge, block_bio_frontmerge,
549
550 TP_PROTO(struct request_queue *q, struct request *rq, struct bio *bio),
551
552 TP_ARGS(q, rq, bio)
553 )
554
555 /**
556 * block_bio_queue - putting new block IO operation in queue
557 * @q: queue holding operation
558 * @bio: new block operation
559 *
560 * About to place the block IO operation @bio into queue @q.
561 */
562 LTTNG_TRACEPOINT_EVENT(block_bio_queue,
563
564 TP_PROTO(struct request_queue *q, struct bio *bio),
565
566 TP_ARGS(q, bio),
567
568 TP_STRUCT__entry(
569 __field( dev_t, dev )
570 __field( sector_t, sector )
571 __field( unsigned int, nr_sector )
572 __field( unsigned int, rwbs )
573 __field( pid_t, tid )
574 __array_text( char, comm, TASK_COMM_LEN )
575 ),
576
577 TP_fast_assign(
578 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0))
579 tp_assign(dev, bio->bi_bdev->bd_dev)
580 tp_assign(sector, bio->bi_iter.bi_sector)
581 tp_assign(nr_sector, bio_sectors(bio))
582 blk_fill_rwbs(rwbs, bio->bi_rw, bio->bi_iter.bi_size)
583 tp_memcpy(comm, current->comm, TASK_COMM_LEN)
584 tp_assign(tid, current->pid)
585 #else /* #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0)) */
586 tp_assign(dev, bio->bi_bdev->bd_dev)
587 tp_assign(sector, bio->bi_sector)
588 tp_assign(nr_sector, bio->bi_size >> 9)
589 blk_fill_rwbs(rwbs, bio->bi_rw, bio->bi_size)
590 tp_memcpy(comm, current->comm, TASK_COMM_LEN)
591 tp_assign(tid, current->pid)
592 #endif /* #else #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0)) */
593 ),
594
595 TP_printk("%d,%d %s %llu + %u [%s] %d",
596 MAJOR(__entry->dev), MINOR(__entry->dev), __entry->rwbs,
597 (unsigned long long)__entry->sector,
598 __entry->nr_sector, __entry->comm, __entry->tid)
599 )
600 #else
601 LTTNG_TRACEPOINT_EVENT_CLASS(block_bio,
602
603 TP_PROTO(struct request_queue *q, struct bio *bio),
604
605 TP_ARGS(q, bio),
606
607 TP_STRUCT__entry(
608 __field( dev_t, dev )
609 __field( sector_t, sector )
610 __field( unsigned int, nr_sector )
611 __field( unsigned int, rwbs )
612 __field( pid_t, tid )
613 __array_text( char, comm, TASK_COMM_LEN )
614 ),
615
616 TP_fast_assign(
617 tp_assign(dev, bio->bi_bdev ? bio->bi_bdev->bd_dev : 0)
618 tp_assign(sector, bio->bi_sector)
619 tp_assign(nr_sector, bio->bi_size >> 9)
620 blk_fill_rwbs(rwbs, bio->bi_rw, bio->bi_size)
621 tp_memcpy(comm, current->comm, TASK_COMM_LEN)
622 tp_assign(tid, current->pid)
623 ),
624
625 TP_printk("%d,%d %s %llu + %u [%s] %d",
626 MAJOR(__entry->dev), MINOR(__entry->dev),
627 __print_rwbs_flags(__entry->rwbs),
628 (unsigned long long)__entry->sector,
629 __entry->nr_sector, __entry->comm, __entry->tid)
630 )
631
632 /**
633 * block_bio_backmerge - merging block operation to the end of an existing operation
634 * @q: queue holding operation
635 * @bio: new block operation to merge
636 *
637 * Merging block request @bio to the end of an existing block request
638 * in queue @q.
639 */
640 LTTNG_TRACEPOINT_EVENT_INSTANCE(block_bio, block_bio_backmerge,
641
642 TP_PROTO(struct request_queue *q, struct bio *bio),
643
644 TP_ARGS(q, bio)
645 )
646
647 /**
648 * block_bio_frontmerge - merging block operation to the beginning of an existing operation
649 * @q: queue holding operation
650 * @bio: new block operation to merge
651 *
652 * Merging block IO operation @bio to the beginning of an existing block
653 * operation in queue @q.
654 */
655 LTTNG_TRACEPOINT_EVENT_INSTANCE(block_bio, block_bio_frontmerge,
656
657 TP_PROTO(struct request_queue *q, struct bio *bio),
658
659 TP_ARGS(q, bio)
660 )
661
662 /**
663 * block_bio_queue - putting new block IO operation in queue
664 * @q: queue holding operation
665 * @bio: new block operation
666 *
667 * About to place the block IO operation @bio into queue @q.
668 */
669 LTTNG_TRACEPOINT_EVENT_INSTANCE(block_bio, block_bio_queue,
670
671 TP_PROTO(struct request_queue *q, struct bio *bio),
672
673 TP_ARGS(q, bio)
674 )
675 #endif
676
677 LTTNG_TRACEPOINT_EVENT_CLASS(block_get_rq,
678
679 TP_PROTO(struct request_queue *q, struct bio *bio, int rw),
680
681 TP_ARGS(q, bio, rw),
682
683 TP_STRUCT__entry(
684 __field( dev_t, dev )
685 __field( sector_t, sector )
686 __field( unsigned int, nr_sector )
687 __field( unsigned int, rwbs )
688 __field( pid_t, tid )
689 __array_text( char, comm, TASK_COMM_LEN )
690 ),
691
692 TP_fast_assign(
693 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0))
694 tp_assign(dev, bio ? bio->bi_bdev->bd_dev : 0)
695 tp_assign(sector, bio ? bio->bi_iter.bi_sector : 0)
696 tp_assign(nr_sector, bio ? bio_sectors(bio) : 0)
697 blk_fill_rwbs(rwbs, bio ? bio->bi_rw : 0,
698 bio ? bio_sectors(bio) : 0)
699 tp_memcpy(comm, current->comm, TASK_COMM_LEN)
700 tp_assign(tid, current->pid)
701 #else /* #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0)) */
702 tp_assign(dev, bio ? bio->bi_bdev->bd_dev : 0)
703 tp_assign(sector, bio ? bio->bi_sector : 0)
704 tp_assign(nr_sector, bio ? bio->bi_size >> 9 : 0)
705 blk_fill_rwbs(rwbs, bio ? bio->bi_rw : 0,
706 bio ? bio->bi_size >> 9 : 0)
707 tp_memcpy(comm, current->comm, TASK_COMM_LEN)
708 tp_assign(tid, current->pid)
709 #endif /* #else #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0)) */
710 ),
711
712 TP_printk("%d,%d %s %llu + %u [%s] %d",
713 MAJOR(__entry->dev), MINOR(__entry->dev),
714 __print_rwbs_flags(__entry->rwbs),
715 (unsigned long long)__entry->sector,
716 __entry->nr_sector, __entry->comm, __entry->tid)
717 )
718
719 /**
720 * block_getrq - get a free request entry in queue for block IO operations
721 * @q: queue for operations
722 * @bio: pending block IO operation
723 * @rw: low bit indicates a read (%0) or a write (%1)
724 *
725 * A request struct for queue @q has been allocated to handle the
726 * block IO operation @bio.
727 */
728 LTTNG_TRACEPOINT_EVENT_INSTANCE(block_get_rq, block_getrq,
729
730 TP_PROTO(struct request_queue *q, struct bio *bio, int rw),
731
732 TP_ARGS(q, bio, rw)
733 )
734
735 /**
736 * block_sleeprq - waiting to get a free request entry in queue for block IO operation
737 * @q: queue for operation
738 * @bio: pending block IO operation
739 * @rw: low bit indicates a read (%0) or a write (%1)
740 *
741 * In the case where a request struct cannot be provided for queue @q
742 * the process needs to wait for an request struct to become
743 * available. This tracepoint event is generated each time the
744 * process goes to sleep waiting for request struct become available.
745 */
746 LTTNG_TRACEPOINT_EVENT_INSTANCE(block_get_rq, block_sleeprq,
747
748 TP_PROTO(struct request_queue *q, struct bio *bio, int rw),
749
750 TP_ARGS(q, bio, rw)
751 )
752
753 /**
754 * block_plug - keep operations requests in request queue
755 * @q: request queue to plug
756 *
757 * Plug the request queue @q. Do not allow block operation requests
758 * to be sent to the device driver. Instead, accumulate requests in
759 * the queue to improve throughput performance of the block device.
760 */
761 LTTNG_TRACEPOINT_EVENT(block_plug,
762
763 TP_PROTO(struct request_queue *q),
764
765 TP_ARGS(q),
766
767 TP_STRUCT__entry(
768 __field( pid_t, tid )
769 __array_text( char, comm, TASK_COMM_LEN )
770 ),
771
772 TP_fast_assign(
773 tp_memcpy(comm, current->comm, TASK_COMM_LEN)
774 tp_assign(tid, current->pid)
775 ),
776
777 TP_printk("[%s] %d", __entry->comm, __entry->tid)
778 )
779
780 LTTNG_TRACEPOINT_EVENT_CLASS(block_unplug,
781
782 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,39))
783 TP_PROTO(struct request_queue *q, unsigned int depth, bool explicit),
784
785 TP_ARGS(q, depth, explicit),
786 #else
787 TP_PROTO(struct request_queue *q),
788
789 TP_ARGS(q),
790 #endif
791
792 TP_STRUCT__entry(
793 __field( int, nr_rq )
794 __field( pid_t, tid )
795 __array_text( char, comm, TASK_COMM_LEN )
796 ),
797
798 TP_fast_assign(
799 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,39))
800 tp_assign(nr_rq, depth)
801 #else
802 tp_assign(nr_rq, q->rq.count[READ] + q->rq.count[WRITE])
803 #endif
804 tp_memcpy(comm, current->comm, TASK_COMM_LEN)
805 tp_assign(tid, current->pid)
806 ),
807
808 TP_printk("[%s] %d %d", __entry->comm, , __entry->tid,
809 __entry->nr_rq)
810 )
811
812 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,39))
813 /**
814 * block_unplug_timer - timed release of operations requests in queue to device driver
815 * @q: request queue to unplug
816 *
817 * Unplug the request queue @q because a timer expired and allow block
818 * operation requests to be sent to the device driver.
819 */
820 LTTNG_TRACEPOINT_EVENT_INSTANCE(block_unplug, block_unplug_timer,
821
822 TP_PROTO(struct request_queue *q),
823
824 TP_ARGS(q)
825 )
826 #endif
827
828 /**
829 * block_unplug - release of operations requests in request queue
830 * @q: request queue to unplug
831 * @depth: number of requests just added to the queue
832 * @explicit: whether this was an explicit unplug, or one from schedule()
833 *
834 * Unplug request queue @q because device driver is scheduled to work
835 * on elements in the request queue.
836 */
837 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,39))
838 LTTNG_TRACEPOINT_EVENT_INSTANCE(block_unplug, block_unplug,
839 #else
840 LTTNG_TRACEPOINT_EVENT_INSTANCE(block_unplug, block_unplug_io,
841 #endif
842
843 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,39))
844 TP_PROTO(struct request_queue *q, unsigned int depth, bool explicit),
845
846 TP_ARGS(q, depth, explicit)
847 #else
848 TP_PROTO(struct request_queue *q),
849
850 TP_ARGS(q)
851 #endif
852 )
853
854 /**
855 * block_split - split a single bio struct into two bio structs
856 * @q: queue containing the bio
857 * @bio: block operation being split
858 * @new_sector: The starting sector for the new bio
859 *
860 * The bio request @bio in request queue @q needs to be split into two
861 * bio requests. The newly created @bio request starts at
862 * @new_sector. This split may be required due to hardware limitation
863 * such as operation crossing device boundaries in a RAID system.
864 */
865 LTTNG_TRACEPOINT_EVENT(block_split,
866
867 TP_PROTO(struct request_queue *q, struct bio *bio,
868 unsigned int new_sector),
869
870 TP_ARGS(q, bio, new_sector),
871
872 TP_STRUCT__entry(
873 __field( dev_t, dev )
874 __field( sector_t, sector )
875 __field( sector_t, new_sector )
876 __field( unsigned int, rwbs )
877 __field( pid_t, tid )
878 __array_text( char, comm, TASK_COMM_LEN )
879 ),
880
881 TP_fast_assign(
882 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0))
883 tp_assign(dev, bio->bi_bdev->bd_dev)
884 tp_assign(sector, bio->bi_iter.bi_sector)
885 tp_assign(new_sector, new_sector)
886 blk_fill_rwbs(rwbs, bio->bi_rw, bio->bi_iter.bi_size)
887 tp_memcpy(comm, current->comm, TASK_COMM_LEN)
888 tp_assign(tid, current->pid)
889 #else /* #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0)) */
890 tp_assign(dev, bio->bi_bdev->bd_dev)
891 tp_assign(sector, bio->bi_sector)
892 tp_assign(new_sector, new_sector)
893 blk_fill_rwbs(rwbs, bio->bi_rw, bio->bi_size)
894 tp_memcpy(comm, current->comm, TASK_COMM_LEN)
895 tp_assign(tid, current->pid)
896 #endif /* #else #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0)) */
897 ),
898
899 TP_printk("%d,%d %s %llu / %llu [%s] %d",
900 MAJOR(__entry->dev), MINOR(__entry->dev),
901 __print_rwbs_flags(__entry->rwbs),
902 (unsigned long long)__entry->sector,
903 (unsigned long long)__entry->new_sector,
904 __entry->comm, __entry->tid)
905 )
906
907 /**
908 * block_bio_remap - map request for a logical device to the raw device
909 * @q: queue holding the operation
910 * @bio: revised operation
911 * @dev: device for the operation
912 * @from: original sector for the operation
913 *
914 * An operation for a logical device has been mapped to the
915 * raw block device.
916 */
917 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
918 LTTNG_TRACEPOINT_EVENT(block_bio_remap,
919 #else
920 LTTNG_TRACEPOINT_EVENT(block_remap,
921 #endif
922
923 TP_PROTO(struct request_queue *q, struct bio *bio, dev_t dev,
924 sector_t from),
925
926 TP_ARGS(q, bio, dev, from),
927
928 TP_STRUCT__entry(
929 __field( dev_t, dev )
930 __field( sector_t, sector )
931 __field( unsigned int, nr_sector )
932 __field( dev_t, old_dev )
933 __field( sector_t, old_sector )
934 __field( unsigned int, rwbs )
935 ),
936
937 TP_fast_assign(
938 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0))
939 tp_assign(dev, bio->bi_bdev->bd_dev)
940 tp_assign(sector, bio->bi_iter.bi_sector)
941 tp_assign(nr_sector, bio_sectors(bio))
942 tp_assign(old_dev, dev)
943 tp_assign(old_sector, from)
944 blk_fill_rwbs(rwbs, bio->bi_rw, bio->bi_iter.bi_size)
945 #else /* #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0)) */
946 tp_assign(dev, bio->bi_bdev->bd_dev)
947 tp_assign(sector, bio->bi_sector)
948 tp_assign(nr_sector, bio->bi_size >> 9)
949 tp_assign(old_dev, dev)
950 tp_assign(old_sector, from)
951 blk_fill_rwbs(rwbs, bio->bi_rw, bio->bi_size)
952 #endif /* #else #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0)) */
953 ),
954
955 TP_printk("%d,%d %s %llu + %u <- (%d,%d) %llu",
956 MAJOR(__entry->dev), MINOR(__entry->dev),
957 __print_rwbs_flags(__entry->rwbs),
958 (unsigned long long)__entry->sector,
959 __entry->nr_sector,
960 MAJOR(__entry->old_dev), MINOR(__entry->old_dev),
961 (unsigned long long)__entry->old_sector)
962 )
963
964 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,32))
965 /**
966 * block_rq_remap - map request for a block operation request
967 * @q: queue holding the operation
968 * @rq: block IO operation request
969 * @dev: device for the operation
970 * @from: original sector for the operation
971 *
972 * The block operation request @rq in @q has been remapped. The block
973 * operation request @rq holds the current information and @from hold
974 * the original sector.
975 */
976 LTTNG_TRACEPOINT_EVENT(block_rq_remap,
977
978 TP_PROTO(struct request_queue *q, struct request *rq, dev_t dev,
979 sector_t from),
980
981 TP_ARGS(q, rq, dev, from),
982
983 TP_STRUCT__entry(
984 __field( dev_t, dev )
985 __field( sector_t, sector )
986 __field( unsigned int, nr_sector )
987 __field( dev_t, old_dev )
988 __field( sector_t, old_sector )
989 __field( unsigned int, rwbs )
990 ),
991
992 TP_fast_assign(
993 tp_assign(dev, disk_devt(rq->rq_disk))
994 tp_assign(sector, blk_rq_pos(rq))
995 tp_assign(nr_sector, blk_rq_sectors(rq))
996 tp_assign(old_dev, dev)
997 tp_assign(old_sector, from)
998 blk_fill_rwbs(rwbs, rq->cmd_flags, blk_rq_bytes(rq))
999 ),
1000
1001 TP_printk("%d,%d %s %llu + %u <- (%d,%d) %llu",
1002 MAJOR(__entry->dev), MINOR(__entry->dev),
1003 __print_rwbs_flags(__entry->rwbs),
1004 (unsigned long long)__entry->sector,
1005 __entry->nr_sector,
1006 MAJOR(__entry->old_dev), MINOR(__entry->old_dev),
1007 (unsigned long long)__entry->old_sector)
1008 )
1009 #endif
1010
1011 #undef __print_rwbs_flags
1012 #undef blk_fill_rwbs
1013
1014 #endif /* LTTNG_TRACE_BLOCK_H */
1015
1016 /* This part must be outside protection */
1017 #include "../../../probes/define_trace.h"
1018
This page took 0.080349 seconds and 4 git commands to generate.