Skip to content

Commit

Permalink
blk-stat: don't use this_cpu_ptr() in a preemptable section
Browse files Browse the repository at this point in the history
If PREEMPT_RCU is enabled, rcu_read_lock() isn't strong enough
for us to use this_cpu_ptr() in that section. Use the safer
get/put_cpu_ptr() variants instead.

Reported-by: Mike Galbraith <[email protected]>
Fixes: 34dbad5 ("blk-stat: convert to callback-based statistics reporting")
Signed-off-by: Jens Axboe <[email protected]>
  • Loading branch information
axboe committed May 10, 2017
1 parent 340ff32 commit d373812
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions block/blk-stat.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,16 @@ void blk_stat_add(struct request *rq)

rcu_read_lock();
list_for_each_entry_rcu(cb, &q->stats->callbacks, list) {
if (blk_stat_is_active(cb)) {
bucket = cb->bucket_fn(rq);
if (bucket < 0)
continue;
stat = &this_cpu_ptr(cb->cpu_stat)[bucket];
__blk_stat_add(stat, value);
}
if (!blk_stat_is_active(cb))
continue;

bucket = cb->bucket_fn(rq);
if (bucket < 0)
continue;

stat = &get_cpu_ptr(cb->cpu_stat)[bucket];
__blk_stat_add(stat, value);
put_cpu_ptr(cb->cpu_stat);
}
rcu_read_unlock();
}
Expand Down

0 comments on commit d373812

Please sign in to comment.