Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751498AbdFFXmh (ORCPT ); Tue, 6 Jun 2017 19:42:37 -0400 Received: from LGEAMRELO13.lge.com ([156.147.23.53]:39007 "EHLO lgeamrelo13.lge.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751437AbdFFXmg (ORCPT ); Tue, 6 Jun 2017 19:42:36 -0400 X-Original-SENDERIP: 156.147.1.151 X-Original-MAILFROM: byungchul.park@lge.com X-Original-SENDERIP: 165.244.249.26 X-Original-MAILFROM: byungchul.park@lge.com X-Original-SENDERIP: 10.177.222.33 X-Original-MAILFROM: byungchul.park@lge.com Date: Wed, 7 Jun 2017 08:42:24 +0900 From: Byungchul Park To: Juri Lelli CC: , , , , , Subject: Re: [PATCH 2/2] sched/deadline: Don't return invalid cpu in cpudl_maximum_cpu() Message-ID: <20170606234224.GD3623@X58A-UD3R> References: <1496388663-29067-1-git-send-email-byungchul.park@lge.com> <1496388663-29067-2-git-send-email-byungchul.park@lge.com> <20170606151225.xlhrnh2usajmlu52@e106622-lin> MIME-Version: 1.0 In-Reply-To: <20170606151225.xlhrnh2usajmlu52@e106622-lin> User-Agent: Mutt/1.5.21 (2010-09-15) X-MIMETrack: Itemize by SMTP Server on LGEKRMHUB04/LGE/LG Group(Release 8.5.3FP6|November 21, 2013) at 2017/06/07 08:42:31, Serialize by Router on LGEKRMHUB04/LGE/LG Group(Release 8.5.3FP6|November 21, 2013) at 2017/06/07 08:42:31, Serialize complete at 2017/06/07 08:42:31 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1047 Lines: 39 On Tue, Jun 06, 2017 at 04:12:25PM +0100, Juri Lelli wrote: > Hi, > > On 02/06/17 16:31, Byungchul Park wrote: > > When the heap tree is empty, cp->elements[0].cpu has meaningless value. Hi, The meaningless value is 0. > > 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? The function does not return -1 without my patch. Right? > > Thanks, > > - Juri