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: 6385961 X-Patchwork-Delegate: rjw@sisk.pl Return-Path: X-Original-To: patchwork-linux-pm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id CB4309F1C2 for ; Tue, 12 May 2015 06:52:28 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 00162203AC for ; Tue, 12 May 2015 06:52:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6637220395 for ; Tue, 12 May 2015 06:52:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751843AbbELGwZ (ORCPT ); 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-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=pQmC0CEALWvyuk6wqG5ppmRArzjX+QTRnUM8d20kz9k=; b=XEn9J29xXKpqkQ7YyRGx7MtjozQeQl/EopOJfm4TWbvC7BRG/Lpib1CwgFjiW0IU6g X4it9rjRoumfmpCUWvL6p8OArvD+oFe38c29OBW3QdUYvgtnD4HG0yz1YYwb/oSBG7tH yiNqSqeW7FzrEU1/K0TRqp8QTfkeMOIlxbfTsuhe5t8tlPp5Gc+V0ITKzPG0Pf4nf6cQ lw6cEt7K21R+XaqM9Lgdu3X8PQRyRARXSf+DWKE24vGrAA6O0lj4ZkwU27DYFC+wB+VF I00hoZGE+cny7LLNY9TCIVKq3x0L3igR9Y4M+pzw7QxDGRH/gc9rGi3pe8+UKMcs9glI u1Ww== X-Gm-Message-State: ALoCoQlWiFI7myR8/X4TecicvcrEJpp1v7wnyeUyOROAWO1rM5IfSHth2yYBzD7cNXJiZrSXnQNu 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: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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