1 /* SPDX-License-Identifier: GPL-2.0-only */
3 #define TRACE_SYSTEM block
5 #if !defined(LTTNG_TRACE_BLOCK_H) || defined(TRACE_HEADER_MULTI_READ)
6 #define LTTNG_TRACE_BLOCK_H
8 #include <probes/lttng-tracepoint-event.h>
9 #include <linux/blktrace_api.h>
10 #include <linux/blkdev.h>
11 #include <linux/trace_seq.h>
13 #include <scsi/scsi_request.h>
15 #ifndef _TRACE_BLOCK_DEF_
16 #define _TRACE_BLOCK_DEF_
19 RWBS_FLAG_WRITE
= (1 << 0),
20 RWBS_FLAG_DISCARD
= (1 << 1),
21 RWBS_FLAG_READ
= (1 << 2),
22 RWBS_FLAG_RAHEAD
= (1 << 3),
23 RWBS_FLAG_BARRIER
= (1 << 4),
24 RWBS_FLAG_SYNC
= (1 << 5),
25 RWBS_FLAG_META
= (1 << 6),
26 RWBS_FLAG_SECURE
= (1 << 7),
27 RWBS_FLAG_FLUSH
= (1 << 8),
28 RWBS_FLAG_FUA
= (1 << 9),
29 RWBS_FLAG_PREFLUSH
= (1 << 10),
32 #endif /* _TRACE_BLOCK_DEF_ */
34 LTTNG_TRACEPOINT_ENUM(block_rq_type
,
36 ctf_enum_value("RWBS_FLAG_WRITE", RWBS_FLAG_WRITE
)
37 ctf_enum_value("RWBS_FLAG_DISCARD", RWBS_FLAG_DISCARD
)
38 ctf_enum_value("RWBS_FLAG_READ", RWBS_FLAG_READ
)
39 ctf_enum_value("RWBS_FLAG_RAHEAD", RWBS_FLAG_RAHEAD
)
40 ctf_enum_value("RWBS_FLAG_BARRIER", RWBS_FLAG_BARRIER
)
41 ctf_enum_value("RWBS_FLAG_SYNC", RWBS_FLAG_SYNC
)
42 ctf_enum_value("RWBS_FLAG_META", RWBS_FLAG_META
)
43 ctf_enum_value("RWBS_FLAG_SECURE", RWBS_FLAG_SECURE
)
44 ctf_enum_value("RWBS_FLAG_FLUSH", RWBS_FLAG_FLUSH
)
45 ctf_enum_value("RWBS_FLAG_FUA", RWBS_FLAG_FUA
)
46 ctf_enum_value("RWBS_FLAG_PREFLUSH", RWBS_FLAG_PREFLUSH
)
50 #define lttng_req_op(rq) req_op(rq)
51 #define lttng_req_rw(rq) ((rq)->cmd_flags)
52 #define lttng_bio_op(bio) bio_op(bio)
53 #define lttng_bio_rw(bio) ((bio)->bi_opf)
55 #define blk_rwbs_ctf_integer(type, rwbs, op, rw, bytes) \
56 ctf_enum(block_rq_type, type, rwbs, \
57 (((op) == REQ_OP_WRITE || (op) == REQ_OP_WRITE_SAME) ? RWBS_FLAG_WRITE : \
58 ( (op) == REQ_OP_DISCARD ? RWBS_FLAG_DISCARD : \
59 ( (op) == REQ_OP_SECURE_ERASE ? (RWBS_FLAG_DISCARD | RWBS_FLAG_SECURE) : \
60 ( (op) == REQ_OP_FLUSH ? RWBS_FLAG_FLUSH : \
61 ( (op) == REQ_OP_READ ? RWBS_FLAG_READ : \
63 | ((rw) & REQ_RAHEAD ? RWBS_FLAG_RAHEAD : 0) \
64 | ((rw) & REQ_SYNC ? RWBS_FLAG_SYNC : 0) \
65 | ((rw) & REQ_META ? RWBS_FLAG_META : 0) \
66 | ((rw) & REQ_PREFLUSH ? RWBS_FLAG_PREFLUSH : 0) \
67 | ((rw) & REQ_FUA ? RWBS_FLAG_FUA : 0))
69 LTTNG_TRACEPOINT_EVENT_CLASS(block_buffer
,
71 TP_PROTO(struct buffer_head
*bh
),
76 ctf_integer(dev_t
, dev
, bh
->b_bdev
->bd_dev
)
77 ctf_integer(sector_t
, sector
, bh
->b_blocknr
)
78 ctf_integer(size_t, size
, bh
->b_size
)
83 * block_touch_buffer - mark a buffer accessed
84 * @bh: buffer_head being touched
86 * Called from touch_buffer().
88 LTTNG_TRACEPOINT_EVENT_INSTANCE(block_buffer
, block_touch_buffer
,
90 TP_PROTO(struct buffer_head
*bh
),
96 * block_dirty_buffer - mark a buffer dirty
97 * @bh: buffer_head being dirtied
99 * Called from mark_buffer_dirty().
101 LTTNG_TRACEPOINT_EVENT_INSTANCE(block_buffer
, block_dirty_buffer
,
103 TP_PROTO(struct buffer_head
*bh
),
109 * block_rq_requeue - place block IO request back on a queue
110 * @q: queue holding operation
111 * @rq: block IO operation request
113 * The block operation request @rq is being placed back into queue
114 * @q. For some reason the request was not completed and needs to be
115 * put back in the queue.
117 LTTNG_TRACEPOINT_EVENT(block_rq_requeue
,
119 TP_PROTO(struct request_queue
*q
, struct request
*rq
),
124 ctf_integer(dev_t
, dev
,
125 rq
->rq_disk
? disk_devt(rq
->rq_disk
) : 0)
126 ctf_integer(sector_t
, sector
, blk_rq_trace_sector(rq
))
127 ctf_integer(unsigned int, nr_sector
, blk_rq_trace_nr_sectors(rq
))
128 blk_rwbs_ctf_integer(unsigned int, rwbs
,
129 lttng_req_op(rq
), lttng_req_rw(rq
), blk_rq_bytes(rq
))
134 * block_rq_complete - block IO operation completed by device driver
135 * @q: queue containing the block operation request
136 * @rq: block operations request
137 * @nr_bytes: number of completed bytes
139 * The block_rq_complete tracepoint event indicates that some portion
140 * of operation request has been completed by the device driver. If
141 * the @rq->bio is %NULL, then there is absolutely no additional work to
142 * do for the request. If @rq->bio is non-NULL then there is
143 * additional work required to complete the request.
145 LTTNG_TRACEPOINT_EVENT(block_rq_complete
,
147 TP_PROTO(struct request
*rq
, int error
, unsigned int nr_bytes
),
149 TP_ARGS(rq
, error
, nr_bytes
),
152 ctf_integer(dev_t
, dev
,
153 rq
->rq_disk
? disk_devt(rq
->rq_disk
) : 0)
154 ctf_integer(sector_t
, sector
, blk_rq_pos(rq
))
155 ctf_integer(unsigned int, nr_sector
, nr_bytes
>> 9)
156 ctf_integer(int, error
, error
)
157 blk_rwbs_ctf_integer(unsigned int, rwbs
,
158 lttng_req_op(rq
), lttng_req_rw(rq
), nr_bytes
)
162 LTTNG_TRACEPOINT_EVENT_CLASS(block_rq
,
164 TP_PROTO(struct request_queue
*q
, struct request
*rq
),
169 ctf_integer(dev_t
, dev
,
170 rq
->rq_disk
? disk_devt(rq
->rq_disk
) : 0)
171 ctf_integer(sector_t
, sector
, blk_rq_trace_sector(rq
))
172 ctf_integer(unsigned int, nr_sector
, blk_rq_trace_nr_sectors(rq
))
173 ctf_integer(unsigned int, bytes
, blk_rq_bytes(rq
))
174 ctf_integer(pid_t
, tid
, current
->pid
)
175 blk_rwbs_ctf_integer(unsigned int, rwbs
,
176 lttng_req_op(rq
), lttng_req_rw(rq
), blk_rq_bytes(rq
))
177 ctf_array_text(char, comm
, current
->comm
, TASK_COMM_LEN
)
182 * block_rq_insert - insert block operation request into queue
184 * @rq: block IO operation request
186 * Called immediately before block operation request @rq is inserted
187 * into queue @q. The fields in the operation request @rq struct can
188 * be examined to determine which device and sectors the pending
189 * operation would access.
191 LTTNG_TRACEPOINT_EVENT_INSTANCE(block_rq
, block_rq_insert
,
193 TP_PROTO(struct request_queue
*q
, struct request
*rq
),
199 * block_rq_issue - issue pending block IO request operation to device driver
200 * @q: queue holding operation
201 * @rq: block IO operation operation request
203 * Called when block operation request @rq from queue @q is sent to a
204 * device driver for processing.
206 LTTNG_TRACEPOINT_EVENT_INSTANCE(block_rq
, block_rq_issue
,
208 TP_PROTO(struct request_queue
*q
, struct request
*rq
),
214 * block_bio_bounce - used bounce buffer when processing block operation
215 * @q: queue holding the block operation
216 * @bio: block operation
218 * A bounce buffer was used to handle the block operation @bio in @q.
219 * This occurs when hardware limitations prevent a direct transfer of
220 * data between the @bio data memory area and the IO device. Use of a
221 * bounce buffer requires extra copying of data and decreases
224 LTTNG_TRACEPOINT_EVENT(block_bio_bounce
,
226 TP_PROTO(struct request_queue
*q
, struct bio
*bio
),
231 ctf_integer(dev_t
, dev
, bio_dev(bio
))
232 ctf_integer(sector_t
, sector
, bio
->bi_iter
.bi_sector
)
233 ctf_integer(unsigned int, nr_sector
, bio_sectors(bio
))
234 blk_rwbs_ctf_integer(unsigned int, rwbs
,
235 lttng_bio_op(bio
), lttng_bio_rw(bio
),
236 bio
->bi_iter
.bi_size
)
237 ctf_integer(pid_t
, tid
, current
->pid
)
238 ctf_array_text(char, comm
, current
->comm
, TASK_COMM_LEN
)
243 * block_bio_complete - completed all work on the block operation
244 * @q: queue holding the block operation
245 * @bio: block operation completed
246 * @error: io error value
248 * This tracepoint indicates there is no further work to do on this
249 * block IO operation @bio.
251 LTTNG_TRACEPOINT_EVENT(block_bio_complete
,
253 TP_PROTO(struct request_queue
*q
, struct bio
*bio
, int error
),
255 TP_ARGS(q
, bio
, error
),
258 ctf_integer(dev_t
, dev
, bio_dev(bio
))
259 ctf_integer(sector_t
, sector
, bio
->bi_iter
.bi_sector
)
260 ctf_integer(unsigned int, nr_sector
, bio_sectors(bio
))
261 ctf_integer(int, error
, error
)
262 blk_rwbs_ctf_integer(unsigned int, rwbs
,
263 lttng_bio_op(bio
), lttng_bio_rw(bio
),
264 bio
->bi_iter
.bi_size
)
268 LTTNG_TRACEPOINT_EVENT_CLASS(block_bio_merge
,
270 TP_PROTO(struct request_queue
*q
, struct request
*rq
, struct bio
*bio
),
275 ctf_integer(dev_t
, dev
, bio_dev(bio
))
276 ctf_integer(sector_t
, sector
, bio
->bi_iter
.bi_sector
)
277 ctf_integer(unsigned int, nr_sector
, bio_sectors(bio
))
278 blk_rwbs_ctf_integer(unsigned int, rwbs
,
279 lttng_bio_op(bio
), lttng_bio_rw(bio
),
280 bio
->bi_iter
.bi_size
)
281 ctf_integer(pid_t
, tid
, current
->pid
)
282 ctf_array_text(char, comm
, current
->comm
, TASK_COMM_LEN
)
287 * block_bio_backmerge - merging block operation to the end of an existing operation
288 * @q: queue holding operation
289 * @bio: new block operation to merge
291 * Merging block request @bio to the end of an existing block request
294 LTTNG_TRACEPOINT_EVENT_INSTANCE(block_bio_merge
, block_bio_backmerge
,
296 TP_PROTO(struct request_queue
*q
, struct request
*rq
, struct bio
*bio
),
302 * block_bio_frontmerge - merging block operation to the beginning of an existing operation
303 * @q: queue holding operation
304 * @bio: new block operation to merge
306 * Merging block IO operation @bio to the beginning of an existing block
307 * operation in queue @q.
309 LTTNG_TRACEPOINT_EVENT_INSTANCE(block_bio_merge
, block_bio_frontmerge
,
311 TP_PROTO(struct request_queue
*q
, struct request
*rq
, struct bio
*bio
),
317 * block_bio_queue - putting new block IO operation in queue
318 * @q: queue holding operation
319 * @bio: new block operation
321 * About to place the block IO operation @bio into queue @q.
323 LTTNG_TRACEPOINT_EVENT(block_bio_queue
,
325 TP_PROTO(struct request_queue
*q
, struct bio
*bio
),
330 ctf_integer(dev_t
, dev
, bio_dev(bio
))
331 ctf_integer(sector_t
, sector
, bio
->bi_iter
.bi_sector
)
332 ctf_integer(unsigned int, nr_sector
, bio_sectors(bio
))
333 blk_rwbs_ctf_integer(unsigned int, rwbs
,
334 lttng_bio_op(bio
), lttng_bio_rw(bio
),
335 bio
->bi_iter
.bi_size
)
336 ctf_integer(pid_t
, tid
, current
->pid
)
337 ctf_array_text(char, comm
, current
->comm
, TASK_COMM_LEN
)
341 LTTNG_TRACEPOINT_EVENT_CLASS(block_get_rq
,
343 TP_PROTO(struct request_queue
*q
, struct bio
*bio
, int rw
),
348 ctf_integer(dev_t
, dev
, bio
? bio_dev(bio
) : 0)
349 ctf_integer(sector_t
, sector
, bio
? bio
->bi_iter
.bi_sector
: 0)
350 ctf_integer(unsigned int, nr_sector
,
351 bio
? bio_sectors(bio
) : 0)
352 blk_rwbs_ctf_integer(unsigned int, rwbs
,
353 bio
? lttng_bio_op(bio
) : 0,
354 bio
? lttng_bio_rw(bio
) : 0,
355 bio
? bio
->bi_iter
.bi_size
: 0)
356 ctf_integer(pid_t
, tid
, current
->pid
)
357 ctf_array_text(char, comm
, current
->comm
, TASK_COMM_LEN
)
362 * block_getrq - get a free request entry in queue for block IO operations
363 * @q: queue for operations
364 * @bio: pending block IO operation (can be %NULL)
365 * @rw: low bit indicates a read (%0) or a write (%1)
367 * A request struct for queue @q has been allocated to handle the
368 * block IO operation @bio.
370 LTTNG_TRACEPOINT_EVENT_INSTANCE(block_get_rq
, block_getrq
,
372 TP_PROTO(struct request_queue
*q
, struct bio
*bio
, int rw
),
378 * block_sleeprq - waiting to get a free request entry in queue for block IO operation
379 * @q: queue for operation
380 * @bio: pending block IO operation (can be %NULL)
381 * @rw: low bit indicates a read (%0) or a write (%1)
383 * In the case where a request struct cannot be provided for queue @q
384 * the process needs to wait for an request struct to become
385 * available. This tracepoint event is generated each time the
386 * process goes to sleep waiting for request struct become available.
388 LTTNG_TRACEPOINT_EVENT_INSTANCE(block_get_rq
, block_sleeprq
,
390 TP_PROTO(struct request_queue
*q
, struct bio
*bio
, int rw
),
396 * block_plug - keep operations requests in request queue
397 * @q: request queue to plug
399 * Plug the request queue @q. Do not allow block operation requests
400 * to be sent to the device driver. Instead, accumulate requests in
401 * the queue to improve throughput performance of the block device.
403 LTTNG_TRACEPOINT_EVENT(block_plug
,
405 TP_PROTO(struct request_queue
*q
),
410 ctf_integer(pid_t
, tid
, current
->pid
)
411 ctf_array_text(char, comm
, current
->comm
, TASK_COMM_LEN
)
415 LTTNG_TRACEPOINT_EVENT_CLASS(block_unplug
,
417 TP_PROTO(struct request_queue
*q
, unsigned int depth
, bool explicit),
419 TP_ARGS(q
, depth
, explicit),
422 ctf_integer(int, nr_rq
, depth
)
423 ctf_integer(pid_t
, tid
, current
->pid
)
424 ctf_array_text(char, comm
, current
->comm
, TASK_COMM_LEN
)
429 * block_unplug - release of operations requests in request queue
430 * @q: request queue to unplug
431 * @depth: number of requests just added to the queue
432 * @explicit: whether this was an explicit unplug, or one from schedule()
434 * Unplug request queue @q because device driver is scheduled to work
435 * on elements in the request queue.
437 LTTNG_TRACEPOINT_EVENT_INSTANCE(block_unplug
, block_unplug
,
439 TP_PROTO(struct request_queue
*q
, unsigned int depth
, bool explicit),
441 TP_ARGS(q
, depth
, explicit)
445 * block_split - split a single bio struct into two bio structs
446 * @q: queue containing the bio
447 * @bio: block operation being split
448 * @new_sector: The starting sector for the new bio
450 * The bio request @bio in request queue @q needs to be split into two
451 * bio requests. The newly created @bio request starts at
452 * @new_sector. This split may be required due to hardware limitation
453 * such as operation crossing device boundaries in a RAID system.
455 LTTNG_TRACEPOINT_EVENT(block_split
,
457 TP_PROTO(struct request_queue
*q
, struct bio
*bio
,
458 unsigned int new_sector
),
460 TP_ARGS(q
, bio
, new_sector
),
463 ctf_integer(dev_t
, dev
, bio_dev(bio
))
464 ctf_integer(sector_t
, sector
, bio
->bi_iter
.bi_sector
)
465 blk_rwbs_ctf_integer(unsigned int, rwbs
,
466 lttng_bio_op(bio
), lttng_bio_rw(bio
),
467 bio
->bi_iter
.bi_size
)
468 ctf_integer(sector_t
, new_sector
, new_sector
)
469 ctf_integer(pid_t
, tid
, current
->pid
)
470 ctf_array_text(char, comm
, current
->comm
, TASK_COMM_LEN
)
475 * block_bio_remap - map request for a logical device to the raw device
476 * @q: queue holding the operation
477 * @bio: revised operation
478 * @dev: device for the operation
479 * @from: original sector for the operation
481 * An operation for a logical device has been mapped to the
484 LTTNG_TRACEPOINT_EVENT(block_bio_remap
,
486 TP_PROTO(struct request_queue
*q
, struct bio
*bio
, dev_t dev
,
489 TP_ARGS(q
, bio
, dev
, from
),
492 ctf_integer(dev_t
, dev
, bio_dev(bio
))
493 ctf_integer(sector_t
, sector
, bio
->bi_iter
.bi_sector
)
494 ctf_integer(unsigned int, nr_sector
, bio_sectors(bio
))
495 blk_rwbs_ctf_integer(unsigned int, rwbs
,
496 lttng_bio_op(bio
), lttng_bio_rw(bio
),
497 bio
->bi_iter
.bi_size
)
498 ctf_integer(dev_t
, old_dev
, dev
)
499 ctf_integer(sector_t
, old_sector
, from
)
504 * block_rq_remap - map request for a block operation request
505 * @q: queue holding the operation
506 * @rq: block IO operation request
507 * @dev: device for the operation
508 * @from: original sector for the operation
510 * The block operation request @rq in @q has been remapped. The block
511 * operation request @rq holds the current information and @from hold
512 * the original sector.
514 LTTNG_TRACEPOINT_EVENT(block_rq_remap
,
516 TP_PROTO(struct request_queue
*q
, struct request
*rq
, dev_t dev
,
519 TP_ARGS(q
, rq
, dev
, from
),
522 ctf_integer(dev_t
, dev
, disk_devt(rq
->rq_disk
))
523 ctf_integer(sector_t
, sector
, blk_rq_pos(rq
))
524 ctf_integer(unsigned int, nr_sector
, blk_rq_sectors(rq
))
525 ctf_integer(dev_t
, old_dev
, dev
)
526 ctf_integer(sector_t
, old_sector
, from
)
527 blk_rwbs_ctf_integer(unsigned int, rwbs
,
528 lttng_req_op(rq
), lttng_req_rw(rq
), blk_rq_bytes(rq
))
532 #undef __print_rwbs_flags
535 #endif /* LTTNG_TRACE_BLOCK_H */
537 /* This part must be outside protection */
538 #include <probes/define_trace.h>
This page took 0.040373 seconds and 4 git commands to generate.