2011-09-24 :-)
_ 午前
1030 起床 || 部屋掃除
_ 夜
2000 飯。ぶりかま
_ [NetBSD][カーネルモジュール][翻訳]hubertf's NetBSD blog - Looking at the new kernel modules in NetBSD-current
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.
current と以前の NetBSD リリースとは対称的に、NetBSD-current と次のメジャーリリース (6.0) は新しいカーネルモジュールを使う。旧ローダブルカーネルモジュール(LKM) とは異なり、新しいモジュールフレームワークはモジュール間の依存関係に対応し、必要に応じてカーネルモジュールをロードする。
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:
今日、NetBSD-current/i386 をインストールし、/kern, /proc といくつかの NFS とローカルディスクの追加を設定した。いまロード済みカーネルモジュールの一覧を以下に示す:
% 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! ;)
ここで興味深い点は、 nfs, kernfs と procf は /etc/fstab に挙げられているだけであり、関連するファイルシステムモジュールは、必要かそうでないか手間をかける必要なくロードされた。実際 GENERIC カーネルに NFS が書いてあるだけだ。モジュールとしてロードされたのである! ヽ( ´ー`)ノ
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.
他の興味深いモジュールは coredump だ。これは 32bit ELF プログラムを実行するためのモジュール exec_elf32 からロードされた。これはモジュール依存の例であり、再び手動での作業が必要とされなかった。
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.
それでモジュールはどこだって? まず、カーネルモジュールはカーネル実行のための仕組みを実装したオブジェクトコードであり、実行中のカーネルと密接したインターフェースであるということを思い出そう。よって、理想的にはカーネルバージョンにマッチしている必要がある。カーネルの API か ABI のインターフェースを 1 つでも変更したら、すべてのモジュールを再構築するのが最善である。NetBSD カーネルのバージョン 5.99.15 から 5.99.16 でインターフェースの変更があった。それらの変更点を追跡すると助けになる。
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
モジュールはどこなのか、という問いに戻ろう。いまやカーネルモジュールはカーネルのバージョンに密接に結びついていることは既知だ( ちなみに /netbsd にもある ) 例えば NetBSD/i386 5.99.15 に連するモジュールは /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.
おもなカーネルサブシステムの名前がついたディレクトリがある。各々カーネルモジュールとして .kmod 拡張子がついた様々なファイルを含んでいる。サブシステムは、カーネル accept filter、様々なファイルシステム、互換性モジュール、様々なバイナリ形式を実行するためのモジュール、その他いろいろを含んでいる。現在カーネルモジュールは 58 個ある。将来もっと増えるだろう。
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. :-)
P.S. このシステムについて、すべての拡張についてカーネルモジュールを使えば実際のカーネルバイナリーのサイズを縮小するといった混乱を見かけた。カーネルモジュールを使ったとしてもオペレーティングシステムはいまだモノリシックカーネルなのだ。モジュールは一度ロードされれば、モノリシックシステムの終了までシステムに密接に結びつく。 対称的にマイクロカーネルは たくさんの違い が何かしらある。そしてカーネルモジュールについて何も知らない ( ´_ゝ`)