aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--block/blktrace.c81
-rw-r--r--drivers/block/loop.c2
-rw-r--r--include/linux/scatterlist.h4
3 files changed, 6 insertions, 81 deletions
diff --git a/block/blktrace.c b/block/blktrace.c
index 498a0a54a6aa..9b4da4ae3c7d 100644
--- a/block/blktrace.c
+++ b/block/blktrace.c
@@ -25,7 +25,6 @@
25#include <linux/time.h> 25#include <linux/time.h>
26#include <asm/uaccess.h> 26#include <asm/uaccess.h>
27 27
28static DEFINE_PER_CPU(unsigned long long, blk_trace_cpu_offset) = { 0, };
29static unsigned int blktrace_seq __read_mostly = 1; 28static unsigned int blktrace_seq __read_mostly = 1;
30 29
31/* 30/*
@@ -41,7 +40,7 @@ static void trace_note(struct blk_trace *bt, pid_t pid, int action,
41 const int cpu = smp_processor_id(); 40 const int cpu = smp_processor_id();
42 41
43 t->magic = BLK_IO_TRACE_MAGIC | BLK_IO_TRACE_VERSION; 42 t->magic = BLK_IO_TRACE_MAGIC | BLK_IO_TRACE_VERSION;
44 t->time = cpu_clock(cpu) - per_cpu(blk_trace_cpu_offset, cpu); 43 t->time = ktime_to_ns(ktime_get());
45 t->device = bt->dev; 44 t->device = bt->dev;
46 t->action = action; 45 t->action = action;
47 t->pid = pid; 46 t->pid = pid;
@@ -159,7 +158,7 @@ void __blk_add_trace(struct blk_trace *bt, sector_t sector, int bytes,
159 158
160 t->magic = BLK_IO_TRACE_MAGIC | BLK_IO_TRACE_VERSION; 159 t->magic = BLK_IO_TRACE_MAGIC | BLK_IO_TRACE_VERSION;
161 t->sequence = ++(*sequence); 160 t->sequence = ++(*sequence);
162 t->time = cpu_clock(cpu) - per_cpu(blk_trace_cpu_offset, cpu); 161 t->time = ktime_to_ns(ktime_get());
163 t->sector = sector; 162 t->sector = sector;
164 t->bytes = bytes; 163 t->bytes = bytes;
165 t->action = what; 164 t->action = what;
@@ -179,7 +178,7 @@ void __blk_add_trace(struct blk_trace *bt, sector_t sector, int bytes,
179EXPORT_SYMBOL_GPL(__blk_add_trace); 178EXPORT_SYMBOL_GPL(__blk_add_trace);
180 179
181static struct dentry *blk_tree_root; 180static struct dentry *blk_tree_root;
182static struct mutex blk_tree_mutex; 181static DEFINE_MUTEX(blk_tree_mutex);
183static unsigned int root_users; 182static unsigned int root_users;
184 183
185static inline void blk_remove_root(void) 184static inline void blk_remove_root(void)
@@ -505,77 +504,3 @@ void blk_trace_shutdown(struct request_queue *q)
505 blk_trace_remove(q); 504 blk_trace_remove(q);
506 } 505 }
507} 506}
508
509/*
510 * Average offset over two calls to cpu_clock() with a gettimeofday()
511 * in the middle
512 */
513static void blk_check_time(unsigned long long *t, int this_cpu)
514{
515 unsigned long long a, b;
516 struct timeval tv;
517
518 a = cpu_clock(this_cpu);
519 do_gettimeofday(&tv);
520 b = cpu_clock(this_cpu);
521
522 *t = tv.tv_sec * 1000000000 + tv.tv_usec * 1000;
523 *t -= (a + b) / 2;
524}
525
526/*
527 * calibrate our inter-CPU timings
528 */
529static void blk_trace_check_cpu_time(void *data)
530{
531 unsigned long long *t;
532 int this_cpu = get_cpu();
533
534 t = &per_cpu(blk_trace_cpu_offset, this_cpu);
535
536 /*
537 * Just call it twice, hopefully the second call will be cache hot
538 * and a little more precise
539 */
540 blk_check_time(t, this_cpu);
541 blk_check_time(t, this_cpu);
542
543 put_cpu();
544}
545
546static void blk_trace_set_ht_offsets(void)
547{
548#if defined(CONFIG_SCHED_SMT)
549 int cpu, i;
550
551 /*
552 * now make sure HT siblings have the same time offset
553 */
554 preempt_disable();
555 for_each_online_cpu(cpu) {
556 unsigned long long *cpu_off, *sibling_off;
557
558 for_each_cpu_mask(i, per_cpu(cpu_sibling_map, cpu)) {
559 if (i == cpu)
560 continue;
561
562 cpu_off = &per_cpu(blk_trace_cpu_offset, cpu);
563 sibling_off = &per_cpu(blk_trace_cpu_offset, i);
564 *sibling_off = *cpu_off;
565 }
566 }
567 preempt_enable();
568#endif
569}
570
571static __init int blk_trace_init(void)
572{
573 mutex_init(&blk_tree_mutex);
574 on_each_cpu(blk_trace_check_cpu_time, NULL, 1, 1);
575 blk_trace_set_ht_offsets();
576
577 return 0;
578}
579
580module_init(blk_trace_init);
581
diff --git a/drivers/block/loop.c b/drivers/block/loop.c
index 56e23042728a..b8af22e610df 100644
--- a/drivers/block/loop.c
+++ b/drivers/block/loop.c
@@ -610,7 +610,7 @@ static int loop_thread(void *data)
610static int loop_switch(struct loop_device *lo, struct file *file) 610static int loop_switch(struct loop_device *lo, struct file *file)
611{ 611{
612 struct switch_request w; 612 struct switch_request w;
613 struct bio *bio = bio_alloc(GFP_KERNEL, 1); 613 struct bio *bio = bio_alloc(GFP_KERNEL, 0);
614 if (!bio) 614 if (!bio)
615 return -ENOMEM; 615 return -ENOMEM;
616 init_completion(&w.wait); 616 init_completion(&w.wait);
diff --git a/include/linux/scatterlist.h b/include/linux/scatterlist.h
index 416e000dfe81..e3ff21dbac53 100644
--- a/include/linux/scatterlist.h
+++ b/include/linux/scatterlist.h
@@ -191,8 +191,8 @@ static inline void sg_chain(struct scatterlist *prv, unsigned int prv_nents,
191 /* 191 /*
192 * offset and length are unused for chain entry. Clear them. 192 * offset and length are unused for chain entry. Clear them.
193 */ 193 */
194 prv->offset = 0; 194 prv[prv_nents - 1].offset = 0;
195 prv->length = 0; 195 prv[prv_nents - 1].length = 0;
196 196
197 /* 197 /*
198 * Set lowest bit to indicate a link pointer, and make sure to clear 198 * Set lowest bit to indicate a link pointer, and make sure to clear