All of lore.kernel.org
 help / color / mirror / Atom feed
* sched/fair: avoid using uninitialized variable in preferred_group_nid()
@ 2015-01-23  8:25 Jan Beulich
  2015-01-23  9:54 ` Peter Zijlstra
  2015-01-28 14:29 ` [tip:sched/urgent] sched/fair: Avoid " tip-bot for Jan Beulich
  0 siblings, 2 replies; 10+ messages in thread
From: Jan Beulich @ 2015-01-23  8:25 UTC (permalink / raw)
  To: Peter Zijlstra, mingo; +Cc: linux-kernel

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. For the
compiler's sake, mark max_group uninitialized, as we're now able to
prove it's not actually being used uninitalized anymore.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Cc: Rik van Riel <riel@redhat.com>
---
 kernel/sched/fair.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

--- 3.19-rc5/kernel/sched/fair.c
+++ 3.19-rc5-sched-fair-preferred-group-nid/kernel/sched/fair.c
@@ -1730,7 +1730,7 @@ static int preferred_group_nid(struct ta
 	nodes = node_online_map;
 	for (dist = sched_max_numa_distance; dist > LOCAL_DISTANCE; dist--) {
 		unsigned long max_faults = 0;
-		nodemask_t max_group;
+		nodemask_t uninitialized_var(max_group);
 		int a, b;
 
 		/* Are there nodes at this distance from each other? */
@@ -1764,6 +1764,8 @@ static int preferred_group_nid(struct ta
 			}
 		}
 		/* Next round, evaluate the nodes within max_group. */
+		if (!max_faults)
+			break;
 		nodes = max_group;
 	}
 	return nid;




^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2015-02-18 17:11 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-01-23  8:25 sched/fair: avoid using uninitialized variable in preferred_group_nid() Jan Beulich
2015-01-23  9:54 ` Peter Zijlstra
2015-01-23 10:01   ` Jan Beulich
2015-01-28 14:29 ` [tip:sched/urgent] sched/fair: Avoid " tip-bot for Jan Beulich
2015-01-28 14:46   ` Jan Beulich
2015-01-28 15:37     ` Peter Zijlstra
2015-02-09  8:21       ` Ingo Molnar
2015-02-09 11:37         ` Peter Zijlstra
2015-02-09 11:41           ` Jan Beulich
2015-02-18 17:10           ` [tip:sched/core] sched/numa: Avoid some pointless iterations tip-bot for Jan Beulich

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.