All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
To: Mike Snitzer <snitzer@redhat.com>
Cc: Keith Busch <keith.busch@intel.com>,
	dm-devel@redhat.com, Thomas Gleixner <tglx@linutronix.de>,
	Alasdair Kergon <agk@redhat.com>
Subject: [PATCH] dm rq: replace BUG_ON(!irqs_disabled) with lockdep's lock annotation
Date: Mon, 14 May 2018 18:24:07 +0200	[thread overview]
Message-ID: <20180514162407.rigrq3enfic3i7xw@linutronix.de> (raw)
In-Reply-To: <20180504155311.GA4787@redhat.com>

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

      parent reply	other threads:[~2018-05-14 16:24 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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   ` Sebastian Andrzej Siewior [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180514162407.rigrq3enfic3i7xw@linutronix.de \
    --to=bigeasy@linutronix.de \
    --cc=agk@redhat.com \
    --cc=dm-devel@redhat.com \
    --cc=keith.busch@intel.com \
    --cc=snitzer@redhat.com \
    --cc=tglx@linutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.