From patchwork Mon Jan 19 04:49:38 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "pang.xunlei" X-Patchwork-Id: 43290 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f199.google.com (mail-lb0-f199.google.com [209.85.217.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 768402034D for ; Mon, 19 Jan 2015 04:54:11 +0000 (UTC) Received: by mail-lb0-f199.google.com with SMTP id f15sf1655270lbj.2 for ; Sun, 18 Jan 2015 20:54:10 -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=cLKX1AnZq02VBq52tFgQVD0YvaxFJ0w7ifojFXr7rYI=; b=TAleM08LTOwO20UmahUGjZA/Bp/GDxzWzCTOX9OJ48UZ1brLqQAc/KoASasMp+wgLh Nq9dsWlf6Ek4UDKDcwoA6d39b0n5N9Nk1SqPs1IGMcO0hw09UJU2ZCxHl7MYI6mIPsR6 JuXhDsEHF0ttbI34SOIG3syA+fYUYEwmZLoiHLInB79cf2TTjYp9Uyxs7XojBWPwa4uw x7fFWuKerGidTjuGKCzg1UbG8K/0cMm0m1gAhyMRXXwd3xZXOeBiTcDYNRkXAaKA9DBy zvVffuA1LVa1VbK/LibfsHz+fJgADpfgNEMidTdBMaDqAMIubnX2flZQC4p+sbszgab1 l55g== X-Gm-Message-State: ALoCoQk8Oun4SGXolEI5dm4f7ye8ZVmIaXmz8Rbxfmam874nJLiUPZRF7m/j77yU71WVAGxJy0v7 X-Received: by 10.112.148.198 with SMTP id tu6mr3277000lbb.3.1421643250023; Sun, 18 Jan 2015 20:54:10 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.206.37 with SMTP id ll5ls603617lac.53.gmail; Sun, 18 Jan 2015 20:54:09 -0800 (PST) X-Received: by 10.112.140.196 with SMTP id ri4mr27564523lbb.55.1421643249683; Sun, 18 Jan 2015 20:54:09 -0800 (PST) Received: from mail-la0-f52.google.com (mail-la0-f52.google.com. [209.85.215.52]) by mx.google.com with ESMTPS id n7si11242363laf.123.2015.01.18.20.54.09 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 18 Jan 2015 20:54:09 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.52 as permitted sender) client-ip=209.85.215.52; Received: by mail-la0-f52.google.com with SMTP id hs14so26741073lab.11 for ; Sun, 18 Jan 2015 20:54:09 -0800 (PST) X-Received: by 10.152.6.132 with SMTP id b4mr28149335laa.59.1421643249520; Sun, 18 Jan 2015 20:54:09 -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.9.200 with SMTP id c8csp972937lbb; Sun, 18 Jan 2015 20:54:08 -0800 (PST) X-Received: by 10.68.131.39 with SMTP id oj7mr41050879pbb.145.1421643247699; Sun, 18 Jan 2015 20:54:07 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id px8si14268798pbb.206.2015.01.18.20.54.06; Sun, 18 Jan 2015 20:54:07 -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 S1752174AbbASEyC (ORCPT + 28 others); Sun, 18 Jan 2015 23:54:02 -0500 Received: from mail-qg0-f44.google.com ([209.85.192.44]:60422 "EHLO mail-qg0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751185AbbASEv4 (ORCPT ); Sun, 18 Jan 2015 23:51:56 -0500 Received: by mail-qg0-f44.google.com with SMTP id l89so14908781qgf.3 for ; Sun, 18 Jan 2015 20:51:56 -0800 (PST) X-Received: by 10.140.42.105 with SMTP id b96mr42531204qga.47.1421643116247; Sun, 18 Jan 2015 20:51:56 -0800 (PST) Received: from ip-10-181-65-231.ec2.internal ([54.235.93.228]) by mx.google.com with ESMTPSA id k91sm4332434qgf.48.2015.01.18.20.51.55 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 18 Jan 2015 20:51:55 -0800 (PST) From: Xunlei Pang To: linux-kernel@vger.kernel.org Cc: Peter Zijlstra , Juri Lelli , Xunlei Pang Subject: [PATCH 3/5] sched/deadline: Fix wrong cpudl_find() in check_preempt_equal_dl() Date: Mon, 19 Jan 2015 04:49:38 +0000 Message-Id: <1421642980-10045-3-git-send-email-pang.xunlei@linaro.org> X-Mailer: git-send-email 2.2.1 In-Reply-To: <1421642980-10045-1-git-send-email-pang.xunlei@linaro.org> References: <1421642980-10045-1-git-send-email-pang.xunlei@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: pang.xunlei@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.52 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org 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: , 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;