Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751463AbdFFPMa (ORCPT ); Tue, 6 Jun 2017 11:12:30 -0400 Received: from foss.arm.com ([217.140.101.70]:47828 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751388AbdFFPM3 (ORCPT ); Tue, 6 Jun 2017 11:12:29 -0400 Date: Tue, 6 Jun 2017 16:12:25 +0100 From: Juri Lelli To: Byungchul Park Cc: peterz@infradead.org, mingo@kernel.org, linux-kernel@vger.kernel.org, juri.lelli@gmail.com, rostedt@goodmis.org, kernel-team@lge.com Subject: Re: [PATCH 2/2] sched/deadline: Don't return invalid cpu in cpudl_maximum_cpu() Message-ID: <20170606151225.xlhrnh2usajmlu52@e106622-lin> References: <1496388663-29067-1-git-send-email-byungchul.park@lge.com> <1496388663-29067-2-git-send-email-byungchul.park@lge.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1496388663-29067-2-git-send-email-byungchul.park@lge.com> User-Agent: NeoMutt/20170113 (1.7.2) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 836 Lines: 28 Hi, On 02/06/17 16:31, Byungchul Park wrote: > When the heap tree is empty, cp->elements[0].cpu has meaningless value. > We need to consider the case. > > Signed-off-by: Byungchul Park > --- > kernel/sched/cpudeadline.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/kernel/sched/cpudeadline.c b/kernel/sched/cpudeadline.c > index d4a6963..9b314a9 100644 > --- a/kernel/sched/cpudeadline.c > +++ b/kernel/sched/cpudeadline.c > @@ -110,7 +110,8 @@ static void cpudl_heapify(struct cpudl *cp, int idx) > > static inline int cpudl_maximum_cpu(struct cpudl *cp) > { > - return cp->elements[0].cpu; > + int cpu = cp->elements[0].cpu; > + return cp->elements[cpu].idx == IDX_INVALID ? -1 : cpu; Mmm, don't we get a WARN from cpumask_check() if we return -1 here? Thanks, - Juri