[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1233045908.4012.1.camel@johannes.local>
Date: Tue, 27 Jan 2009 09:45:08 +0100
From: Johannes Berg <johannes@...solutions.net>
To: Ingo Molnar <mingo@...e.hu>
Cc: Thomas Gleixner <tglx@...utronix.de>,
Linux Kernel list <linux-kernel@...r.kernel.org>,
Peter Zijlstra <peterz@...radead.org>
Subject: Re: [PATCH] timer: implement lockdep deadlock detection
On Tue, 2009-01-27 at 00:07 +0100, Ingo Molnar wrote:
> * Johannes Berg <johannes@...solutions.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
Download attachment "signature.asc" of type "application/pgp-signature" (837 bytes)
Powered by blists - more mailing lists