blk-iocost: fix lockdep warning on blkcg->lock
authorMing Lei <ming.lei@redhat.com>
Tue, 3 Aug 2021 07:06:08 +0000 (15:06 +0800)
committerJens Axboe <axboe@kernel.dk>
Tue, 10 Aug 2021 02:00:26 +0000 (20:00 -0600)
commit11431e26c9c43fa26f6b33ee1a90989f57b86024
treeffa97a8ceceb46d02e715ff6fb62ed20846818ec
parentfb7b9b0231ba8f77587c23f5257a4fdb6df1219e
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 <tj@kernel.org>
Reported-by: Bruno Goncalves <bgoncalv@redhat.com>
Link: https://lore.kernel.org/linux-block/CA+QYu4rzz6079ighEanS3Qq_Dmnczcf45ZoJoHKVLVATTo1e4Q@mail.gmail.com/T/#u
Signed-off-by: Ming Lei <ming.lei@redhat.com>
Acked-by: Tejun Heo <tj@kernel.org>
Link: https://lore.kernel.org/r/20210803070608.1766400-1-ming.lei@redhat.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
block/blk-iocost.c