diff options
author | Greg Kroah-Hartman <gregkh@suse.de> | 2012-01-26 18:49:14 -0500 |
---|---|---|
committer | Tony Luck <tony.luck@intel.com> | 2012-02-22 15:58:06 -0500 |
commit | d6126ef5f31ca54980cb067af659a360dfcca037 (patch) | |
tree | cd2d841daabb02f050c085d463dd314bef05c3c8 | |
parent | b01543dfe67bb1d191998e90d20534dc354de059 (diff) |
x86/mce: Convert static array of pointers to per-cpu variables
When I previously fixed up the mce_device code, I used a static array of
the pointers. It was (rightfully) pointed out to me that I should be
using the per_cpu code instead.
This patch converts the code over to that structure, moving the variable
back into the per_cpu area, like it used to be for 3.2 and earlier.
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Reviewed-by: Srivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com>
Link: https://lkml.org/lkml/2012/1/27/165
Signed-off-by: Tony Luck <tony.luck@intel.com>
-rw-r--r-- | arch/x86/include/asm/mce.h | 2 | ||||
-rw-r--r-- | arch/x86/kernel/cpu/mcheck/mce.c | 8 | ||||
-rw-r--r-- | arch/x86/kernel/cpu/mcheck/mce_amd.c | 9 |
3 files changed, 10 insertions, 9 deletions
diff --git a/arch/x86/include/asm/mce.h b/arch/x86/include/asm/mce.h index 6aefb14cbbc5..441520e4174f 100644 --- a/arch/x86/include/asm/mce.h +++ b/arch/x86/include/asm/mce.h | |||
@@ -151,7 +151,7 @@ static inline void enable_p5_mce(void) {} | |||
151 | 151 | ||
152 | void mce_setup(struct mce *m); | 152 | void mce_setup(struct mce *m); |
153 | void mce_log(struct mce *m); | 153 | void mce_log(struct mce *m); |
154 | extern struct device *mce_device[CONFIG_NR_CPUS]; | 154 | DECLARE_PER_CPU(struct device *, mce_device); |
155 | 155 | ||
156 | /* | 156 | /* |
157 | * Maximum banks number. | 157 | * Maximum banks number. |
diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/mce.c index 5a11ae2e9e91..4979a5dfeba2 100644 --- a/arch/x86/kernel/cpu/mcheck/mce.c +++ b/arch/x86/kernel/cpu/mcheck/mce.c | |||
@@ -1859,7 +1859,7 @@ static struct bus_type mce_subsys = { | |||
1859 | .dev_name = "machinecheck", | 1859 | .dev_name = "machinecheck", |
1860 | }; | 1860 | }; |
1861 | 1861 | ||
1862 | struct device *mce_device[CONFIG_NR_CPUS]; | 1862 | DEFINE_PER_CPU(struct device *, mce_device); |
1863 | 1863 | ||
1864 | __cpuinitdata | 1864 | __cpuinitdata |
1865 | void (*threshold_cpu_callback)(unsigned long action, unsigned int cpu); | 1865 | void (*threshold_cpu_callback)(unsigned long action, unsigned int cpu); |
@@ -2038,7 +2038,7 @@ static __cpuinit int mce_device_create(unsigned int cpu) | |||
2038 | goto error2; | 2038 | goto error2; |
2039 | } | 2039 | } |
2040 | cpumask_set_cpu(cpu, mce_device_initialized); | 2040 | cpumask_set_cpu(cpu, mce_device_initialized); |
2041 | mce_device[cpu] = dev; | 2041 | per_cpu(mce_device, cpu) = dev; |
2042 | 2042 | ||
2043 | return 0; | 2043 | return 0; |
2044 | error2: | 2044 | error2: |
@@ -2055,7 +2055,7 @@ error: | |||
2055 | 2055 | ||
2056 | static __cpuinit void mce_device_remove(unsigned int cpu) | 2056 | static __cpuinit void mce_device_remove(unsigned int cpu) |
2057 | { | 2057 | { |
2058 | struct device *dev = mce_device[cpu]; | 2058 | struct device *dev = per_cpu(mce_device, cpu); |
2059 | int i; | 2059 | int i; |
2060 | 2060 | ||
2061 | if (!cpumask_test_cpu(cpu, mce_device_initialized)) | 2061 | if (!cpumask_test_cpu(cpu, mce_device_initialized)) |
@@ -2069,7 +2069,7 @@ static __cpuinit void mce_device_remove(unsigned int cpu) | |||
2069 | 2069 | ||
2070 | device_unregister(dev); | 2070 | device_unregister(dev); |
2071 | cpumask_clear_cpu(cpu, mce_device_initialized); | 2071 | cpumask_clear_cpu(cpu, mce_device_initialized); |
2072 | mce_device[cpu] = NULL; | 2072 | per_cpu(mce_device, cpu) = NULL; |
2073 | } | 2073 | } |
2074 | 2074 | ||
2075 | /* Make sure there are no machine checks on offlined CPUs. */ | 2075 | /* Make sure there are no machine checks on offlined CPUs. */ |
diff --git a/arch/x86/kernel/cpu/mcheck/mce_amd.c b/arch/x86/kernel/cpu/mcheck/mce_amd.c index 786e76a86322..a4bf9d23cdba 100644 --- a/arch/x86/kernel/cpu/mcheck/mce_amd.c +++ b/arch/x86/kernel/cpu/mcheck/mce_amd.c | |||
@@ -523,7 +523,7 @@ static __cpuinit int threshold_create_bank(unsigned int cpu, unsigned int bank) | |||
523 | { | 523 | { |
524 | int i, err = 0; | 524 | int i, err = 0; |
525 | struct threshold_bank *b = NULL; | 525 | struct threshold_bank *b = NULL; |
526 | struct device *dev = mce_device[cpu]; | 526 | struct device *dev = per_cpu(mce_device, cpu); |
527 | char name[32]; | 527 | char name[32]; |
528 | 528 | ||
529 | sprintf(name, "threshold_bank%i", bank); | 529 | sprintf(name, "threshold_bank%i", bank); |
@@ -585,7 +585,7 @@ static __cpuinit int threshold_create_bank(unsigned int cpu, unsigned int bank) | |||
585 | if (i == cpu) | 585 | if (i == cpu) |
586 | continue; | 586 | continue; |
587 | 587 | ||
588 | dev = mce_device[i]; | 588 | dev = per_cpu(mce_device, i); |
589 | if (dev) | 589 | if (dev) |
590 | err = sysfs_create_link(&dev->kobj,b->kobj, name); | 590 | err = sysfs_create_link(&dev->kobj,b->kobj, name); |
591 | if (err) | 591 | if (err) |
@@ -665,7 +665,8 @@ static void threshold_remove_bank(unsigned int cpu, int bank) | |||
665 | #ifdef CONFIG_SMP | 665 | #ifdef CONFIG_SMP |
666 | /* sibling symlink */ | 666 | /* sibling symlink */ |
667 | if (shared_bank[bank] && b->blocks->cpu != cpu) { | 667 | if (shared_bank[bank] && b->blocks->cpu != cpu) { |
668 | sysfs_remove_link(&mce_device[cpu]->kobj, name); | 668 | dev = per_cpu(mce_device, cpu); |
669 | sysfs_remove_link(&dev->kobj, name); | ||
669 | per_cpu(threshold_banks, cpu)[bank] = NULL; | 670 | per_cpu(threshold_banks, cpu)[bank] = NULL; |
670 | 671 | ||
671 | return; | 672 | return; |
@@ -677,7 +678,7 @@ static void threshold_remove_bank(unsigned int cpu, int bank) | |||
677 | if (i == cpu) | 678 | if (i == cpu) |
678 | continue; | 679 | continue; |
679 | 680 | ||
680 | dev = mce_device[i]; | 681 | dev = per_cpu(mce_device, i); |
681 | if (dev) | 682 | if (dev) |
682 | sysfs_remove_link(&dev->kobj, name); | 683 | sysfs_remove_link(&dev->kobj, name); |
683 | per_cpu(threshold_banks, i)[bank] = NULL; | 684 | per_cpu(threshold_banks, i)[bank] = NULL; |