aboutsummaryrefslogtreecommitdiffstats
path: root/block/blktrace.c
diff options
context:
space:
mode:
Diffstat (limited to 'block/blktrace.c')
-rw-r--r--block/blktrace.c32
1 files changed, 13 insertions, 19 deletions
diff --git a/block/blktrace.c b/block/blktrace.c
index 2b4ef2b89b8d..135593c8e45b 100644
--- a/block/blktrace.c
+++ b/block/blktrace.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (C) 2006 Jens Axboe <axboe@suse.de> 2 * Copyright (C) 2006 Jens Axboe <axboe@kernel.dk>
3 * 3 *
4 * This program is free software; you can redistribute it and/or modify 4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as 5 * it under the terms of the GNU General Public License version 2 as
@@ -69,7 +69,7 @@ static u32 ddir_act[2] __read_mostly = { BLK_TC_ACT(BLK_TC_READ), BLK_TC_ACT(BLK
69/* 69/*
70 * Bio action bits of interest 70 * Bio action bits of interest
71 */ 71 */
72static u32 bio_act[5] __read_mostly = { 0, BLK_TC_ACT(BLK_TC_BARRIER), BLK_TC_ACT(BLK_TC_SYNC), 0, BLK_TC_ACT(BLK_TC_AHEAD) }; 72static u32 bio_act[9] __read_mostly = { 0, BLK_TC_ACT(BLK_TC_BARRIER), BLK_TC_ACT(BLK_TC_SYNC), 0, BLK_TC_ACT(BLK_TC_AHEAD), 0, 0, 0, BLK_TC_ACT(BLK_TC_META) };
73 73
74/* 74/*
75 * More could be added as needed, taking care to increment the decrementer 75 * More could be added as needed, taking care to increment the decrementer
@@ -81,6 +81,8 @@ static u32 bio_act[5] __read_mostly = { 0, BLK_TC_ACT(BLK_TC_BARRIER), BLK_TC_AC
81 (((rw) & (1 << BIO_RW_SYNC)) >> (BIO_RW_SYNC - 1)) 81 (((rw) & (1 << BIO_RW_SYNC)) >> (BIO_RW_SYNC - 1))
82#define trace_ahead_bit(rw) \ 82#define trace_ahead_bit(rw) \
83 (((rw) & (1 << BIO_RW_AHEAD)) << (2 - BIO_RW_AHEAD)) 83 (((rw) & (1 << BIO_RW_AHEAD)) << (2 - BIO_RW_AHEAD))
84#define trace_meta_bit(rw) \
85 (((rw) & (1 << BIO_RW_META)) >> (BIO_RW_META - 3))
84 86
85/* 87/*
86 * The worker for the various blk_add_trace*() types. Fills out a 88 * The worker for the various blk_add_trace*() types. Fills out a
@@ -103,6 +105,7 @@ void __blk_add_trace(struct blk_trace *bt, sector_t sector, int bytes,
103 what |= bio_act[trace_barrier_bit(rw)]; 105 what |= bio_act[trace_barrier_bit(rw)];
104 what |= bio_act[trace_sync_bit(rw)]; 106 what |= bio_act[trace_sync_bit(rw)];
105 what |= bio_act[trace_ahead_bit(rw)]; 107 what |= bio_act[trace_ahead_bit(rw)];
108 what |= bio_act[trace_meta_bit(rw)];
106 109
107 pid = tsk->pid; 110 pid = tsk->pid;
108 if (unlikely(act_log_check(bt, what, sector, pid))) 111 if (unlikely(act_log_check(bt, what, sector, pid)))
@@ -450,8 +453,10 @@ int blk_trace_ioctl(struct block_device *bdev, unsigned cmd, char __user *arg)
450 **/ 453 **/
451void blk_trace_shutdown(request_queue_t *q) 454void blk_trace_shutdown(request_queue_t *q)
452{ 455{
453 blk_trace_startstop(q, 0); 456 if (q->blk_trace) {
454 blk_trace_remove(q); 457 blk_trace_startstop(q, 0);
458 blk_trace_remove(q);
459 }
455} 460}
456 461
457/* 462/*
@@ -471,6 +476,9 @@ static void blk_check_time(unsigned long long *t)
471 *t -= (a + b) / 2; 476 *t -= (a + b) / 2;
472} 477}
473 478
479/*
480 * calibrate our inter-CPU timings
481 */
474static void blk_trace_check_cpu_time(void *data) 482static void blk_trace_check_cpu_time(void *data)
475{ 483{
476 unsigned long long *t; 484 unsigned long long *t;
@@ -488,20 +496,6 @@ static void blk_trace_check_cpu_time(void *data)
488 put_cpu(); 496 put_cpu();
489} 497}
490 498
491/*
492 * Call blk_trace_check_cpu_time() on each CPU to calibrate our inter-CPU
493 * timings
494 */
495static void blk_trace_calibrate_offsets(void)
496{
497 unsigned long flags;
498
499 smp_call_function(blk_trace_check_cpu_time, NULL, 1, 1);
500 local_irq_save(flags);
501 blk_trace_check_cpu_time(NULL);
502 local_irq_restore(flags);
503}
504
505static void blk_trace_set_ht_offsets(void) 499static void blk_trace_set_ht_offsets(void)
506{ 500{
507#if defined(CONFIG_SCHED_SMT) 501#if defined(CONFIG_SCHED_SMT)
@@ -530,7 +524,7 @@ static void blk_trace_set_ht_offsets(void)
530static __init int blk_trace_init(void) 524static __init int blk_trace_init(void)
531{ 525{
532 mutex_init(&blk_tree_mutex); 526 mutex_init(&blk_tree_mutex);
533 blk_trace_calibrate_offsets(); 527 on_each_cpu(blk_trace_check_cpu_time, NULL, 1, 1);
534 blk_trace_set_ht_offsets(); 528 blk_trace_set_ht_offsets();
535 529
536 return 0; 530 return 0;