From patchwork Mon Jan 19 04:49:40 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "pang.xunlei" X-Patchwork-Id: 43289 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wg0-f70.google.com (mail-wg0-f70.google.com [74.125.82.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 620412034D for ; Mon, 19 Jan 2015 04:52:44 +0000 (UTC) Received: by mail-wg0-f70.google.com with SMTP id y19sf15441950wgg.1 for ; Sun, 18 Jan 2015 20:52:43 -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=aogc6mAsDA7C0u6V5jGvJBneJTUID5slIl9WkvhWLKs=; b=mOlhjoq6h0uJ9rAId2uTJS/Bv6D6UMGgky+OxibAMsLWCo9ttTK3fH03PBCMGz3WLp YxxIUvBt4WYQlKOiyfsUM22dCQ50M1AByZ1vmBTfLcy0aFmBb/tQTpeYYEpCRyv/nr5D PSwIWJi7XJf4mEqujXs2TMEILJQk8qI/QLg+MqEzYZcuoo7EHPzCLBVQSfgOkg2GQewi g0cBCt92KhdADliRroA5PFv1aCUm2L8czlCzjurAVJyRMTi64t5tvBSuD0AKMGtBEctN cfD1Xz7NL9Ja6G+eJ2Uen2pDVvGiJEzpwj9EMvNXjLnI4OiKB4lQU7gCwk7nKTGtSuZB /ojA== X-Gm-Message-State: ALoCoQlUoflSR/LJjXtv1QD7W7QcNvU8Q+NP1mw1JbuH5n7JE/hj6mi81kOnHhx68b0ae2tk/BXd X-Received: by 10.194.204.201 with SMTP id la9mr4740wjc.6.1421643163672; Sun, 18 Jan 2015 20:52:43 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.6.229 with SMTP id e5ls416871laa.105.gmail; Sun, 18 Jan 2015 20:52:43 -0800 (PST) X-Received: by 10.112.44.230 with SMTP id h6mr118847lbm.98.1421643163461; Sun, 18 Jan 2015 20:52:43 -0800 (PST) Received: from mail-la0-f47.google.com (mail-la0-f47.google.com. [209.85.215.47]) by mx.google.com with ESMTPS id em9si9848573lbc.102.2015.01.18.20.52.43 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 18 Jan 2015 20:52:43 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.47 as permitted sender) client-ip=209.85.215.47; Received: by mail-la0-f47.google.com with SMTP id hz20so26729646lab.6 for ; Sun, 18 Jan 2015 20:52:43 -0800 (PST) X-Received: by 10.112.98.99 with SMTP id eh3mr27357815lbb.32.1421643163047; Sun, 18 Jan 2015 20:52:43 -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 c8csp972709lbb; Sun, 18 Jan 2015 20:52:42 -0800 (PST) X-Received: by 10.66.163.137 with SMTP id yi9mr40476927pab.58.1421643161194; Sun, 18 Jan 2015 20:52:41 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id nl8si14208457pbc.250.2015.01.18.20.52.40; Sun, 18 Jan 2015 20:52:41 -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 S1751908AbbASEwh (ORCPT + 28 others); Sun, 18 Jan 2015 23:52:37 -0500 Received: from mail-qa0-f46.google.com ([209.85.216.46]:51894 "EHLO mail-qa0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751128AbbASEv6 (ORCPT ); Sun, 18 Jan 2015 23:51:58 -0500 Received: by mail-qa0-f46.google.com with SMTP id j7so22449009qaq.5 for ; Sun, 18 Jan 2015 20:51:57 -0800 (PST) X-Received: by 10.140.41.113 with SMTP id y104mr32980798qgy.51.1421643117678; Sun, 18 Jan 2015 20:51:57 -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.56 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 18 Jan 2015 20:51:57 -0800 (PST) From: Xunlei Pang To: linux-kernel@vger.kernel.org Cc: Peter Zijlstra , Juri Lelli , Xunlei Pang Subject: [PATCH 5/5] sched/rt: Optimize find_lowest_rq() to select a cache hot cpu Date: Mon, 19 Jan 2015 04:49:40 +0000 Message-Id: <1421642980-10045-5-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.47 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 find_lowest_rq(), if we can't find a wake_affine cpu from sched_domain, then we can actually determine a cache hot cpu instead of simply calling "cpumask_any(lowest_mask)" which always returns the first cpu in the mask. So, we can determine the cache hot cpu during the interation of sched_domain() in passing. Signed-off-by: Xunlei Pang --- kernel/sched/rt.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/kernel/sched/rt.c b/kernel/sched/rt.c index d28cfa4..e6a42e6 100644 --- a/kernel/sched/rt.c +++ b/kernel/sched/rt.c @@ -1535,6 +1535,7 @@ static int find_lowest_rq(struct task_struct *task) struct cpumask *lowest_mask = this_cpu_cpumask_var_ptr(local_cpu_mask); int this_cpu = smp_processor_id(); int cpu = task_cpu(task); + int cachehot_cpu = nr_cpu_ids; /* Make sure the mask is initialized first */ if (unlikely(!lowest_mask)) @@ -1566,8 +1567,12 @@ static int find_lowest_rq(struct task_struct *task) rcu_read_lock(); for_each_domain(cpu, sd) { + if (cachehot_cpu >= nr_cpu_ids) + cachehot_cpu = cpumask_first_and(lowest_mask, + sched_domain_span(sd)); + if (sd->flags & SD_WAKE_AFFINE) { - int best_cpu; + int wakeaffine_cpu; /* * "this_cpu" is cheaper to preempt than a @@ -1579,16 +1584,20 @@ static int find_lowest_rq(struct task_struct *task) return this_cpu; } - best_cpu = cpumask_first_and(lowest_mask, + wakeaffine_cpu = cpumask_first_and(lowest_mask, sched_domain_span(sd)); - if (best_cpu < nr_cpu_ids) { + if (wakeaffine_cpu < nr_cpu_ids) { rcu_read_unlock(); - return best_cpu; + return wakeaffine_cpu; } } } rcu_read_unlock(); + /* most likely cache-hot */ + if (cachehot_cpu < nr_cpu_ids) + return cachehot_cpu; + /* * And finally, if there were no matches within the domains * just give the caller *something* to work with from the compatible