File:  [NetBSD Developer Wiki] / wikisrc / tutorials / how_to_reduce_kernel_size.mdwn
Revision 1.3: download - view: text, annotated - select for diffs
Mon Sep 2 20:48:38 2019 UTC (10 months ago) by cnst
Branches: MAIN
CVS tags: HEAD
find wikisrc -name '*.mdwn' | xargs perl -pi'' -e's#\[(http[^]]*)]\(\1\)#<\1>#g'

    1: **Contents**
    2: 
    3: [[!toc levels=3]]
    4: 
    5: #  Introduction 
    6: 
    7: The NetBSD kernel is not big, but it can be made smaller. Generic size reduction steps are: 
    8: 
    9:   * compile with size optimizations 
   10:   * removing debugging and logging features 
   11:   * remove non-essentian functionality 
   12: 
   13: Here is an example which shows how these steps were applied to a NetBSD kernel for an ARM development board. As a result the kernel size got reduced from 2251 to 1124 kilobytes. 
   14: 
   15: Since kernel executable size is not the only measure of kernel memory usage, some tools and their example output are also shown. 
   16: 
   17: #  Example: OMAP 2420 
   18: 
   19: The board receives the kernel via TFTP and the root filesystem is on NFS. Most important components on the board are the serial ports and the Ethernet adapter. 
   20: 
   21: NetBSD current has a default kernel configuration for the board: **sys/arch/evbarm/conf/TISDP2420**. This file includes a number of other configuration files, but after compilation the resulting configuration is available as **sys/arch/evbarm/compile/obj/TISDP2420/config_file.h**. 
   22: 
   23: The configuration file structure and most options are explained in options(4) manual page. In this example options were changed by adding a **no options OPTION_NAME** directive or an **options OPTION_NAME** directive to the end of the default configuration file. By adding these to end of the file, previous declarations from included options files were easily replaced without changing the included files. 
   24: 
   25: ##  Default TISDP2420, 2251 kb 
   26: 
   27: Default kernel is build with -O2 optimization and stripped with objdump. Many debugging options are still enabled. 
   28:     
   29:     $ ls -l sys/arch/evbarm/compile/obj/TISDP2420/netbsd*
   30:     -rwxr-xr-x 1 test test  2614515 2008-06-23 11:32 sys/arch/evbarm/compile/obj/TISDP2420/netbsd
   31:     -rwxr-xr-x 1 test test  2305536 2008-06-23 11:32 sys/arch/evbarm/compile/obj/TISDP2420/netbsd.bin
   32:     -rwxr-xr-x 1 test test 13908834 2008-06-23 11:32 sys/arch/evbarm/compile/obj/TISDP2420/netbsd.gdb
   33:     -rw-r--r-- 1 test test  3440335 2008-06-23 11:32 sys/arch/evbarm/compile/obj/TISDP2420/netbsd.map
   34:     
   35:     
   36:     $ size sys/arch/evbarm/compile/obj/TISDP2420/netbsd
   37:        text    data     bss     dec     hex filename
   38:     1902956  339456  214740 2457152  257e40 sys/arch/evbarm/compile/obj/TISDP2420/netbsd
   39:     
   40: 
   41: Dmesg shows how much memory is available after boot, when the kernel executable been loaded to RAM and most of the RAM based data structures have been initialized: 
   42:     
   43:     # dmesg|egrep "memory|gpm"
   44:     total memory = 62464 KB
   45:     avail memory = 58032 KB
   46:     DISPC: omap2_lcd_alloc_fb(): memory allocated at vaddr=0x82536000, paddr=0x80710DISPC: omap2_lcd_alloc_fb(): memory  
   47:     allocated at vaddr=0x8255c000, paddr=0x80740DISPC: omap2_lcd_alloc_fb(): memory allocated at vaddr=0x82582000, 
   48:     paddr=0x80760gpmc0 at mainbus0 base 0x6800a000: General Purpose Memory Controller, rev 2.0
   49:     gpmc0: CS#0 valid, addr 0x04000000, size  64MB
   50:     gpmc0: CS#1 valid, addr 0x08000000, size  16MB
   51:     sm0 at gpmc0 addr 0x08000300 intr 188
   52:     
   53: 
   54: ##  Optimize for size with -Os, 2059 kb 
   55: 
   56: Compiler can optimize for size when build variable DEFCOPTS is set to **-Os** instead of the default **-O2**. 
   57:     
   58:     -rwxr-xr-x 1 test test  2458323 2008-06-25 09:48 sys/arch/evbarm/compile/obj/TISDP2420/netbsd
   59:     -rwxr-xr-x 1 test test  2109012 2008-06-25 09:48 sys/arch/evbarm/compile/obj/TISDP2420/netbsd.bin
   60:     -rwxr-xr-x 1 test test 13390766 2008-06-25 09:48 sys/arch/evbarm/compile/obj/TISDP2420/netbsd.gdb
   61:     -rw-r--r-- 1 test test  3446815 2008-06-25 09:48 sys/arch/evbarm/compile/obj/TISDP2420/netbsd.map
   62:     
   63:     
   64:        text    data     bss     dec     hex filename
   65:     1764840  339540  214768 2319148  23632c sys/arch/evbarm/compile/obj/TISDP2420/netbsd
   66:     
   67:     
   68:     # dmesg | egrep "memory|gpm"
   69:     total memory = 62464 KB
   70:     avail memory = 58220 KB
   71:     DISPC: omap2_lcd_alloc_fb(): memory allocated at vaddr=0x82537000, paddr=0x806e0DISPC: omap2_lcd_alloc_fb(): memory
   72:     allocated at vaddr=0x8255d000, paddr=0x80710DISPC: omap2_lcd_alloc_fb(): memory allocated at vaddr=0x82583000, 
   73:     paddr=0x80730gpmc0 at mainbus0 base 0x6800a000: General Purpose Memory Controller, rev 2.0
   74:     gpmc0: CS#0 valid, addr 0x04000000, size  64MB
   75:     gpmc0: CS#1 valid, addr 0x08000000, size  16MB
   76:     sm0 at gpmc0 addr 0x08000300 intr 188
   77:     
   78: 
   79: ##  Remove debugging symbols, without -g, 2059 kb 
   80: 
   81: Build variable DEBUG contains the **-g** flag. Build without it. Results show that the kernel was already stripped of debug symbols by objdump, so this step is not usefull. 
   82:     
   83:     -rwxr-xr-x 1 test test 2502667 2008-06-25 09:58 sys/arch/evbarm/compile/obj/TISDP2420/netbsd
   84:     -rwxr-xr-x 1 test test 2109012 2008-06-25 09:58 sys/arch/evbarm/compile/obj/TISDP2420/netbsd.bin
   85:     -rw-r--r-- 1 test test 3238409 2008-06-25 09:58 sys/arch/evbarm/compile/obj/TISDP2420/netbsd.map
   86:     
   87:     
   88:        text    data     bss     dec     hex filename
   89:     1764840  339540  214768 2319148  23632c sys/arch/evbarm/compile/obj/TISDP2420/netbsd
   90:     
   91:     
   92:     # dmesg|egrep "memory|gpm"
   93:     total memory = 62464 KB
   94:     avail memory = 58220 KB
   95:     DISPC: omap2_lcd_alloc_fb(): memory allocated at vaddr=0x82537000, paddr=0x806e0DISPC: omap2_lcd_alloc_fb(): memory 
   96:     allocated at vaddr=0x8255d000, paddr=0x80710DISPC: omap2_lcd_alloc_fb(): memory allocated at vaddr=0x82583000, 
   97:     paddr=0x80730gpmc0 at mainbus0 base 0x6800a000: General Purpose Memory Controller, rev 2.0
   98:     gpmc0: CS#0 valid, addr 0x04000000, size  64MB
   99:     gpmc0: CS#1 valid, addr 0x08000000, size  16MB
  100:     sm0 at gpmc0 addr 0x08000300 intr 188
  101:     
  102: 
  103: ##  DIAGNOSTIC, 1867 kb 
  104: 
  105: Kernel build without DIAGNOSTIC support. 
  106:     
  107:     -rwxr-xr-x 1 test test 2304678 2008-06-25 10:05 sys/arch/evbarm/compile/obj/TISDP2420/netbsd
  108:     -rwxr-xr-x 1 test test 1912404 2008-06-25 10:05 sys/arch/evbarm/compile/obj/TISDP2420/netbsd.bin
  109:     -rw-r--r-- 1 test test 3208060 2008-06-25 10:05 sys/arch/evbarm/compile/obj/TISDP2420/netbsd.map
  110:     
  111:     
  112:        text    data     bss     dec     hex filename
  113:     1567336  339540  214768 2121644  205fac sys/arch/evbarm/compile/obj/TISDP2420/netbsd
  114:     
  115:     
  116:     # dmesg|egrep "memory|gpm"
  117:     total memory = 62464 KB
  118:     avail memory = 58408 KB
  119:     DISPC: omap2_lcd_alloc_fb(): memory allocated at vaddr=0x82538000, paddr=0x806b0DISPC: omap2_lcd_alloc_fb(): memory 
  120:     allocated at vaddr=0x8255e000, paddr=0x806e0DISPC: omap2_lcd_alloc_fb(): memory allocated at vaddr=0x82584000, 
  121:     paddr=0x80700gpmc0 at mainbus0 base 0x6800a000: General Purpose Memory Controller, rev 2.0
  122:     gpmc0: CS#0 valid, addr 0x04000000, size  64MB
  123:     gpmc0: CS#1 valid, addr 0x08000000, size  16MB
  124:     sm0 at gpmc0 addr 0x08000300 intr 188
  125:     
  126: 
  127: ##  VERBOSE_INIT_ARM, 1867 kb 
  128: 
  129: Kernel build without verbose ARM specific boot messages. VERBOSE_INIT_ARM seems to depend on DDB support. 
  130:     
  131:     -rwxr-xr-x 1 test test 2304616 2008-06-25 10:22 sys/arch/evbarm/compile/obj/TISDP2420/netbsd
  132:     -rwxr-xr-x 1 test test 1912404 2008-06-25 10:22 sys/arch/evbarm/compile/obj/TISDP2420/netbsd.bin
  133:     -rw-r--r-- 1 test test 3207741 2008-06-25 10:22 sys/arch/evbarm/compile/obj/TISDP2420/netbsd.map
  134:     
  135:     
  136:        text    data     bss     dec     hex filename
  137:     1565468  339540  214768 2119776  205860 sys/arch/evbarm/compile/obj/TISDP2420/netbsd
  138:     
  139:     
  140:     # dmesg|egrep "memory|gpm"
  141:     total memory = 62464 KB
  142:     avail memory = 58408 KB
  143:     DISPC: omap2_lcd_alloc_fb(): memory allocated at vaddr=0x82538000, paddr=0x806b0DISPC: omap2_lcd_alloc_fb(): memory 
  144:     allocated at vaddr=0x8255e000, paddr=0x806e0DISPC: omap2_lcd_alloc_fb(): memory allocated at vaddr=0x82584000, 
  145:     paddr=0x80700gpmc0 at mainbus0 base 0x6800a000: General Purpose Memory Controller, rev 2.0
  146:     gpmc0: CS#0 valid, addr 0x04000000, size  64MB
  147:     gpmc0: CS#1 valid, addr 0x08000000, size  16MB
  148:     sm0 at gpmc0 addr 0x08000300 intr 188
  149:     
  150: 
  151: ##  KTRACE, 1867 kb 
  152: 
  153: Kernel without KTRACE system call tracing support. KTRACE seems to depend on DDB kernel debugger support, since boot hangs without it. 
  154:     
  155:     -rwxr-xr-x 1 test test 2303792 2008-06-25 10:39 sys/arch/evbarm/compile/obj/TISDP2420/netbsd
  156:     -rwxr-xr-x 1 test test 1912372 2008-06-25 10:39 sys/arch/evbarm/compile/obj/TISDP2420/netbsd.bin
  157:     -rw-r--r-- 1 test test 3198575 2008-06-25 10:39 sys/arch/evbarm/compile/obj/TISDP2420/netbsd.map
  158:     
  159:     
  160:        text    data     bss     dec     hex filename
  161:     1557776  339508  214704 2111988  2039f4 sys/arch/evbarm/compile/obj/TISDP2420/netbsd
  162:     
  163:     
  164:     # dmesg|egrep "memory|gpm"
  165:     total memory = 62464 KB
  166:     avail memory = 58408 KB
  167:     DISPC: omap2_lcd_alloc_fb(): memory allocated at vaddr=0x82538000, paddr=0x806b0DISPC: omap2_lcd_alloc_fb(): memory 
  168:     allocated at vaddr=0x8255e000, paddr=0x806e0DISPC: omap2_lcd_alloc_fb(): memory allocated at vaddr=0x82584000, 
  169:     paddr=0x80700gpmc0 at mainbus0 base 0x6800a000: General Purpose Memory Controller, rev 2.0
  170:     gpmc0: CS#0 valid, addr 0x04000000, size  64MB
  171:     gpmc0: CS#1 valid, addr 0x08000000, size  16MB
  172:     sm0 at gpmc0 addr 0x08000300 intr 188
  173:     
  174: 
  175: ##  DDB, 1867 kb 
  176: 
  177: Build kernel without DDB in kernel debugger. 
  178:     
  179:     -rwxr-xr-x 1 test test 2260235 2008-06-25 10:42 sys/arch/evbarm/compile/obj/TISDP2420/netbsd
  180:     -rwxr-xr-x 1 test test 1911944 2008-06-25 10:42 sys/arch/evbarm/compile/obj/TISDP2420/netbsd.bin
  181:     -rw-r--r-- 1 test test 3076696 2008-06-25 10:42 sys/arch/evbarm/compile/obj/TISDP2420/netbsd.map
  182:     
  183:     
  184:        text    data     bss     dec     hex filename
  185:     1512444  339080  209440 2060964  1f72a4 sys/arch/evbarm/compile/obj/TISDP2420/netbsd
  186:     
  187:     
  188:     total memory = 62464 KB
  189:     avail memory = 58416 KB
  190:     DISPC: omap2_lcd_alloc_fb(): memory allocated at vaddr=0x82538000, paddr=0x806b0DISPC: omap2_lcd_alloc_fb(): memory  
  191:     allocated at vaddr=0x8255e000, paddr=0x806e0DISPC: omap2_lcd_alloc_fb(): memory allocated at vaddr=0x82584000, 
  192:     paddr=0x80700gpmc0 at mainbus0 base 0x6800a000: General Purpose Memory Controller, rev 2.0
  193:     gpmc0: CS#0 valid, addr 0x04000000, size  64MB
  194:     gpmc0: CS#1 valid, addr 0x08000000, size  16MB
  195:     sm0 at gpmc0 addr 0x08000300 intr 188
  196:     
  197: 
  198: ##  COMPAT_30, 1867 kb 
  199: 
  200: Kernel without NetBSD 3.0 compatibility. 
  201:     
  202:     -rwxr-xr-x 1 test test 2259424 2008-06-25 10:55 sys/arch/evbarm/compile/obj/TISDP2420/netbsd
  203:     -rwxr-xr-x 1 test test 1911944 2008-06-25 10:55 sys/arch/evbarm/compile/obj/TISDP2420/netbsd.bin
  204:     -rw-r--r-- 1 test test 3031468 2008-06-25 10:55 sys/arch/evbarm/compile/obj/TISDP2420/netbsd.map
  205:     
  206:     
  207:        text    data     bss     dec     hex filename
  208:     1509828  339080  209440 2058348  1f686c sys/arch/evbarm/compile/obj/TISDP2420/netbsd
  209:     
  210:     
  211:     # dmesg|egrep "memory|gpm"
  212:     total memory = 62464 KB
  213:     avail memory = 58416 KB
  214:     DISPC: omap2_lcd_alloc_fb(): memory allocated at vaddr=0x82538000, paddr=0x806b0DISPC: omap2_lcd_alloc_fb(): memory 
  215:     allocated at vaddr=0x8255e000, paddr=0x806e0DISPC: omap2_lcd_alloc_fb(): memory allocated at vaddr=0x82584000, 
  216:     paddr=0x80700gpmc0 at mainbus0 base 0x6800a000: General Purpose Memory Controller, rev 2.0
  217:     gpmc0: CS#0 valid, addr 0x04000000, size  64MB
  218:     gpmc0: CS#1 valid, addr 0x08000000, size  16MB
  219:     sm0 at gpmc0 addr 0x08000300 intr 188
  220:     
  221: 
  222: ##  ksyms, 1510 kb 
  223: 
  224: Kernel without /dev/ksyms support. 
  225:     
  226:     -rwxr-xr-x 1 test test 1925248 2008-06-25 10:59 sys/arch/evbarm/compile/obj/TISDP2420/netbsd
  227:     -rwxr-xr-x 1 test test 1546376 2008-06-25 10:59 sys/arch/evbarm/compile/obj/TISDP2420/netbsd.bin
  228:     -rw-r--r-- 1 test test 3023265 2008-06-25 10:59 sys/arch/evbarm/compile/obj/TISDP2420/netbsd.map
  229:     
  230:     
  231:        text    data     bss     dec     hex filename
  232:     1503148   39048  209056 1751252  1ab8d4 sys/arch/evbarm/compile/obj/TISDP2420/netbsd
  233:     
  234:     
  235:     # dmesg|egrep "memory|gpm"
  236:     total memory = 62464 KB
  237:     avail memory = 58764 KB
  238:     DISPC: omap2_lcd_alloc_fb(): memory allocated at vaddr=0x8253a000, paddr=0x80660DISPC: omap2_lcd_alloc_fb(): memory 
  239:     allocated at vaddr=0x82560000, paddr=0x80680DISPC: omap2_lcd_alloc_fb(): memory allocated at vaddr=0x82586000, 
  240:     paddr=0x806b0gpmc0 at mainbus0 base 0x6800a000: General Purpose Memory Controller, rev 2.0
  241:     gpmc0: CS#0 valid, addr 0x04000000, size  64MB
  242:     gpmc0: CS#1 valid, addr 0x08000000, size  16MB
  243:     sm0 at gpmc0 addr 0x08000300 intr 188
  244:     
  245: 
  246: ##  PTRACE, 1510 kb 
  247: 
  248: Kernel without process tracing support. 
  249:     
  250:     -rwxr-xr-x 1 test test 1924948 2008-06-25 11:04 sys/arch/evbarm/compile/obj/TISDP2420/netbsd
  251:     -rwxr-xr-x 1 test test 1546376 2008-06-25 11:04 sys/arch/evbarm/compile/obj/TISDP2420/netbsd.bin
  252:     -rw-r--r-- 1 test test 3015392 2008-06-25 11:04 sys/arch/evbarm/compile/obj/TISDP2420/netbsd.map
  253:     
  254:     
  255:        text    data     bss     dec     hex filename
  256:     1499312   39048  209056 1747416  1aa9d8 sys/arch/evbarm/compile/obj/TISDP2420/netbsd
  257:     
  258:     
  259:     # dmesg|egrep "memory|gpm"
  260:     total memory = 62464 KB
  261:     avail memory = 58764 KB
  262:     DISPC: omap2_lcd_alloc_fb(): memory allocated at vaddr=0x8253a000, paddr=0x80660DISPC: omap2_lcd_alloc_fb(): memory 
  263:     allocated at vaddr=0x82560000, paddr=0x80680DISPC: omap2_lcd_alloc_fb(): memory allocated at vaddr=0x82586000, 
  264:     paddr=0x806b0gpmc0 at mainbus0 base 0x6800a000: General Purpose Memory Controller, rev 2.0
  265:     gpmc0: CS#0 valid, addr 0x04000000, size  64MB
  266:     gpmc0: CS#1 valid, addr 0x08000000, size  16MB
  267:     sm0 at gpmc0 addr 0x08000300 intr 188
  268:     
  269: 
  270: ##  FFS, 1510 kb 
  271: 
  272: Kernel without fast filesystem support. 
  273:     
  274:     -rwxr-xr-x 1 test test 1924948 2008-06-25 11:09 sys/arch/evbarm/compile/obj/TISDP2420/netbsd
  275:     -rwxr-xr-x 1 test test 1546376 2008-06-25 11:09 sys/arch/evbarm/compile/obj/TISDP2420/netbsd.bin
  276:     -rw-r--r-- 1 test test 3015329 2008-06-25 11:09 sys/arch/evbarm/compile/obj/TISDP2420/netbsd.map
  277:     
  278:     
  279:        text    data     bss     dec     hex filename
  280:     1499248   39048  209056 1747352  1aa998 sys/arch/evbarm/compile/obj/TISDP2420/netbsd
  281:     
  282:     
  283:     # dmesg|egrep "memory|gpm"
  284:     total memory = 62464 KB
  285:     avail memory = 58764 KB
  286:     DISPC: omap2_lcd_alloc_fb(): memory allocated at vaddr=0x8253a000, paddr=0x80660DISPC: omap2_lcd_alloc_fb(): memory  
  287:     allocated at vaddr=0x82560000, paddr=0x80680DISPC: omap2_lcd_alloc_fb(): memory allocated at vaddr=0x82586000, 
  288:     paddr=0x806b0gpmc0 at mainbus0 base 0x6800a000: General Purpose Memory Controller, rev 2.0
  289:     gpmc0: CS#0 valid, addr 0x04000000, size  64MB
  290:     gpmc0: CS#1 valid, addr 0x08000000, size  16MB
  291:     sm0 at gpmc0 addr 0x08000300 intr 188
  292:     
  293: 
  294: ##  MSDOSFS, 1509 kb 
  295: 
  296: Kernel without FAT filesystem support. 
  297:     
  298:     -rwxr-xr-x 1 test test 1887407 2008-06-25 11:21 sys/arch/evbarm/compile/obj/TISDP2420/netbsd
  299:     -rwxr-xr-x 1 test test 1546152 2008-06-25 11:21 sys/arch/evbarm/compile/obj/TISDP2420/netbsd.bin
  300:     -rw-r--r-- 1 test test 2955657 2008-06-25 11:21 sys/arch/evbarm/compile/obj/TISDP2420/netbsd.map
  301:     
  302:     
  303:        text    data     bss     dec     hex filename
  304:     1463132   38824  208672 1710628  1a1a24 sys/arch/evbarm/compile/obj/TISDP2420/netbsd
  305:     
  306:     
  307:     # dmesg|egrep "memory|gpm"
  308:     total memory = 62464 KB
  309:     avail memory = 58764 KB
  310:     DISPC: omap2_lcd_alloc_fb(): memory allocated at vaddr=0x82538000, paddr=0x80660DISPC: omap2_lcd_alloc_fb(): memory 
  311:     allocated at vaddr=0x8255e000, paddr=0x80680DISPC: omap2_lcd_alloc_fb(): memory allocated at vaddr=0x82584000, 
  312:     paddr=0x806b0gpmc0 at mainbus0 base 0x6800a000: General Purpose Memory Controller, rev 2.0
  313:     gpmc0: CS#0 valid, addr 0x04000000, size  64MB
  314:     gpmc0: CS#1 valid, addr 0x08000000, size  16MB
  315:     sm0 at gpmc0 addr 0x08000300 intr 188
  316:     
  317: 
  318: ##  PTYFS, 1509 kb 
  319: 
  320: Kernel without pseudo TTY filesystem and pseudo-device pty. 
  321:     
  322:     -rwxr-xr-x 1 test test 1883462 2008-06-25 11:37 sys/arch/evbarm/compile/obj/TISDP2420/netbsd
  323:     -rwxr-xr-x 1 test test 1545916 2008-06-25 11:37 sys/arch/evbarm/compile/obj/TISDP2420/netbsd.bin
  324:     -rw-r--r-- 1 test test 2911049 2008-06-25 11:37 sys/arch/evbarm/compile/obj/TISDP2420/netbsd.map
  325:     
  326:     
  327:        text    data     bss     dec     hex filename
  328:     1446512   38588  208536 1693636  19d7c4 sys/arch/evbarm/compile/obj/TISDP2420/netbsd
  329:     
  330:     
  331:     # dmesg|egrep "memory|gpm"
  332:     total memory = 62464 KB
  333:     avail memory = 58764 KB
  334:     DISPC: omap2_lcd_alloc_fb(): memory allocated at vaddr=0x82536000, paddr=0x80660DISPC: omap2_lcd_alloc_fb(): memory 
  335:     allocated at vaddr=0x8255c000, paddr=0x80680DISPC: omap2_lcd_alloc_fb(): memory allocated at vaddr=0x82582000, 
  336:     paddr=0x806b0gpmc0 at mainbus0 base 0x6800a000: General Purpose Memory Controller, rev 2.0
  337:     gpmc0: CS#0 valid, addr 0x04000000, size  64MB
  338:     gpmc0: CS#1 valid, addr 0x08000000, size  16MB
  339:     sm0 at gpmc0 addr 0x08000300 intr 188
  340:     
  341: 
  342: ##  bpfilter, 1445 kb 
  343: 
  344: Kernel without Berkeley packet filter pseudo-device support. 
  345:     
  346:     -rwxr-xr-x 1 test test 1848968 2008-06-25 11:46 sys/arch/evbarm/compile/obj/TISDP2420/netbsd
  347:     -rwxr-xr-x 1 test test 1480372 2008-06-25 11:46 sys/arch/evbarm/compile/obj/TISDP2420/netbsd.bin
  348:     -rw-r--r-- 1 test test 2896335 2008-06-25 11:46 sys/arch/evbarm/compile/obj/TISDP2420/netbsd.map
  349:     
  350:     
  351:        text    data     bss     dec     hex filename
  352:     1435984   38580  208272 1682836  19ad94 sys/arch/evbarm/compile/obj/TISDP2420/netbsd
  353:     
  354:     
  355:     # dmesg|egrep "memory|gpm"
  356:     total memory = 62464 KB
  357:     avail memory = 58828 KB
  358:     DISPC: omap2_lcd_alloc_fb(): memory allocated at vaddr=0x82536000, paddr=0x80650DISPC: omap2_lcd_alloc_fb(): memory  
  359:     allocated at vaddr=0x8255c000, paddr=0x80670DISPC: omap2_lcd_alloc_fb(): memory allocated at vaddr=0x82582000, 
  360:     paddr=0x806a0gpmc0 at mainbus0 base 0x6800a000: General Purpose Memory Controller, rev 2.0
  361:     gpmc0: CS#0 valid, addr 0x04000000, size  64MB
  362:     gpmc0: CS#1 valid, addr 0x08000000, size  16MB
  363:     sm0 at gpmc0 addr 0x08000300 intr 188
  364:     
  365: 
  366: ##  INSECURE, 1445 kb 
  367: 
  368: Kernel without integrity protection. 
  369:     
  370:     -rwxr-xr-x 1 test test 1848968 2008-06-25 11:54 sys/arch/evbarm/compile/obj/TISDP2420/netbsd
  371:     -rwxr-xr-x 1 test test 1480372 2008-06-25 11:54 sys/arch/evbarm/compile/obj/TISDP2420/netbsd.bin
  372:     -rw-r--r-- 1 test test 2896335 2008-06-25 11:54 sys/arch/evbarm/compile/obj/TISDP2420/netbsd.map
  373:     
  374:     
  375:        text    data     bss     dec     hex filename
  376:     1435984   38580  208272 1682836  19ad94 sys/arch/evbarm/compile/obj/TISDP2420/netbsd
  377:     
  378:     
  379:     # dmesg|egrep "memory|gpm"
  380:     total memory = 62464 KB
  381:     avail memory = 58828 KB
  382:     DISPC: omap2_lcd_alloc_fb(): memory allocated at vaddr=0x82536000, paddr=0x80650DISPC: omap2_lcd_alloc_fb(): memory 
  383:     allocated at vaddr=0x8255c000, paddr=0x80670DISPC: omap2_lcd_alloc_fb(): memory allocated at vaddr=0x82582000, 
  384:     paddr=0x806a0gpmc0 at mainbus0 base 0x6800a000: General Purpose Memory Controller, rev 2.0
  385:     gpmc0: CS#0 valid, addr 0x04000000, size  64MB
  386:     gpmc0: CS#1 valid, addr 0x08000000, size  16MB
  387:     sm0 at gpmc0 addr 0x08000300 intr 188
  388:     
  389: 
  390: ##  INET6, 1316 kb 
  391: 
  392: Kernel without IPv6 support. 
  393:     
  394:     -rwxr-xr-x 1 test test 1666318 2008-06-25 11:57 sys/arch/evbarm/compile/obj/TISDP2420/netbsd
  395:     -rwxr-xr-x 1 test test 1348532 2008-06-25 11:57 sys/arch/evbarm/compile/obj/TISDP2420/netbsd.bin
  396:     -rw-r--r-- 1 test test 2666559 2008-06-25 11:57 sys/arch/evbarm/compile/obj/TISDP2420/netbsd.map
  397:     
  398:     
  399:        text    data     bss     dec     hex filename
  400:     1271320   37812  199760 1508892  17061c sys/arch/evbarm/compile/obj/TISDP2420/netbsd
  401:     
  402:     
  403:     # dmesg|egrep "memory|gpm"
  404:     total memory = 62464 KB
  405:     avail memory = 58960 KB
  406:     DISPC: omap2_lcd_alloc_fb(): memory allocated at vaddr=0x82537000, paddr=0x80630DISPC: omap2_lcd_alloc_fb(): memory 
  407:     allocated at vaddr=0x8255d000, paddr=0x80650DISPC: omap2_lcd_alloc_fb(): memory allocated at vaddr=0x82583000, 
  408:     paddr=0x80680gpmc0 at mainbus0 base 0x6800a000: General Purpose Memory Controller, rev 2.0
  409:     gpmc0: CS#0 valid, addr 0x04000000, size  64MB
  410:     gpmc0: CS#1 valid, addr 0x08000000, size  16MB
  411:     sm0 at gpmc0 addr 0x08000300 intr 188
  412:     
  413: 
  414: ##  MALLOC_NOINLINE, 1316 kb 
  415: 
  416: Kernel without inlined malloc functions. 
  417:     
  418:     -rwxr-xr-x 1 test test 1666318 2008-06-25 12:01 sys/arch/evbarm/compile/obj/TISDP2420/netbsd
  419:     -rwxr-xr-x 1 test test 1348532 2008-06-25 12:01 sys/arch/evbarm/compile/obj/TISDP2420/netbsd.bin
  420:     -rw-r--r-- 1 test test 2666559 2008-06-25 12:01 sys/arch/evbarm/compile/obj/TISDP2420/netbsd.map
  421:     
  422:     
  423:        text    data     bss     dec     hex filename
  424:     1271320   37812  199760 1508892  17061c sys/arch/evbarm/compile/obj/TISDP2420/netbsd
  425:     
  426:     
  427:     # dmesg|egrep "memory|gpm"
  428:     total memory = 62464 KB
  429:     avail memory = 58960 KB
  430:     DISPC: omap2_lcd_alloc_fb(): memory allocated at vaddr=0x82537000, paddr=0x80630DISPC: omap2_lcd_alloc_fb(): memory  
  431:     allocated at vaddr=0x8255d000, paddr=0x80650DISPC: omap2_lcd_alloc_fb(): memory allocated at vaddr=0x82583000, 
  432:     paddr=0x80680gpmc0 at mainbus0 base 0x6800a000: General Purpose Memory Controller, rev 2.0
  433:     gpmc0: CS#0 valid, addr 0x04000000, size  64MB
  434:     gpmc0: CS#1 valid, addr 0x08000000, size  16MB
  435:     sm0 at gpmc0 addr 0x08000300 intr 188
  436:     
  437: 
  438: ##  PIPE_SOCKETPAIR, 1316 kb 
  439: 
  440: Kernel with smaller but slower pipe implementation. 
  441:     
  442:     -rwxr-xr-x 1 test test 1665096 2008-06-25 12:04 sys/arch/evbarm/compile/obj/TISDP2420/netbsd
  443:     -rwxr-xr-x 1 test test 1348468 2008-06-25 12:04 sys/arch/evbarm/compile/obj/TISDP2420/netbsd.bin
  444:     -rw-r--r-- 1 test test 2658886 2008-06-25 12:04 sys/arch/evbarm/compile/obj/TISDP2420/netbsd.map
  445:     
  446:     
  447:        text    data     bss     dec     hex filename
  448:     1264788   37748  199760 1502296  16ec58 sys/arch/evbarm/compile/obj/TISDP2420/netbsd
  449:     
  450:     
  451:     # dmesg|egrep "memory|gpm"
  452:     total memory = 62464 KB
  453:     avail memory = 58964 KB
  454:     DISPC: omap2_lcd_alloc_fb(): memory allocated at vaddr=0x82537000, paddr=0x80630DISPC: omap2_lcd_alloc_fb(): memory  
  455:     allocated at vaddr=0x8255d000, paddr=0x80650DISPC: omap2_lcd_alloc_fb(): memory allocated at vaddr=0x82583000,  
  456:     paddr=0x80670gpmc0 at mainbus0 base 0x6800a000: General Purpose Memory Controller, rev 2.0
  457:     gpmc0: CS#0 valid, addr 0x04000000, size  64MB
  458:     gpmc0: CS#1 valid, addr 0x08000000, size  16MB
  459:     sm0 at gpmc0 addr 0x08000300 intr 188
  460:     
  461: 
  462: ##  VMSWAP, 1316 kb 
  463: 
  464: Kernel without swap support. Requires a build patch, but may still crash the kernel when uvm statistics are called from top, ps etc. programs. 
  465:     
  466:     --- a/sys/uvm/uvm_pdpolicy_clock.c
  467:     +++ b/sys/uvm/uvm_pdpolicy_clock.c
  468:     @@ -262,12 +262,13 @@ uvmpdpol_balancequeue(int swap_shortage)
  469:                     /*
  470:                      * if there's a shortage of swap slots, try to free it.
  471:                      */
  472:     -
  473:     +#if defined(VMSWAP)
  474:                     if (swap_shortage > 0 && (p->pqflags & PQ_SWAPBACKED) != 0) {
  475:                             if (uvmpd_trydropswap(p)) {
  476:                                     swap_shortage--;
  477:                             }
  478:                     }
  479:     +#endif /* defined(VMSWAP) */
  480:     
  481:                     /*
  482:                      * if there's a shortage of inactive pages, deactivate.
  483:     
  484:     
  485:     -rwxr-xr-x 1 test test 1662968 2008-06-25 12:09 sys/arch/evbarm/compile/obj/TISDP2420/netbsd
  486:     -rwxr-xr-x 1 test test 1348392 2008-06-25 12:09 sys/arch/evbarm/compile/obj/TISDP2420/netbsd.bin
  487:     -rw-r--r-- 1 test test 2642042 2008-06-25 12:09 sys/arch/evbarm/compile/obj/TISDP2420/netbsd.map
  488:     
  489:     
  490:        text    data     bss     dec     hex filename
  491:     1248392   37672  199248 1485312  16aa00 sys/arch/evbarm/compile/obj/TISDP2420/netbsd
  492:     
  493:     
  494:     # dmesg|egrep "memory|gpm"
  495:     total memory = 62464 KB
  496:     avail memory = 58968 KB
  497:     DISPC: omap2_lcd_alloc_fb(): memory allocated at vaddr=0x82537000, paddr=0x80630DISPC: omap2_lcd_alloc_fb(): memory 
  498:     allocated at vaddr=0x8255d000, paddr=0x80650DISPC: omap2_lcd_alloc_fb(): memory allocated at vaddr=0x82583000, 
  499:     paddr=0x80670gpmc0 at mainbus0 base 0x6800a000: General Purpose Memory Controller, rev 2.0
  500:     gpmc0: CS#0 valid, addr 0x04000000, size  64MB
  501:     gpmc0: CS#1 valid, addr 0x08000000, size  16MB
  502:     sm0 at gpmc0 addr 0x08000300 intr 188
  503:     
  504: 
  505: ##  SYSVMSG, SYSVSEM, SYSVSHM, 1252 kb 
  506: 
  507: Kernel without system V message queues, semaphores and shared memory. 
  508:     
  509:     -rwxr-xr-x 1 test test 1627140 2008-06-25 12:15 sys/arch/evbarm/compile/obj/TISDP2420/netbsd
  510:     -rwxr-xr-x 1 test test 1282748 2008-06-25 12:15 sys/arch/evbarm/compile/obj/TISDP2420/netbsd.bin
  511:     -rw-r--r-- 1 test test 2612942 2008-06-25 12:15 sys/arch/evbarm/compile/obj/TISDP2420/netbsd.map
  512:     
  513:     
  514:        text    data     bss     dec     hex filename
  515:     1225204   37564  198904 1461672  164da8 sys/arch/evbarm/compile/obj/TISDP2420/netbsd
  516:     
  517:     
  518:     # dmesg|egrep "memory|gpm"
  519:     total memory = 62464 KB
  520:     avail memory = 59032 KB
  521:     DISPC: omap2_lcd_alloc_fb(): memory allocated at vaddr=0x82537000, paddr=0x80620DISPC: omap2_lcd_alloc_fb(): memory 
  522:     allocated at vaddr=0x8255d000, paddr=0x80640DISPC: omap2_lcd_alloc_fb(): memory allocated at vaddr=0x82583000, 
  523:     paddr=0x80660gpmc0 at mainbus0 base 0x6800a000: General Purpose Memory Controller, rev 2.0
  524:     gpmc0: CS#0 valid, addr 0x04000000, size  64MB
  525:     gpmc0: CS#1 valid, addr 0x08000000, size  16MB
  526:     sm0 at gpmc0 addr 0x08000300 intr 188
  527:     
  528: 
  529: ##  rnd, 1252 kb 
  530: 
  531: Kernel without /dev/random pseudo-device. 
  532:     
  533:     -rwxr-xr-x 1 test test 1625313 2008-06-25 12:25 sys/arch/evbarm/compile/obj/TISDP2420/netbsd
  534:     -rwxr-xr-x 1 test test 1282684 2008-06-25 12:25 sys/arch/evbarm/compile/obj/TISDP2420/netbsd.bin
  535:     -rw-r--r-- 1 test test 2599464 2008-06-25 12:25 sys/arch/evbarm/compile/obj/TISDP2420/netbsd.map
  536:     
  537:     
  538:        text    data     bss     dec     hex filename
  539:     1219556   37500  197944 1455000  163398 sys/arch/evbarm/compile/obj/TISDP2420/netbsd
  540:     
  541:     
  542:     # dmesg|egrep "memory|gpm"
  543:     total memory = 62464 KB
  544:     avail memory = 59032 KB
  545:     DISPC: omap2_lcd_alloc_fb(): memory allocated at vaddr=0x82537000, paddr=0x80620DISPC: omap2_lcd_alloc_fb(): memory 
  546:     allocated at vaddr=0x8255d000, paddr=0x80640DISPC: omap2_lcd_alloc_fb(): memory allocated at vaddr=0x82583000, 
  547:     paddr=0x80660gpmc0 at mainbus0 base 0x6800a000: General Purpose Memory Controller, rev 2.0
  548:     gpmc0: CS#0 valid, addr 0x04000000, size  64MB
  549:     gpmc0: CS#1 valid, addr 0x08000000, size  16MB
  550:     sm0 at gpmc0 addr 0x08000300 intr 188
  551:     
  552: 
  553: ##  md, 1252 kb 
  554: 
  555: Kernel without support for memory devices like ramdisks. 
  556:     
  557:     -rwxr-xr-x 1 test test 1624021 2008-06-25 12:29 sys/arch/evbarm/compile/obj/TISDP2420/netbsd
  558:     -rwxr-xr-x 1 test test 1282588 2008-06-25 12:29 sys/arch/evbarm/compile/obj/TISDP2420/netbsd.bin
  559:     -rw-r--r-- 1 test test 2581393 2008-06-25 12:29 sys/arch/evbarm/compile/obj/TISDP2420/netbsd.map
  560:     
  561:     
  562:        text    data     bss     dec     hex filename
  563:     1214024   37404  197752 1449180  161cdc sys/arch/evbarm/compile/obj/TISDP2420/netbsd
  564:     
  565:     
  566:     # dmesg|egrep "memory|gpm"
  567:     total memory = 62464 KB
  568:     avail memory = 59032 KB
  569:     DISPC: omap2_lcd_alloc_fb(): memory allocated at vaddr=0x82537000, paddr=0x80620DISPC: omap2_lcd_alloc_fb(): memory 
  570:     allocated at vaddr=0x8255d000, paddr=0x80640DISPC: omap2_lcd_alloc_fb(): memory allocated at vaddr=0x82583000,  
  571:     paddr=0x80660gpmc0 at mainbus0 base 0x6800a000: General Purpose Memory Controller, rev 2.0
  572:     gpmc0: CS#0 valid, addr 0x04000000, size  64MB
  573:     gpmc0: CS#1 valid, addr 0x08000000, size  16MB
  574:     sm0 at gpmc0 addr 0x08000300 intr 188
  575:     
  576: 
  577: ##  maxusers 2, 1252 kb 
  578: 
  579: Kernel with maxusers set to two instead of the default 32. 
  580:     
  581:     -rwxr-xr-x 1 test test 1624021 2008-06-25 12:34 sys/arch/evbarm/compile/obj/TISDP2420/netbsd
  582:     -rwxr-xr-x 1 test test 1282588 2008-06-25 12:34 sys/arch/evbarm/compile/obj/TISDP2420/netbsd.bin
  583:     -rw-r--r-- 1 test test 2581393 2008-06-25 12:34 sys/arch/evbarm/compile/obj/TISDP2420/netbsd.map
  584:     
  585:     
  586:        text    data     bss     dec     hex filename
  587:     1214024   37404  197752 1449180  161cdc sys/arch/evbarm/compile/obj/TISDP2420/netbsd
  588:     
  589:     
  590:     # dmesg|egrep "memory|gpm"
  591:     total memory = 62464 KB
  592:     avail memory = 59548 KB
  593:     DISPC: omap2_lcd_alloc_fb(): memory allocated at vaddr=0x824b6000, paddr=0x805a0DISPC: omap2_lcd_alloc_fb(): memory 
  594:     allocated at vaddr=0x824dc000, paddr=0x805c0DISPC: omap2_lcd_alloc_fb(): memory allocated at vaddr=0x82502000, 
  595:     paddr=0x805e0gpmc0 at mainbus0 base 0x6800a000: General Purpose Memory Controller, rev 2.0
  596:     gpmc0: CS#0 valid, addr 0x04000000, size  64MB
  597:     gpmc0: CS#1 valid, addr 0x08000000, size  16MB
  598:     sm0 at gpmc0 addr 0x08000300 intr 188
  599:     
  600: 
  601: ##  MFS, 1124 kb 
  602: 
  603: Kernel without memory filesystem. 
  604:     
  605:     -rwxr-xr-x 1 test test 1483269 2008-06-25 12:37 sys/arch/evbarm/compile/obj/TISDP2420/netbsd
  606:     -rwxr-xr-x 1 test test 1151292 2008-06-25 12:37 sys/arch/evbarm/compile/obj/TISDP2420/netbsd.bin
  607:     -rw-r--r-- 1 test test 2437216 2008-06-25 12:37 sys/arch/evbarm/compile/obj/TISDP2420/netbsd.map
  608:     
  609:     
  610:        text    data     bss     dec     hex filename
  611:     1106936   37180  197688 1341804  14796c sys/arch/evbarm/compile/obj/TISDP2420/netbsd
  612:     
  613:     
  614:     # dmesg|egrep "memory|gpm"
  615:     total memory = 62464 KB
  616:     avail memory = 59672 KB
  617:     DISPC: omap2_lcd_alloc_fb(): memory allocated at vaddr=0x824b3000, paddr=0x80580DISPC: omap2_lcd_alloc_fb(): memory 
  618:     allocated at vaddr=0x824d9000, paddr=0x805a0DISPC: omap2_lcd_alloc_fb(): memory allocated at vaddr=0x824ff000, 
  619:     paddr=0x805d0gpmc0 at mainbus0 base 0x6800a000: General Purpose Memory Controller, rev 2.0
  620:     gpmc0: CS#0 valid, addr 0x04000000, size  64MB
  621:     gpmc0: CS#1 valid, addr 0x08000000, size  16MB
  622:     sm0 at gpmc0 addr 0x08000300 intr 188
  623:     
  624: 
  625: ##  COREDUMP, 1124 kb 
  626: 
  627: Kernel without core dump support. 
  628:     
  629:     -rwxr-xr-x 1 test test 1482841 2008-06-25 13:34 sys/arch/evbarm/compile/obj/TISDP2420/netbsd
  630:     -rwxr-xr-x 1 test test 1151292 2008-06-25 13:34 sys/arch/evbarm/compile/obj/TISDP2420/netbsd.bin
  631:     -rw-r--r-- 1 test test 2428587 2008-06-25 13:34 sys/arch/evbarm/compile/obj/TISDP2420/netbsd.map
  632:     
  633:     
  634:        text    data     bss     dec     hex filename
  635:     1102708   37180  197688 1337576  1468e8 sys/arch/evbarm/compile/obj/TISDP2420/netbsd
  636:     
  637:     
  638:     # dmesg|egrep "memory|gpm"
  639:     total memory = 62464 KB
  640:     avail memory = 59672 KB
  641:     DISPC: omap2_lcd_alloc_fb(): memory allocated at vaddr=0x824b3000, paddr=0x80580DISPC: omap2_lcd_alloc_fb(): memory 
  642:     allocated at vaddr=0x824d9000, paddr=0x805a0DISPC: omap2_lcd_alloc_fb(): memory allocated at vaddr=0x824ff000, 
  643:     paddr=0x805d0gpmc0 at mainbus0 base 0x6800a000: General Purpose Memory Controller, rev 2.0
  644:     gpmc0: CS#0 valid, addr 0x04000000, size  64MB
  645:     gpmc0: CS#1 valid, addr 0x08000000, size  16MB
  646:     sm0 at gpmc0 addr 0x08000300 intr 188
  647:     
  648: 
  649: #  Kernel memory consumption 
  650: 
  651: The kernel executable size is not the only measure of kernel memory consumption. A number of userspace tools are able to show how the kernel and it's executable threads use memory while the system is running. Following chapters list some example tool output on the ARM OMAP 2420 board. 
  652: 
  653: Using these tools is easy, but interpreting the numbers seems to require some indepth knowledge of the NetBSD kernel's memory management system uvm. More details on the meaning of these numbers as well as examples of found problems and countermeasures like kernel configurations and sysctl setting would be appreciated. 
  654: 
  655: ##  top 
  656: 
  657: top shows overall memory usage in the system and an interesting process called system. 
  658:     
  659:     # top
  660:     load averages:  0.14,  0.03,  0.01             09:20:54
  661:     4 processes:   3 sleeping, 1 on CPU
  662:     CPU states:     % user,     % nice,     % system,     % interrupt,     % idle
  663:     Memory: 1916K Act, 208K Wired, 996K Exec, 428K File, 52M Free
  664:     Swap:
  665:       PID USERNAME PRI NICE   SIZE   RES STATE      TIME   WCPU    CPU COMMAND
  666:        51 root      43    0   976K  784K CPU        0:00 14.00%  0.68% top
  667:         0 root     125    0     0K 1008K schedule   0:00  0.00%  0.00% [system]
  668:        40 root      85    0   980K  956K wait       0:00  0.00%  0.00% sh
  669:         1 root      85    0    32K  500K wait       0:00  0.00%  0.00% init
  670:     
  671:     
  672:     # dmesg|grep -i mem
  673:     total memory = 62464 KB
  674:     avail memory = 58032 KB
  675:     DISPC: omap2_lcd_alloc_fb(): memory allocated at vaddr=0x82536000, paddr=0x80710DISPC: omap2_lcd_alloc_fb(): memory  
  676:     allocated at vaddr=0x8255c000, paddr=0x80740DISPC: omap2_lcd_alloc_fb(): memory allocated at vaddr=0x82582000, 
  677:     paddr=0x80760gpmc0 at mainbus0 base 0x6800a000: General Purpose Memory Controller, rev 2.0
  678:     
  679:     
  680:     # top -t
  681:     load averages:  0.00,  0.00,  0.00          up 0 days,  1:54   11:14:37
  682:     23 threads:    5 idle, 17 sleeping, 1 on CPU
  683:     CPU states:     % user,     % nice,     % system,     % interrupt,     % idle
  684:     Memory: 3844K Act, 208K Wired, 1308K Exec, 2044K File, 50M Free
  685:     Swap:
  686:       PID   LID USERNAME PRI STATE      TIME   WCPU    CPU COMMAND      NAME
  687:         0     6 root     223 IDLE       0:00  0.00%  0.00% [system]     softser/0
  688:         0     3 root     222 IDLE       0:00  0.00%  0.00% [system]     softnet/0
  689:         0     4 root     221 IDLE       0:00  0.00%  0.00% [system]     softbio/0
  690:         0     5 root     220 IDLE       0:00  0.00%  0.00% [system]     softclk/0
  691:         0     2 root       0 IDLE       0:00  0.00%  0.00% [system]     idle/0
  692:        77     1 root      43 CPU        0:00  0.00%  0.00% top          -
  693:         0     7 root     127 xcall      0:00  0.00%  0.00% [system]     xcall/0
  694:         0    25 root     126 pgdaemon   0:00  0.00%  0.00% [system]     pgdaemon
  695:         0     1 root     125 schedule   0:00  0.00%  0.00% [system]     swapper
  696:         0    28 root     125 vmem_reh   0:00  0.00%  0.00% [system]     vmem_rehash
  697:         0    27 root     125 aiodoned   0:00  0.00%  0.00% [system]     aiodoned
  698:         0     9 root     125 cachegc    0:00  0.00%  0.00% [system]     cachegc
  699:         0     8 root     125 vrele      0:00  0.00%  0.00% [system]     vrele
  700:         0    26 root     124 syncer     0:00  0.00%  0.00% [system]     ioflush
  701:         0    11 root      96 iicintr    0:00  0.00%  0.00% [system]     iic0
  702:     
  703: 
  704: ##  ps 
  705: 
  706: ps can show the system light weight processes/threads too with **-s** flag and lname displays a more sesible name: 
  707:     
  708:     # ps -awxs -o uid,pid,lid,nlwp,pri,ni,vsz,rss,command,lname
  709:     UID PID LID NLWP PRI NI VSZ RSS COMMAND LNAME
  710:       0   0  28   20 125  0   0 976 [system vmem_rehash
  711:       0   0  27   20 125  0   0 976 [system aiodoned
  712:       0   0  26   20 124  0   0 976 [system ioflush
  713:       0   0  25   20 126  0   0 976 [system pgdaemon
  714:       0   0  24   20  96  0   0 976 [system nfsio
  715:       0   0  23   20  96  0   0 976 [system nfsio
  716:       0   0  22   20  96  0   0 976 [system nfsio
  717:       0   0  21   20  96  0   0 976 [system nfsio
  718:       0   0  12   20  96  0   0 976 [system iic1
  719:       0   0  11   20  96  0   0 976 [system iic0
  720:       0   0  10   20  96  0   0 976 [system pmfevent
  721:       0   0   9   20 125  0   0 976 [system cachegc
  722:       0   0   8   20 125  0   0 976 [system vrele
  723:       0   0   7   20 127  0   0 976 [system xcall/0
  724:       0   0   6   20 223  0   0 976 [system softser/0
  725:       0   0   5   20 220  0   0 976 [system softclk/0
  726:       0   0   4   20 221  0   0 976 [system softbio/0
  727:       0   0   3   20 222  0   0 976 [system softnet/0
  728:       0   0   2   20   0  0   0 976 [system idle/0
  729:       0   0   1   20 125  0   0 976 [system swapper
  730:       0   1   1    1  85  0  32 500 init    -
  731:       0  40   1    1  85  0 980 968 -sh     -
  732:       0  62   1    1  42  0 976 676 ps -awx -
  733:       0  63   1    1  85  0 980 784 less -r -
  734:     
  735: 
  736: ##  pmap 
  737: 
  738: Displaying process 0 memory map with pmap shows the kernel's memory map. 
  739:     
  740:     # pmap 0
  741:     80000000  17680K read/write/exec     [ anon ]
  742:     81144000      4K read/write/exec     [ anon ]
  743:     81145000     20K read/write/exec     [ anon ]
  744:     8114A000   7328K read/write/exec     [ kmem_map ]
  745:     81872000   4096K read/write/exec     [ pager_map ]
  746:     81C72000    304K read/write/exec     [ anon ]
  747:     81CBE000      4K read/write/exec     [ anon ]
  748:     81CBF000    580K read/write/exec     [ anon ]
  749:     81D50000   4096K read/write/exec     [ exec_map ]
  750:     82150000   1200K read/write/exec     [ phys_map ]
  751:     8227C000   2096K read/write/exec     [ mb_map ]
  752:     82488000     20K read/write/exec     [ anon ]
  753:     8248D000      8K read/write/exec     [ uvm_aobj ]
  754:     8248F000    524K read/write/exec     [ anon ]
  755:     82512000     48K read/write/exec     [ uvm_aobj ]
  756:     8251E000     32K read/write/exec     [ anon ]
  757:     82526000      8K read/write/exec     [ uvm_aobj ]
  758:     82528000     48K read/write/exec     [ anon ]
  759:     82534000      8K read/write/exec     [ uvm_aobj ]
  760:     82536000    456K read/write/exec     [ anon ]
  761:     825A8000     16K read/write/exec     [ uvm_aobj ]
  762:     825AC000     12K read/write/exec     [ anon ]
  763:     825AF000     48K read/write/exec     [ uvm_aobj ]
  764:     825BB000      4K read/write/exec     [ anon ]
  765:     825BC000     16K read/write/exec     [ uvm_aobj ]
  766:     825C0000     56K read/write/exec     [ anon ]
  767:     825CE000   8192K read/write/exec     [ ubc_pager ]
  768:     82DCE000     52K read/write/exec     [ anon ]
  769:     82DDB000      8K read/write/exec     [ uvm_aobj ]
  770:     82DDD000     20K read/write/exec     [ anon ]
  771:     82DE2000      8K read/write/exec     [ uvm_aobj ]
  772:     82DE4000      4K read/write/exec     [ anon ]
  773:     82DE6000      4K read/write/exec     [ anon ]
  774:     82DE9000      8K read/write/exec     [ uvm_aobj ]
  775:     82DEB000      8K read/write/exec     [ anon ]
  776:     82DED000      8K read/write/exec     [ uvm_aobj ]
  777:     82DEF000     16K read/write/exec     [ anon ]
  778:     82DF7000     16K read/write/exec     [ uvm_aobj ]
  779:     82DFB000     12K read/write/exec     [ anon ]
  780:     82DFE000      8K read/write/exec     [ uvm_aobj ]
  781:     82E00000    400K read/write/exec     [ anon ]
  782:     82E68000     12K read/write/exec     [ anon ]
  783:     82E70000    576K read/write/exec     [ anon ]
  784:      total    48064K
  785:     
  786: 
  787: ##  vmstat 
  788: 
  789: vmstat can display a lot of NetBSD memory management details and statistics, especially if the kernel is compiled with KMEMSTAT options. [Output of **vmstat -C -m**](http://wiki.netbsd.se/images/1/1b/vmstat_C_m.txt) on the ARM board. 
  790: 
  791: #  References 
  792: 
  793:   * options(4) 
  794:   * <http://www.netbsd.org/docs/guide/en/chap-tuning.html#tuning-considerations-kernel>
  795:   * [[Tuning NetBSD for performance]]
  796:   * KMEMSTAT <http://mail-index.netbsd.org/tech-net/2006/03/27/0004.html>
  797:   * [VM tuning from swap perspective](http://www.selonen.org/arto/netbsd/)
  798:   * [NetBSD Internals: Memory Management](http://www.netbsd.org/docs/internals/en/chap-memory.html)
  799:   * <http://www.netbsd.org/docs/guide/en/chap-tuning.html#tuning-mtools>
  800:   * [[How to reduce libc size]]
  801:   * <http://mail-index.netbsd.org/port-arm/2008/06/27/msg000275.html>

CVSweb for NetBSD wikisrc <wikimaster@NetBSD.org> software: FreeBSD-CVSweb