aboutsummaryrefslogtreecommitdiffstats
path: root/block
diff options
context:
space:
mode:
authorPeter Zijlstra <peterz@infradead.org>2013-11-12 22:42:14 -0500
committerIngo Molnar <mingo@kernel.org>2013-11-13 07:54:08 -0500
commit90d3839b90fe379557dae4a44735a6af78f42885 (patch)
treea7c36fe04e8adcc5f1fb4a7917c1c6fcbc73ed96 /block
parent5216d530bbd8581c927b250a11533c2a31b57510 (diff)
block: Use u64_stats_init() to initialize seqcounts
Now that seqcounts are lockdep enabled objects, we need to explicitly initialize runtime allocated seqcounts so that lockdep can track them. Without this patch, Fengguang was seeing: [ 4.127282] INFO: trying to register non-static key. [ 4.128027] the code is fine but needs lockdep annotation. [ 4.128027] turning off the locking correctness validator. [ 4.128027] CPU: 0 PID: 96 Comm: kworker/u4:1 Not tainted 3.12.0-next-20131108-10601-gbad570d #2 [ 4.128027] Hardware name: Bochs Bochs, BIOS Bochs 01/01/2011 [ ... ] [ 4.128027] Call Trace: [ 4.128027] [<7908e744>] ? console_unlock+0x353/0x380 [ 4.128027] [<79dc7cf2>] dump_stack+0x48/0x60 [ 4.128027] [<7908953e>] __lock_acquire.isra.26+0x7e3/0xceb [ 4.128027] [<7908a1c5>] lock_acquire+0x71/0x9a [ 4.128027] [<794079aa>] ? blk_throtl_bio+0x1c3/0x485 [ 4.128027] [<7940658b>] throtl_update_dispatch_stats+0x7c/0x153 [ 4.128027] [<794079aa>] ? blk_throtl_bio+0x1c3/0x485 [ 4.128027] [<794079aa>] blk_throtl_bio+0x1c3/0x485 ... Use u64_stats_init() for all affected data structures, which initializes the seqcount. Reported-and-Tested-by: Fengguang Wu <fengguang.wu@intel.com> Cc: Vivek Goyal <vgoyal@redhat.com> Cc: Jens Axboe <axboe@kernel.dk> Signed-off-by: Peter Zijlstra <peterz@infradead.org> [ Folded in another fix from the mailing list as well as a fix to that fix. Tweaked commit message. ] Signed-off-by: John Stultz <john.stultz@linaro.org> Signed-off-by: Peter Zijlstra <peterz@infradead.org> Link: http://lkml.kernel.org/r/1384314134-6895-1-git-send-email-john.stultz@linaro.org [ So I actually think that the two SOBs from PeterZ are the right depiction of the patch route. ] Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'block')
-rw-r--r--block/blk-cgroup.h10
-rw-r--r--block/blk-throttle.c10
-rw-r--r--block/cfq-iosched.c25
3 files changed, 45 insertions, 0 deletions
diff --git a/block/blk-cgroup.h b/block/blk-cgroup.h
index ae6969a7ffd4..1610b22edf09 100644
--- a/block/blk-cgroup.h
+++ b/block/blk-cgroup.h
@@ -402,6 +402,11 @@ struct request_list *__blk_queue_next_rl(struct request_list *rl,
402#define blk_queue_for_each_rl(rl, q) \ 402#define blk_queue_for_each_rl(rl, q) \
403 for ((rl) = &(q)->root_rl; (rl); (rl) = __blk_queue_next_rl((rl), (q))) 403 for ((rl) = &(q)->root_rl; (rl); (rl) = __blk_queue_next_rl((rl), (q)))
404 404
405static inline void blkg_stat_init(struct blkg_stat *stat)
406{
407 u64_stats_init(&stat->syncp);
408}
409
405/** 410/**
406 * blkg_stat_add - add a value to a blkg_stat 411 * blkg_stat_add - add a value to a blkg_stat
407 * @stat: target blkg_stat 412 * @stat: target blkg_stat
@@ -458,6 +463,11 @@ static inline void blkg_stat_merge(struct blkg_stat *to, struct blkg_stat *from)
458 blkg_stat_add(to, blkg_stat_read(from)); 463 blkg_stat_add(to, blkg_stat_read(from));
459} 464}
460 465
466static inline void blkg_rwstat_init(struct blkg_rwstat *rwstat)
467{
468 u64_stats_init(&rwstat->syncp);
469}
470
461/** 471/**
462 * blkg_rwstat_add - add a value to a blkg_rwstat 472 * blkg_rwstat_add - add a value to a blkg_rwstat
463 * @rwstat: target blkg_rwstat 473 * @rwstat: target blkg_rwstat
diff --git a/block/blk-throttle.c b/block/blk-throttle.c
index 8331aba9426f..06534049afba 100644
--- a/block/blk-throttle.c
+++ b/block/blk-throttle.c
@@ -256,6 +256,12 @@ static struct throtl_data *sq_to_td(struct throtl_service_queue *sq)
256 } \ 256 } \
257} while (0) 257} while (0)
258 258
259static void tg_stats_init(struct tg_stats_cpu *tg_stats)
260{
261 blkg_rwstat_init(&tg_stats->service_bytes);
262 blkg_rwstat_init(&tg_stats->serviced);
263}
264
259/* 265/*
260 * Worker for allocating per cpu stat for tgs. This is scheduled on the 266 * Worker for allocating per cpu stat for tgs. This is scheduled on the
261 * system_wq once there are some groups on the alloc_list waiting for 267 * system_wq once there are some groups on the alloc_list waiting for
@@ -269,12 +275,16 @@ static void tg_stats_alloc_fn(struct work_struct *work)
269 275
270alloc_stats: 276alloc_stats:
271 if (!stats_cpu) { 277 if (!stats_cpu) {
278 int cpu;
279
272 stats_cpu = alloc_percpu(struct tg_stats_cpu); 280 stats_cpu = alloc_percpu(struct tg_stats_cpu);
273 if (!stats_cpu) { 281 if (!stats_cpu) {
274 /* allocation failed, try again after some time */ 282 /* allocation failed, try again after some time */
275 schedule_delayed_work(dwork, msecs_to_jiffies(10)); 283 schedule_delayed_work(dwork, msecs_to_jiffies(10));
276 return; 284 return;
277 } 285 }
286 for_each_possible_cpu(cpu)
287 tg_stats_init(per_cpu_ptr(stats_cpu, cpu));
278 } 288 }
279 289
280 spin_lock_irq(&tg_stats_alloc_lock); 290 spin_lock_irq(&tg_stats_alloc_lock);
diff --git a/block/cfq-iosched.c b/block/cfq-iosched.c
index 434944cbd761..4d5cec1ad80d 100644
--- a/block/cfq-iosched.c
+++ b/block/cfq-iosched.c
@@ -1508,6 +1508,29 @@ static void cfq_init_cfqg_base(struct cfq_group *cfqg)
1508} 1508}
1509 1509
1510#ifdef CONFIG_CFQ_GROUP_IOSCHED 1510#ifdef CONFIG_CFQ_GROUP_IOSCHED
1511static void cfqg_stats_init(struct cfqg_stats *stats)
1512{
1513 blkg_rwstat_init(&stats->service_bytes);
1514 blkg_rwstat_init(&stats->serviced);
1515 blkg_rwstat_init(&stats->merged);
1516 blkg_rwstat_init(&stats->service_time);
1517 blkg_rwstat_init(&stats->wait_time);
1518 blkg_rwstat_init(&stats->queued);
1519
1520 blkg_stat_init(&stats->sectors);
1521 blkg_stat_init(&stats->time);
1522
1523#ifdef CONFIG_DEBUG_BLK_CGROUP
1524 blkg_stat_init(&stats->unaccounted_time);
1525 blkg_stat_init(&stats->avg_queue_size_sum);
1526 blkg_stat_init(&stats->avg_queue_size_samples);
1527 blkg_stat_init(&stats->dequeue);
1528 blkg_stat_init(&stats->group_wait_time);
1529 blkg_stat_init(&stats->idle_time);
1530 blkg_stat_init(&stats->empty_time);
1531#endif
1532}
1533
1511static void cfq_pd_init(struct blkcg_gq *blkg) 1534static void cfq_pd_init(struct blkcg_gq *blkg)
1512{ 1535{
1513 struct cfq_group *cfqg = blkg_to_cfqg(blkg); 1536 struct cfq_group *cfqg = blkg_to_cfqg(blkg);
@@ -1515,6 +1538,8 @@ static void cfq_pd_init(struct blkcg_gq *blkg)
1515 cfq_init_cfqg_base(cfqg); 1538 cfq_init_cfqg_base(cfqg);
1516 cfqg->weight = blkg->blkcg->cfq_weight; 1539 cfqg->weight = blkg->blkcg->cfq_weight;
1517 cfqg->leaf_weight = blkg->blkcg->cfq_leaf_weight; 1540 cfqg->leaf_weight = blkg->blkcg->cfq_leaf_weight;
1541 cfqg_stats_init(&cfqg->stats);
1542 cfqg_stats_init(&cfqg->dead_stats);
1518} 1543}
1519 1544
1520static void cfq_pd_offline(struct blkcg_gq *blkg) 1545static void cfq_pd_offline(struct blkcg_gq *blkg)