Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753440AbdCWKfj (ORCPT ); Thu, 23 Mar 2017 06:35:39 -0400 Received: from LGEAMRELO11.lge.com ([156.147.23.51]:38416 "EHLO lgeamrelo11.lge.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933162AbdCWKdZ (ORCPT ); Thu, 23 Mar 2017 06:33:25 -0400 X-Original-SENDERIP: 156.147.1.126 X-Original-MAILFROM: byungchul.park@lge.com X-Original-SENDERIP: 165.244.249.25 X-Original-MAILFROM: byungchul.park@lge.com X-Original-SENDERIP: 10.177.222.33 X-Original-MAILFROM: byungchul.park@lge.com From: Byungchul Park To: , CC: , , , Subject: [PATCH 6/8] sched/deadline: Don't return meaningless cpu in cpudl_maximum_cpu() Date: Thu, 23 Mar 2017 19:32:41 +0900 Message-ID: <1490265163-29981-7-git-send-email-byungchul.park@lge.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1490265163-29981-1-git-send-email-byungchul.park@lge.com> References: <1490265163-29981-1-git-send-email-byungchul.park@lge.com> X-MIMETrack: Itemize by SMTP Server on LGEKRMHUB07/LGE/LG Group(Release 8.5.3FP6|November 21, 2013) at 2017/03/23 19:33:19, Serialize by Router on LGEKRMHUB07/LGE/LG Group(Release 8.5.3FP6|November 21, 2013) at 2017/03/23 19:33:19, Serialize complete at 2017/03/23 19:33:19 MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1121 Lines: 34 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 | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/kernel/sched/cpudeadline.c b/kernel/sched/cpudeadline.c index 37bbb66..21404b8 100644 --- a/kernel/sched/cpudeadline.c +++ b/kernel/sched/cpudeadline.c @@ -107,7 +107,8 @@ static void cpudl_heapify(struct cpudl_item *e, int size, 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; } static inline u64 cpudl_maximum_dl(struct cpudl *cp) @@ -127,7 +128,8 @@ static int cpudl_fast_find(struct cpudl *cp, struct task_struct *p) max_dl = cpudl_maximum_dl(cp); raw_spin_unlock_irqrestore(&cp->lock, flags); - if (cpumask_test_cpu(max_cpu, &p->cpus_allowed) && + if (max_cpu != -1 && + cpumask_test_cpu(max_cpu, &p->cpus_allowed) && dl_time_before(dl_se->deadline, max_dl)) return max_cpu; -- 1.9.1