Hi,
I use sparse (cgcc) with different kernel versions to do some quick checks on the batman-adv kernel module. I noticed that my change from UP to SMP kernel generated some 'weird' warnings regarding a 'context imbalance' which I couldn't find, but went away when switching from spin_(un)lock to spin_(un)lock_bh - something which doesn't make sense in my mind.
I am not quite sure if this is linux-headers or sparse related - so I try to post it here first. I choose 2.6.32 because it is the latest long stable kernel and will be used in by Debian Squeeze.
My current test was done like that (on debian squeeze i386): ----------------------------------------------------------- $ cd $MY_v2.6.32 $ make mrproper $ make allnoconfig $ grep -v 'CONFIG_MODULES is not set' .config > .config.tmp; mv .config.tmp \ .config $ grep -v 'CONFIG_NET is not set' .config > .config.tmp; mv .config.tmp \ .config $ grep -v 'CONFIG_SMP is not set' .config > .config.tmp; mv .config.tmp \ .config $ grep -v 'CONFIG_MODULE_UNLOAD is not set' .config > .config.tmp; mv \ .config.tmp .config $ echo 'CONFIG_MODULES=y' >> .config $ echo 'CONFIG_NET=y' >> .config $ echo 'CONFIG_SMP=y' >> .config $ echo 'CONFIG_MODULE_UNLOAD=y' >> .config $ echo 'xy'|make menuconfig $ make prepare $ make modules
$ mkdir test $ cd test $ cat << EOF > Makefile obj-m += test.o test-y += main.o EOF $ cat << EOF > main.c #include <linux/module.h> #include <linux/spinlock.h>
static DEFINE_SPINLOCK(testlock);
static int __init test_init(void) { spin_lock(&testlock); spin_unlock(&testlock); return 0; }
static void __exit test_exit(void) { }
module_init(test_init); module_exit(test_exit); EOF
$ make CC=cgcc -C $MY_v2.6.32/linux-next M=$(pwd) modules make: Entering directory `$MY_v2.6.32' CC [M] $MY_v2.6.32/testmodule/main.o $MY_v2.6.32/test/main.c:6:19: warning: context imbalance in 'test_init' - wrong count at exit LD [M] $MY_v2.6.32/test/test.o Building modules, stage 2. MODPOST 1 modules LD [M] $MY_v2.6.32/test/test.ko make: Leaving directory `$MY_v2.6.32' -----------------------------------------------------------
The sparse version was v0.4.3. It was obtained from git and and build using the current Debian squeeze tools provided by build-essential. It was run from the build dir by specifying it in $PATH
$ export PATH=$MY_SPARSE_CHECKOUT:$PATH
Best regards, Sven