History

block: simplify and extend the block_bio_merge tracepoint class

The block_bio_merge tracepoint class can be reused for most bio-based tracepoints. For that it just needs to lose the superfluous q and rq parameters.

Christoph Hellwig committed 5 years ago

Commit e8a676d1 parent b81b8f46 files · +48 −161Browse files

Unified · Split

6 files
  1. block/blk-core.c +1 −1
  2. block/blk-merge.c +2 −2
  3. block/blk-mq.c +1 −1
  4. block/bounce.c +1 −1
  5. include/trace/events/block.h +33 −125
  6. kernel/trace/blktrace.c +10 −31
block/blk-core.c+1−1
@@ -907,7 +907,7 @@ static noinline_for_stack bool submit_bio_checks(struct bio *bio) · 906 unmodified lines
907 blkcg_bio_issue_init(bio);907 blkcg_bio_issue_init(bio);
908 908
909 if (!bio_flagged(bio, BIO_TRACE_COMPLETION)) {909 if (!bio_flagged(bio, BIO_TRACE_COMPLETION)) {
910 trace_block_bio_queue(q, bio);910 trace_block_bio_queue(bio);
911 /* Now that enqueuing has been traced, we need to trace911 /* Now that enqueuing has been traced, we need to trace
912 * completion as well.912 * completion as well.
913 */913 */
block/blk-merge.c+2−2
@@ -922,7 +922,7 @@ static enum bio_merge_status bio_attempt_back_merge(struct request *req, · 921 unmodified lines
922 if (!ll_back_merge_fn(req, bio, nr_segs))922 if (!ll_back_merge_fn(req, bio, nr_segs))
923 return BIO_MERGE_FAILED;923 return BIO_MERGE_FAILED;
924 924
925 trace_block_bio_backmerge(req->q, req, bio);925 trace_block_bio_backmerge(bio);
926 rq_qos_merge(req->q, req, bio);926 rq_qos_merge(req->q, req, bio);
927 927
928 if ((req->cmd_flags & REQ_FAILFAST_MASK) != ff)928 if ((req->cmd_flags & REQ_FAILFAST_MASK) != ff)
@@ -946,7 +946,7 @@ static enum bio_merge_status bio_attempt_front_merge(struct request *req, · 17 unmodified lines
946 if (!ll_front_merge_fn(req, bio, nr_segs))946 if (!ll_front_merge_fn(req, bio, nr_segs))
947 return BIO_MERGE_FAILED;947 return BIO_MERGE_FAILED;
948 948
949 trace_block_bio_frontmerge(req->q, req, bio);949 trace_block_bio_frontmerge(bio);
950 rq_qos_merge(req->q, req, bio);950 rq_qos_merge(req->q, req, bio);
951 951
952 if ((req->cmd_flags & REQ_FAILFAST_MASK) != ff)952 if ((req->cmd_flags & REQ_FAILFAST_MASK) != ff)
block/blk-mq.c+1−1
@@ -2184,7 +2184,7 @@ blk_qc_t blk_mq_submit_bio(struct bio *bio) · 2183 unmodified lines
2184 goto queue_exit;2184 goto queue_exit;
2185 }2185 }
2186 2186
2187 trace_block_getrq(q, bio, bio->bi_opf);2187 trace_block_getrq(bio);
2188 2188
2189 rq_qos_track(q, rq, bio);2189 rq_qos_track(q, rq, bio);
2190 2190
block/bounce.c+1−1
@@ -340,7 +340,7 @@ static void __blk_queue_bounce(struct request_queue *q, struct bio **bio_orig, · 339 unmodified lines
340 }340 }
341 }341 }
342 342
343 trace_block_bio_bounce(q, *bio_orig);343 trace_block_bio_bounce(*bio_orig);
344 344
345 bio->bi_flags |= (1 << BIO_BOUNCED);345 bio->bi_flags |= (1 << BIO_BOUNCED);
346 346
include/trace/events/block.h+33−125
@@ -226,45 +226,6 @@ DEFINE_EVENT(block_rq, block_rq_merge, · 225 unmodified lines
226 TP_ARGS(q, rq)226 TP_ARGS(q, rq)
227);227);
228 228
229/**
230 * block_bio_bounce - used bounce buffer when processing block operation
231 * @q: queue holding the block operation
232 * @bio: block operation
233 *
234 * A bounce buffer was used to handle the block operation @bio in @q.
235 * This occurs when hardware limitations prevent a direct transfer of
236 * data between the @bio data memory area and the IO device. Use of a
237 * bounce buffer requires extra copying of data and decreases
238 * performance.
239 */
240TRACE_EVENT(block_bio_bounce,
241
242 TP_PROTO(struct request_queue *q, struct bio *bio),
243
244 TP_ARGS(q, bio),
245
246 TP_STRUCT__entry(
247 __field( dev_t, dev )
248 __field( sector_t, sector )
249 __field( unsigned int, nr_sector )
250 __array( char, rwbs, RWBS_LEN )
251 __array( char, comm, TASK_COMM_LEN )
252 ),
253
254 TP_fast_assign(
255 __entry->dev = bio_dev(bio);
256 __entry->sector = bio->bi_iter.bi_sector;
257 __entry->nr_sector = bio_sectors(bio);
258 blk_fill_rwbs(__entry->rwbs, bio->bi_opf, bio->bi_iter.bi_size);
259 memcpy(__entry->comm, current->comm, TASK_COMM_LEN);
260 ),
261
262 TP_printk("%d,%d %s %llu + %u [%s]",
263 MAJOR(__entry->dev), MINOR(__entry->dev), __entry->rwbs,
264 (unsigned long long)__entry->sector,
265 __entry->nr_sector, __entry->comm)
266);
267
268/**229/**
269 * block_bio_complete - completed all work on the block operation230 * block_bio_complete - completed all work on the block operation
270 * @q: queue holding the block operation231 * @q: queue holding the block operation
@@ -301,11 +262,11 @@ TRACE_EVENT(block_bio_complete, · 30 unmodified lines
301 __entry->nr_sector, __entry->error)262 __entry->nr_sector, __entry->error)
302);263);
303 264
304DECLARE_EVENT_CLASS(block_bio_merge,265DECLARE_EVENT_CLASS(block_bio,
305 266
306 TP_PROTO(struct request_queue *q, struct request *rq, struct bio *bio),267 TP_PROTO(struct bio *bio),
307 268
308 TP_ARGS(q, rq, bio),269 TP_ARGS(bio),
309 270
310 TP_STRUCT__entry(271 TP_STRUCT__entry(
311 __field( dev_t, dev )272 __field( dev_t, dev )
@@ -329,116 +290,63 @@ DECLARE_EVENT_CLASS(block_bio_merge, · 17 unmodified lines
329 __entry->nr_sector, __entry->comm)290 __entry->nr_sector, __entry->comm)
330);291);
331 292
293/**
294 * block_bio_bounce - used bounce buffer when processing block operation
295 * @bio: block operation
296 *
297 * A bounce buffer was used to handle the block operation @bio in @q.
298 * This occurs when hardware limitations prevent a direct transfer of
299 * data between the @bio data memory area and the IO device. Use of a
300 * bounce buffer requires extra copying of data and decreases
301 * performance.
302 */
303DEFINE_EVENT(block_bio, block_bio_bounce,
304 TP_PROTO(struct bio *bio),
305 TP_ARGS(bio)
306);
307
332/**308/**
333 * block_bio_backmerge - merging block operation to the end of an existing operation309 * block_bio_backmerge - merging block operation to the end of an existing operation
334 * @q: queue holding operation
335 * @rq: request bio is being merged into
336 * @bio: new block operation to merge310 * @bio: new block operation to merge
337 *311 *
338 * Merging block request @bio to the end of an existing block request312 * Merging block request @bio to the end of an existing block request.
339 * in queue @q.
340 */313 */
341DEFINE_EVENT(block_bio_merge, block_bio_backmerge,314DEFINE_EVENT(block_bio, block_bio_backmerge,
342 315 TP_PROTO(struct bio *bio),
343 TP_PROTO(struct request_queue *q, struct request *rq, struct bio *bio),316 TP_ARGS(bio)
344
345 TP_ARGS(q, rq, bio)
346);317);
347 318
348/**319/**
349 * block_bio_frontmerge - merging block operation to the beginning of an existing operation320 * block_bio_frontmerge - merging block operation to the beginning of an existing operation
350 * @q: queue holding operation
351 * @rq: request bio is being merged into
352 * @bio: new block operation to merge321 * @bio: new block operation to merge
353 *322 *
354 * Merging block IO operation @bio to the beginning of an existing block323 * Merging block IO operation @bio to the beginning of an existing block request.
355 * operation in queue @q.
356 */324 */
357DEFINE_EVENT(block_bio_merge, block_bio_frontmerge,325DEFINE_EVENT(block_bio, block_bio_frontmerge,
358 326 TP_PROTO(struct bio *bio),
359 TP_PROTO(struct request_queue *q, struct request *rq, struct bio *bio),327 TP_ARGS(bio)
360
361 TP_ARGS(q, rq, bio)
362);328);
363 329
364/**330/**
365 * block_bio_queue - putting new block IO operation in queue331 * block_bio_queue - putting new block IO operation in queue
366 * @q: queue holding operation
367 * @bio: new block operation332 * @bio: new block operation
368 *333 *
369 * About to place the block IO operation @bio into queue @q.334 * About to place the block IO operation @bio into queue @q.
370 */335 */
371TRACE_EVENT(block_bio_queue,336DEFINE_EVENT(block_bio, block_bio_queue,
372 337 TP_PROTO(struct bio *bio),
373 TP_PROTO(struct request_queue *q, struct bio *bio),338 TP_ARGS(bio)
374
375 TP_ARGS(q, bio),
376
377 TP_STRUCT__entry(
378 __field( dev_t, dev )
379 __field( sector_t, sector )
380 __field( unsigned int, nr_sector )
381 __array( char, rwbs, RWBS_LEN )
382 __array( char, comm, TASK_COMM_LEN )
383 ),
384
385 TP_fast_assign(
386 __entry->dev = bio_dev(bio);
387 __entry->sector = bio->bi_iter.bi_sector;
388 __entry->nr_sector = bio_sectors(bio);
389 blk_fill_rwbs(__entry->rwbs, bio->bi_opf, bio->bi_iter.bi_size);
390 memcpy(__entry->comm, current->comm, TASK_COMM_LEN);
391 ),
392
393 TP_printk("%d,%d %s %llu + %u [%s]",
394 MAJOR(__entry->dev), MINOR(__entry->dev), __entry->rwbs,
395 (unsigned long long)__entry->sector,
396 __entry->nr_sector, __entry->comm)
397);
398
399DECLARE_EVENT_CLASS(block_get_rq,
400
401 TP_PROTO(struct request_queue *q, struct bio *bio, int rw),
402
403 TP_ARGS(q, bio, rw),
404
405 TP_STRUCT__entry(
406 __field( dev_t, dev )
407 __field( sector_t, sector )
408 __field( unsigned int, nr_sector )
409 __array( char, rwbs, RWBS_LEN )
410 __array( char, comm, TASK_COMM_LEN )
411 ),
412
413 TP_fast_assign(
414 __entry->dev = bio ? bio_dev(bio) : 0;
415 __entry->sector = bio ? bio->bi_iter.bi_sector : 0;
416 __entry->nr_sector = bio ? bio_sectors(bio) : 0;
417 blk_fill_rwbs(__entry->rwbs,
418 bio ? bio->bi_opf : 0, __entry->nr_sector);
419 memcpy(__entry->comm, current->comm, TASK_COMM_LEN);
420 ),
421
422 TP_printk("%d,%d %s %llu + %u [%s]",
423 MAJOR(__entry->dev), MINOR(__entry->dev), __entry->rwbs,
424 (unsigned long long)__entry->sector,
425 __entry->nr_sector, __entry->comm)
426);339);
427 340
428/**341/**
429 * block_getrq - get a free request entry in queue for block IO operations342 * block_getrq - get a free request entry in queue for block IO operations
430 * @q: queue for operations
431 * @bio: pending block IO operation (can be %NULL)343 * @bio: pending block IO operation (can be %NULL)
432 * @rw: low bit indicates a read (%0) or a write (%1)
433 *344 *
434 * A request struct for queue @q has been allocated to handle the345 * A request struct has been allocated to handle the block IO operation @bio.
435 * block IO operation @bio.
436 */346 */
437DEFINE_EVENT(block_get_rq, block_getrq,347DEFINE_EVENT(block_bio, block_getrq,
438 348 TP_PROTO(struct bio *bio),
439 TP_PROTO(struct request_queue *q, struct bio *bio, int rw),349 TP_ARGS(bio)
440
441 TP_ARGS(q, bio, rw)
442);350);
443 351
444/**352/**
kernel/trace/blktrace.c+10−31
@@ -906,10 +906,9 @@ static void blk_add_trace_bio(struct request_queue *q, struct bio *bio, · 905 unmodified lines
906 rcu_read_unlock();906 rcu_read_unlock();
907}907}
908 908
909static void blk_add_trace_bio_bounce(void *ignore,909static void blk_add_trace_bio_bounce(void *ignore, struct bio *bio)
910 struct request_queue *q, struct bio *bio)
911{910{
912 blk_add_trace_bio(q, bio, BLK_TA_BOUNCE, 0);911 blk_add_trace_bio(bio->bi_disk->queue, bio, BLK_TA_BOUNCE, 0);
913}912}
914 913
915static void blk_add_trace_bio_complete(void *ignore,914static void blk_add_trace_bio_complete(void *ignore,
@@ -919,44 +918,24 @@ static void blk_add_trace_bio_complete(void *ignore, · 3 unmodified lines
919 blk_status_to_errno(bio->bi_status));918 blk_status_to_errno(bio->bi_status));
920}919}
921 920
922static void blk_add_trace_bio_backmerge(void *ignore,921static void blk_add_trace_bio_backmerge(void *ignore, struct bio *bio)
923 struct request_queue *q,
924 struct request *rq,
925 struct bio *bio)
926{922{
927 blk_add_trace_bio(q, bio, BLK_TA_BACKMERGE, 0);923 blk_add_trace_bio(bio->bi_disk->queue, bio, BLK_TA_BACKMERGE, 0);
928}924}
929 925
930static void blk_add_trace_bio_frontmerge(void *ignore,926static void blk_add_trace_bio_frontmerge(void *ignore, struct bio *bio)
931 struct request_queue *q,
932 struct request *rq,
933 struct bio *bio)
934{927{
935 blk_add_trace_bio(q, bio, BLK_TA_FRONTMERGE, 0);928 blk_add_trace_bio(bio->bi_disk->queue, bio, BLK_TA_FRONTMERGE, 0);
936}929}
937 930
938static void blk_add_trace_bio_queue(void *ignore,931static void blk_add_trace_bio_queue(void *ignore, struct bio *bio)
939 struct request_queue *q, struct bio *bio)
940{932{
941 blk_add_trace_bio(q, bio, BLK_TA_QUEUE, 0);933 blk_add_trace_bio(bio->bi_disk->queue, bio, BLK_TA_QUEUE, 0);
942}934}
943 935
944static void blk_add_trace_getrq(void *ignore,936static void blk_add_trace_getrq(void *ignore, struct bio *bio)
945 struct request_queue *q,
946 struct bio *bio, int rw)
947{937{
948 if (bio)938 blk_add_trace_bio(bio->bi_disk->queue, bio, BLK_TA_GETRQ, 0);
949 blk_add_trace_bio(q, bio, BLK_TA_GETRQ, 0);
950 else {
951 struct blk_trace *bt;
952
953 rcu_read_lock();
954 bt = rcu_dereference(q->blk_trace);
955 if (bt)
956 __blk_add_trace(bt, 0, 0, rw, 0, BLK_TA_GETRQ, 0, 0,
957 NULL, 0);
958 rcu_read_unlock();
959 }
960}939}
961 940
962static void blk_add_trace_plug(void *ignore, struct request_queue *q)941static void blk_add_trace_plug(void *ignore, struct request_queue *q)

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t