From: Samuel Ortiz <samuel@sortiz.org>
To: David Miller <davem@davemloft.net>
Cc: davej@redhat.com, linux-kernel@vger.kernel.org, mingo@redhat.com
Subject: Re: irda rmmod lockdep trace.
Date: Fri, 16 Mar 2007 22:19:00 +0200 [thread overview]
Message-ID: <20070316201900.GA3396@sortiz.org> (raw)
In-Reply-To: <20070313.192237.112853631.davem@davemloft.net>
On Tue, Mar 13, 2007 at 07:22:37PM -0700, David Miller wrote:
> From: Samuel Ortiz <samuel@sortiz.org>
> Date: Wed, 14 Mar 2007 02:50:03 +0200
>
> > On Mon, Mar 12, 2007 at 04:49:21PM -0700, David Miller wrote:
> > > I would strongly caution against adding any run-time overhead just to
> > > cure a false lockdep warning. Even adding a new function argument
> > > is too much IMHO.
> > >
> > > Make the cost show up for lockdep only, perhaps by putting each
> > > hashbin lock into a seperate locking class?
> > Does that look better to you:
>
> Yes, it does.:)
Unfortunately, it doesn't work, as the lock key is not on the stack. We get
hit by the lockdep code checking if our lock key is static:
if (!static_obj(key)) {
printk("BUG: key %p not in .data!\n", key);
DEBUG_LOCKS_WARN_ON(1);
return;
}
So, instead, I propose the following, which does work, and adds runtime
overhead only when LOCKDEP is enabled:
---
net/irda/irqueue.c | 9 ++++++++-
1 files changed, 8 insertions(+), 1 deletions(-)
diff --git a/net/irda/irqueue.c b/net/irda/irqueue.c
index 9266233..d058b46 100644
--- a/net/irda/irqueue.c
+++ b/net/irda/irqueue.c
@@ -384,6 +384,9 @@ EXPORT_SYMBOL(hashbin_new);
* for deallocating this structure if it's complex. If not the user can
* just supply kfree, which should take care of the job.
*/
+#ifdef CONFIG_LOCKDEP
+static int hashbin_lock_depth = 0;
+#endif
int hashbin_delete( hashbin_t* hashbin, FREE_FUNC free_func)
{
irda_queue_t* queue;
@@ -395,7 +398,8 @@ int hashbin_delete( hashbin_t* hashbin, FREE_FUNC free_func)
/* Synchronize */
if ( hashbin->hb_type & HB_LOCK ) {
- spin_lock_irqsave(&hashbin->hb_spinlock, flags);
+ spin_lock_irqsave_nested(&hashbin->hb_spinlock, flags,
+ hashbin_lock_depth++);
}
/*
@@ -419,6 +423,9 @@ int hashbin_delete( hashbin_t* hashbin, FREE_FUNC free_func)
/* Release lock */
if ( hashbin->hb_type & HB_LOCK) {
spin_unlock_irqrestore(&hashbin->hb_spinlock, flags);
+#ifdef CONFIG_LOCKDEP
+ hashbin_lock_depth--;
+#endif
}
/*
prev parent reply other threads:[~2007-03-16 20:25 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-03-08 22:54 irda rmmod lockdep trace Dave Jones
2007-03-10 17:43 ` Samuel Ortiz
2007-03-12 0:38 ` Samuel Ortiz
2007-03-12 23:49 ` David Miller
2007-03-13 16:18 ` Samuel Ortiz
2007-03-14 0:50 ` Samuel Ortiz
2007-03-14 2:22 ` David Miller
2007-03-16 20:19 ` Samuel Ortiz [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=20070316201900.GA3396@sortiz.org \
--to=samuel@sortiz.org \
--cc=davej@redhat.com \
--cc=davem@davemloft.net \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).