Skip to content

Commit e8a676d

Browse files
Christoph Hellwigaxboe
authored andcommitted
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. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Damien Le Moal <damien.lemoal@wdc.com> Reviewed-by: Hannes Reinecke <hare@suse.de> Reviewed-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com> Acked-by: Tejun Heo <tj@kernel.org> Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent b81b8f4 commit e8a676d

6 files changed

Lines changed: 48 additions & 161 deletions

File tree

‎block/blk-core.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -907,7 +907,7 @@ static noinline_for_stack bool submit_bio_checks(struct bio *bio)
907907
blkcg_bio_issue_init(bio);
908908

909909
if (!bio_flagged(bio, BIO_TRACE_COMPLETION)) {
910-
trace_block_bio_queue(q, bio);
910+
trace_block_bio_queue(bio);
911911
/* Now that enqueuing has been traced, we need to trace
912912
* completion as well.
913913
*/

‎block/blk-merge.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -922,7 +922,7 @@ static enum bio_merge_status bio_attempt_back_merge(struct request *req,
922922
if (!ll_back_merge_fn(req, bio, nr_segs))
923923
return BIO_MERGE_FAILED;
924924

925-
trace_block_bio_backmerge(req->q, req, bio);
925+
trace_block_bio_backmerge(bio);
926926
rq_qos_merge(req->q, req, bio);
927927

928928
if ((req->cmd_flags & REQ_FAILFAST_MASK) != ff)
@@ -946,7 +946,7 @@ static enum bio_merge_status bio_attempt_front_merge(struct request *req,
946946
if (!ll_front_merge_fn(req, bio, nr_segs))
947947
return BIO_MERGE_FAILED;
948948

949-
trace_block_bio_frontmerge(req->q, req, bio);
949+
trace_block_bio_frontmerge(bio);
950950
rq_qos_merge(req->q, req, bio);
951951

952952
if ((req->cmd_flags & REQ_FAILFAST_MASK) != ff)

‎block/blk-mq.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2184,7 +2184,7 @@ blk_qc_t blk_mq_submit_bio(struct bio *bio)
21842184
goto queue_exit;
21852185
}
21862186

2187-
trace_block_getrq(q, bio, bio->bi_opf);
2187+
trace_block_getrq(bio);
21882188

21892189
rq_qos_track(q, rq, bio);
21902190

‎block/bounce.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ static void __blk_queue_bounce(struct request_queue *q, struct bio **bio_orig,
340340
}
341341
}
342342

343-
trace_block_bio_bounce(q, *bio_orig);
343+
trace_block_bio_bounce(*bio_orig);
344344

345345
bio->bi_flags |= (1 << BIO_BOUNCED);
346346

‎include/trace/events/block.h‎

Lines changed: 33 additions & 125 deletions
Original file line numberDiff line numberDiff line change
@@ -226,45 +226,6 @@ DEFINE_EVENT(block_rq, block_rq_merge,
226226
TP_ARGS(q, rq)
227227
);
228228

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-
*/
240-
TRACE_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-
268229
/**
269230
* block_bio_complete - completed all work on the block operation
270231
* @q: queue holding the block operation
@@ -301,11 +262,11 @@ TRACE_EVENT(block_bio_complete,
301262
__entry->nr_sector, __entry->error)
302263
);
303264

304-
DECLARE_EVENT_CLASS(block_bio_merge,
265+
DECLARE_EVENT_CLASS(block_bio,
305266

306-
TP_PROTO(struct request_queue *q, struct request *rq, struct bio *bio),
267+
TP_PROTO(struct bio *bio),
307268

308-
TP_ARGS(q, rq, bio),
269+
TP_ARGS(bio),
309270

310271
TP_STRUCT__entry(
311272
__field( dev_t, dev )
@@ -329,116 +290,63 @@ DECLARE_EVENT_CLASS(block_bio_merge,
329290
__entry->nr_sector, __entry->comm)
330291
);
331292

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+
*/
303+
DEFINE_EVENT(block_bio, block_bio_bounce,
304+
TP_PROTO(struct bio *bio),
305+
TP_ARGS(bio)
306+
);
307+
332308
/**
333309
* 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
336310
* @bio: new block operation to merge
337311
*
338-
* Merging block request @bio to the end of an existing block request
339-
* in queue @q.
312+
* Merging block request @bio to the end of an existing block request.
340313
*/
341-
DEFINE_EVENT(block_bio_merge, block_bio_backmerge,
342-
343-
TP_PROTO(struct request_queue *q, struct request *rq, struct bio *bio),
344-
345-
TP_ARGS(q, rq, bio)
314+
DEFINE_EVENT(block_bio, block_bio_backmerge,
315+
TP_PROTO(struct bio *bio),
316+
TP_ARGS(bio)
346317
);
347318

348319
/**
349320
* 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
352321
* @bio: new block operation to merge
353322
*
354-
* Merging block IO operation @bio to the beginning of an existing block
355-
* operation in queue @q.
323+
* Merging block IO operation @bio to the beginning of an existing block request.
356324
*/
357-
DEFINE_EVENT(block_bio_merge, block_bio_frontmerge,
358-
359-
TP_PROTO(struct request_queue *q, struct request *rq, struct bio *bio),
360-
361-
TP_ARGS(q, rq, bio)
325+
DEFINE_EVENT(block_bio, block_bio_frontmerge,
326+
TP_PROTO(struct bio *bio),
327+
TP_ARGS(bio)
362328
);
363329

364330
/**
365331
* block_bio_queue - putting new block IO operation in queue
366-
* @q: queue holding operation
367332
* @bio: new block operation
368333
*
369334
* About to place the block IO operation @bio into queue @q.
370335
*/
371-
TRACE_EVENT(block_bio_queue,
372-
373-
TP_PROTO(struct request_queue *q, struct bio *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-
399-
DECLARE_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)
336+
DEFINE_EVENT(block_bio, block_bio_queue,
337+
TP_PROTO(struct bio *bio),
338+
TP_ARGS(bio)
426339
);
427340

428341
/**
429342
* block_getrq - get a free request entry in queue for block IO operations
430-
* @q: queue for operations
431343
* @bio: pending block IO operation (can be %NULL)
432-
* @rw: low bit indicates a read (%0) or a write (%1)
433344
*
434-
* A request struct for queue @q has been allocated to handle the
435-
* block IO operation @bio.
345+
* A request struct has been allocated to handle the block IO operation @bio.
436346
*/
437-
DEFINE_EVENT(block_get_rq, block_getrq,
438-
439-
TP_PROTO(struct request_queue *q, struct bio *bio, int rw),
440-
441-
TP_ARGS(q, bio, rw)
347+
DEFINE_EVENT(block_bio, block_getrq,
348+
TP_PROTO(struct bio *bio),
349+
TP_ARGS(bio)
442350
);
443351

444352
/**

‎kernel/trace/blktrace.c‎

Lines changed: 10 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -906,10 +906,9 @@ static void blk_add_trace_bio(struct request_queue *q, struct bio *bio,
906906
rcu_read_unlock();
907907
}
908908

909-
static void blk_add_trace_bio_bounce(void *ignore,
910-
struct request_queue *q, struct bio *bio)
909+
static void blk_add_trace_bio_bounce(void *ignore, struct bio *bio)
911910
{
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);
913912
}
914913

915914
static void blk_add_trace_bio_complete(void *ignore,
@@ -919,44 +918,24 @@ static void blk_add_trace_bio_complete(void *ignore,
919918
blk_status_to_errno(bio->bi_status));
920919
}
921920

922-
static void blk_add_trace_bio_backmerge(void *ignore,
923-
struct request_queue *q,
924-
struct request *rq,
925-
struct bio *bio)
921+
static void blk_add_trace_bio_backmerge(void *ignore, struct bio *bio)
926922
{
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);
928924
}
929925

930-
static void blk_add_trace_bio_frontmerge(void *ignore,
931-
struct request_queue *q,
932-
struct request *rq,
933-
struct bio *bio)
926+
static void blk_add_trace_bio_frontmerge(void *ignore, struct bio *bio)
934927
{
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);
936929
}
937930

938-
static void blk_add_trace_bio_queue(void *ignore,
939-
struct request_queue *q, struct bio *bio)
931+
static void blk_add_trace_bio_queue(void *ignore, struct bio *bio)
940932
{
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);
942934
}
943935

944-
static void blk_add_trace_getrq(void *ignore,
945-
struct request_queue *q,
946-
struct bio *bio, int rw)
936+
static void blk_add_trace_getrq(void *ignore, struct bio *bio)
947937
{
948-
if (bio)
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-
}
938+
blk_add_trace_bio(bio->bi_disk->queue, bio, BLK_TA_GETRQ, 0);
960939
}
961940

962941
static void blk_add_trace_plug(void *ignore, struct request_queue *q)

0 commit comments

Comments
 (0)