Re: [PATCH -v3.2 3/3] x86, AMD: Move BSP code to cpu_dev helper

From: H. Peter Anvin
Date: Fri Aug 05 2011 - 18:57:11 EST


On 08/05/2011 03:52 PM, Borislav Petkov wrote:
> On Fri, Aug 05, 2011 at 04:07:40PM -0400, H. Peter Anvin wrote:
>> On 08/05/2011 11:04 AM, Borislav Petkov wrote:
>>> Move code which is run once on the BSP during boot into the cpu_dev
>>> helper.
>>> +static void __cpuinit bsp_init_amd(struct cpuinfo_x86 *c)
>>> +{
>>> + if (static_cpu_has(X86_FEATURE_CONSTANT_TSC)) {
>>> +
>>
>> You can't use static_cpu_has() here, since this code runs before
>> alternatives -- it will always be false. Furthermore, for code that
>> only runs once, it is never a win to do patching.
>
> Oh crap, this is a leftover from when run_on_bsp was struct
> x86_cpuinit_ops member with no args. And I f*cked it up even then
> although I went and got myself a pointer to boot_cpu_data:
>

I fixed it up directly.

>
>> Arguably bsp_init should be __init and not __cpuinit, but I don't know
>> how to make that work with the machinery, and is something that can be
>> fixed anyway.
>
> Yeah, how do we do that? struct cpu_dev is __cpuinitconst,
> x86_cpuinit_ops is __cpuinitdata.
>
> We could add it to identify_boot_cpu() - there's already some per-vendor
> stuff like init_amd_e400_c1e_mask() which wouldn't hurt to be behind a
> vendor check. early_identify_cpu() does already the vendor check with
> get_cpu_vendor() so later, in identify_cpu() we could add a run_on_bsp()
> which is __init and switch/case on the ->x86_vendor inside.
>
> Then we can collect all the run-once-on-the-BSP code in there.
>
> Hmmm..
>

As I said, we can fix this up incrementally.

-hpa
--
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/