From patchwork Thu Feb 19 11:32:12 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 44825 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f199.google.com (mail-wi0-f199.google.com [209.85.212.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 9A96921554 for ; Thu, 19 Feb 2015 11:34:11 +0000 (UTC) Received: by mail-wi0-f199.google.com with SMTP id bs8sf5181292wib.2 for ; Thu, 19 Feb 2015 03:34:10 -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: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=ScwhOnZizivGa6PCU3acoYzDlp9podNvxgrkuT16S7E=; b=aRGFWI8asZakUMyM1j95jTAgeWAPQhW1UzjTT6jVoCi17ykQMZBhHKkmwRcNMaVpA4 4SPJ/Vh6VG3rlOCYgZMKC0duj65q0KkCH0ASsjSrA2rYPezzzpHvIdjZoldiLwOypJWS rX5l9GDCgwSrRxyg2T2f7wwab2jIBnD39uFRK2F3m0oDMMC7Y743KfNT7l19oeICgVQC v/fVwWLAG2Ib7RVzCgr3pQNeVhNMCwUOQqLG39mWAmq3i8nvynNphTKQrFYBXFCNR1QX d55P7zUjPitXKWKT92nsjdn4dRcLfq53DIDpee6HyFYq4/efdr4QvQG/Mj3DMdLYiQ14 Et3w== X-Gm-Message-State: ALoCoQldDS4OB/5jv8e1dfUUfbgwgD2Aiyyri8zzO3jpCVGDbyMOiC5ZXBnQyhvQMLerRLw2EvQ+ X-Received: by 10.112.160.3 with SMTP id xg3mr511140lbb.5.1424345650887; Thu, 19 Feb 2015 03:34:10 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.204.39 with SMTP id kv7ls125327lac.76.gmail; Thu, 19 Feb 2015 03:34:10 -0800 (PST) X-Received: by 10.112.154.199 with SMTP id vq7mr3282153lbb.99.1424345650698; Thu, 19 Feb 2015 03:34:10 -0800 (PST) Received: from mail-la0-f51.google.com (mail-la0-f51.google.com. [209.85.215.51]) by mx.google.com with ESMTPS id w8si1382208law.75.2015.02.19.03.34.10 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 19 Feb 2015 03:34:10 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.51 as permitted sender) client-ip=209.85.215.51; Received: by labpn19 with SMTP id pn19so6966013lab.4 for ; Thu, 19 Feb 2015 03:34:10 -0800 (PST) X-Received: by 10.112.135.196 with SMTP id pu4mr3444608lbb.41.1424345650622; Thu, 19 Feb 2015 03:34: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.35.133 with SMTP id h5csp431751lbj; Thu, 19 Feb 2015 03:34:09 -0800 (PST) X-Received: by 10.68.139.98 with SMTP id qx2mr6897942pbb.39.1424345648894; Thu, 19 Feb 2015 03:34:08 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id kp7si8957741pdb.137.2015.02.19.03.34.07; Thu, 19 Feb 2015 03:34:08 -0800 (PST) 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 S1753385AbbBSLeD (ORCPT + 11 others); Thu, 19 Feb 2015 06:34:03 -0500 Received: from mail-pa0-f47.google.com ([209.85.220.47]:32773 "EHLO mail-pa0-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753417AbbBSLeB (ORCPT ); Thu, 19 Feb 2015 06:34:01 -0500 Received: by pabkx10 with SMTP id kx10so8914208pab.0 for ; Thu, 19 Feb 2015 03:34:00 -0800 (PST) X-Received: by 10.68.111.227 with SMTP id il3mr7094038pbb.46.1424345640843; Thu, 19 Feb 2015 03:34:00 -0800 (PST) Received: from localhost ([122.172.249.58]) by mx.google.com with ESMTPSA id n4sm23598014pdl.12.2015.02.19.03.33.59 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 19 Feb 2015 03:34:00 -0800 (PST) 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, Viresh Kumar Subject: [PATCH V2 10/20] cpufreq: Don't traverse list of all policies for adding policy for a cpu Date: Thu, 19 Feb 2015 17:02:12 +0530 Message-Id: <3311b25e3e3f698ad654215d7bf9a1c3613b7d78.1424345053.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.3.0.rc0.44.ga94655d 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.51 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 in question. As cpufreq_cpu_data is filled once and for all now, we can reuse it to find the relevant policy instead of traversing the list of all policies. 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 f849b2a33d3e..20d5f4590c4b 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -1211,7 +1211,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; @@ -1224,16 +1224,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