From patchwork Mon May 18 05:13:27 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 48671 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f70.google.com (mail-la0-f70.google.com [209.85.215.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 4345B21411 for ; Mon, 18 May 2015 05:14:17 +0000 (UTC) Received: by lagv1 with SMTP id v1sf6698248lag.1 for ; Sun, 17 May 2015 22:14:16 -0700 (PDT) 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: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=qhHYBX9uszkOiwnqwmwPPJz25VMMDuEgyr4n6Aqk3dg=; b=A6lI5jGhl1D2pz95e1CN5WI6QkuKWkPBdlwiLM3eqYJFY4vH0UsW9HH1ljXto6qbG1 5H4RD0ErJ3h8FqM6PiAsz9I1HohiTQbSK+0TB7RfPpBnMDQOiebmPAh2e/bn+e+t6P1D yZ5FrDa0OMkoun31XY4GN22TBQbmORkI/TtNTeNqHe6JxDoJiV3+t+hEP5OMdQn6LmNT iXh4sa7eIHfsJq3ks0hKev2lLNJ8nDXzMMZRSPPRWwb9YlFGlbR+eXs8ln8vYRY43moG FrEo7BgkM5SOVwF9uetgi8MQ6ftZucWnTvCLBtuRF7UiR197CvmSbK0n+PNwO3ogActH 7c6A== X-Gm-Message-State: ALoCoQnjUOqUaknjAknde6zPKg9okc8WilN/VqkWD7+FP5nPR4EZZMVKDM+7kVh57F/nnh6htpAQ X-Received: by 10.180.97.9 with SMTP id dw9mr8617239wib.2.1431926056247; Sun, 17 May 2015 22:14:16 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.87.171 with SMTP id az11ls292715lab.107.gmail; Sun, 17 May 2015 22:14:16 -0700 (PDT) X-Received: by 10.152.2.227 with SMTP id 3mr16019103lax.73.1431926056085; Sun, 17 May 2015 22:14:16 -0700 (PDT) Received: from mail-la0-f45.google.com (mail-la0-f45.google.com. [209.85.215.45]) by mx.google.com with ESMTPS id y9si5947455lbo.119.2015.05.17.22.14.16 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 17 May 2015 22:14:16 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.45 as permitted sender) client-ip=209.85.215.45; Received: by laat2 with SMTP id t2so201802280laa.1 for ; Sun, 17 May 2015 22:14:16 -0700 (PDT) X-Received: by 10.112.222.133 with SMTP id qm5mr16088145lbc.86.1431926055949; Sun, 17 May 2015 22:14:15 -0700 (PDT) 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.108.230 with SMTP id hn6csp3711438lbb; Sun, 17 May 2015 22:14:14 -0700 (PDT) X-Received: by 10.68.69.35 with SMTP id b3mr10037503pbu.144.1431926054221; Sun, 17 May 2015 22:14:14 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id iu9si2678127pbc.77.2015.05.17.22.14.06; Sun, 17 May 2015 22:14:14 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751946AbbERFOG (ORCPT + 11 others); Mon, 18 May 2015 01:14:06 -0400 Received: from mail-pa0-f51.google.com ([209.85.220.51]:33081 "EHLO mail-pa0-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751285AbbERFOF (ORCPT ); Mon, 18 May 2015 01:14:05 -0400 Received: by padbw4 with SMTP id bw4so136044311pad.0 for ; Sun, 17 May 2015 22:14:05 -0700 (PDT) X-Received: by 10.70.47.68 with SMTP id b4mr41035890pdn.33.1431926044994; Sun, 17 May 2015 22:14:04 -0700 (PDT) Received: from localhost ([122.167.226.34]) by mx.google.com with ESMTPSA id fe10sm8604074pdb.59.2015.05.17.22.14.03 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Sun, 17 May 2015 22:14:04 -0700 (PDT) From: Viresh Kumar To: Rafael Wysocki Cc: linaro-kernel@lists.linaro.org, linux-pm@vger.kernel.org, sboyd@codeaurora.org, prarit@redhat.com, skannan@codeaurora.org, Srivatsa Bhat , Viresh Kumar Subject: [PATCH V5 04/14] cpufreq: Don't traverse all active policies to find policy for a cpu Date: Mon, 18 May 2015 10:43:27 +0530 Message-Id: X-Mailer: git-send-email 2.4.0 In-Reply-To: References: In-Reply-To: References: Sender: linux-pm-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: viresh.kumar@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.45 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: , We reach here while adding policy for a CPU and enter into the 'if' block only if a policy already exists for the CPU. As cpufreq_cpu_data is set for all policy->related_cpus now, when the policy is first added, we can use that to find the CPU's policy instead of traversing the list of all active policies. Acked-by: Saravana Kannan Signed-off-by: Viresh Kumar --- drivers/cpufreq/cpufreq.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index eb0c3a802b14..e6a63d6ba6f1 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -1213,16 +1213,13 @@ static int cpufreq_add_dev(struct device *dev, struct subsys_interface *sif) return 0; /* Check if this CPU already has a policy to manage it */ - read_lock_irqsave(&cpufreq_driver_lock, flags); - for_each_active_policy(policy) { - if (cpumask_test_cpu(cpu, policy->related_cpus)) { - read_unlock_irqrestore(&cpufreq_driver_lock, flags); - ret = cpufreq_add_policy_cpu(policy, cpu, dev); - up_read(&cpufreq_rwsem); - return ret; - } + policy = per_cpu(cpufreq_cpu_data, cpu); + if (policy && !policy_is_inactive(policy)) { + WARN_ON(!cpumask_test_cpu(cpu, policy->related_cpus)); + ret = cpufreq_add_policy_cpu(policy, cpu, dev); + up_read(&cpufreq_rwsem); + return ret; } - read_unlock_irqrestore(&cpufreq_driver_lock, flags); /* * Restore the saved policy when doing light-weight init and fall back