hubertf's NetBSD Blog
Send interesting links to hubert at feyrer dot de!
 
[20090927] Looking at the new kernel modules in NetBSD-current
In contrast to the current and previous NetBSD releases, NetBSD-current and the next major release (6.0) uses a new system for kernel modules. Unlike the "old" loadable kernel modules (LKMs), the new module framework supports dependencies between modules, and loading of kernel modules on demand.

Today, I've found time to install NetBSD-current/i386, and configure things that I use here - /kern, /proc, and some NFS, in addition to a local disk. Now, looking at the list of loaded kernel modules reveals:

% modstat 
NAME            CLASS   SOURCE  REFS    SIZE    REQUIRES
compat          misc    builtin 0       -       -
coredump        misc    filesys 1       3067    -
exec_elf32      misc    filesys 0       7225    coredump
exec_script     misc    filesys 0       1187    -
ffs             vfs     boot    0       166292  -
kernfs          vfs     filesys 0       11131   -
nfs             vfs     filesys 0       145345  -
procfs          vfs     filesys 0       28068   -
ptyfs           vfs     filesys 0       8975    - 
Interesting points here are that nfs, kernfs and procfs are just listed in /etc/fstab, and the related filesystem modules are loaded automatically, without a need to worry if they are needed or not. In fact I just assumed NFS is in the GENERIC kernel. Seems it's loaded as module! ;)

Another interesting module is "coredump", which is loaded by the module to execure 32bit ELF programs, exec_elf32. This is an example of module dependencies, and again no manual intervention was needed.

So what modules are there? First, let's remember that kernel modules are object code that implements facilities for the running kernel, and which interfaces closely with the running kernel. As such, they need to match the kernel version, ideally. When one of the kernel's API or ABI interfaces changes, it's best to rebuild all modules. For NetBSD, the kernel's version is bumped e.g. from 5.99.15 to 5.99.16 for such an interface change, which helps tracking those changes.

Back to the question of what modules are there. Now that we know kernel modules are closely tied to the version of the kernel (which still is in the file /netbsd, btw), associated modules -- for the example of NetBSD/i386 5.99.15 -- can be found in /stand/i386/5.99.15/modules:

% cd /stand/i386/5.99.15/modules
% ls -F
accf_dataready/     drm/                lfs/                ptyfs/
accf_httpready/     efs/                mfs/                puffs/
adosfs/             exec_aout/          miniroot/           putter/
aio/                exec_elf32/         mqueue/             radeondrm/
azalia/             exec_script/        msdos/              smbfs/
cd9660/             ext2fs/             nfs/                sysvbfs/
coda/               fdesc/              nfsserver/          tmpfs/
coda5/              ffs/                nilfs/              tprof/
compat/             filecore/           ntfs/               tprof_pmi/
compat_freebsd/     fss/                null/               udf/
compat_ibcs2/       hfs/                overlay/            umap/
compat_linux/       i915drm/            portal/             union/
compat_ossaudio/    kernfs/             ppp_bsdcomp/        vnd/
compat_svr4/        ksem/               ppp_deflate/
coredump/           layerfs/            procfs/

% ls */*.kmod
accf_dataready/accf_dataready.kmod      layerfs/layerfs.kmod
accf_httpready/accf_httpready.kmod      lfs/lfs.kmod
adosfs/adosfs.kmod                      mfs/mfs.kmod
aio/aio.kmod                            miniroot/miniroot.kmod
azalia/azalia.kmod                      mqueue/mqueue.kmod
cd9660/cd9660.kmod                      msdos/msdos.kmod
coda/coda.kmod                          nfs/nfs.kmod
coda5/coda5.kmod                        nfsserver/nfsserver.kmod
compat/compat.kmod                      nilfs/nilfs.kmod
compat_freebsd/compat_freebsd.kmod      ntfs/ntfs.kmod
compat_ibcs2/compat_ibcs2.kmod          null/null.kmod
compat_linux/compat_linux.kmod          overlay/overlay.kmod
compat_ossaudio/compat_ossaudio.kmod    portal/portal.kmod
compat_svr4/compat_svr4.kmod            ppp_bsdcomp/ppp_bsdcomp.kmod
coredump/coredump.kmod                  ppp_deflate/ppp_deflate.kmod
drm/drm.kmod                            procfs/procfs.kmod
efs/efs.kmod                            ptyfs/ptyfs.kmod
exec_aout/exec_aout.kmod                puffs/puffs.kmod
exec_elf32/exec_elf32.kmod              putter/putter.kmod
exec_script/exec_script.kmod            radeondrm/radeondrm.kmod
ext2fs/ext2fs.kmod                      smbfs/smbfs.kmod
fdesc/fdesc.kmod                        sysvbfs/sysvbfs.kmod
ffs/ffs.kmod                            tmpfs/tmpfs.kmod
filecore/filecore.kmod                  tprof/tprof.kmod
fss/fss.kmod                            tprof_pmi/tprof_pmi.kmod
hfs/hfs.kmod                            udf/udf.kmod
i915drm/i915drm.kmod                    umap/umap.kmod
kernfs/kernfs.kmod                      union/union.kmod
ksem/ksem.kmod                          vnd/vnd.kmod

% find . -type f -print | wc -l
      58 
There are directories with major kernel subsystems in the named directory, each one containing various files with the ".kmod" extension, for kernel modules. Subsystems include kernel accept filters, various file systems, compatibility modules, execution modules for various binary formats, and many others. Currently there are 58 kernel modules, and I guess we can expect more in the future.

P.S.: I've seen one confusion WRT systems that use kernel modules to whatever extent, as they shrink the size of the actual kernel binary: Even with kernel modules, an operating system is still a monolithic kernel: The modules are tied in closely into the system once loaded, ending in a monolithic system. In contrast, a "microkernel" is something very different, and it doesn't have anything to do with kernel modules. :-)

[Tags: , , ]


Disclaimer: All opinion expressed here is purely my own. No responsibility is taken for anything.

Access count: 36111578
Copyright (c) Hubert Feyrer