Re: mmotm 2009-04-24-18-14 uploaded - NVidia indigestion

From: Nick Piggin
Date: Tue Apr 28 2009 - 02:16:18 EST


On Mon, Apr 27, 2009 at 02:45:15PM -0400, Valdis.Kletnieks@xxxxxx wrote:
> On Sat, 25 Apr 2009 07:24:34 +0200, Nick Piggin said:
>
> > > #include <linux/version.h>
> > > #include <linux/utsname.h>
> > > int main() {
> > > if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)) {
> > > return 0;
> > > } else {
> > > return 1;
> > > }
>
> > Yeah BUILD_BUG_ON does work like that. I can't for the life of me
> > understand why it triggered though. Is anything in your external
> > code calling kmalloc_slab directly?
>
> See above - I didn't think LINUX_VERSION_CODE cared about kmalloc, but
> I could be wrong on this. ;)
>
> > What's the preprocessor output look like?
>
> The problem appears to be that if you only include version.h and utsname.h,
> and *don't* actually reference kmalloc_slab, it doesn't know that the size_t
> is actually a constant, so it whinges. Most modules end up doing at least
> one kmalloc(), so kmalloc() and kmalloc_slab() get inlined, the constant 'size'
> gets propogated, and life is good. If you *don't* call kmalloc(), bad things
> happen. ;)

Hmm, yes if you build without -O, then it appears like the compiler
trips over this. I wouldn't be unhappy with just removing the BUILD_BUG_ON,
but shouldn't the module be using -O[s2]?

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