This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision Last revision Both sides next revision | ||
start [2015-01-30 21:41] joshtriplett |
start [2020-07-06 21:25] joshtriplett Drop mention of CONFIG_EMBEDDED, and explain use of CONFIG_EXPERT. |
||
---|---|---|---|
Line 7: | Line 7: | ||
====== Building a tiny kernel ====== | ====== Building a tiny kernel ====== | ||
- | With Linux 3.17-rc1 and newer, ''make tinyconfig'' will produce a minimal kernel. You can then turn on the minimal set of options you need. | + | With current Linux (since 3.17-rc1 and newer, ''make tinyconfig'' will produce a minimal kernel. You can then turn on the minimal set of options you need. |
- | + | ||
- | On previous kernels, you'll need to take a few additional steps to make the kernel as small as possible: | + | |
- | + | ||
- | * Prior to 3.15-rc1, ''make allnoconfig'' did not turn off options behind CONFIG_EXPERT or CONFIG_EMBEDDED, so you'll have to do so manually. | + | |
- | * Change the allocator from SLUB to SLOB | + | |
- | * Change the kernel compression method from GZIP to XZ | + | |
- | * Disable HIGHMEM4G, using NOHIGHMEM instead | + | |
- | * Set ''CONFIG_OPTIMIZE_INLINING=y'' | + | |
- | * Set ''CONFIG_CC_OPTIMIZE_FOR_SIZE=y'' | + | |
You'll want to target the most code-size-efficient architecture supported by your target machine; for instance, on x86 systems, build a 32-bit kernel rather than a 64-bit kernel. On current kernels, ''make allnoconfig'' should do this automatically. | You'll want to target the most code-size-efficient architecture supported by your target machine; for instance, on x86 systems, build a 32-bit kernel rather than a 64-bit kernel. On current kernels, ''make allnoconfig'' should do this automatically. | ||
Line 22: | Line 13: | ||
====== Submitting tinification changes ====== | ====== Submitting tinification changes ====== | ||
- | When submitting a change to make the kernel smaller, use 'scripts/bloat-o-meter'' to compare the size of the old and new vmlinux, overall and broken out by symbol. Include the bloat-o-meter output in your commit message. | + | When submitting a change to make the kernel smaller, use ''scripts/bloat-o-meter'' to compare the size of the old and new vmlinux, overall and broken out by symbol. Include the bloat-o-meter output in your commit message. |
- | Most new configuration options added as part of this effort should depend on CONFIG_EMBEDDED or CONFIG_EXPERT. | + | When introducing a new configuration option for an existing kernel feature, the new option should likely depend on CONFIG_EXPERT. |
If your changes affect the size of the decompression stub, you may additionally need to run bloat-o-meter on the stub. | If your changes affect the size of the decompression stub, you may additionally need to run bloat-o-meter on the stub. | ||
Line 31: | Line 22: | ||
You can find the latest tinification changes in Josh Triplett's tree at https://git.kernel.org/cgit/linux/kernel/git/josh/linux.git/ , in the tiny/* branches. Note that tiny/next gets reset for each new merge window, and other tiny/* branches may be recreated or rebased. | You can find the latest tinification changes in Josh Triplett's tree at https://git.kernel.org/cgit/linux/kernel/git/josh/linux.git/ , in the tiny/* branches. Note that tiny/next gets reset for each new merge window, and other tiny/* branches may be recreated or rebased. | ||
+ | |||
+ | ====== Searching for tinification opportunities ====== | ||
+ | On a built kernel, try running ''nm --size-sort vmlinux''. This will show all the symbols in vmlinux, sorted by size. | ||
====== Use Cases ====== | ====== Use Cases ====== | ||
See the [[Use Cases]] page. | See the [[Use Cases]] page. |