[dm-devel] [PATCH REPOST] dm rq: replace BUG_ON(!irqs_disabled) with lockdep's lock annotation

Sebastian Andrzej Siewior bigeasy at linutronix.de
Wed Jul 11 15:22:35 UTC 2018


In commit 052189a2ec95 ("dm: remove superfluous irq disablement in
dm_request_fn") the spin_lock_irq() was replaced with spin_lock() + a
check for disabled interrupts. Later the locking part was removed in
commit 2eb6e1e3aa87 ("dm: submit stacked requests in irq enabled
context") but the BUG_ON() check remained.
Mike Snitzer explained that:
|the queue_lock hasn't been removed for the old .request_fn path in block
|core -- which dm_old_request_fn is providing the hook for.
|
|This BUG_ON() documents that reality.

The BUG_ON() statement checks for disabled interrupts. The better check
would to let lockdep check if the required lock (queue_lock) is held.
Lockdep will then validate that the lock is held an complain if this is
not the case. Since lockdep will see this lock held in IRQ-context it
will also complain should the interrupts be enabled while lock still
held or acquired with enabled interrupts. So this !irq_disabled() is not
required.
This change helps to avoid the BUG_ON() statement on preempt-rt where
the lock is a sleeping lock and interrupts are never really disabled.

Cc: Alasdair Kergon <agk at redhat.com>
Cc: Keith Busch <keith.busch at intel.com>
Cc: Mike Snitzer <snitzer at redhat.com>
Cc: dm-devel at redhat.com
Signed-off-by: Sebastian Andrzej Siewior <bigeasy at linutronix.de>
---
 drivers/md/dm-rq.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/md/dm-rq.c b/drivers/md/dm-rq.c
index 6e547b8dd298..cbd6c7655f38 100644
--- a/drivers/md/dm-rq.c
+++ b/drivers/md/dm-rq.c
@@ -688,7 +688,7 @@ static void dm_old_request_fn(struct request_queue *q)
 		/* Establish tio->ti before queuing work (map_tio_request) */
 		tio->ti = ti;
 		kthread_queue_work(&md->kworker, &tio->work);
-		BUG_ON(!irqs_disabled());
+		lockdep_assert_held(q->queue_lock);
 	}
 }
 
-- 
2.18.0




More information about the dm-devel mailing list