From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1760176AbbBILhh (ORCPT ); Mon, 9 Feb 2015 06:37:37 -0500 Received: from bombadil.infradead.org ([198.137.202.9]:53665 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1759835AbbBILhg (ORCPT ); Mon, 9 Feb 2015 06:37:36 -0500 Date: Mon, 9 Feb 2015 12:37:27 +0100 From: Peter Zijlstra To: Ingo Molnar Cc: Jan Beulich , tglx@linutronix.de, torvalds@linux-foundation.org, riel@redhat.com, linux-kernel@vger.kernel.org, hpa@zytor.com Subject: Re: [tip:sched/urgent] sched/fair: Avoid using uninitialized variable in preferred_group_nid() Message-ID: <20150209113727.GS5029@twins.programming.kicks-ass.net> References: <54C2139202000078000588F7@mail.emea.novell.com> <54C9044B020000780005A5E6@mail.emea.novell.com> <20150128153754.GG23038@twins.programming.kicks-ass.net> <20150209082115.GA32322@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20150209082115.GA32322@gmail.com> User-Agent: Mutt/1.5.21 (2012-12-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 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 Signed-off-by: Peter Zijlstra (Intel) --- 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;