Skip to content

Commit 11431e2

Browse files
Ming Leiaxboe
authored andcommitted
blk-iocost: fix lockdep warning on blkcg->lock
blkcg->lock depends on q->queue_lock which may depend on another driver lock required in irq context, one example is dm-thin: Chain exists of: &pool->lock#3 --> &q->queue_lock --> &blkcg->lock Possible interrupt unsafe locking scenario: CPU0 CPU1 ---- ---- lock(&blkcg->lock); local_irq_disable(); lock(&pool->lock#3); lock(&q->queue_lock); <Interrupt> lock(&pool->lock#3); Fix the issue by using spin_lock_irq(&blkcg->lock) in ioc_weight_write(). Cc: Tejun Heo <[email protected]> Reported-by: Bruno Goncalves <[email protected]> Link: https://lore.kernel.org/linux-block/CA+QYu4rzz6079ighEanS3Qq_Dmnczcf45ZoJoHKVLVATTo1e4Q@mail.gmail.com/T/#u Signed-off-by: Ming Lei <[email protected]> Acked-by: Tejun Heo <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jens Axboe <[email protected]>
1 parent fb7b9b0 commit 11431e2

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

block/blk-iocost.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3061,19 +3061,19 @@ static ssize_t ioc_weight_write(struct kernfs_open_file *of, char *buf,
30613061
if (v < CGROUP_WEIGHT_MIN || v > CGROUP_WEIGHT_MAX)
30623062
return -EINVAL;
30633063

3064-
spin_lock(&blkcg->lock);
3064+
spin_lock_irq(&blkcg->lock);
30653065
iocc->dfl_weight = v * WEIGHT_ONE;
30663066
hlist_for_each_entry(blkg, &blkcg->blkg_list, blkcg_node) {
30673067
struct ioc_gq *iocg = blkg_to_iocg(blkg);
30683068

30693069
if (iocg) {
3070-
spin_lock_irq(&iocg->ioc->lock);
3070+
spin_lock(&iocg->ioc->lock);
30713071
ioc_now(iocg->ioc, &now);
30723072
weight_updated(iocg, &now);
3073-
spin_unlock_irq(&iocg->ioc->lock);
3073+
spin_unlock(&iocg->ioc->lock);
30743074
}
30753075
}
3076-
spin_unlock(&blkcg->lock);
3076+
spin_unlock_irq(&blkcg->lock);
30773077

30783078
return nbytes;
30793079
}

0 commit comments

Comments
 (0)