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]
Message-ID: <20100418211215.GA25720@feather>
Date:	Sun, 18 Apr 2010 14:12:16 -0700
From:	Josh Triplett <josh@...htriplett.org>
To:	"Paul E. McKenney" <paulmck@...ux.vnet.ibm.com>
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,
	eric.dumazet@...il.com
Subject: Re: [PATCH RFC tip/core/rcu 02/16] rcu: make dead code really dead

On Sun, Apr 18, 2010 at 06:42:17AM -0700, Paul E. McKenney wrote:
> On Sat, Apr 17, 2010 at 08:53:09PM -0700, Josh Triplett wrote:
> > On Sat, Apr 17, 2010 at 06:12:13PM -0700, Paul E. McKenney wrote:
> > > On Fri, Apr 16, 2010 at 09:53:27PM -0700, Josh Triplett wrote:
> > > > On Fri, Apr 16, 2010 at 03:29:27PM -0700, Paul E. McKenney wrote:
> > > > > On Fri, Apr 16, 2010 at 02:16:10PM -0700, Josh Triplett wrote:
> > > > > > On Fri, Apr 16, 2010 at 07:23:48AM -0700, Paul E. McKenney wrote:
> > > > > > > On Thu, Apr 15, 2010 at 04:52:52PM -0700, Josh Triplett wrote:
> > > > > > > > On Thu, Apr 15, 2010 at 11:13:25AM -0700, Paul E. McKenney wrote:
> > > > > > > > > From: Lai Jiangshan <laijs@...fujitsu.com>
> > > > > > > > > 
> > > > > > > > > cleanup: make dead code really dead
> > > > > > > > > 
> > > > > > > > > Signed-off-by: Lai Jiangshan <laijs@...fujitsu.com>
> > > > > > > > > Signed-off-by: Paul E. McKenney <paulmck@...ux.vnet.ibm.com>
> > > > > > > > > ---
> > > > > > > > >  kernel/rcutree.c |    4 ++--
> > > > > > > > >  1 files changed, 2 insertions(+), 2 deletions(-)
> > > > > > > > > 
> > > > > > > > > diff --git a/kernel/rcutree.c b/kernel/rcutree.c
> > > > > > > > > index e54c123..6042fb8 100644
> > > > > > > > > --- a/kernel/rcutree.c
> > > > > > > > > +++ b/kernel/rcutree.c
> > > > > > > > > @@ -1236,11 +1236,11 @@ static void force_quiescent_state(struct rcu_state *rsp, int relaxed)
> > > > > > > > >  		break; /* grace period idle or initializing, ignore. */
> > > > > > > > >  
> > > > > > > > >  	case RCU_SAVE_DYNTICK:
> > > > > > > > > -
> > > > > > > > > -		raw_spin_unlock(&rnp->lock);  /* irqs remain disabled */
> > > > > > > > >  		if (RCU_SIGNAL_INIT != RCU_SAVE_DYNTICK)
> > > > > > > > >  			break; /* So gcc recognizes the dead code. */
> > > > > > > > 
> > > > > > > > GCC's new __builtin_unreachable would help here, though obviously we
> > > > > > > > can't count on 4.5 or newer quite yet.  A wrapper in compiler.h would
> > > > > > > > let us use it when available though.
> > > > > > > 
> > > > > > > So at some time when we can count on gcc 4.5 or newer, the code
> > > > > > > would look something like the following?
> > > > > > > 
> > > > > > > 	if (RCU_SIGNAL_INIT == RCU_SAVE_DYNTICK)
> > > > > > > 		this_is_unreachable();
> > > > > > 
> > > > > > Yes, exactly.
> > > > > > 
> > > > > > > I suppose that in the meantime one could supply the code to use
> > > > > > > in the unreachable case:
> > > > > > > 
> > > > > > > 	if (RCU_SIGNAL_INIT == RCU_SAVE_DYNTICK)
> > > > > > > 		this_is_unreachable(break);
> > > > > > > 
> > > > > > > But this is beginning to seem a bit strained to me.  ;-)
> > > > > > 
> > > > > > I'd suggest spelling that this way:
> > > > > > 
> > > > > > 	if (RCU_SIGNAL_INIT == RCU_SAVE_DYNTICK) {
> > > > > > 		unreachable();
> > > > > > 		break;
> > > > > > 	}
> > > > > > 
> > > > > > But in any case, all of these do seem excessive just to avoid the need
> > > > > > for an ifdef. :)
> > > > > 
> > > > > Actually, the "if" condition is a comparison of numerical constants,
> > > > > so no #ifdef is required.
> > > > 
> > > > I just meant that those constants get #defined based on CONFIG_NO_HZ, so
> > > > an #ifdef on that would remove the need for the special handling of dead
> > > > code.
> > > 
> > > True, I could put a #ifdef CONFIG_NO_HZ around that leg of the switch
> > > statement.  Or am I still missing your point?
> > 
> > No, you got it exactly.  Hence my suggesting that all the other
> > alternatives (the if with a break, or with __builtin_unreachable) seemed
> > excessive just to try to convince the compiler to infer what an ifdef
> > would tell it explicitly. :)
> 
> Which is exactly the purpose of the "if" statement comparing the two
> constants, right?  ;-)

Right, which also seems excessive compared to an ifdef, since it serves
the same purpose but more confusingly. ;)

- Josh Triplett
--
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