From patchwork Fri May 8 06:23:47 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 48148 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f200.google.com (mail-lb0-f200.google.com [209.85.217.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id A81E32121F for ; Fri, 8 May 2015 06:24:53 +0000 (UTC) Received: by lbos2 with SMTP id s2sf18294564lbo.2 for ; Thu, 07 May 2015 23:24:52 -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=MnUFSwi/MR1JgaDbyyjUHTaf64H5Bce84027mXD3tW0=; b=G6Rc2uhjh/dN5eE9SR2mIVOmsbq93nD4RTF//LBRJwCbTuekoBkmIoyPjEaEa56UiY CVqEJNyGoMr2jK4JdbM4U5YiTgOkQcQLF2a+myT+IJMuLKgHdfA7RQhycGtJNKoSDzQq oHfj6zCzCkaU6/hvAVNKDWFYkKrImGgz0GFb3L9wszZtK6ppP4FFfchx2ce/GlnqgXZ5 N9tVf46RKOGekBax+oPayp0A2HFjtKJVLzBQTSPtY4rrNjB85jA+678WnfeUodwBbZag +7FhGceFAv+uupI+0WIrkYmallDR8PRknmxwZ7BqKzZiuKKc/LB6dY3+/zIWElGbEJ1c aYzA== X-Gm-Message-State: ALoCoQlCPg3V36f71Y8cHRIHMazuojk+NnDWULb90f2L3eAIN2P9BoDFK3mTKiSd3Eh88j00Ohf9 X-Received: by 10.152.206.36 with SMTP id ll4mr1236963lac.6.1431066292675; Thu, 07 May 2015 23:24:52 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.36.169 with SMTP id r9ls286846laj.86.gmail; Thu, 07 May 2015 23:24:52 -0700 (PDT) X-Received: by 10.112.72.132 with SMTP id d4mr1682455lbv.1.1431066292533; Thu, 07 May 2015 23:24:52 -0700 (PDT) Received: from mail-la0-f48.google.com (mail-la0-f48.google.com. [209.85.215.48]) by mx.google.com with ESMTPS id jp4si2660970lab.155.2015.05.07.23.24.52 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 May 2015 23:24:52 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.48 as permitted sender) client-ip=209.85.215.48; Received: by layy10 with SMTP id y10so46030250lay.0 for ; Thu, 07 May 2015 23:24:52 -0700 (PDT) X-Received: by 10.152.27.1 with SMTP id p1mr1653368lag.112.1431066292447; Thu, 07 May 2015 23:24:52 -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 hn6csp269218lbb; Thu, 7 May 2015 23:24:51 -0700 (PDT) X-Received: by 10.70.88.170 with SMTP id bh10mr4038365pdb.62.1431066291497; Thu, 07 May 2015 23:24:51 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t17si5783046pdi.227.2015.05.07.23.24.50; Thu, 07 May 2015 23:24:51 -0700 (PDT) Received-SPF: none (google.com: linux-pm-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 S1751288AbbEHGYu (ORCPT + 11 others); Fri, 8 May 2015 02:24:50 -0400 Received: from mail-pd0-f171.google.com ([209.85.192.171]:34176 "EHLO mail-pd0-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751196AbbEHGYt (ORCPT ); Fri, 8 May 2015 02:24:49 -0400 Received: by pdbqa5 with SMTP id qa5so66447614pdb.1 for ; Thu, 07 May 2015 23:24:49 -0700 (PDT) X-Received: by 10.68.65.17 with SMTP id t17mr4031222pbs.74.1431066268847; Thu, 07 May 2015 23:24:28 -0700 (PDT) Received: from localhost ([122.172.243.237]) by mx.google.com with ESMTPSA id ih1sm3966923pbb.92.2015.05.07.23.24.27 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 07 May 2015 23:24:28 -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 V3 04/14] cpufreq: Don't traverse all active policies to find policy for a cpu Date: Fri, 8 May 2015 11:53:47 +0530 Message-Id: <91b416f7a706ae0cbb5f90168988326793e05001.1431065963.git.viresh.kumar@linaro.org> 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.48 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 | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index b60311fe207f..a3eb76969969 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -1212,7 +1212,7 @@ static int cpufreq_add_dev(struct device *dev, struct subsys_interface *sif) { unsigned int j, cpu = dev->id; int ret = -ENOMEM; - struct cpufreq_policy *policy, *tpolicy; + struct cpufreq_policy *policy; unsigned long flags; bool recover_policy = cpufreq_suspended; @@ -1225,16 +1225,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, tpolicy) { - 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