1 / 14

Drivers and the Kernel

Explore the roles of the kernel in a UNIX system, understand kernel-wide design approaches, learn to build custom kernels, and optimize FreeBSD performance through tuning. Step-by-step guide with references and troubleshooting tips.

rglines
Download Presentation

Drivers and the Kernel

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Drivers and the Kernel

  2. Roles of the Kernel – (1) • Components of a UNIX System • User-level programs • Kernel • Hardware • Kernel manages the resources • CPU – process management • Memory – memory management • I/O devices – device management • Kernel provides method for • Inter-process communication (IPC) • Synchronization, communication • Processes to request resources • System calls

  3. Roles of the Kernel – (2)

  4. Kernel-wide Design Approaches • Monolithic kernels • Kernel space, shared memory, fast, …, need reboot • Eg. Linux, *BSD, MS-DOS, MS Windows 9x series… • Microkernels • User space, message passing, slow, …, as services • Eg. Mac OS X, BeOS, … • Hybrid • Monolithic + Micro • Eg. MS Windows NT series, DragonFly BSD, … • Nanokernels • Exokernels

  5. Why Build a Custom Kernel • FreeBSD kernel • Monolithic  modular • The functionality cannot be dynamically loadable • Building a custom kernel • To be an advanced BSD user • Time-consuming task • Customized kernel vs. GENERIC • Fast boot time • Lower memory usage • Additional hardware support • Fine-tune system performance • Such as adjusting important system parameters

  6. Finding the System Hardware • Before venturing into kernel configuration • Get an inventory of the machine’s hardware • Microsoft's Device Manager • dmesg • cat /var/run/dmesg.boot • pciconf -lv • man 4 ath • man -k Atheros psm0: <PS/2 Mouse> irq 12 on atkbdc0 psm0: [GIANT-LOCKED] psm0: [ITHREAD] psm0: model Generic PS/2 mouse, device ID 0 ath0@pci0:3:0:0: class=0x020000 card=0x058a1014 chip=0x1014168c vendor = 'Atheros Communications Inc.' device = 'AR5212 Atheros AR5212 802.11abg wireless' class = network subclass = ethernet

  7. Kernel Drivers and Modules • Before building a custom kernel • Load kernel modules to get the specific hardware support • Kernel modules • kldstat • kldload • /boot/kernel/*.ko • Modify /boot/loader.conf to load modules in boot time automatically • if_ath_load="YES" • kldunload zfs [/home/liuyh] -liuyh- kldstat Id Refs Address Size Name 1 62 0xffffffff80100000 6a2dc8 kernel 2 1 0xffffffff807a3000 1abd08 zfs.ko 3 2 0xffffffff8094f000 3a68 opensolaris.ko 4 4 0xffffffff80953000 1f348 krpc.ko 5 1 0xffffffff80973000 bc28 geom_label.ko

  8. Building and Installing a Custom Kernel – (1) • Obtain full FreeBSD source tree • sysinstall • Configure  Distributions  src  All • csup • csup -h cvsup.tw.freebsd.org /usr/share/examples/cvsup/standard-supfile • Customized kernel configuration file • Sample files • /usr/src/sys/<ARCH>/conf • GENERIC, NOTES, LINT (generated by “make LINT”) • /usr/src/sys/conf/NOTES for architecture independent options • Customized file • cp GENERIC /usr/local/etc/MYKERNEL • ln -s /usr/local/etc/MYKERNEL /usr/src/sys/<ARCH>/conf/

  9. Building and Installing a Custom Kernel – (2) • Building a kernel • cd /usr/src • make buildkernel KERNCONF=MYKERNEL • make installkernel KERNCONF=MYKERNEL • kernel = buildkernel + installkernel • MODULES_OVERRIDE • Set to a list of modules to build instead of all of them • NO_MODULES • Set to not build modules with the kernel • WITHOUT_MODULES • Set to a list of modules to exclude from the build • Kernel locations • /boot/kernel/kernel • /boot/kernel  /boot/kernel.old make.conf(5)

  10. The Configuration File • Each line contains a keyword and one or more arguments • http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/kernelconfig-config.html

  11. If Something Goes Wrong • Config failed • Make sure the keyword is typed correctly • Make failed • Look over your configuration • Send mail to the FreeBSD general questions mailing list with kernel configuration • Boot failed • ok mode • boot kernel.old • unload kernel && load /boot/kernel.old/kernel && boot • nextboot(8) • ps(1) failed • Recompile and install a world

  12. Ok mode

  13. Tuning the FreeBSD Kernel • sysctl command • Dynamically set or get kernel parameters • All changes made by sysctl will be lost across reboot • Use sysctl to tune the kernel and test it, then recompile the kernel • Format: % sysctl [options] name[=value] … Ex: % sysctl –a list all kernel variables % sysctl –d kern.maxfiles print the description of the variable % sysctl kern.maxfiles print the value of the variable % sudo sysctl kern.maxfiles=2048

  14. Reference • References • http://www.freebsd.org/doc/en/books/handbook/kernelconfig-config.html • /usr/src/sys/<ARCH>/conf • NOTES • LINT • GENERIC • Further reading • http://www.freebsd.org/doc/handbook/configtuning-kernel-limits.html • http://www.freebsd.org/doc/en/books/developers-handbook/kerneldebug.html

More Related