dynamic smp aware modules (was: Re: Multiple kernel building/installing)

Simon 'corecode' Schubert corecode at fs.ei.tum.de
Thu Feb 22 16:48:39 PST 2007


YONETANI Tomokazu wrote:
On Thu, Feb 22, 2007 at 11:49:32PM +0100, Gergo Szakal wrote:
(did not want to pollute the commits list)
Does the last commit by corecode make it possivle to build/install an SMP and a non-SMP kernel together?
You've been able to *build* multiple kernels:
  make KERNCONF='GENERIC LINT' buildkernel
but you couldn't install the kernels with different names.
Yes, that didn't change either.  I just changed the infrastructure so that nrelease could build multiple kernels as well.

 However,
even if you install an SMP and non-SMP kernels with different names,
not all kernel modules can be shared -- at least any kernel modules
using spinlocks, such as nfs.ko and acpi.ko
I think we should change this.  And actually it is quite easy.  Replace

#ifdef SMP
	code
#endif
with
	if (is_smp) {
		code
	}
and have some header doing

#ifndef _KERNEL_MODULE
const static int is_smp =
# ifdef SMP
	1;
# else
	0;
# endif
#else
extern const int is_smp;
#endif
and initialize is_smp appropriately in some kernel source.

The kernel will be compiled optimized, because the compiler knows that is_smp is a const value and thus can remove dead code.  Modules will take the penalty of checking this variable, but that's hardly an impact, because it will be in the cache anyways.  Just make sure that the variable is in its own cache line, which never changes.

comments?

cheers
 simon
--
Serve - BSD     +++  RENT this banner advert  +++    ASCII Ribbon   /"\
Work - Mac      +++  space for low €€€ NOW!1  +++      Campaign     \ /
Party Enjoy Relax   |   http://dragonflybsd.org      Against  HTML   \
Dude 2c 2 the max   !   http://golden-apple.biz       Mail + News   / \
Attachment:
signature.asc
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pgp00017.pgp
Type: application/octet-stream
Size: 252 bytes
Desc: "Description: OpenPGP digital signature"
URL: <http://lists.dragonflybsd.org/pipermail/kernel/attachments/20070222/de7991f3/attachment-0014.obj>


More information about the Kernel mailing list