* improper sparse warnings in linux kernel build?
@ 2011-09-09 22:41 H Hartley Sweeten
2011-09-10 5:27 ` Dan Carpenter
0 siblings, 1 reply; 3+ messages in thread
From: H Hartley Sweeten @ 2011-09-09 22:41 UTC (permalink / raw)
To: linux-sparse; +Cc: Linux Kernel
Hello all,
I'm not sure if this is the correct place to post this. Please let me know.
I am seeing a lot of sparse warnings when compiling the linux kernel that
look like this:
arch/x86/kernel/cpu/mcheck/mce_intel.c:25:8:
warning: symbol 'mce_banks_owned' was not declared. Should it be static?
This line in the code is:
static DEFINE_PER_CPU(mce_banks_t, mce_banks_owned);
I'm not really sure what the DEFINE_PER_CPU macro expands to so I'm not
sure if the 'static' in front is actually getting used or if sparse is just
confused.
Is this an actual problem in the linux kernel or is sparse just getting
tripped up by the DEFINE_PER_CPU macro?
Thanks,
Hartley
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: improper sparse warnings in linux kernel build?
2011-09-09 22:41 improper sparse warnings in linux kernel build? H Hartley Sweeten
@ 2011-09-10 5:27 ` Dan Carpenter
2011-09-19 17:49 ` H Hartley Sweeten
0 siblings, 1 reply; 3+ messages in thread
From: Dan Carpenter @ 2011-09-10 5:27 UTC (permalink / raw)
To: H Hartley Sweeten; +Cc: linux-sparse, Linux Kernel
On Fri, Sep 09, 2011 at 03:41:28PM -0700, H Hartley Sweeten wrote:
> I'm not really sure what the DEFINE_PER_CPU macro expands to so I'm not
> sure if the 'static' in front is actually getting used or if sparse is just
> confused.
>
> Is this an actual problem in the linux kernel or is sparse just getting
> tripped up by the DEFINE_PER_CPU macro?
>
I don't have a kernel git archive handy, but probably sparse is
correct. Do a "make arch/x86/kernel/cpu/mcheck/mce_intel.i" and run
sparse on the .i file to find the line number that complains.
regards,
dan carpenter
^ permalink raw reply [flat|nested] 3+ messages in thread
* RE: improper sparse warnings in linux kernel build?
2011-09-10 5:27 ` Dan Carpenter
@ 2011-09-19 17:49 ` H Hartley Sweeten
0 siblings, 0 replies; 3+ messages in thread
From: H Hartley Sweeten @ 2011-09-19 17:49 UTC (permalink / raw)
To: Dan Carpenter; +Cc: linux-sparse@vger.kernel.org, Linux Kernel
On Friday, September 09, 2011 10:27 PM, Dan Carpenter wrote:
> On Fri, Sep 09, 2011 at 03:41:28PM -0700, H Hartley Sweeten wrote:
>> I'm not really sure what the DEFINE_PER_CPU macro expands to so I'm not
>> sure if the 'static' in front is actually getting used or if sparse is just
>> confused.
>>
>> Is this an actual problem in the linux kernel or is sparse just getting
>> tripped up by the DEFINE_PER_CPU macro?
>>
>
> I don't have a kernel git archive handy, but probably sparse is
> correct. Do a "make arch/x86/kernel/cpu/mcheck/mce_intel.i" and run
> sparse on the .i file to find the line number that complains.
Dan,
The DEFINE_PER_CPU line in that file gets expanded from:
static DEFINE_PER_CPU(mce_banks_t, mce_banks_owned);
To (line breaks added for readability):
static __attribute__((section(".discard"), unused)) char __pcpu_scope_mce_banks_owned;
extern __attribute__((section(".discard"), unused)) char __pcpu_unique_mce_banks_owned;
__attribute__((section(".discard"), unused)) char __pcpu_unique_mce_banks_owned;
__attribute__((section(".data..percpu" ""))) __attribute__((weak)) __typeof__(mce_banks_t) mce_banks_owned;
It looks like the static tag is getting correctly applied to the first variable,
__pcpu_scope_mce_banks_owned. The second one, __pcpu_unique_mce_banks_owned, is
getting tagged extern by the macro so the next __pcpu_unique_mce_banks_owned is ok.
The last variable, mce_banks_owned, seems to be the problem.
mce_banks_owned appears to be the only variable actually used in the file. I'm not
sure what the other three are used for.
I think the only way to fix this is by creating a new DEFINE_PER_CPU macro
(DEFINE_PER_CPU_STATIC or DEFINE_STATIC_PER_CPU?) that automatically adds the static
tags correctly.
Regards,
Hartley
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2011-09-19 17:49 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-09-09 22:41 improper sparse warnings in linux kernel build? H Hartley Sweeten
2011-09-10 5:27 ` Dan Carpenter
2011-09-19 17:49 ` H Hartley Sweeten
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox