From patchwork Thu Nov 6 07:52:03 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "pang.xunlei" X-Patchwork-Id: 40254 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ee0-f72.google.com (mail-ee0-f72.google.com [74.125.83.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 126E3240B2 for ; Thu, 6 Nov 2014 07:53:12 +0000 (UTC) Received: by mail-ee0-f72.google.com with SMTP id d17sf1787073eek.3 for ; Wed, 05 Nov 2014 23:53:11 -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=hShtgXP1UPW/6G55tIHbSI/LuIk3rrzQK+SEsMC4HVs=; b=Gqpws/TOStDOWzX4Zt5eBgY3mvOpeg6ZwCUb5JuJWGLmnhnBASTxERFiKJez08g+0k 8q2ioOFBOUdijW/9XKZJleEOSJndCPuInRjS4qLHuVQ4Ei4trX3kOEhcfI5HDbWIQvQf dT6+wu25YIvAG7eohpbjLloen4YjEGA6TM6VOxk64ZYXzMJvOvUsCoSYGJRyJ/AgLP2O m1HVVSCDfxcYBXxtzA6mteLRH//KJVP0s0quKA79Vy0tjKCh6E1kW8dU50O+XKuE+erM DWT+dlOOVTESboaQ89elOj/RhBaoGq7VvIxrgtp4u9yS9MN3Bv+324ycUNwA3msRVq+Z e6vw== X-Gm-Message-State: ALoCoQl8YXIGlHmc03DEgMED/x6ZddEEFKfeVEB4OBb9S3ldDfNrHk4dY20x+EiOMBojPLNwQebm X-Received: by 10.180.100.100 with SMTP id ex4mr1675193wib.2.1415260391308; Wed, 05 Nov 2014 23:53:11 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.18.226 with SMTP id z2ls49417lad.13.gmail; Wed, 05 Nov 2014 23:53:11 -0800 (PST) X-Received: by 10.112.45.228 with SMTP id q4mr2985906lbm.35.1415260391024; Wed, 05 Nov 2014 23:53:11 -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 ei3si10156167lad.84.2014.11.05.23.53.11 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 05 Nov 2014 23:53:11 -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 pv20so2071921lab.39 for ; Wed, 05 Nov 2014 23:53:10 -0800 (PST) X-Received: by 10.112.12.35 with SMTP id v3mr3017169lbb.80.1415260390812; Wed, 05 Nov 2014 23:53:10 -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 ew9csp8577lbc; Wed, 5 Nov 2014 23:53:08 -0800 (PST) X-Received: by 10.67.5.41 with SMTP id cj9mr2584309pad.73.1415260387526; Wed, 05 Nov 2014 23:53:07 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id sz3si5111556pab.188.2014.11.05.23.53.06 for ; Wed, 05 Nov 2014 23:53: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 S1751626AbaKFHxE (ORCPT + 25 others); Thu, 6 Nov 2014 02:53:04 -0500 Received: from mail-pa0-f43.google.com ([209.85.220.43]:60505 "EHLO mail-pa0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751560AbaKFHxA (ORCPT ); Thu, 6 Nov 2014 02:53:00 -0500 Received: by mail-pa0-f43.google.com with SMTP id eu11so761842pac.2 for ; Wed, 05 Nov 2014 23:52:59 -0800 (PST) X-Received: by 10.70.124.137 with SMTP id mi9mr2564575pdb.91.1415260379925; Wed, 05 Nov 2014 23:52:59 -0800 (PST) Received: from wangdeqiang.com ([210.21.223.3]) by mx.google.com with ESMTPSA id yc4sm5168431pab.27.2014.11.05.23.52.56 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 05 Nov 2014 23:52:59 -0800 (PST) From: "pang.xunlei" To: linux-kernel@vger.kernel.org Cc: Peter Zijlstra , Steven Rostedt , Juri Lelli , "pang.xunlei" Subject: [PATCH v4 3/7] sched/rt: Optimize find_lowest_rq() to select a cache hot cpu Date: Thu, 6 Nov 2014 15:52:03 +0800 Message-Id: <1415260327-30465-3-git-send-email-pang.xunlei@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1415260327-30465-1-git-send-email-pang.xunlei@linaro.org> References: <1415260327-30465-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: , Add the case for iteration of sched_domains without SD_WAKE_AFFINE flags to select a cpu, this flag may be unset through proc by users. Signed-off-by: pang.xunlei --- kernel/sched/rt.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/kernel/sched/rt.c b/kernel/sched/rt.c index da6922e..49164f1 100644 --- a/kernel/sched/rt.c +++ b/kernel/sched/rt.c @@ -1549,6 +1549,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)) @@ -1581,7 +1582,7 @@ static int find_lowest_rq(struct task_struct *task) rcu_read_lock(); for_each_domain(cpu, sd) { if (sd->flags & SD_WAKE_AFFINE) { - int best_cpu; + int wakeaffine_cpu; /* * "this_cpu" is cheaper to preempt than a @@ -1593,16 +1594,25 @@ 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; } + } else { + /* affine domain outweighs lower level non-affine domain? */ + if (cachehot_cpu >= nr_cpu_ids) + cachehot_cpu = cpumask_first_and(lowest_mask, + sched_domain_span(sd)); } } 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