linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
To: Alexander Gordeev <agordeev@redhat.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH 00/10] rcu: Cleanup RCU tree initialization
Date: Tue, 10 Mar 2015 07:52:21 -0700	[thread overview]
Message-ID: <20150310145220.GM5708@linux.vnet.ibm.com> (raw)
In-Reply-To: <20150310143939.GB5084@agordeev.usersys.redhat.com>

On Tue, Mar 10, 2015 at 02:39:39PM +0000, Alexander Gordeev wrote:
> On Mon, Mar 09, 2015 at 09:43:18PM -0700, Paul E. McKenney wrote:
> > On Mon, Mar 09, 2015 at 04:49:43PM -0700, Paul E. McKenney wrote:
> > > On Mon, Mar 09, 2015 at 04:39:47PM -0700, Paul E. McKenney wrote:
> > > > On Mon, Mar 09, 2015 at 02:40:21PM -0700, Paul E. McKenney wrote:
> > > > > On Mon, Mar 09, 2015 at 09:34:04AM +0100, Alexander Gordeev wrote:
> > > > > > Hi Paul,
> > > > > > 
> > > > > > Here is cleanup of RCU tree initialization rebased on linux-rcu rcu/next
> > > > > > repo, as you requested. Please, note an extra patch #10 that was not
> > > > > > present in the first post.
> > > > > > 
> > > > > > The series successfully passes kernel build test with CONFIG_RCU_FANOUT
> > > > > > and CONFIG_RCU_FANOUT_LEAF equal to 5.
> > > > > 
> > > > > I queued up 1-9, as discussed and have started testing.  I will let you
> > > > > know how it goes.
> > > > 
> > > > Initial testing went well except for the following warning:
> > > > 
> > > > /home/paulmck/public_git/linux-rcu/kernel/rcu/tree.c: In function ‘rcu_init_one.isra.63’:
> > > > /home/paulmck/public_git/linux-rcu/kernel/rcu/tree.c:3961:3: warning: ‘levelcnt[0]’ may be used uninitialized in this function [-Wmaybe-uninitialized]
> > > >    for (j = 0; j < levelcnt[i]; j++, rnp++) {
> > > > 
> > > > This warning looks like a false positive to me, given that the loop
> > > > near the beginning of the function initializes levelcnt[0].  Am I
> > > > missing something here, and either way, what is the best way to shut
> > > > this warning up?
> > > 
> > > My suggestion is the following:
> > > 
> > > 	if (rcu_num_lvls <= 0)
> > > 		panic("rcu_init_one: rcu_num_lvls underflow");
> > > 
> > > Just following the other panic() in rcu_init_one().
> > 
> > As in the following patch.
> > 
> > 							Thanx, Paul
> > 
> > ------------------------------------------------------------------------
> > 
> > rcu: Shut up spurious gcc uninitialized-variable warning
> > 
> > Because gcc doesn't realize that rcu_num_lvls must be strictly greater
> > than zero, some versions give a spurious warning about levelcnt[0] being
> > uninitialized in rcu_init_one().  This commit adds a panic() in that
> > case in order to educate gcc on this point.
> > 
> > Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
> > 
> > diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c
> > index bd5a9a1db048..5b42d94335e3 100644
> > --- a/kernel/rcu/tree.c
> > +++ b/kernel/rcu/tree.c
> > @@ -3942,6 +3942,8 @@ static void __init rcu_init_one(struct rcu_state *rsp,
> >  	/* Silence gcc 4.8 warning about array index out of range. */
> >  	if (rcu_num_lvls > RCU_NUM_LVLS)
> >  		panic("rcu_init_one: rcu_num_lvls overflow");
> > +	if (rcu_num_lvls <= 0)
> > +		panic("rcu_init_one: rcu_num_lvls underflow");
> 
> I believe '... else if (rcu_num_lvls <= 0)' is more appropriate here.

Good point.

> But do you think keeping two static strings just to shut the compiler
> worth it? May be a single complain would be enough?

As in the following?

	if (rcu_num_lvls <= 0 || rcu_num_lvls > RCU_NUM_LVLS)
		panic("rcu_init_one: rcu_num_lvls out of range");


For Tree RCU, I doubt that the memory size matters, but I do like
having two lines of code instead of four lines.  I took this approach.

							Thanx, Paul

>   	if (rcu_num_lvls <= 0 || rcu_num_lvls > RCU_NUM_LVLS)
>   		panic("rcu_init_one: rcu_num_lvls is out of range");
> 
> >  	/* Initialize the level-tracking arrays. */
> >  
> > 
> 
> -- 
> Regards,
> Alexander Gordeev
> agordeev@redhat.com
> 


      reply	other threads:[~2015-03-10 14:52 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-09  8:34 [PATCH 00/10] rcu: Cleanup RCU tree initialization Alexander Gordeev
2015-03-09  8:34 ` [PATCH 01/10] rcu: Panic if RCU tree can not accommodate all CPUs Alexander Gordeev
2015-03-09  8:34 ` [PATCH 02/10] rcu: Remove superfluous local variable in rcu_init_geometry() Alexander Gordeev
2015-03-09  8:34 ` [PATCH 03/10] rcu: Cleanup rcu_init_geometry() code and arithmetics Alexander Gordeev
2015-03-09  8:34 ` [PATCH 04/10] rcu: Simplify rcu_init_geometry() capacity arithmetics Alexander Gordeev
2015-03-09  8:34 ` [PATCH 05/10] rcu: Limit rcu_state::levelcnt[] to RCU_NUM_LVLS items Alexander Gordeev
2015-03-09  8:34 ` [PATCH 06/10] rcu: Limit rcu_capacity[] size " Alexander Gordeev
2015-03-09  8:34 ` [PATCH 07/10] rcu: Remove unnecessary fields from rcu_state structure Alexander Gordeev
2015-03-09  8:34 ` [PATCH 08/10] rcu: Limit count of static data to the number of RCU levels Alexander Gordeev
2015-03-09  8:34 ` [PATCH 09/10] rcu: Simplify arithmetic to calculate number of RCU nodes Alexander Gordeev
2015-03-09  8:34 ` [PATCH 10/10] rcu: Remove unnecessary grpnum field from rcu_node structure Alexander Gordeev
2015-03-09  9:36 ` [PATCH 00/10] rcu: Cleanup RCU tree initialization Alexander Gordeev
2015-03-09 21:35   ` Paul E. McKenney
2015-03-10 14:33     ` Alexander Gordeev
2015-03-10 14:57       ` Paul E. McKenney
2015-03-09 21:40 ` Paul E. McKenney
2015-03-09 23:39   ` Paul E. McKenney
2015-03-09 23:49     ` Paul E. McKenney
2015-03-10  4:43       ` Paul E. McKenney
2015-03-10 14:39         ` Alexander Gordeev
2015-03-10 14:52           ` Paul E. McKenney [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150310145220.GM5708@linux.vnet.ibm.com \
    --to=paulmck@linux.vnet.ibm.com \
    --cc=agordeev@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).