From: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Ingo Molnar <mingo@kernel.org>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
Peter Zijlstra <a.p.zijlstra@chello.nl>,
Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [GIT PULL] RCU changes for v4.1
Date: Tue, 14 Apr 2015 21:12:43 -0700 [thread overview]
Message-ID: <20150415041243.GQ23685@linux.vnet.ibm.com> (raw)
In-Reply-To: <CA+55aFz2sOTesK9ubr8Ds1SO9TxoUC37qP1opJvRofGNMZU4tg@mail.gmail.com>
On Tue, Apr 14, 2015 at 08:19:57PM -0700, Linus Torvalds wrote:
> On Tue, Apr 14, 2015 at 7:55 PM, Paul E. McKenney
> <paulmck@linux.vnet.ibm.com> wrote:
> >
> > Does the (currently being tested) patch below fix things up? If not,
> > please fill me in on the further error of my ways.
>
> Looks ok.
>
> That said, couldn't that last dummy gp_init_delay variable:
>
> > +/* Delay in jiffies for grace-period initialization delays, debug only. */
> > +#ifdef CONFIG_RCU_TORTURE_TEST_SLOW_INIT
> > +static int gp_init_delay = CONFIG_RCU_TORTURE_TEST_SLOW_INIT_DELAY;
> > module_param(gp_init_delay, int, 0644);
> > +#else /* #ifdef CONFIG_RCU_TORTURE_TEST_SLOW_INIT */
> > +static const int gp_init_delay;
> > +#endif /* #else #ifdef CONFIG_RCU_TORTURE_TEST_SLOW_INIT */
>
> be just a
>
> #define gp_init_delay 0
>
> for the non-CONFIG_RCU_TORTURE_TEST_SLOW_INIT case, so that the code
> that then does
>
> + if (gp_init_delay > 0 &&
> + !(rsp->gpnum % (rcu_num_nodes * PER_RCU_NODE_PERIOD)))
>
> would just trivially compile away.
>
> I guess the compiler *might* see a 'static const int' that is never
> touched and realize it's always zero, but it's not obvious that will
> be the case.
Well, if I attempt to modify gp_init_delay in its const guise, for
example, using gp_init_delay++, I get the following:
/media/homes/git/linux-2.6-tip/kernel/rcu/tree.c: In function ‘rcu_gp_init’:
/media/homes/git/linux-2.6-tip/kernel/rcu/tree.c:1849:3: error: increment of read-only variable ‘gp_init_delay’
make[2]: *** [kernel/rcu/tree.o] Error 1
make[1]: *** [kernel/rcu/tree.o] Error 2
make[1]: Leaving directory `/tmp/b'
make: *** [sub-make] Error 2
So the compiler knows that it cannot change. And if I compile with
CONFIG_RCU_TORTURE_TEST_SLOW_INIT=y, then:
$ nm /tmp/b/kernel/rcu/tree.o | grep gp_init_delay
00000060 r __param_gp_init_delay
000000e3 r __param_str_gp_init_delay
00000444 d gp_init_delay
On the other hand, compiling with CONFIG_RCU_TORTURE_TEST_SLOW_INIT=n
results in:
$ nm /tmp/b/kernel/rcu/tree.o | grep gp_init_delay
So the compiler isn't creating a variable in the const case.
>From what I can see, at -O1 or better, gcc optimizes the const variable
away. At -O0, gcc allocates space for it and actually tests it.
But if you prefer #define, not a problem.
Thanx, Paul
prev parent reply other threads:[~2015-04-15 4:12 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-13 12:14 Ingo Molnar
2015-04-15 0:22 ` Linus Torvalds
2015-04-15 0:25 ` Linus Torvalds
2015-04-15 2:55 ` Paul E. McKenney
2015-04-15 3:19 ` Linus Torvalds
2015-04-15 4:12 ` 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=20150415041243.GQ23685@linux.vnet.ibm.com \
--to=paulmck@linux.vnet.ibm.com \
--cc=a.p.zijlstra@chello.nl \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=torvalds@linux-foundation.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
Powered by JetHome