Messages in this thread | | | Subject | Re: 2.6.24-rc6: possible recursive locking detected | From | Peter Zijlstra <> | Date | Sun, 13 Jan 2008 17:32:07 +0100 |
| |
On Mon, 2008-01-07 at 20:49 +0300, Oleg Nesterov wrote: > On 01/07, Oleg Nesterov wrote: > > > > Consider this "just for illustration" patch, > > > > --- t/kernel/lockdep.c 2007-11-09 12:57:31.000000000 +0300 > > +++ t/kernel/lockdep.c 2008-01-07 19:43:50.000000000 +0300 > > @@ -1266,10 +1266,13 @@ check_deadlock(struct task_struct *curr, > > struct held_lock *prev; > > int i; > > > > - for (i = 0; i < curr->lockdep_depth; i++) { > > + for (i = curr->lockdep_depth; --i >= 0; ) { > > prev = curr->held_locks + i; > > if (prev->class != next->class) > > continue; > > + > > + if (prev->trylock == -1) > > + return 2; > > /* > > * Allow read-after-read recursion of the same > > * lock class (i.e. read_lock(lock)+read_lock(lock)): > > ------------------------------------------------------------------------- > > > > Now, > > > > // trylock == -1 > > #define spin_mark_nested(l) \ > > lock_acquire(&(l)->dep_map, 0, -1, 0, 2, _THIS_IP_) > > #define spin_unmark_nested(l) \ > > lock_release(&(l)->dep_map, 1, _THIS_IP_) > > > > and ep_poll_safewake() can do: > > > > /* Do really wake up now */ > > spin_mark_nested(&wq->lock); > > wake_up(wq); > > spin_unmark_nested(&wq->lock); > > I tested the patch above with the following code, > > wait_queue_head_t w1, w2, w3; > > init_waitqueue_head(&w1); > init_waitqueue_head(&w2); > init_waitqueue_head(&w3); > > local_irq_disable(); > spin_lock(&w1.lock); > > spin_mark_nested(&w2.lock); > spin_lock(&w2.lock); > > spin_mark_nested(&w3.lock); > wake_up(&w3); > spin_unmark_nested(&w3.lock); > > spin_unlock(&w2.lock); > spin_unmark_nested(&w2.lock); > > spin_unlock(&w1.lock); > local_irq_enable(); > > seems to work. What do you think?
I've been pondering this for a while, and some days I really like it, some days I don't.
The problem I have with it is that it becomes very easy to falsely annotate problems away - its a very powerful annotation. That said, its almost powerful enough to annotate the device semaphore/mutex problem.
I think I'll do wake_up_nested() for now and keep this around.
Thanks for this very nice idea though.
| |