From: Saravana Kannan <skannan@codeaurora.org>
To: "Rafael J. Wysocki" <rjw@rjwysocki.net>,
Viresh Kumar <viresh.kumar@linaro.org>
Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-arm-msm@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
Saravana Kannan <skannan@codeaurora.org>
Subject: [PATCH 1/3] cpufreq: stats: Remove redundant cpufreq_cpu_get() call
Date: Tue, 25 Feb 2014 19:38:33 -0800 [thread overview]
Message-ID: <1393385915-19138-1-git-send-email-skannan@codeaurora.org> (raw)
In-Reply-To: <1789244.B5CzWbcp6h@vostro.rjw.lan>
__cpufreq_stats_create_table always gets pass the valid and real policy
struct. So, there's no need to call cpufreq_cpu_get() to get the policy
again.
Change-Id: I0136b3e67018ee3af2335906407f55d8c6219f71
Signed-off-by: Saravana Kannan <skannan@codeaurora.org>
---
Viresh/Rafael,
These 3 patches is the approximate code I have in mind.
Approximate because:
* I inserted one question as a comment into the code.
* If the patch doesn't have any bugs, the plan is to remove
cpufreq_generic_get() and references to it.
This takes care of the "don't advertise before it's ready for use" rule.
Viresh,
I think the locking updates needs to be done in addition to this.
Regards,
Saravana
drivers/cpufreq/cpufreq_stats.c | 12 +-----------
1 file changed, 1 insertion(+), 11 deletions(-)
diff --git a/drivers/cpufreq/cpufreq_stats.c b/drivers/cpufreq/cpufreq_stats.c
index 5793e14..e4bd27f 100644
--- a/drivers/cpufreq/cpufreq_stats.c
+++ b/drivers/cpufreq/cpufreq_stats.c
@@ -185,7 +185,6 @@ static int __cpufreq_stats_create_table(struct cpufreq_policy *policy,
{
unsigned int i, j, count = 0, ret = 0;
struct cpufreq_stats *stat;
- struct cpufreq_policy *current_policy;
unsigned int alloc_size;
unsigned int cpu = policy->cpu;
if (per_cpu(cpufreq_stats_table, cpu))
@@ -194,13 +193,7 @@ static int __cpufreq_stats_create_table(struct cpufreq_policy *policy,
if ((stat) == NULL)
return -ENOMEM;
- current_policy = cpufreq_cpu_get(cpu);
- if (current_policy == NULL) {
- ret = -EINVAL;
- goto error_get_fail;
- }
-
- ret = sysfs_create_group(¤t_policy->kobj, &stats_attr_group);
+ ret = sysfs_create_group(&policy->kobj, &stats_attr_group);
if (ret)
goto error_out;
@@ -243,11 +236,8 @@ static int __cpufreq_stats_create_table(struct cpufreq_policy *policy,
stat->last_time = get_jiffies_64();
stat->last_index = freq_table_get_index(stat, policy->cur);
spin_unlock(&cpufreq_stats_lock);
- cpufreq_cpu_put(current_policy);
return 0;
error_out:
- cpufreq_cpu_put(current_policy);
-error_get_fail:
kfree(stat);
per_cpu(cpufreq_stats_table, cpu) = NULL;
return ret;
--
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
hosted by The Linux Foundation
next prev parent reply other threads:[~2014-02-26 3:38 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-02-24 6:57 [PATCH] cpufreq: Set policy to non-NULL only after all hotplug online work is done Saravana Kannan
2014-02-24 7:42 ` Srivatsa S. Bhat
2014-02-24 8:11 ` Viresh Kumar
2014-02-24 8:41 ` skannan
2014-02-24 8:43 ` Viresh Kumar
2014-02-24 8:47 ` skannan
2014-02-24 8:50 ` Viresh Kumar
2014-02-24 9:00 ` skannan
2014-02-24 8:39 ` skannan
2014-02-24 10:55 ` Viresh Kumar
2014-02-24 20:23 ` Saravana Kannan
2014-02-25 8:50 ` Viresh Kumar
2014-02-25 13:04 ` Rafael J. Wysocki
2014-02-25 14:40 ` Viresh Kumar
2014-02-25 21:11 ` Saravana Kannan
2014-02-25 22:41 ` Rafael J. Wysocki
2014-02-26 1:48 ` Saravana Kannan
2014-02-26 6:02 ` Viresh Kumar
2014-02-26 20:20 ` Saravana Kannan
2014-02-26 3:38 ` Saravana Kannan [this message]
2014-02-26 5:06 ` [PATCH 1/3] cpufreq: stats: Remove redundant cpufreq_cpu_get() call Viresh Kumar
2014-02-26 20:04 ` Saravana Kannan
2014-02-26 3:38 ` [PATCH 2/3] cpufreq: stats: Fix error handling in __cpufreq_stats_create_table() Saravana Kannan
2014-02-26 5:11 ` Viresh Kumar
2014-02-26 3:38 ` [PATCH 3/3] cpufreq: Set policy to non-NULL only after all hotplug online work is done Saravana Kannan
2014-02-26 6:14 ` Viresh Kumar
2014-02-26 5:20 ` [PATCH] " Viresh Kumar
-- strict thread matches above, loose matches on Subject: below --
2014-02-26 20:17 [PATCH 1/3] cpufreq: stats: Remove redundant cpufreq_cpu_get() call Saravana Kannan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1393385915-19138-1-git-send-email-skannan@codeaurora.org \
--to=skannan@codeaurora.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=rjw@rjwysocki.net \
--cc=viresh.kumar@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).