Subject: Re: [PATCH -next] x86 msrs: alloc/free for CONFIG_SMP=n

From: "H. Peter Anvin" <[email-masked]>
Date: Wed, 16 Dec 2009 14:41:13 -0800

On 12/16/2009 01:58 PM, Borislav Petkov wrote:
> 
>>
>> --- linux-next-20091216.orig/arch/x86/lib/Makefile
>> +++ linux-next-20091216/arch/x86/lib/Makefile
>> @@ -14,7 +14,7 @@ $(obj)/inat.o: $(obj)/inat-tables.c
>>  
>>  clean-files := inat-tables.c
>>  
>> -obj-$(CONFIG_SMP) := msr.o
>> +obj-$(CONFIG_X86_MSR) := msr.o
> 
> however, CONFIG_X86_MSR is the x86 MSR access module and the <lib/msr.c>
> is the library of MSR accessing functions which is always in. So this
> should be unconditional as in my version or Peter might have a better
> idea...?
> 

Both are wrong.

CONFIG_X86_MSR has nothing at all to do with this and is a complete red
herring.  Involving CONFIG_X86_MSR is just totally bogus.

Including msr.o unconditionally is also wrong, but for a more subtle
reason: msr.c is written to contain functions that apply to SMP only;
with UP replacement stubs written as inlines in
arch/x86/include/asm/msr.h.

Putting most of the file inside a big #ifdef of course works, but is a
pretty bad case of beating it with the ugly stick.  My preference would
be to move the SMP-specific functions to a new file, call it msr-smp.c,
and then leave only the functions that should be included
unconditionally in msr.c (I believe it is cleaner to do it that way than
the opposite.)

	-hpa