From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: Pan Xinhui <xinhuix.pan@intel.com>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
linux-pm@vger.kernel.org, rjw@rjwysocki.net,
viresh.kumar@linaro.org, "mnipxh@163.com" <mnipxh@163.com>,
"yanmin_zhang@linux.intel.com" <yanmin_zhang@linux.intel.com>
Subject: Re: [PATCH V2] acpi-cpufreq: replace per_cpu with driver_data of policy
Date: Tue, 7 Jul 2015 10:11:26 -0700 [thread overview]
Message-ID: <20150707171126.GB12491@dtor-ws> (raw)
In-Reply-To: <559BC96E.8020804@intel.com>
Hi Pan,
On Tue, Jul 07, 2015 at 08:43:26PM +0800, Pan Xinhui wrote:
> @@ -364,19 +363,24 @@ static u32 get_cur_val(const struct cpumask *mask)
>
> static unsigned int get_cur_freq_on_cpu(unsigned int cpu)
> {
> - struct acpi_cpufreq_data *data = per_cpu(acfreq_data, cpu);
> + struct acpi_cpufreq_data *data;
> + struct cpufreq_policy *policy;
> unsigned int freq;
> unsigned int cached_freq;
>
> pr_debug("get_cur_freq_on_cpu (%d)\n", cpu);
>
> - if (unlikely(data == NULL ||
> - data->acpi_data == NULL || data->freq_table == NULL)) {
> + policy = cpufreq_cpu_get(cpu);
> + if (unlikely(!policy))
> + return 0;
> +
> + data = policy->driver_data;
> + cpufreq_cpu_put(policy);
If we put policy here can we guarantee that memory pointed to by data
stays valid? Shoudln't we issue cpufreq_cpu_put(policy) after we done
assessing the pointer?
> + if (unlikely(!data || !data->acpi_data || !data->freq_table))
> return 0;
> - }
>
> cached_freq = data->freq_table[data->acpi_data->state].frequency;
> - freq = extract_freq(get_cur_val(cpumask_of(cpu)), data);
> + freq = extract_freq(get_cur_val(cpumask_of(cpu), data), data);
> if (freq != cached_freq) {
> /*
> * The dreaded BIOS frequency change behind our back.
Thanks.
--
Dmitry
next prev parent reply other threads:[~2015-07-07 17:11 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-07 12:43 [PATCH V2] acpi-cpufreq: replace per_cpu with driver_data of policy Pan Xinhui
2015-07-07 12:49 ` Pan Xinhui
2015-07-07 14:34 ` Viresh Kumar
2015-07-09 0:20 ` Rafael J. Wysocki
2015-07-09 1:28 ` Pan Xinhui
2015-07-10 1:16 ` Rafael J. Wysocki
2015-07-07 17:11 ` Dmitry Torokhov [this message]
2015-07-08 4:51 ` Viresh Kumar
2015-07-08 12:28 ` Pan Xinhui
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=20150707171126.GB12491@dtor-ws \
--to=dmitry.torokhov@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=mnipxh@163.com \
--cc=rjw@rjwysocki.net \
--cc=viresh.kumar@linaro.org \
--cc=xinhuix.pan@intel.com \
--cc=yanmin_zhang@linux.intel.com \
/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