Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 75373
b: refs/heads/master
c: 2997c8c
h: refs/heads/master
i:
  75371: e37f819
v: v3
  • Loading branch information
Ingo Molnar authored and Jens Axboe committed Jan 11, 2008
1 parent 26ea50f commit 002b302
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 68 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: a24eab1ed506f3e0bcbcd3f619558935549d4ace
refs/heads/master: 2997c8c4a0b179e8b834a7f30ba4323f2c60ccf4
69 changes: 2 additions & 67 deletions trunk/block/blktrace.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
#include <linux/time.h>
#include <asm/uaccess.h>

static DEFINE_PER_CPU(unsigned long long, blk_trace_cpu_offset) = { 0, };
static unsigned int blktrace_seq __read_mostly = 1;

/*
Expand All @@ -41,7 +40,7 @@ static void trace_note(struct blk_trace *bt, pid_t pid, int action,
const int cpu = smp_processor_id();

t->magic = BLK_IO_TRACE_MAGIC | BLK_IO_TRACE_VERSION;
t->time = cpu_clock(cpu) - per_cpu(blk_trace_cpu_offset, cpu);
t->time = ktime_to_ns(ktime_get());
t->device = bt->dev;
t->action = action;
t->pid = pid;
Expand Down Expand Up @@ -159,7 +158,7 @@ void __blk_add_trace(struct blk_trace *bt, sector_t sector, int bytes,

t->magic = BLK_IO_TRACE_MAGIC | BLK_IO_TRACE_VERSION;
t->sequence = ++(*sequence);
t->time = cpu_clock(cpu) - per_cpu(blk_trace_cpu_offset, cpu);
t->time = ktime_to_ns(ktime_get());
t->sector = sector;
t->bytes = bytes;
t->action = what;
Expand Down Expand Up @@ -506,73 +505,9 @@ void blk_trace_shutdown(struct request_queue *q)
}
}

/*
* Average offset over two calls to cpu_clock() with a gettimeofday()
* in the middle
*/
static void blk_check_time(unsigned long long *t, int this_cpu)
{
unsigned long long a, b;
struct timeval tv;

a = cpu_clock(this_cpu);
do_gettimeofday(&tv);
b = cpu_clock(this_cpu);

*t = tv.tv_sec * 1000000000 + tv.tv_usec * 1000;
*t -= (a + b) / 2;
}

/*
* calibrate our inter-CPU timings
*/
static void blk_trace_check_cpu_time(void *data)
{
unsigned long long *t;
int this_cpu = get_cpu();

t = &per_cpu(blk_trace_cpu_offset, this_cpu);

/*
* Just call it twice, hopefully the second call will be cache hot
* and a little more precise
*/
blk_check_time(t, this_cpu);
blk_check_time(t, this_cpu);

put_cpu();
}

static void blk_trace_set_ht_offsets(void)
{
#if defined(CONFIG_SCHED_SMT)
int cpu, i;

/*
* now make sure HT siblings have the same time offset
*/
preempt_disable();
for_each_online_cpu(cpu) {
unsigned long long *cpu_off, *sibling_off;

for_each_cpu_mask(i, per_cpu(cpu_sibling_map, cpu)) {
if (i == cpu)
continue;

cpu_off = &per_cpu(blk_trace_cpu_offset, cpu);
sibling_off = &per_cpu(blk_trace_cpu_offset, i);
*sibling_off = *cpu_off;
}
}
preempt_enable();
#endif
}

static __init int blk_trace_init(void)
{
mutex_init(&blk_tree_mutex);
on_each_cpu(blk_trace_check_cpu_time, NULL, 1, 1);
blk_trace_set_ht_offsets();

return 0;
}
Expand Down

0 comments on commit 002b302

Please sign in to comment.