All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH REPOST] dm rq: remove BUG_ON(!irqs_disabled) check
@ 2018-05-04 14:36 Sebastian Andrzej Siewior
  2018-05-04 15:53 ` Mike Snitzer
  0 siblings, 1 reply; 4+ messages in thread
From: Sebastian Andrzej Siewior @ 2018-05-04 14:36 UTC (permalink / raw)
  To: dm-devel
  Cc: Keith Busch, Thomas Gleixner, Mike Snitzer,
	Sebastian Andrzej Siewior, Alasdair Kergon

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.

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

diff --git a/drivers/md/dm-rq.c b/drivers/md/dm-rq.c
index bf0b840645cc..1a524f992f72 100644
--- a/drivers/md/dm-rq.c
+++ b/drivers/md/dm-rq.c
@@ -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());
 	}
 }
 
-- 
2.17.0

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH REPOST] dm rq: remove BUG_ON(!irqs_disabled) check
  2018-05-04 14:36 [PATCH REPOST] dm rq: remove BUG_ON(!irqs_disabled) check Sebastian Andrzej Siewior
@ 2018-05-04 15:53 ` Mike Snitzer
  2018-05-04 16:33   ` Sebastian Andrzej Siewior
  2018-05-14 16:24   ` [PATCH] dm rq: replace BUG_ON(!irqs_disabled) with lockdep's lock annotation Sebastian Andrzej Siewior
  0 siblings, 2 replies; 4+ messages in thread
From: Mike Snitzer @ 2018-05-04 15:53 UTC (permalink / raw)
  To: Sebastian Andrzej Siewior
  Cc: Keith Busch, dm-devel, Thomas Gleixner, Alasdair Kergon

On Fri, May 04 2018 at 10:36am -0400,
Sebastian Andrzej Siewior <bigeasy@linutronix.de> wrote:

> 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.
> 
> Cc: Keith Busch <keith.busch@intel.com>
> Cc: Mike Snitzer <snitzer@redhat.com>
> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
> ---
>  drivers/md/dm-rq.c | 1 -
>  1 file changed, 1 deletion(-)
> 
> diff --git a/drivers/md/dm-rq.c b/drivers/md/dm-rq.c
> index bf0b840645cc..1a524f992f72 100644
> --- a/drivers/md/dm-rq.c
> +++ b/drivers/md/dm-rq.c
> @@ -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());
>  	}
>  }
>  
> -- 
> 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:

Nacked-by: Mike Snitzer <snitzer@redhat.com>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH REPOST] dm rq: remove BUG_ON(!irqs_disabled) check
  2018-05-04 15:53 ` Mike Snitzer
@ 2018-05-04 16:33   ` Sebastian Andrzej Siewior
  2018-05-14 16:24   ` [PATCH] dm rq: replace BUG_ON(!irqs_disabled) with lockdep's lock annotation Sebastian Andrzej Siewior
  1 sibling, 0 replies; 4+ messages in thread
From: Sebastian Andrzej Siewior @ 2018-05-04 16:33 UTC (permalink / raw)
  To: Mike Snitzer; +Cc: Keith Busch, dm-devel, Thomas Gleixner, Alasdair Kergon

On 2018-05-04 11:53:12 [-0400], Mike Snitzer wrote:
> 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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH] dm rq: replace BUG_ON(!irqs_disabled) with lockdep's lock annotation
  2018-05-04 15:53 ` Mike Snitzer
  2018-05-04 16:33   ` Sebastian Andrzej Siewior
@ 2018-05-14 16:24   ` Sebastian Andrzej Siewior
  1 sibling, 0 replies; 4+ messages in thread
From: Sebastian Andrzej Siewior @ 2018-05-14 16:24 UTC (permalink / raw)
  To: Mike Snitzer; +Cc: Keith Busch, dm-devel, Thomas Gleixner, Alasdair Kergon

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.

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@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 bf0b840645cc..78a44bb7537f 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.17.0

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-05-14 16:24 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-04 14:36 [PATCH REPOST] dm rq: remove BUG_ON(!irqs_disabled) check Sebastian Andrzej Siewior
2018-05-04 15:53 ` Mike Snitzer
2018-05-04 16:33   ` Sebastian Andrzej Siewior
2018-05-14 16:24   ` [PATCH] dm rq: replace BUG_ON(!irqs_disabled) with lockdep's lock annotation Sebastian Andrzej Siewior

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.