From patchwork Tue Jan 6 15:39:05 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 42776 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wg0-f71.google.com (mail-wg0-f71.google.com [74.125.82.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 93A732055F for ; Tue, 6 Jan 2015 15:39:55 +0000 (UTC) Received: by mail-wg0-f71.google.com with SMTP id k14sf5701226wgh.6 for ; Tue, 06 Jan 2015 07:39:54 -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=dCSEyHwjQ9VOwH+KJtStKV+WvUocX4LyVkg7D3hu+hk=; b=T6QdsMzOGia0Zs7X3iOvGXy+y616W6LUcLgVCkGPpATwojRzyBhbyS5LKvqUBqogh2 122tMpblWOcvzCXgZLB1UCuQaxCBkfMA9R5iRp9mDp5zIFmt/ugRv0zPhdz7yCPnMu6b rjhVSIMUmfwVoGmIq+TNSitrrCP+uVHbKqKHJdQ558zf68UWBmpIA2Y48w/Xzle+2fr3 VHhuywJyZgRXGNj+YCgsxjh1xil2uBDMN7DlPGY9jxlUFEx/QDvEb8XygTaT+A9xVeHu RE5Xxq5VVYpeh9QhG5ogJZWRo2eIvn0k3e9aHm9vBXb9P31YfAxc8p53yWaePJQBUqE/ E3xw== X-Gm-Message-State: ALoCoQmDpgERNU5XIAOxlvUySADaCaeO3HO4ZEeWh3Bd3ooVHy/z6wPGfYoH7aW6Z6/O9gYaJ343 X-Received: by 10.112.141.98 with SMTP id rn2mr8415385lbb.2.1420558794847; Tue, 06 Jan 2015 07:39:54 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.19.39 with SMTP id b7ls49880lae.93.gmail; Tue, 06 Jan 2015 07:39:54 -0800 (PST) X-Received: by 10.152.115.172 with SMTP id jp12mr100459057lab.33.1420558794707; Tue, 06 Jan 2015 07:39:54 -0800 (PST) Received: from mail-lb0-f179.google.com (mail-lb0-f179.google.com. [209.85.217.179]) by mx.google.com with ESMTPS id q8si64382441lbr.108.2015.01.06.07.39.54 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 06 Jan 2015 07:39:54 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.179 as permitted sender) client-ip=209.85.217.179; Received: by mail-lb0-f179.google.com with SMTP id z11so19490433lbi.10 for ; Tue, 06 Jan 2015 07:39:54 -0800 (PST) X-Received: by 10.112.41.234 with SMTP id i10mr102090772lbl.25.1420558794587; Tue, 06 Jan 2015 07:39:54 -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.9.200 with SMTP id c8csp1209545lbb; Tue, 6 Jan 2015 07:39:53 -0800 (PST) X-Received: by 10.66.171.206 with SMTP id aw14mr156123632pac.40.1420558792620; Tue, 06 Jan 2015 07:39:52 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id hz4si17325227pbb.8.2015.01.06.07.39.51; Tue, 06 Jan 2015 07:39:52 -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 S1754670AbbAFPjv (ORCPT + 12 others); Tue, 6 Jan 2015 10:39:51 -0500 Received: from mail-pd0-f173.google.com ([209.85.192.173]:62941 "EHLO mail-pd0-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754224AbbAFPju (ORCPT ); Tue, 6 Jan 2015 10:39:50 -0500 Received: by mail-pd0-f173.google.com with SMTP id ft15so30626216pdb.32 for ; Tue, 06 Jan 2015 07:39:50 -0800 (PST) X-Received: by 10.70.130.108 with SMTP id od12mr156422880pdb.109.1420558790408; Tue, 06 Jan 2015 07:39:50 -0800 (PST) Received: from localhost ([122.167.212.196]) by mx.google.com with ESMTPSA id ni9sm57370655pdb.36.2015.01.06.07.39.49 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Tue, 06 Jan 2015 07:39:49 -0800 (PST) From: Viresh Kumar To: Rafael Wysocki Cc: linaro-kernel@lists.linaro.org, linux-pm@vger.kernel.org, prarit@redhat.com, skannan@codeaurora.org, Viresh Kumar Subject: [PATCH V3 06/16] cpufreq: stats: pass 'stat' to cpufreq_stats_update() Date: Tue, 6 Jan 2015 21:09:05 +0530 Message-Id: <181e3a27d02ce74569478191e6fa84aea73caf6c.1420558386.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.2.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.217.179 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: , It is better to pass a struct cpufreq_stats pointer to cpufreq_stats_update() instead of a CPU number, because that's all it needs. Even if we pass a cpu number to cpufreq_stats_update(), it reads the per-cpu variable to get 'stats' out of it. So we are doing these operations unnecessarily: - First getting the cpu number to pass to cpufreq_stats_update(), stat->cpu. - And then getting stats from the cpu, per_cpu(cpufreq_stats_table, cpu). Reviewed-by: Prarit Bhargava Signed-off-by: Viresh Kumar --- drivers/cpufreq/cpufreq_stats.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/drivers/cpufreq/cpufreq_stats.c b/drivers/cpufreq/cpufreq_stats.c index e9d68420b876..6c234f548601 100644 --- a/drivers/cpufreq/cpufreq_stats.c +++ b/drivers/cpufreq/cpufreq_stats.c @@ -33,13 +33,11 @@ struct cpufreq_stats { static DEFINE_PER_CPU(struct cpufreq_stats *, cpufreq_stats_table); -static int cpufreq_stats_update(unsigned int cpu) +static int cpufreq_stats_update(struct cpufreq_stats *stat) { - struct cpufreq_stats *stat; unsigned long long cur_time = get_jiffies_64(); spin_lock(&cpufreq_stats_lock); - stat = per_cpu(cpufreq_stats_table, cpu); if (stat->time_in_state) stat->time_in_state[stat->last_index] += cur_time - stat->last_time; @@ -64,7 +62,7 @@ static ssize_t show_time_in_state(struct cpufreq_policy *policy, char *buf) struct cpufreq_stats *stat = per_cpu(cpufreq_stats_table, policy->cpu); if (!stat) return 0; - cpufreq_stats_update(stat->cpu); + cpufreq_stats_update(stat); for (i = 0; i < stat->state_num; i++) { len += sprintf(buf + len, "%u %llu\n", stat->freq_table[i], (unsigned long long) @@ -82,7 +80,7 @@ static ssize_t show_trans_table(struct cpufreq_policy *policy, char *buf) struct cpufreq_stats *stat = per_cpu(cpufreq_stats_table, policy->cpu); if (!stat) return 0; - cpufreq_stats_update(stat->cpu); + cpufreq_stats_update(stat); len += snprintf(buf + len, PAGE_SIZE - len, " From : To\n"); len += snprintf(buf + len, PAGE_SIZE - len, " : "); for (i = 0; i < stat->state_num; i++) { @@ -307,7 +305,7 @@ static int cpufreq_stat_notifier_trans(struct notifier_block *nb, if (old_index == -1 || new_index == -1) return 0; - cpufreq_stats_update(freq->cpu); + cpufreq_stats_update(stat); if (old_index == new_index) return 0;