From patchwork Wed Nov 19 15:46:22 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "pang.xunlei" X-Patchwork-Id: 41186 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f72.google.com (mail-la0-f72.google.com [209.85.215.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id BCFF5241C9 for ; Wed, 19 Nov 2014 15:47:14 +0000 (UTC) Received: by mail-la0-f72.google.com with SMTP id mc6sf615424lab.3 for ; Wed, 19 Nov 2014 07:47:13 -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=P0XXAinnFtfMAR2L96clQRKZSytmncuJR6HoeK+Q9z0=; b=EvQmGbVxuPQFI8Pil52YK44cPFI11Td+hr4SWQdDyyF7EFc8uG+GfNSbSSVjGt0eSg TwG4x3Tcgo6ac6xVASnDEma73A93yN1WUT66d1JYQrGqA1HmWxW7QGF0Yek/TjU9XyZI y/SVcv/nz2lz0kD5muZTxBF+OKhOe97oFIwptGlfb5LT5gYHowL3v6xBAVGgn1adN6bM MuLRv/nlcXbbcWxNGQgLrH+wD4q8/V4yC7TisVD5GSfqSGQ00ib8N6R0txCuBMXemLwS X8psD/P4IkeLlGTi5UxfQWYfEvP5aE52wRCH6eaXnVRQXcnepsmQvAgyfsuhBB+4bpli Hj2w== X-Gm-Message-State: ALoCoQmSOgGOy+E8zoYOhTU4WU0jxfP/L/+RLyqvQaiBo7mod1et7fLZ1RPmXLhD73imyN1oyNZD X-Received: by 10.181.13.147 with SMTP id ey19mr5430187wid.2.1416412033772; Wed, 19 Nov 2014 07:47:13 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.87.176 with SMTP id az16ls305696lab.87.gmail; Wed, 19 Nov 2014 07:47:13 -0800 (PST) X-Received: by 10.152.120.73 with SMTP id la9mr42910817lab.23.1416412033419; Wed, 19 Nov 2014 07:47:13 -0800 (PST) Received: from mail-lb0-f178.google.com (mail-lb0-f178.google.com. [209.85.217.178]) by mx.google.com with ESMTPS id y4si2128273lae.120.2014.11.19.07.47.13 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 19 Nov 2014 07:47:13 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.178 as permitted sender) client-ip=209.85.217.178; Received: by mail-lb0-f178.google.com with SMTP id f15so798153lbj.9 for ; Wed, 19 Nov 2014 07:47:13 -0800 (PST) X-Received: by 10.112.45.102 with SMTP id l6mr6018933lbm.46.1416412033332; Wed, 19 Nov 2014 07:47:13 -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.184.201 with SMTP id ew9csp105754lbc; Wed, 19 Nov 2014 07:47:12 -0800 (PST) X-Received: by 10.68.246.229 with SMTP id xz5mr21701790pbc.131.1416412030336; Wed, 19 Nov 2014 07:47:10 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id gy3si933937pac.10.2014.11.19.07.47.09 for ; Wed, 19 Nov 2014 07:47:10 -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 S1756151AbaKSPrG (ORCPT + 26 others); Wed, 19 Nov 2014 10:47:06 -0500 Received: from mail-pa0-f42.google.com ([209.85.220.42]:59469 "EHLO mail-pa0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756065AbaKSPrD (ORCPT ); Wed, 19 Nov 2014 10:47:03 -0500 Received: by mail-pa0-f42.google.com with SMTP id et14so470327pad.29 for ; Wed, 19 Nov 2014 07:47:02 -0800 (PST) X-Received: by 10.68.129.69 with SMTP id nu5mr47354096pbb.51.1416412022690; Wed, 19 Nov 2014 07:47:02 -0800 (PST) Received: from vptest-PC.zte.com.cn ([167.160.116.27]) by mx.google.com with ESMTPSA id r2sm2136022pdi.60.2014.11.19.07.46.58 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 19 Nov 2014 07:47:02 -0800 (PST) From: "pang.xunlei" To: linux-kernel@vger.kernel.org Cc: Peter Zijlstra , Steven Rostedt , Juri Lelli , "pang.xunlei" Subject: [PATCH v2 4/4] sched/deadline: change cpudl_find() to return bool instead of best_cpu Date: Wed, 19 Nov 2014 23:46:22 +0800 Message-Id: <1416411982-1204-4-git-send-email-pang.xunlei@linaro.org> X-Mailer: git-send-email 2.0.4 In-Reply-To: <1416411982-1204-1-git-send-email-pang.xunlei@linaro.org> References: <1416411982-1204-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.217.178 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: , cpudl_find() is not a good place to select the best cpu, so leave this role to its call site, currently it is find_later_rq() where we can do the election of the best cpu according to sd topology. Signed-off-by: pang.xunlei --- kernel/sched/cpudeadline.c | 15 +++++---------- kernel/sched/deadline.c | 17 ++++++----------- 2 files changed, 11 insertions(+), 21 deletions(-) diff --git a/kernel/sched/cpudeadline.c b/kernel/sched/cpudeadline.c index 3047846..41d3578 100644 --- a/kernel/sched/cpudeadline.c +++ b/kernel/sched/cpudeadline.c @@ -100,29 +100,24 @@ static inline int cpudl_maximum(struct cpudl *cp) * @later_mask: a mask to fill in with the selected CPUs (not NULL) * @set_flag: indicate if later_mask should be set * - * Returns: int - best CPU (heap maximum if suitable) + * Return: (int)bool - CPUs were found */ int cpudl_find(struct cpudl *cp, struct task_struct *p, struct cpumask *later_mask, int set_flag) { - int best_cpu = -1; const struct sched_dl_entity *dl_se = &p->dl; cpumask_and(later_mask, cpu_active_mask, &p->cpus_allowed); if (cpumask_and(later_mask, later_mask, cp->free_cpus)) { - best_cpu = cpumask_any(later_mask); - goto out; + return 1; } 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 (set_flag) - cpumask_set_cpu(best_cpu, later_mask); + cpumask_set_cpu(cpudl_maximum(cp), later_mask); + return 1; } -out: - WARN_ON(best_cpu != -1 && !cpu_present(best_cpu)); - - return best_cpu; + return 0; } /* diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c index e8208d0..3e82cf3 100644 --- a/kernel/sched/deadline.c +++ b/kernel/sched/deadline.c @@ -976,7 +976,7 @@ static void check_preempt_equal_dl(struct rq *rq, struct task_struct *p) * let's hope p can move out. */ if (rq->curr->nr_cpus_allowed == 1 || - cpudl_find(&rq->rd->cpudl, rq->curr, later_mask, 0) == -1) + !cpudl_find(&rq->rd->cpudl, rq->curr, later_mask, 0)) return; /* @@ -984,7 +984,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, later_mask, 0) != -1) + cpudl_find(&rq->rd->cpudl, p, later_mask, 0)) return; resched_curr(rq); @@ -1189,9 +1189,7 @@ static int find_later_rq(struct task_struct *task) * We have to consider system topology and task affinity * first, then we can look for a suitable cpu. */ - best_cpu = cpudl_find(&task_rq(task)->rd->cpudl, - task, later_mask, 1); - if (best_cpu == -1) + if (!cpudl_find(&task_rq(task)->rd->cpudl, task, later_mask, 1)) return -1; /* @@ -1230,12 +1228,9 @@ static int find_later_rq(struct task_struct *task) return this_cpu; } - /* - * Last chance: if best_cpu is valid and is - * in the mask, that becomes our choice. - */ - if (best_cpu < nr_cpu_ids && - cpumask_test_cpu(best_cpu, sched_domain_span(sd))) { + best_cpu = cpumask_first_and(lowest_mask, + sched_domain_span(sd)); + if (best_cpu < nr_cpu_ids) { rcu_read_unlock(); return best_cpu; }