From b801a1e7dbca3f51d0a4b22a750ae257196002cb Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Fri, 11 Jan 2008 10:12:55 +0100 Subject: Don't blatt first element of prv in sg_chain() I realize that sg chaining is a ploy to make the rest of the kernel devs feel the pain of the SCSI subsystem. But this was a little unsubtle. Signed-off-by: Rusty Russell Acked-by: Tejun Heo Signed-off-by: Jens Axboe --- include/linux/scatterlist.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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, /* * offset and length are unused for chain entry. Clear them. */ - prv->offset = 0; - prv->length = 0; + prv[prv_nents - 1].offset = 0; + prv[prv_nents - 1].length = 0; /* * Set lowest bit to indicate a link pointer, and make sure to clear -- cgit v1.2.3 From a24eab1ed506f3e0bcbcd3f619558935549d4ace Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Fri, 11 Jan 2008 10:14:40 +0100 Subject: loop: fix bad bio_alloc() nr_iovec request Don't allocate room for an iovec when it is not needed. Signed-off-by: Jens Axboe --- drivers/block/loop.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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) static int loop_switch(struct loop_device *lo, struct file *file) { struct switch_request w; - struct bio *bio = bio_alloc(GFP_KERNEL, 1); + struct bio *bio = bio_alloc(GFP_KERNEL, 0); if (!bio) return -ENOMEM; init_completion(&w.wait); -- cgit v1.2.3 From 2997c8c4a0b179e8b834a7f30ba4323f2c60ccf4 Mon Sep 17 00:00:00 2001 From: Ingo Molnar Date: Fri, 11 Jan 2008 13:35:54 +0100 Subject: block: fix blktrace timestamps David Dillow reported broken blktrace timestamps. The reason is cpu_clock() which is not a global time source. Fix bkltrace timestamps by using ktime_get() like the networking code does for packet timestamps. This also removes a whole lot of complexity from bkltrace.c and shrinks the code by 500 bytes: text data bss dec hex filename 2888 124 44 3056 bf0 blktrace.o.before 2390 116 44 2550 9f6 blktrace.o.after Signed-off-by: Ingo Molnar Signed-off-by: Jens Axboe --- block/blktrace.c | 69 ++------------------------------------------------------ 1 file changed, 2 insertions(+), 67 deletions(-) diff --git a/block/blktrace.c b/block/blktrace.c index 498a0a54a6aa..7471621d4ded 100644 --- a/block/blktrace.c +++ b/block/blktrace.c @@ -25,7 +25,6 @@ #include #include -static DEFINE_PER_CPU(unsigned long long, blk_trace_cpu_offset) = { 0, }; static unsigned int blktrace_seq __read_mostly = 1; /* @@ -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; @@ -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; @@ -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; } -- cgit v1.2.3 From 11a57153e3377ffdf8cfca2eda9a99063f66b957 Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Fri, 11 Jan 2008 13:37:01 +0100 Subject: blktrace: kill the unneeded initcall It just inits the mutex, we can do that with DEFINE_MUTEX() instead. Signed-off-by: Jens Axboe --- block/blktrace.c | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/block/blktrace.c b/block/blktrace.c index 7471621d4ded..9b4da4ae3c7d 100644 --- a/block/blktrace.c +++ b/block/blktrace.c @@ -178,7 +178,7 @@ void __blk_add_trace(struct blk_trace *bt, sector_t sector, int bytes, EXPORT_SYMBOL_GPL(__blk_add_trace); static struct dentry *blk_tree_root; -static struct mutex blk_tree_mutex; +static DEFINE_MUTEX(blk_tree_mutex); static unsigned int root_users; static inline void blk_remove_root(void) @@ -504,13 +504,3 @@ void blk_trace_shutdown(struct request_queue *q) blk_trace_remove(q); } } - -static __init int blk_trace_init(void) -{ - mutex_init(&blk_tree_mutex); - - return 0; -} - -module_init(blk_trace_init); - -- cgit v1.2.3