Re: [PATCH 0/8] x86 boot, pda and gdt cleanups
From: Rusty Russell
Date: Tue Mar 13 2007 - 22:26:13 EST
On Tue, 2007-03-13 at 13:48 -0700, Jeremy Fitzhardinge wrote:
> Rusty Russell wrote:
> > Hi all,
> >
> > The GDT stuff on x86 is a little more complex than it need be, but
> > playing with boot code is always dangerous. These compile and boot on
> > UP and SMP for me, but Andrew should let the cook in -mm for a while.
> >
> Hi Rusty,
>
> This is my rough hacking patch I needed to get things into a Xen-shape
> state.
Looks good. Just one thing:
> void __devinit native_smp_prepare_boot_cpu(void)
> {
> - cpu_set(smp_processor_id(), cpu_online_map);
> - cpu_set(smp_processor_id(), cpu_callout_map);
> - cpu_set(smp_processor_id(), cpu_present_map);
> - cpu_set(smp_processor_id(), cpu_possible_map);
> - per_cpu(cpu_state, smp_processor_id()) = CPU_ONLINE;
> + int cpu = smp_processor_id();
> +
> + cpu_set(cpu, cpu_online_map);
> + cpu_set(cpu, cpu_callout_map);
> + cpu_set(cpu, cpu_present_map);
> + cpu_set(cpu, cpu_possible_map);
> + per_cpu(cpu_state, cpu) = CPU_ONLINE;
>
> /* Set up %fs to point to our per-CPU area now it's allocated */
> - init_gdt(smp_processor_id(), &init_task);
> - cpu_set_gdt(smp_processor_id());
> + init_gdt(cpu, &init_task);
> + cpu_set_gdt(cpu);
> }
This is called "pissing in the corners". Don't do it: we don't need to
touch that code and I actually prefer the original anyway (explicit is
*good*).
The habit of extracting cpu number once then using it is an optimization
which we should be aiming to get rid of (it simply hurts archs with
efficient per-cpu implementations).
Cheers,
Rusty.
-
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/