hello....

I would like to know if it is possible to compile a module such that it can be run from either the UP or SMP version of the kernel.

The problem that I have right now is that when I compile my module it includes linux/module.h (eventually) and so gets the __module_kernel_version[] string set to the kernel version that it was compiled on. This string either has ...smp attached to the kernel version of not depending on whether or not the build machine was booted in SMP mode or not. I then install the module into both /lib/modules/<version>/misc and /lib/modules/<version>smp/misc.

If the machine was booted in SMP mode and the module built on a UP machine I get the following whiny-gram from insmod:

[root@sunfrh9 atmii]# insmod streams-a_sscop
Using /lib/modules/2.4.20-8smp/misc/streams-a_sscop
/lib/modules/2.4.20-8smp/misc/streams-a_sscop: kernel-module version mismatch
/lib/modules/2.4.20-8smp/misc/streams-a_sscop was compiled for kernel version 2.4.20-8
while this kernel is version 2.4.20-8smp.

and the module doesn't load. I need to explictly do an "insmod -f" to force the module to load.

Ok, the problem with this is that I am trying to make it so that my module will automatically be loaded the first time that it is pushed.

The module is a STREAMS module which uses LiS v2.18.0. LiS "insulates" my module by abstracting any kernel interfaces that my driver may need. LiS is compiled on the machine which runs the driver, but my drivers and modules can simply be shipped as binaries. Therefore it doesn't make any difference to my driver if the kernel is SMP or UP because LiS will automatically call the right function since it is compiled on the target machine.

What LiS does to load my module is to call request_module() the first time that the module is pushed. request_module() is a linux kernel function which pretty much just calls:
/sbin/modprobe -s -k --
(see kernel/kmod.c:149).

So, the long and the short is:

1) Is there a way to do away with the __module_kernel_version string?

1b) will this fix the problem with the "mismatching" kernel versions?

2) Is there a different method for loading modules other than request_module() that can force the module to load (kind of the equivelent of insmod -f from inside the kernel)?

3) Why does insmod barf on this? Why are modules compiled on a SMP machine inhierently incompatible with a UP kernel of the same version?

I can work around this by just including a startup script to do a insmod -f or distributing two different modules, one complied for UP and one for SMP, but I'd like to know if it's possible to defeat this kernel versioning "feature".

BTW I am running RH 9.0 (kernel 2.4.20-8, or 2.4.20-8smp).

Any insights are appreciated.

thanks-
dan