Re: [PATCH] x86: Replace uses of current_cpu_data with this_cpu ops

From: Eric Dumazet
Date: Wed Dec 08 2010 - 08:38:34 EST


Le mercredi 08 dÃcembre 2010 Ã 14:16 +0100, Tejun Heo a Ãcrit :
> From 9e9b27bff0e2441512ec27d3a90b252ecdc6ec3e Mon Sep 17 00:00:00 2001
> From: Christoph Lameter <cl@xxxxxxxxx>
> Date: Wed, 8 Dec 2010 14:11:07 +0100
>
> Replace all uses of current_cpu_data with this_cpu operations on the
> per cpu structure cpu_info. The scala accesses are replaced with the
> matching this_cpu ops which results in smaller and more efficient
> code.
>
> In the long run, it might be a good idea to remove cpu_data() macro
> too and use per_cpu macro directly.
>

or introduce this_cpu_has() to remove the adress computation

- if (cpu_has(__this_cpu_ptr(&cpu_info), X86_FEATURE_ARAT)) {

+ if (this_cpu_has(X86_FEATURE_ARAT)) {

> tj: updated description
>
> Cc: Yinghai Lu <yinghai@xxxxxxxxxx>
> Cc: Ingo Molnar <mingo@xxxxxxx>
> Signed-off-by: Christoph Lameter <cl@xxxxxxxxx>
> Signed-off-by: Tejun Heo <tj@xxxxxxxxxx>
> ---
> Comitted with updated description. Thanks.
>
> arch/x86/include/asm/processor.h | 3 +--
> arch/x86/kernel/apic/apic.c | 2 +-
> arch/x86/kernel/cpu/amd.c | 2 +-
> arch/x86/kernel/cpu/cpufreq/powernow-k8.c | 2 +-
> arch/x86/kernel/cpu/intel_cacheinfo.c | 4 ++--
> arch/x86/kernel/cpu/mcheck/mce.c | 14 +++++++-------
> arch/x86/kernel/cpu/mcheck/mce_intel.c | 2 +-
> arch/x86/kernel/process.c | 4 ++--
> arch/x86/kernel/smpboot.c | 12 ++++++------
> arch/x86/oprofile/op_model_ppro.c | 8 ++++----
> drivers/staging/lirc/lirc_serial.c | 4 ++--
> 11 files changed, 28 insertions(+), 29 deletions(-)
>
> diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h
> index cae9c3c..c6efecf 100644
> --- a/arch/x86/include/asm/processor.h
> +++ b/arch/x86/include/asm/processor.h
> @@ -141,10 +141,9 @@ extern __u32 cpu_caps_set[NCAPINTS];
> #ifdef CONFIG_SMP
> DECLARE_PER_CPU_SHARED_ALIGNED(struct cpuinfo_x86, cpu_info);
> #define cpu_data(cpu) per_cpu(cpu_info, cpu)
> -#define current_cpu_data __get_cpu_var(cpu_info)
> #else
> +#define cpu_info boot_cpu_data
> #define cpu_data(cpu) boot_cpu_data
> -#define current_cpu_data boot_cpu_data
> #endif
>
> extern const struct seq_operations cpuinfo_op;
> diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c
> index 3f838d5..8accfe3 100644
> --- a/arch/x86/kernel/apic/apic.c
> +++ b/arch/x86/kernel/apic/apic.c
> @@ -516,7 +516,7 @@ static void __cpuinit setup_APIC_timer(void)
> {
> struct clock_event_device *levt = &__get_cpu_var(lapic_events);
>
> - if (cpu_has(&current_cpu_data, X86_FEATURE_ARAT)) {
> + if (cpu_has(__this_cpu_ptr(&cpu_info), X86_FEATURE_ARAT)) {
> lapic_clockevent.features &= ~CLOCK_EVT_FEAT_C3STOP;
> /* Make LAPIC timer preferrable over percpu HPET */
> lapic_clockevent.rating = 150;

...


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/