From: Johannes Berg <johannes@sipsolutions.net>
To: Ingo Molnar <mingo@elte.hu>
Cc: Thomas Gleixner <tglx@linutronix.de>,
Linux Kernel list <linux-kernel@vger.kernel.org>,
Peter Zijlstra <peterz@infradead.org>
Subject: Re: [PATCH] timer: implement lockdep deadlock detection
Date: Tue, 27 Jan 2009 09:45:08 +0100 [thread overview]
Message-ID: <1233045908.4012.1.camel@johannes.local> (raw)
In-Reply-To: <20090126230721.GA6556@elte.hu>
[-- Attachment #1: Type: text/plain, Size: 2294 bytes --]
On Tue, 2009-01-27 at 00:07 +0100, Ingo Molnar wrote:
> * Johannes Berg <johannes@sipsolutions.net> wrote:
>
> > This modifies the timer code in a way to allow lockdep to detect
> > deadlocks resulting from a lock being taken in the timer function as
> > well as around the del_timer_sync() call.
> >
> > Validated with this module, otherwise bootup was clean.
>
> That's a really neat trick ...
Did it with workqueues earlier :)
> Curious: have you hit such a bug recently that motivated you to implement
> it?
No, I haven't hit a bug, but code inspection made me wonder whether or
not it could trigger. Didn't have a chance to try yet, had no hardware
available for this particular case.
> > +#ifdef CONFIG_LOCKDEP
> > +#define init_timer(timer) \
> > + do { \
> > + static struct lock_class_key __key; \
> > + init_timer_key((timer), #timer, &__key); \
> > + } while (0)
> > +#define init_timer_deferrable(timer) \
> > + do { \
>
> (Style detail: please put a newline after each macro block to make them
> stand apart a bit more.)
Sure.
> > int del_timer_sync(struct timer_list *timer)
> > {
> > +#ifdef CONFIG_LOCKDEP
> > + unsigned long flags;
> > +
> > + local_irq_save(flags);
> > + lock_map_acquire(&timer->lockdep_map);
> > + lock_map_release(&timer->lockdep_map);
> > + local_irq_restore(flags);
> > +#endif
>
> yummie. We have repeat bugs in this area that are rather tricky to find.
> This will trigger them in a debuggable way.
>
> > @@ -861,10 +881,21 @@ static inline void __run_timers(struct t
> >
> > set_running_timer(base, timer);
> > detach_timer(timer, 1);
> > +
> > spin_unlock_irq(&base->lock);
>
> Yes, the newline is needed there :-) [seriously]
Hah. I was editing code there in that area and removed it later again,
not realising I left the newline.
> > int preempt_count = preempt_count();
> > +
> > + /* Couple the lock chain with the lock chain at
> > + * del_timer_sync by acquiring the lock_map around
> > + * the fn() call here and in del_timer_sync.
> > + */
>
> Please use the standard multi-line comment style:
>
> /*
> * Comment .....
> * ...... goes here:
> */
Oops, yes.
johannes
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
next prev parent reply other threads:[~2009-01-27 8:46 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-01-26 22:59 [PATCH] timer: implement lockdep deadlock detection Johannes Berg
2009-01-26 23:03 ` Johannes Berg
2009-01-26 23:07 ` Ingo Molnar
2009-01-27 8:45 ` Johannes Berg [this message]
2009-01-27 8:46 ` [PATCH v2] " Johannes Berg
2009-01-27 13:27 ` Ingo Molnar
2009-01-27 13:41 ` Ingo Molnar
2009-01-27 18:06 ` Johannes Berg
2009-01-27 18:30 ` Peter Zijlstra
2009-01-27 18:33 ` Johannes Berg
2009-01-27 18:57 ` [PATCH v3] " Johannes Berg
2009-01-28 8:20 ` Peter Zijlstra
2009-01-28 9:54 ` Johannes Berg
2009-01-28 10:13 ` Peter Zijlstra
2009-01-28 10:54 ` Johannes Berg
2009-01-28 18:06 ` Johannes Berg
2009-01-29 12:38 ` Ingo Molnar
2009-01-29 15:03 ` [PATCH v4] " Johannes Berg
2009-01-29 13:38 ` [PATCH v3] " Peter Zijlstra
2009-01-29 13:44 ` Arnd Bergmann
2009-01-29 14:25 ` Johannes Berg
2009-01-27 18:12 ` [PATCH v2] " Johannes Berg
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=1233045908.4012.1.camel@johannes.local \
--to=johannes@sipsolutions.net \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=peterz@infradead.org \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox