From patchwork Tue May 12 06:52: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: 48333 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f197.google.com (mail-lb0-f197.google.com [209.85.217.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id DEFAD2121F for ; Tue, 12 May 2015 06:52:30 +0000 (UTC) Received: by lbos2 with SMTP id s2sf43894495lbo.2 for ; Mon, 11 May 2015 23:52:29 -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:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=X/Pe9m+MXUoDWAg2PHbatNsp0bi/NxCM3dVvkBl6IdA=; b=ffws/gNG1jQxZN8vUe4UxRE3bU3pmbeu1rQy3Rr9rNRfQSL+2adSLAQ6oBus9tU77K Q7B/SQmhdw4QvNsUgQuyjsciFmYzVHgzNlnmjTrycMu3FzMcFOeQgunRXHdMyPNdgjtJ clih8zl6d1yk3w3voYJDYN5bwqEAoXYAN5Oopvm7laezp6j47cy72byXmn73mGx/8eei xNq8Q7Tpsmk8zdJxymNGbPV6x/NJqdeSbJVbFbJDH+2LU9TKrrYsqTb6gosi1gt3kDb3 3iJq4YA+KMCAlIkoioJxA5hJz5b0o8RAHAdegCIGfFLZLg+Pbko6PaDMOsHaicATzbmF KUvw== X-Gm-Message-State: ALoCoQkV1kokDqf138IdraS7qOH3CSNP8Zc1X68B0NKxPZZgdno1/Yu6Za/2wER2Y5t7NpbJ+ge+ X-Received: by 10.180.105.226 with SMTP id gp2mr10200319wib.1.1431413549727; Mon, 11 May 2015 23:52:29 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.9.37 with SMTP id w5ls674618laa.77.gmail; Mon, 11 May 2015 23:52:29 -0700 (PDT) X-Received: by 10.152.121.6 with SMTP id lg6mr10962045lab.42.1431413549498; Mon, 11 May 2015 23:52:29 -0700 (PDT) Received: from mail-lb0-f170.google.com (mail-lb0-f170.google.com. [209.85.217.170]) by mx.google.com with ESMTPS id lk5si9730775lac.170.2015.05.11.23.52.29 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 11 May 2015 23:52:29 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.170 as permitted sender) client-ip=209.85.217.170; Received: by lbcga7 with SMTP id ga7so110782852lbc.1 for ; Mon, 11 May 2015 23:52:29 -0700 (PDT) X-Received: by 10.112.199.133 with SMTP id jk5mr11199860lbc.32.1431413549287; Mon, 11 May 2015 23:52:29 -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 hn6csp1905406lbb; Mon, 11 May 2015 23:52:28 -0700 (PDT) X-Received: by 10.66.249.198 with SMTP id yw6mr25185896pac.149.1431413547421; Mon, 11 May 2015 23:52:27 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x11si21142168pbt.40.2015.05.11.23.52.26; Mon, 11 May 2015 23:52:27 -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 S1751843AbbELGwZ (ORCPT + 11 others); Tue, 12 May 2015 02:52:25 -0400 Received: from mail-pd0-f175.google.com ([209.85.192.175]:36310 "EHLO mail-pd0-f175.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752000AbbELGwZ (ORCPT ); Tue, 12 May 2015 02:52:25 -0400 Received: by pdea3 with SMTP id a3so173638793pde.3 for ; Mon, 11 May 2015 23:52:24 -0700 (PDT) X-Received: by 10.68.113.132 with SMTP id iy4mr10562120pbb.71.1431413544816; Mon, 11 May 2015 23:52:24 -0700 (PDT) Received: from localhost ([122.167.226.34]) by mx.google.com with ESMTPSA id pn6sm15076075pdb.72.2015.05.11.23.52.21 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Mon, 11 May 2015 23:52:24 -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 V4 04/14] cpufreq: Don't traverse all active policies to find policy for a cpu Date: Tue, 12 May 2015 12:22:12 +0530 Message-Id: X-Mailer: git-send-email 2.4.0 In-Reply-To: <91b416f7a706ae0cbb5f90168988326793e05001.1431065963.git.viresh.kumar@linaro.org> 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.217.170 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 --- V4->V5: - Rebased on top of [V4 1/14] 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