Re: [tip:sched/urgent] sched/fair: Avoid using uninitialized variable in preferred_group_nid()

From: Peter Zijlstra
Date: Mon Feb 09 2015 - 06:37:41 EST


On Mon, Feb 09, 2015 at 09:21:15AM +0100, Ingo Molnar wrote:
> Ok, agreed, please send a separate patch to fix this.

Jan, I didn't want to put your SoB on without feedback, holler and I'll
amend it any way you like.

---
Subject: sched/numa: Avoid some pointless iterations
From: Jan Beulich <JBeulich@xxxxxxxx>
Date: Mon Feb 9 12:30:00 CET 2015

Commit 81907478c431 ("sched/fair: Avoid using uninitialized variable
in preferred_group_nid()") unconditionally initializes max_group with
NODE_MASK_NONE, this means that when !max_faults (max_group didn't get
set), we'll now continue the iteration with an empty mask.

Which in turn makes the actual body of the loop go away, so we'll just
iterate until completion; short circuit this by breaking out of the
loop as soon as this would happen.

Maybe-Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
Signed-off-by: Peter Zijlstra (Intel) <peterz@xxxxxxxxxxxxx>
---
kernel/sched/fair.c | 2 ++
1 file changed, 2 insertions(+)

--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -1763,6 +1763,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;
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/