Re: [PATCH -v4] x86: MCE: Re-implement MCE log ring buffer as per-CPU ring buffer

Hidetoshi Seto
2009-06-08T03:10:21Z

> Emm, it seem hard to analyze mce_log_cpu from per_cpu_var(mce_log_cpus),
> how about following method:
>
> struct mce_log {
> char signature[12];
> ...
> struct mce_log_cpu *mcelog_cpus[];
> };
>
> void mcelog_init(void)
> {
> int cpu;
> mcelog.mcelog_cpus = kmalloc(sizeof(void *) * num_possible_cpus();
> for_each_possible_cpu(cpu)
> mcelog.mcelog_cpus[cpu] = &per_cpu(mce_log_cpus, cpu);
> }

It would be good. Using kzalloc() will be better.
It might be a bit much, but how about adding:

+ mcelog.nr_mcelog_cpus = num_possible_cpus();

Be careful that mcheck_init(), caller of mcelog_init(), will be called
for each booted CPU. You will need:

+ if (mcelog.mcelog_cpus)
+ return;

Thanks,
H.Seto