From patchwork Wed Nov 5 15:48: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: 40197 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f69.google.com (mail-la0-f69.google.com [209.85.215.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id A4BD62404A for ; Wed, 5 Nov 2014 15:49:10 +0000 (UTC) Received: by mail-la0-f69.google.com with SMTP id q1sf660899lam.4 for ; Wed, 05 Nov 2014 07:49:09 -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=TLKlDRg3kEHsT7z37WwR+AKQAg6QfN3PvNWhez6JlHg=; b=Vr64ikHaUBJek1ozGIgVQcHmr57gxcIKsgx5G70YqDqw21/Xw58rkEev5L1ugnxbbH 1G+9FyWw7URGOERtV1SC/qVH8bKsysAiTDaG6nw0znQle4/oD8R+89Dy9yoQKU4+qi5R +acVWWkcjXYlOGSEy2JuHcL4TZK7CNdSsPrBo1S1rYwzcxJe+QrqsOM+ugP0Cju3HqxF cfu0YNn1Jg2dsMUMxhw08ZmeeqXvVck3bZFXUWO9JYjrlxg4WT9+sQneo3js1LTvUBY4 z1VJS1OnINfD57/7qrtUYaLBSmtXjHoQsJcB0qQe7t0ybvhPvJyer9CFG+NzVQZKhABN 2BRA== X-Gm-Message-State: ALoCoQmwxDwu1dY2Z32WzGKPsNJe6D4vDTDqVCrlQvjfG541u3r2CK9ATYjbo9bRGU4DF35f5Mer X-Received: by 10.194.178.163 with SMTP id cz3mr10020278wjc.1.1415202549724; Wed, 05 Nov 2014 07:49:09 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.6.227 with SMTP id e3ls1092926laa.69.gmail; Wed, 05 Nov 2014 07:49:09 -0800 (PST) X-Received: by 10.112.150.136 with SMTP id ui8mr68678992lbb.60.1415202549532; Wed, 05 Nov 2014 07:49:09 -0800 (PST) Received: from mail-lb0-f177.google.com (mail-lb0-f177.google.com. [209.85.217.177]) by mx.google.com with ESMTPS id at1si6962821lbc.2.2014.11.05.07.49.09 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 05 Nov 2014 07:49:09 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.177 as permitted sender) client-ip=209.85.217.177; Received: by mail-lb0-f177.google.com with SMTP id z12so864177lbi.8 for ; Wed, 05 Nov 2014 07:49:09 -0800 (PST) X-Received: by 10.112.77.74 with SMTP id q10mr68052405lbw.66.1415202548930; Wed, 05 Nov 2014 07:49:08 -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 ew9csp303317lbc; Wed, 5 Nov 2014 07:49:08 -0800 (PST) X-Received: by 10.70.88.165 with SMTP id bh5mr20194585pdb.51.1415202546776; Wed, 05 Nov 2014 07:49:06 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ks5si3426744pdb.42.2014.11.05.07.49.06 for ; Wed, 05 Nov 2014 07:49:06 -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 S1755476AbaKEPs6 (ORCPT + 25 others); Wed, 5 Nov 2014 10:48:58 -0500 Received: from mail-pa0-f54.google.com ([209.85.220.54]:62078 "EHLO mail-pa0-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755424AbaKEPsz (ORCPT ); Wed, 5 Nov 2014 10:48:55 -0500 Received: by mail-pa0-f54.google.com with SMTP id rd3so1020317pab.13 for ; Wed, 05 Nov 2014 07:48:55 -0800 (PST) X-Received: by 10.67.30.232 with SMTP id kh8mr2409878pad.149.1415202534998; Wed, 05 Nov 2014 07:48:54 -0800 (PST) Received: from vptest-PC.zte.com.cn ([167.160.116.59]) by mx.google.com with ESMTPSA id e9sm3517098pdp.59.2014.11.05.07.48.50 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 05 Nov 2014 07:48:54 -0800 (PST) From: "pang.xunlei" To: linux-kernel@vger.kernel.org Cc: Peter Zijlstra , Steven Rostedt , Juri Lelli , "pang.xunlei" Subject: [PATCH v3 3/7] sched/rt: Optimize find_lowest_rq() to select a cache hot cpu Date: Wed, 5 Nov 2014 23:48:22 +0800 Message-Id: <1415202506-7800-3-git-send-email-pang.xunlei@linaro.org> X-Mailer: git-send-email 2.0.4 In-Reply-To: <1415202506-7800-1-git-send-email-pang.xunlei@linaro.org> References: <1415202506-7800-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.177 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