[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20150209082115.GA32322@gmail.com>
Date: Mon, 9 Feb 2015 09:21:15 +0100
From: Ingo Molnar <mingo@...nel.org>
To: Peter Zijlstra <peterz@...radead.org>
Cc: Jan Beulich <JBeulich@...e.com>, tglx@...utronix.de,
torvalds@...ux-foundation.org, riel@...hat.com,
linux-kernel@...r.kernel.org, hpa@...or.com
Subject: Re: [tip:sched/urgent] sched/fair: Avoid using uninitialized
variable in preferred_group_nid()
* Peter Zijlstra <peterz@...radead.org> wrote:
> On Wed, Jan 28, 2015 at 02:46:19PM +0000, Jan Beulich wrote:
> > >>> On 28.01.15 at 15:29, <tipbot@...or.com> wrote:
> > > Commit-ID: 81907478c4311a679849216abf723999184ab984
> > > Gitweb:
> > > http://git.kernel.org/tip/81907478c4311a679849216abf723999184ab984
> > > Author: Jan Beulich <JBeulich@...e.com>
> > > AuthorDate: Fri, 23 Jan 2015 08:25:38 +0000
> > > Committer: Ingo Molnar <mingo@...nel.org>
> > > CommitDate: Wed, 28 Jan 2015 13:14:12 +0100
> > >
> > > sched/fair: Avoid using uninitialized variable in preferred_group_nid()
> > >
> > > At least some gcc versions - validly afaict - warn about potentially
> > > using max_group uninitialized: There's no way the compiler can prove
> > > that the body of the conditional where it and max_faults get set/
> > > updated gets executed; in fact, without knowing all the details of
> > > other scheduler code, I can't prove this either.
> > >
> > > Generally the necessary change would appear to be to clear max_group
> > > prior to entering the inner loop, and break out of the outer loop when
> > > it ends up being all clear after the inner one. This, however, seems
> > > inefficient, and afaict the same effect can be achieved by exiting the
> > > outer loop when max_faults is still zero after the inner loop.
> > >
> > > [ mingo: changed the solution to zero initialization: uninitialized_var()
> > > needs to die, as it's an actively dangerous construct: if in the future
> > > a known-proven-good piece of code is changed to have a true, buggy
> > > uninitialized variable, the compiler warning is then supressed...
> >
> > But you went farther than that: You also dropped the breaking
> > out of the outer loop. Yet that has - beyond the fixing of the bug
> > here - the desirable effect of not continuing for perhaps many
> > iterations when nothing new can ever be found anymore.
>
> That break is indeed desired. The 'problem' it fixes is
> that when group_faults() returns 0, faults will be 0,
> which will not > max_faults, and therefore we will not
> set max_group.
>
> Without that break, we'll now set nodes to
> NODE_MASK_NONE, which will mean the for_each_node(a,
> nodes) loop will NOP and our dist loop will iterate
> pointlessly.
Ok, agreed, please send a separate patch to fix this.
Thanks,
Ingo
--
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