From: Tejun Heo <htejun@gmail.com>
To: Christoph Lameter <cl@linux.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>,
Eric Dumazet <eric.dumazet@gmail.com>,
akpm@linux-foundation.org, Pekka Enberg <penberg@cs.helsinki.fi>,
linux-kernel@vger.kernel.org,
Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
rui.zhang@intel.com, lenb@kernel.org, linux-acpi@vger.kernel.org
Subject: Re: acpi throttling: Use this_cpu_has and simplify code
Date: Sat, 18 Dec 2010 16:50:24 +0100 [thread overview]
Message-ID: <4D0CD840.2050100@gmail.com> (raw)
In-Reply-To: <alpine.DEB.2.00.1012161215200.21588@router.home>
(cc'ing ACPI ppl and quoting the whole body)
On 12/16/2010 07:16 PM, Christoph Lameter wrote:
>
> With the this_cpu_xx we no longer need to pass an acpi
> structure to the msr management code. Simplifies code and improves
> performance.
>
> Signed-off-by: Christoph Lameter <cl@linux.com>
>
> ---
> drivers/acpi/processor_throttling.c | 32 ++++++++++----------------------
> 1 file changed, 10 insertions(+), 22 deletions(-)
>
> Index: linux-2.6/drivers/acpi/processor_throttling.c
> ===================================================================
> --- linux-2.6.orig/drivers/acpi/processor_throttling.c 2010-12-16 11:56:57.000000000 -0600
> +++ linux-2.6/drivers/acpi/processor_throttling.c 2010-12-16 12:00:17.000000000 -0600
> @@ -662,20 +662,14 @@ static int acpi_processor_get_throttling
> }
>
> #ifdef CONFIG_X86
> -static int acpi_throttling_rdmsr(struct acpi_processor *pr,
> - u64 *value)
> +static int acpi_throttling_rdmsr(u64 *value)
> {
> - struct cpuinfo_x86 *c;
> u64 msr_high, msr_low;
> - unsigned int cpu;
> u64 msr = 0;
> int ret = -1;
>
> - cpu = pr->id;
> - c = &cpu_data(cpu);
> -
> - if ((c->x86_vendor != X86_VENDOR_INTEL) ||
> - !cpu_has(c, X86_FEATURE_ACPI)) {
> + if ((this_cpu_read(cpu_info.x86_vendor) != X86_VENDOR_INTEL) ||
> + !this_cpu_has(X86_FEATURE_ACPI)) {
> printk(KERN_ERR PREFIX
> "HARDWARE addr space,NOT supported yet\n");
> } else {
> @@ -690,18 +684,13 @@ static int acpi_throttling_rdmsr(struct
> return ret;
> }
>
> -static int acpi_throttling_wrmsr(struct acpi_processor *pr, u64 value)
> +static int acpi_throttling_wrmsr(u64 value)
> {
> - struct cpuinfo_x86 *c;
> - unsigned int cpu;
> int ret = -1;
> u64 msr;
>
> - cpu = pr->id;
> - c = &cpu_data(cpu);
> -
> - if ((c->x86_vendor != X86_VENDOR_INTEL) ||
> - !cpu_has(c, X86_FEATURE_ACPI)) {
> + if ((this_cpu_read(cpu_info.x86_vendor) != X86_VENDOR_INTEL) ||
> + !this_cpu_has(X86_FEATURE_ACPI)) {
> printk(KERN_ERR PREFIX
> "HARDWARE addr space,NOT supported yet\n");
> } else {
> @@ -713,15 +702,14 @@ static int acpi_throttling_wrmsr(struct
> return ret;
> }
> #else
> -static int acpi_throttling_rdmsr(struct acpi_processor *pr,
> - u64 *value)
> +static int acpi_throttling_rdmsr(u64 *value)
> {
> printk(KERN_ERR PREFIX
> "HARDWARE addr space,NOT supported yet\n");
> return -1;
> }
>
> -static int acpi_throttling_wrmsr(struct acpi_processor *pr, u64 value)
> +static int acpi_throttling_wrmsr(u64 value)
> {
> printk(KERN_ERR PREFIX
> "HARDWARE addr space,NOT supported yet\n");
> @@ -753,7 +741,7 @@ static int acpi_read_throttling_status(s
> ret = 0;
> break;
> case ACPI_ADR_SPACE_FIXED_HARDWARE:
> - ret = acpi_throttling_rdmsr(pr, value);
> + ret = acpi_throttling_rdmsr(value);
> break;
> default:
> printk(KERN_ERR PREFIX "Unknown addr space %d\n",
> @@ -786,7 +774,7 @@ static int acpi_write_throttling_state(s
> ret = 0;
> break;
> case ACPI_ADR_SPACE_FIXED_HARDWARE:
> - ret = acpi_throttling_wrmsr(pr, value);
> + ret = acpi_throttling_wrmsr(value);
> break;
> default:
> printk(KERN_ERR PREFIX "Unknown addr space %d\n",
>
It's bothersome that these methods don't have any indication that
they're bound to local CPU when they can't be called with @pr for
another CPU as MSRs can only be accessed from local CPU.
In the longer run, it would be nice if there's an indication that this
is only for the local CPU and maybe a WARN_ON_ONCE(). Maybe dropping
@pr and using this_cpu_*() is better for performance too?
Anyways, the above doesn't make the situation any worse, so...
Acked-by: Tejun Heo <tj@kernel.org>
I think this one too fits the x86 tree better.
Thanks.
--
tejun
next prev parent reply other threads:[~2010-12-18 15:50 UTC|newest]
Thread overview: 49+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-12-14 16:28 [cpuops cmpxchg V2 0/5] Cmpxchg and xchg operations Christoph Lameter
2010-12-14 16:28 ` [cpuops cmpxchg V2 1/5] percpu: Generic this_cpu_cmpxchg() and this_cpu_xchg support Christoph Lameter
2010-12-17 14:55 ` Tejun Heo
2010-12-14 16:28 ` [cpuops cmpxchg V2 2/5] x86: this_cpu_cmpxchg and this_cpu_xchg operations Christoph Lameter
2010-12-17 15:22 ` Tejun Heo
2010-12-14 16:28 ` [cpuops cmpxchg V2 3/5] irq_work: Use per cpu atomics instead of regular atomics Christoph Lameter
2010-12-15 16:32 ` Tejun Heo
2010-12-15 16:34 ` H. Peter Anvin
2010-12-15 16:50 ` Peter Zijlstra
2010-12-15 17:04 ` Christoph Lameter
2010-12-15 17:18 ` Peter Zijlstra
2010-12-15 17:31 ` H. Peter Anvin
2010-12-15 17:32 ` Christoph Lameter
2010-12-18 15:32 ` Tejun Heo
2010-12-14 16:28 ` [cpuops cmpxchg V2 4/5] vmstat: User per cpu atomics to avoid interrupt disable / enable Christoph Lameter
2010-12-15 16:45 ` Tejun Heo
2010-12-15 17:01 ` Christoph Lameter
2010-12-14 16:28 ` [cpuops cmpxchg V2 5/5] cpuops: Use cmpxchg for xchg to avoid lock semantics Christoph Lameter
2010-12-14 16:35 ` Mathieu Desnoyers
2010-12-14 16:44 ` Eric Dumazet
2010-12-14 16:55 ` Christoph Lameter
2010-12-14 17:00 ` H. Peter Anvin
2010-12-14 17:19 ` Christoph Lameter
2010-12-14 17:22 ` H. Peter Anvin
2010-12-14 17:29 ` Tejun Heo
2010-12-14 17:35 ` Christoph Lameter
2010-12-15 1:06 ` H. Peter Anvin
2010-12-15 16:29 ` Tejun Heo
2010-12-15 16:35 ` H. Peter Anvin
2010-12-15 16:39 ` Tejun Heo
2010-12-16 16:14 ` Tejun Heo
2010-12-16 18:13 ` x86: Use this_cpu_has for thermal_interrupt Christoph Lameter
2010-12-18 15:35 ` Tejun Heo
2010-12-21 0:56 ` H. Peter Anvin
2010-12-30 11:29 ` Tejun Heo
2010-12-30 18:19 ` H. Peter Anvin
2010-12-31 12:43 ` Tejun Heo
2010-12-16 18:14 ` x86: udelay: Use this_cpu_read to avoid address calculation Christoph Lameter
2010-12-16 18:15 ` gameport: use this_cpu_read instead of lookup Christoph Lameter
2010-12-18 15:34 ` Tejun Heo
2010-12-16 18:16 ` acpi throttling: Use this_cpu_has and simplify code Christoph Lameter
2010-12-18 15:50 ` Tejun Heo [this message]
2010-12-21 1:52 ` ykzhao
2010-12-21 22:43 ` Christoph Lameter
2010-12-21 4:28 ` Len Brown
2010-12-16 18:19 ` [cpuops cmpxchg V2 5/5] cpuops: Use cmpxchg for xchg to avoid lock semantics H. Peter Anvin
2010-12-16 18:55 ` Tejun Heo
2010-12-16 20:42 ` H. Peter Anvin
2010-12-15 16:47 ` Tejun Heo
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=4D0CD840.2050100@gmail.com \
--to=htejun@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=cl@linux.com \
--cc=eric.dumazet@gmail.com \
--cc=hpa@zytor.com \
--cc=lenb@kernel.org \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mathieu.desnoyers@efficios.com \
--cc=penberg@cs.helsinki.fi \
--cc=rui.zhang@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