Skip to contentSkip to conversation

dm rq: remove BUG_ON(!irqs_disabled) check

PATCH NAK Sebastian Andrzej Siewior 2 participants 4 messages May 4, 2018 – May 14, 2018 Device mapper

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 dm rq: remove BUG_ON(!irqs_disabled) check

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.

Since the original purpose for the "are-irqs-off" check is gone (the ->queue_lock has been removed) remove it.

---
 drivers/md/dm-rq.c | 1 -
 1 file changed, 1 deletion(-)
drivers/md/dm-rq.c +0 -1
index bf0b840645cc..1a524f992f72 100644
@@ -688,7 +688,6 @@ 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());
 	}
 }
 
Signature · 1 line
2.17.0
Nacked-by on v1 1/1 NAK
#1 lore raw
Quoted 31 lines · Sebastian Andrzej Siewior

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.

Since the original purpose for the "are-irqs-off" check is gone (the ->queue_lock has been removed) remove it.

---
 drivers/md/dm-rq.c | 1 -
 1 file changed, 1 deletion(-)
drivers/md/dm-rq.c +0 -1
index bf0b840645cc..1a524f992f72 100644
@@ -688,7 +688,6 @@ 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());
 	}
 }
 
Signature · 1 line
2.17.0

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.

Commit 2eb6e1e3aa87 made it such that work is queued into an irq enabled
context. But it never changed the fact that old block core's
.request_fn (and as such dm_old_request_fn) is called with irqs disabled.

So all said:

#2 lore raw
Quoted 9 lines · Mike Snitzer

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.

Commit 2eb6e1e3aa87 made it such that work is queued into an irq enabled
context. But it never changed the fact that old block core's
.request_fn (and as such dm_old_request_fn) is called with irqs disabled.

As per history it looked different, sorry. Is there a lock that is supposed to be held?

Sebastian

#3 lore raw

PATCH 1/1 dm rq: replace BUG_ON(!irqs_disabled) with lockdep's lock annotation

In reply to Mike Snitzer

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.

---
 drivers/md/dm-rq.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/md/dm-rq.c +1 -1
index bf0b840645cc..78a44bb7537f 100644
@@ -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);
 	}
 }
 
Signature · 1 line
2.17.0