From: Peter Zijlstra <peterz@infradead.org>
To: Qian Cai <cai@lca.pw>
Cc: mingo@redhat.com, valentin.schneider@arm.com,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] sched/core: silence a warning in sched_init()
Date: Tue, 25 Jun 2019 16:25:08 +0200 [thread overview]
Message-ID: <20190625142508.GE3419@hirez.programming.kicks-ass.net> (raw)
In-Reply-To: <1561471459.5154.70.camel@lca.pw>
On Tue, Jun 25, 2019 at 10:04:19AM -0400, Qian Cai wrote:
> On Tue, 2019-06-25 at 15:52 +0200, Peter Zijlstra wrote:
> Yes, -Wmissing-prototype makes no sense, but "-Wunused-but-set-variable" is
> pretty valid to catch certain developer errors. For example,
>
> https://lists.linuxfoundation.org/pipermail/iommu/2019-May/035680.html
>
> >
> > As to this one, ideally the compiler would not be stupid, and understand
> > the below, but alas.
>
> Pretty sure that won't work, as the compiler will complain something like,
>
> ISO C90 forbids mixed declarations and code
No, it builds just fine, it's a new block and C allows new variables at
every block start -- with the scope of that block.
And for our config, alloc_size is an unconditional 0, so it should DCE
the whole block and with that our variable. But clearly the passes are
the other way around :/
> > diff --git a/kernel/sched/core.c b/kernel/sched/core.c
> > index fa43ce3962e7..cb652e165570 100644
> > --- a/kernel/sched/core.c
> > +++ b/kernel/sched/core.c
> > @@ -6369,7 +6369,7 @@ DECLARE_PER_CPU(cpumask_var_t, select_idle_mask);
> >
> > void __init sched_init(void)
> > {
> > - unsigned long alloc_size = 0, ptr;
> > + unsigned long alloc_size = 0;
> > int i;
> >
> > wait_bit_init();
> > @@ -6381,7 +6381,7 @@ void __init sched_init(void)
> > alloc_size += 2 * nr_cpu_ids * sizeof(void **);
> > #endif
> > if (alloc_size) {
> > - ptr = (unsigned long)kzalloc(alloc_size, GFP_NOWAIT);
> > + unsigned long ptr = (unsigned long)kzalloc(alloc_size,
> > GFP_NOWAIT);
> >
> > #ifdef CONFIG_FAIR_GROUP_SCHED
> > root_task_group.se = (struct sched_entity **)ptr;
next prev parent reply other threads:[~2019-06-25 14:25 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-25 12:44 [PATCH v2] sched/core: silence a warning in sched_init() Qian Cai
2019-06-25 13:52 ` Peter Zijlstra
2019-06-25 14:04 ` Qian Cai
2019-06-25 14:25 ` Peter Zijlstra [this message]
2019-06-25 15:07 ` Qian Cai
2019-06-25 15:57 ` Peter Zijlstra
2019-07-18 20:44 ` Qian Cai
2019-07-08 14:32 ` Qian Cai
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=20190625142508.GE3419@hirez.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=cai@lca.pw \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=valentin.schneider@arm.com \
/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).