Skip to content

Commit

Permalink
x86/mce: Convert static array of pointers to per-cpu variables
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Greg Kroah-Hartman authored and Tony Luck committed Feb 22, 2012
1 parent b01543d commit d6126ef
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion arch/x86/include/asm/mce.h
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ static inline void enable_p5_mce(void) {}

void mce_setup(struct mce *m);
void mce_log(struct mce *m);
extern struct device *mce_device[CONFIG_NR_CPUS];
DECLARE_PER_CPU(struct device *, mce_device);

/*
* Maximum banks number.
Expand Down
8 changes: 4 additions & 4 deletions arch/x86/kernel/cpu/mcheck/mce.c
Original file line number Diff line number Diff line change
Expand Up @@ -1859,7 +1859,7 @@ static struct bus_type mce_subsys = {
.dev_name = "machinecheck",
};

struct device *mce_device[CONFIG_NR_CPUS];
DEFINE_PER_CPU(struct device *, mce_device);

__cpuinitdata
void (*threshold_cpu_callback)(unsigned long action, unsigned int cpu);
Expand Down Expand Up @@ -2038,7 +2038,7 @@ static __cpuinit int mce_device_create(unsigned int cpu)
goto error2;
}
cpumask_set_cpu(cpu, mce_device_initialized);
mce_device[cpu] = dev;
per_cpu(mce_device, cpu) = dev;

return 0;
error2:
Expand All @@ -2055,7 +2055,7 @@ static __cpuinit int mce_device_create(unsigned int cpu)

static __cpuinit void mce_device_remove(unsigned int cpu)
{
struct device *dev = mce_device[cpu];
struct device *dev = per_cpu(mce_device, cpu);
int i;

if (!cpumask_test_cpu(cpu, mce_device_initialized))
Expand All @@ -2069,7 +2069,7 @@ static __cpuinit void mce_device_remove(unsigned int cpu)

device_unregister(dev);
cpumask_clear_cpu(cpu, mce_device_initialized);
mce_device[cpu] = NULL;
per_cpu(mce_device, cpu) = NULL;
}

/* Make sure there are no machine checks on offlined CPUs. */
Expand Down
9 changes: 5 additions & 4 deletions arch/x86/kernel/cpu/mcheck/mce_amd.c
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,7 @@ static __cpuinit int threshold_create_bank(unsigned int cpu, unsigned int bank)
{
int i, err = 0;
struct threshold_bank *b = NULL;
struct device *dev = mce_device[cpu];
struct device *dev = per_cpu(mce_device, cpu);
char name[32];

sprintf(name, "threshold_bank%i", bank);
Expand Down Expand Up @@ -585,7 +585,7 @@ static __cpuinit int threshold_create_bank(unsigned int cpu, unsigned int bank)
if (i == cpu)
continue;

dev = mce_device[i];
dev = per_cpu(mce_device, i);
if (dev)
err = sysfs_create_link(&dev->kobj,b->kobj, name);
if (err)
Expand Down Expand Up @@ -665,7 +665,8 @@ static void threshold_remove_bank(unsigned int cpu, int bank)
#ifdef CONFIG_SMP
/* sibling symlink */
if (shared_bank[bank] && b->blocks->cpu != cpu) {
sysfs_remove_link(&mce_device[cpu]->kobj, name);
dev = per_cpu(mce_device, cpu);
sysfs_remove_link(&dev->kobj, name);
per_cpu(threshold_banks, cpu)[bank] = NULL;

return;
Expand All @@ -677,7 +678,7 @@ static void threshold_remove_bank(unsigned int cpu, int bank)
if (i == cpu)
continue;

dev = mce_device[i];
dev = per_cpu(mce_device, i);
if (dev)
sysfs_remove_link(&dev->kobj, name);
per_cpu(threshold_banks, i)[bank] = NULL;
Expand Down

0 comments on commit d6126ef

Please sign in to comment.