lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Tue, 15 Jan 2008 00:27:41 +0300
From:	Oleg Nesterov <oleg@...sign.ru>
To:	Peter Zijlstra <a.p.zijlstra@...llo.nl>
Cc:	Herbert Xu <herbert@...dor.apana.org.au>,
	Ingo Molnar <mingo@...e.hu>, "Rafael J. Wysocki" <rjw@...k.pl>,
	Christian Kujau <lists@...dbynature.de>,
	linux-kernel@...r.kernel.org, jfs-discussion@...ts.sourceforge.net,
	Davide Libenzi <davidel@...ilserver.org>,
	Johannes Berg <johannes@...solutions.net>
Subject: Re: 2.6.24-rc6: possible recursive locking detected

On 01/13, Peter Zijlstra wrote:
> 
> 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);
> > 
> > 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.

Also, I don't like the overloading of ->trylock, this is really hackish.

> I think I'll do wake_up_nested() for now and keep this around.

Agreed.

Perhaps it is a bit easier to use spin_lock_nested() + __wake_up_common()
directly (we have a lot of wake_up_xxx helpers), but this is up to you.


Offtopic question. Why do we have so many lockdep stuff in timer.c and hrtimer.c ?
We never lock 2 bases at the same time, except in migrate_timers(). We can kill
double_spin_lock() and base_lock_keys[] and just use spin_lock_nested in
migrate_timers(), no?

Oleg.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ