From patchwork Wed Mar 18 13:24:29 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xunlei Pang X-Patchwork-Id: 45942 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f199.google.com (mail-wi0-f199.google.com [209.85.212.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id C905B2153C for ; Wed, 18 Mar 2015 13:27:01 +0000 (UTC) Received: by wivz2 with SMTP id z2sf7643190wiv.1 for ; Wed, 18 Mar 2015 06:27:01 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:sender:precedence:list-id:x-original-sender :x-original-authentication-results:mailing-list:list-post:list-help :list-archive:list-unsubscribe; bh=ONFII+knL81CRQa3vpSj/6EIxkRdeKtYgw2bkQimXIo=; b=MMNyi7iqVVdtvkXvU7C7KQJG9KlDv2AYsHcPe8dTB8UiMIofTdbluPALF1bvyVAVMB FIVEe0oLenQb13UcGUXhB86kOLNySfJDnrj2StO3zDo8pEAvuw5rU6QsZzwvk+8+cx53 jWJPs4190UVtB5HjdGFl+5CL5gIe9qUja/uSmkWZehNZJAgOvTcx4HrNp/OAUABvZQSN JaGcYTqhmDiBIv4OThcSj6o2E59iLFlU+tqOb58W39yp7SdiDgxA6zUotx1p1fW/UtTr n6FZCdi7VKw93t6AwugJ+ZxbV7VI4/MECn/q2Scan9e4fiiBUq0tNl4Rs3SikKmMnh+b u2Nw== X-Gm-Message-State: ALoCoQk+U0g84O3t+DJumgzSe7Cl00e02r+oyvU0rgo//A/sZVWbEfVnWYVcavH7qnQhgg74OsXx X-Received: by 10.112.40.81 with SMTP id v17mr7098565lbk.5.1426685220971; Wed, 18 Mar 2015 06:27:00 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.43.10 with SMTP id s10ls161239lal.81.gmail; Wed, 18 Mar 2015 06:27:00 -0700 (PDT) X-Received: by 10.152.219.2 with SMTP id pk2mr63457032lac.107.1426685220729; Wed, 18 Mar 2015 06:27:00 -0700 (PDT) Received: from mail-lb0-x22b.google.com (mail-lb0-x22b.google.com. [2a00:1450:4010:c04::22b]) by mx.google.com with ESMTPS id k3si12913462lak.38.2015.03.18.06.27.00 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 18 Mar 2015 06:27:00 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2a00:1450:4010:c04::22b as permitted sender) client-ip=2a00:1450:4010:c04::22b; Received: by lbnq5 with SMTP id q5so1331020lbn.0 for ; Wed, 18 Mar 2015 06:27:00 -0700 (PDT) X-Received: by 10.112.150.39 with SMTP id uf7mr14708657lbb.72.1426685220447; Wed, 18 Mar 2015 06:27:00 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.35.133 with SMTP id h5csp1155977lbj; Wed, 18 Mar 2015 06:26:59 -0700 (PDT) X-Received: by 10.70.48.5 with SMTP id h5mr124430304pdn.58.1426685216000; Wed, 18 Mar 2015 06:26:56 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id lx1si17959946pdb.68.2015.03.18.06.26.54; Wed, 18 Mar 2015 06:26:55 -0700 (PDT) Received-SPF: none (google.com: linux-kernel-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756279AbbCRN0s (ORCPT + 27 others); Wed, 18 Mar 2015 09:26:48 -0400 Received: from m50-110.126.com ([123.125.50.110]:47837 "EHLO m50-110.126.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756051AbbCRN0o (ORCPT ); Wed, 18 Mar 2015 09:26:44 -0400 Received: from localhost.localdomain (unknown [210.21.223.3]) by smtp4 (Coremail) with SMTP id jdKowAD3aGCWfAlVIG56AQ--.331S2; Wed, 18 Mar 2015 21:24:54 +0800 (CST) From: Xunlei Pang To: linux-kernel@vger.kernel.org Cc: Peter Zijlstra , Steven Rostedt , Juri Lelli , Xunlei Pang Subject: [PATCH RESEND 1/2] sched/deadline: Fix wrong cpudl_find() in check_preempt_equal_dl() Date: Wed, 18 Mar 2015 21:24:29 +0800 Message-Id: <1426685070-4419-1-git-send-email-xlpang@126.com> X-Mailer: git-send-email 1.9.1 X-CM-TRANSID: jdKowAD3aGCWfAlVIG56AQ--.331S2 X-Coremail-Antispam: 1Uf129KBjvJXoWxJw4UWFWkKr1UJw1UXF1UZFb_yoW5Aw45pF 17K3y7Ar4DJFWrJ34Yyr4kZw4fuwn3J34vvFySga9YyFZ5tr1SqF98ta13Xry5GFs5ur47 tFWjgr92g34jyrJanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07jgVyxUUUUU= X-Originating-IP: [210.21.223.3] X-CM-SenderInfo: p0ost0bj6rjloofrz/1tbi7wfAv00vbiOUYQAAsN Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Original-Sender: xlpang@126.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2a00:1450:4010:c04::22b as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org; dkim=neutral (body hash did not verify) header.i=@; dmarc=fail (p=NONE dis=NONE) header.from=126.com Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , From: Xunlei Pang In check_preempt_equal_dl(), cpudl_find() is called with a NULL later_mask, thus cpudl_find() here doesn't check cpudl::free_cpus at all. This patch takles this issue by always passing a non-NULL later_mask to cpudl_find(), thereby fixing this issue. Signed-off-by: Xunlei Pang --- kernel/sched/cpudeadline.c | 8 +++----- kernel/sched/deadline.c | 15 +++++++++++---- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/kernel/sched/cpudeadline.c b/kernel/sched/cpudeadline.c index c6acb07..f331fcf 100644 --- a/kernel/sched/cpudeadline.c +++ b/kernel/sched/cpudeadline.c @@ -97,7 +97,7 @@ static inline int cpudl_maximum(struct cpudl *cp) * cpudl_find - find the best (later-dl) CPU in the system * @cp: the cpudl max-heap context * @p: the task - * @later_mask: a mask to fill in with the selected CPUs (or NULL) + * @later_mask: a mask to fill in with the selected CPUs (not NULL) * * Returns: int - best CPU (heap maximum if suitable) */ @@ -107,15 +107,13 @@ int cpudl_find(struct cpudl *cp, struct task_struct *p, int best_cpu = -1; const struct sched_dl_entity *dl_se = &p->dl; - if (later_mask && - cpumask_and(later_mask, cp->free_cpus, &p->cpus_allowed)) { + if (cpumask_and(later_mask, cp->free_cpus, &p->cpus_allowed)) { best_cpu = cpumask_any(later_mask); goto out; } else if (cpumask_test_cpu(cpudl_maximum(cp), &p->cpus_allowed) && dl_time_before(dl_se->deadline, cp->elements[0].dl)) { best_cpu = cpudl_maximum(cp); - if (later_mask) - cpumask_set_cpu(best_cpu, later_mask); + cpumask_set_cpu(best_cpu, later_mask); } out: diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c index 0a81a95..256099c 100644 --- a/kernel/sched/deadline.c +++ b/kernel/sched/deadline.c @@ -964,14 +964,23 @@ out: return cpu; } +static DEFINE_PER_CPU(cpumask_var_t, local_cpu_mask_dl); + static void check_preempt_equal_dl(struct rq *rq, struct task_struct *p) { + struct cpumask *later_mask = + this_cpu_cpumask_var_ptr(local_cpu_mask_dl); + + /* Make sure the mask is initialized first */ + if (unlikely(!later_mask)) + return; + /* * Current can't be migrated, useless to reschedule, * let's hope p can move out. */ if (rq->curr->nr_cpus_allowed == 1 || - cpudl_find(&rq->rd->cpudl, rq->curr, NULL) == -1) + cpudl_find(&rq->rd->cpudl, rq->curr, later_mask) == -1) return; /* @@ -979,7 +988,7 @@ static void check_preempt_equal_dl(struct rq *rq, struct task_struct *p) * see if it is pushed or pulled somewhere else. */ if (p->nr_cpus_allowed != 1 && - cpudl_find(&rq->rd->cpudl, p, NULL) != -1) + cpudl_find(&rq->rd->cpudl, p, later_mask) != -1) return; resched_curr(rq); @@ -1173,8 +1182,6 @@ next_node: return NULL; } -static DEFINE_PER_CPU(cpumask_var_t, local_cpu_mask_dl); - static int find_later_rq(struct task_struct *task) { struct sched_domain *sd;