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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20100105021919.GN6748@linux.vnet.ibm.com>
Date:	Mon, 4 Jan 2010 18:19:19 -0800
From:	"Paul E. McKenney" <paulmck@...ux.vnet.ibm.com>
To:	Josh Triplett <josh@...htriplett.org>
Cc:	linux-kernel@...r.kernel.org, mingo@...e.hu, laijs@...fujitsu.com,
	dipankar@...ibm.com, akpm@...ux-foundation.org,
	mathieu.desnoyers@...ymtl.ca, dvhltc@...ibm.com, niv@...ibm.com,
	tglx@...utronix.de, peterz@...radead.org, rostedt@...dmis.org,
	Valdis.Kletnieks@...edu, dhowells@...hat.com
Subject: Re: [PATCH tip/core/rcu 2/3] rcu: add debug check for too many
	rcu_read_unlock()

On Mon, Jan 04, 2010 at 06:03:08PM -0800, Josh Triplett wrote:
> On Mon, Jan 04, 2010 at 04:04:01PM -0800, Paul E. McKenney wrote:
> > From: Paul E. McKenney <paulmck@...ux.vnet.ibm.com>
> > 
> > TREE_PREEMPT_RCU maintains an rcu_read_lock_nesting counter in the
> > task structure, which happens to be a signed int.  So this patch adds a
> > check for this counter being negative at the end of __rcu_read_unlock().
> > This check is under CONFIG_PROVE_LOCKING, so can be thought of as being
> > part of lockdep.
> > 
> > Signed-off-by: Paul E. McKenney <paulmck@...ux.vnet.ibm.com>
> > ---
> >  kernel/rcutree_plugin.h |    3 +++
> >  1 files changed, 3 insertions(+), 0 deletions(-)
> > 
> > diff --git a/kernel/rcutree_plugin.h b/kernel/rcutree_plugin.h
> > index f11ebd4..e77cdf3 100644
> > --- a/kernel/rcutree_plugin.h
> > +++ b/kernel/rcutree_plugin.h
> > @@ -304,6 +304,9 @@ void __rcu_read_unlock(void)
> >  	if (--ACCESS_ONCE(t->rcu_read_lock_nesting) == 0 &&
> >  	    unlikely(ACCESS_ONCE(t->rcu_read_unlock_special)))
> >  		rcu_read_unlock_special(t);
> > +#ifdef CONFIG_PROVE_LOCKING
> > +	WARN_ON_ONCE(ACCESS_ONCE(t->rcu_read_lock_nesting) < 0);
> > +#endif /* #ifdef CONFIG_PROVE_LOCKING */
> >  }
> >  EXPORT_SYMBOL_GPL(__rcu_read_unlock);
> 
> Given that you *already* need to access t->rcu_read_lock_nesting here,
> why not just do the test all the time?  Ideally you could access
> t->rcu_read_lock_nesting once, decrement it, and test for both 0 and
> negative.

Because I was paranoid about the extra branch.  Perhaps needlessly
paranoid, but this is rcu_read_unlock() we are talking about here.  ;-)

You seem to be suggesting making the first test be "<=", then
sorting things out later, but given that both the equals-zero and the
greater-than-zero cases are quite common, I couldn't figure out how to
avoid the extra test and branch in the common case.  Hence the #ifdef.

							Thanx, Paul
--
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