From patchwork Thu Jan 29 15:53:19 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xunlei Pang X-Patchwork-Id: 43948 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 65C332410D for ; Thu, 29 Jan 2015 15:59:01 +0000 (UTC) Received: by mail-wi0-f199.google.com with SMTP id r20sf13965303wiv.2 for ; Thu, 29 Jan 2015 07:59:00 -0800 (PST) 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:in-reply-to:references:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=AYVa0WWytZW1zkxhbjOSkajBqiHtva18g0MyKQ24y18=; b=gkpmZ6xlkD84yLKVACs+jPM4YRMsn/vz0yXmuwb1D7q3fE+xYqIpT1nf3jT7jIhdV9 IvG+OeegaNMrK7yXXNnMEklKu8HF/AnoeTVtHUSdI/FnlGRnZt1AVDIpxn8Ov2aQ/4WI 9raNneWXN5KWuIdDqIzFtk5S6y9k0iYhzpUbHMkPqXgoDVwssFbQqr0eCe95+hCgZUSp Ujy6wtsZXkQVox9cCqk0rS/iqaaHl96aMDSemJhIG+Kwu8pVJKe6eS65peOB8POnoL+h segp7ZG2oMol54mISqcHAHnHTFv4azAuXP8h7djepvFt2oWK7kkO0jm4KwX8pUg5EqX2 k+WA== X-Gm-Message-State: ALoCoQlRbw2YH/r28f/JaqUMpChQ3eRSKa+sR19lRjIZp1PF57Gw1ybkdnAOyib6V/3jgkqhcqzA X-Received: by 10.194.201.10 with SMTP id jw10mr205171wjc.3.1422547140647; Thu, 29 Jan 2015 07:59:00 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.87.234 with SMTP id bb10ls321903lab.90.gmail; Thu, 29 Jan 2015 07:59:00 -0800 (PST) X-Received: by 10.112.213.38 with SMTP id np6mr1800962lbc.36.1422547140382; Thu, 29 Jan 2015 07:59:00 -0800 (PST) Received: from mail-lb0-x22a.google.com (mail-lb0-x22a.google.com. [2a00:1450:4010:c04::22a]) by mx.google.com with ESMTPS id m1si7775767lae.105.2015.01.29.07.58.59 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 29 Jan 2015 07:59:00 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2a00:1450:4010:c04::22a as permitted sender) client-ip=2a00:1450:4010:c04::22a; Received: by mail-lb0-f170.google.com with SMTP id w7so29632083lbi.1 for ; Thu, 29 Jan 2015 07:58:59 -0800 (PST) X-Received: by 10.152.6.132 with SMTP id b4mr1622282laa.59.1422547139895; Thu, 29 Jan 2015 07:58:59 -0800 (PST) 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 h5csp1805925lbj; Thu, 29 Jan 2015 07:58:58 -0800 (PST) X-Received: by 10.68.134.74 with SMTP id pi10mr1971760pbb.4.1422547137301; Thu, 29 Jan 2015 07:58:57 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c4si10400759pas.96.2015.01.29.07.58.54; Thu, 29 Jan 2015 07:58:57 -0800 (PST) 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 S1754564AbbA2P6v (ORCPT + 29 others); Thu, 29 Jan 2015 10:58:51 -0500 Received: from m50-111.126.com ([123.125.50.111]:41897 "EHLO m50-111.126.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752375AbbA2P6t (ORCPT ); Thu, 29 Jan 2015 10:58:49 -0500 Received: from localhost.localdomain (unknown [210.21.223.3]) by smtp5 (Coremail) with SMTP id jtKowABHc+eGV8pUbY0NDQ--.885S4; Thu, 29 Jan 2015 23:53:56 +0800 (CST) From: Xunlei Pang To: linux-kernel@vger.kernel.org Cc: Peter Zijlstra , Steven Rostedt , Juri Lelli , Xunlei Pang Subject: [PATCH v2 3/4] sched/deadline: Fix wrong cpudl_find() in check_preempt_equal_dl() Date: Thu, 29 Jan 2015 23:53:19 +0800 Message-Id: <1422546800-2935-3-git-send-email-xlpang@126.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1422546800-2935-1-git-send-email-xlpang@126.com> References: <1422546800-2935-1-git-send-email-xlpang@126.com> X-CM-TRANSID: jtKowABHc+eGV8pUbY0NDQ--.885S4 X-Coremail-Antispam: 1Uf129KBjvJXoWxJw4UWFWkKr1UJw1UXF1UZFb_yoW5Aw45pF 17K3y7Ar4UJFWrJ345Aw4kZw4fuwn3J3sYvrySga9YyFZ5tr1SqF98ta43Xry5GFs5ur47 tFWjgr92g34jyrJanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07jLWrXUUUUU= X-Originating-IP: [210.21.223.3] X-CM-SenderInfo: p0ost0bj6rjloofrz/1tbiWxSQv1PM683UfQAAsw 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::22a 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 e7b2722..82d900f 100644 --- a/kernel/sched/deadline.c +++ b/kernel/sched/deadline.c @@ -943,14 +943,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; /* @@ -958,7 +967,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); @@ -1145,8 +1154,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;