Documentation: Add kernel minimization guide
Subsystems (5)
v2 cover Documentation: Add kernel minimization guide
Hi all,
This series adds documentation and a script for measuring source lines of code (SLOC) in kernel builds, supporting developers and system integrators who need to trim a Linux kernel.
The Workload analysis section of the admin-guide already describes tracing a workload. This series builds on that guidance with a worked example of using workload observations to inform kernel minimization and measure the resulting configuration. The guide is intended for developers working on embedded and safety-critical use cases, including work related to ELISA.
The series builds on the ELISA Aerospace Working Group's ongoing minimization discussions and iterations in
https://github.com/elisa-tech/wg-aerospace/pull/257. That effort explores a generic, newcomer-oriented workflow for tracing a workload, iterating on a kernel configuration, measuring kernel metrics, and understanding userspace metrics. The ELISA documentation aims to present a complete containerized workflow, with analysis steps to guide users through successive iterations. This series contributes reusable, general-purpose kernel documentation and tooling upstream to support that broader process. Clear upstream guidance can also give AI-assisted tools reliable steering context as they help users iterate on kernel configurations. One likely early application is producing minimized release configurations for Space Grade Linux.
Rendered drafts are available online:
Kernel minimization:
https://matthew-l-weber.github.io/linux/admin-guide/kernel-minimization.html
Workload tracing:
https://matthew-l-weber.github.io/linux/admin-guide/workload-tracing.html
The series and its review discussion are in PR #1:
https://github.com/matthew-l-weber/linux/pull/1
The patches are:
1/4 Documentation: kcov: clarify coverage example
Clarify that the saved count bounds the printed entries while KCOV remains enabled until the disable ioctl. Document the relevant config requirements and PC symbolization.
2/4 scripts: Add kernel-sloc helper script
Add a helper to count source lines from compile_commands.json or estimate distinct source lines represented in a vmlinux DWARF line table.
3/4 Documentation: admin-guide: Update workload tracing guide
Expand workload tracing guidance with ftrace function-graph tracing, syscall tracing under QEMU with the GDB stub, and mapping observations to kernel configuration symbols. Add the Workload analysis MAINTAINERS entry.
4/4 Documentation: admin-guide: Add kernel minimization guide
Add the guide to the Workload analysis section, cross-reference it from the workload tracing guide, and add its MAINTAINERS coverage.
Tool-use disclosure: I used GitHub Copilot CLI while preparing this series. It helped revise the KCOV example, edit parts of the documentation, add MAINTAINERS entries, and integrate error-handling revisions to kernel-sloc. I reviewed the changes and take responsibility for the series.
I checked kernel-sloc syntax and help output, and ran checkpatch.pl --strict on all four patches in the new order. The GitHub Actions htmldocs build completed successfully with no warnings from the changed files; the published documentation is available at
https://matthew-l-weber.github.io/linux/admin-guide/index.html#workload-analysis.
I did not run make htmldocs locally.
Changes in v2:
- Reorder the series so the workload tracing update precedes the kernel minimization guide. The guide refers to the "Tracing a minimal user space" and "Mapping observations to configuration" sections added by the tracing update, so those sections now exist before they are referenced (reported by Sashiko).
- Move the cross-references from the workload tracing guide to the kernel minimization guide into the minimization patch, so no patch refers to a document added later in the series.
- Create the Workload analysis MAINTAINERS entry in the tracing patch and extend it with kernel-minimization.rst in the minimization patch.
- No other content changes.
Any feedback is appreciated.
Thanks,
Matthew
Matthew Weber (4):
Documentation: kcov: clarify coverage example
scripts: Add kernel-sloc helper script
Documentation: admin-guide: Update workload tracing guide
Documentation: admin-guide: Add kernel minimization guide
Documentation/admin-guide/index.rst | 1 + .../admin-guide/kernel-minimization.rst | 413 ++++++++++++++++++ .../quickly-build-trimmed-linux.rst | 4 + .../admin-guide/workload-tracing.rst | 139 +++++- Documentation/dev-tools/kcov.rst | 44 +- MAINTAINERS | 13 + scripts/kernel-sloc | 299 +++++++++++++ 7 files changed, 903 insertions(+), 10 deletions(-) create mode 100644 Documentation/admin-guide/kernel-minimization.rst create mode 100755 scripts/kernel-sloc
base-commit: a592a36e49372172d7c7551ec19ed18184c935e1
Signature · 1 line
2.39.5
PATCH v2 1/4 Documentation: kcov: clarify coverage example
Clarify that the saved count bounds the printed entries while KCOV remains enabled, including during output. The examples continue to disable KCOV after printing, as before.
Document the KCOV configuration requirements and how to symbolize collected PCs.
--- Documentation/dev-tools/kcov.rst | 44 +++++++++++++++++++++++++++++--- 1 file changed, 41 insertions(+), 3 deletions(-)
Documentation/dev-tools/kcov.rst +41 -3
@@ -31,6 +31,15 @@ Collecting comparison operands is supported with GCC 8+ or with Clang. To enable KCOV, configure the kernel with:: CONFIG_KCOV=y + CONFIG_DEBUG_FS=y + +``CONFIG_KCOV_INSTRUMENT_ALL=y`` (the default) instruments eligible kernel +code throughout the build. If it is disabled, only explicitly selected code +is instrumented. + +To resolve collected PCs to source locations, also build with debug information +(``CONFIG_DEBUG_INFO=y``) and retain the matching ``vmlinux``. Debug information +is not required for collection itself. To enable comparison operands collection, set::
@@ -94,7 +103,7 @@ single syscall from within a test program: __atomic_store_n(&cover[0], 0, __ATOMIC_RELAXED); /* Call the target syscall call. */ read(-1, NULL, 0); - /* Read number of PCs collected. */ + /* Save the output count; KCOV continues recording until disabled. */ n = __atomic_load_n(&cover[0], __ATOMIC_RELAXED); for (i = 0; i < n; i++) printf("0x%lx\n", cover[i + 1]);
@@ -111,7 +120,36 @@ single syscall from within a test program: return 0; } -After piping through ``addr2line`` the output of the program looks as follows:: +In PC mode, the first ``unsigned long`` holds the count and the remaining +``COVER_SIZE - 1`` slots hold PCs. KCOV stops adding entries when the buffer +is full, so increase the buffer or shorten the collection window if the count +reaches it. An empty buffer can indicate that the target path was not +instrumented; it is not proof that no kernel code ran. + +The count is read while KCOV is enabled and sets the number of entries printed. +KCOV remains enabled while those entries are printed, so the output syscalls +may add entries to the buffer. They are not included in the printed list, +because the loop is bounded by the saved count. Syscall entry/return paths +around the target can also appear. + +Symbolizing PCs +~~~~~~~~~~~~~~~ + +Save the example as ``kcov-example.c``, compile it for the target, and run it +where debugfs is mounted and accessible:: + + cc -O2 -o kcov-example kcov-example.c + sudo ./kcov-example > kcov-pcs.txt + addr2line -f -i -e /path/to/matching/vmlinux < kcov-pcs.txt > kcov-symbols.txt + +For a cross-built target, use the matching toolchain's compiler and +``addr2line`` (for example ``aarch64-linux-gnu-addr2line``). Use the exact build's +debug ELF, not another build's ``vmlinux``. KCOV subtracts the kernel's KASLR +offset on architectures that support it; do not apply an assumed relocation +adjustment. Instrumented modules need their own debug ELF and load-address +handling rather than symbolization against ``vmlinux``. + +The output can look as follows:: SyS_read fs/read_write.c:562
@@ -184,7 +222,7 @@ Comparison operands collection is similar to coverage collection: perror("ioctl"), exit(1); __atomic_store_n(&cover[0], 0, __ATOMIC_RELAXED); read(-1, NULL, 0); - /* Read number of comparisons collected. */ + /* Save the output count, as in PC mode. */ n = __atomic_load_n(&cover[0], __ATOMIC_RELAXED); for (i = 0; i < n; i++) { uint64_t ip;
Signature · 1 line
2.39.5
PATCH v2 2/4 scripts: Add kernel-sloc helper script
In reply to Matthew WeberAdd a helper script scripts/kernel-sloc to count source lines of code (SLOC) for a configured Linux kernel build. It supports counting whole compiled sources from compile_commands.json as well as estimating distinct source lines represented in a vmlinux ELF using DWARF line-table addresses.
It is intended for system integrators and application developers who analyze a trimmed kernel, for example for safety critical applications, and need to report how much kernel code a given configuration builds and links. Add a MAINTAINERS entry for the script.
--- MAINTAINERS | 6 + scripts/kernel-sloc | 299 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 305 insertions(+) create mode 100755 scripts/kernel-sloc
MAINTAINERS +6 -0
@@ -13762,6 +13762,12 @@ T: git git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest.git F: Documentation/dev-tools/kselftest* F: tools/testing/selftests/ +KERNEL SLOC HELPER +M: Matthew Weber <[email protected]> +L: [email protected] +S: Maintained +F: scripts/kernel-sloc + KERNEL SMB3 SERVER (KSMBD) M: Namjae Jeon <[email protected]> M: Namjae Jeon <[email protected]>
scripts/kernel-sloc new file +299 -0
299 lines not on this page · raw message
Signature · 1 line
2.39.5
PATCH v2 3/4 Documentation: admin-guide: Update workload tracing guide
In reply to Matthew WeberExpand workload-tracing.rst, which is aimed at application developers and system integrators analyzing which kernel code a workload relies on, with guidance on ftrace function graph tracing for target binaries, syscall trapping under QEMU with the GDB stub, and mapping workload observations to kernel configuration symbols.
Add a MAINTAINERS entry for the Workload analysis documents.
---
Changes in v2:
- Now precedes the kernel minimization guide.
- Creates the Workload analysis MAINTAINERS entry.
- Refers to "scripts/kernel-sloc --help" instead of the minimization guide, which is added later in the series.
.../admin-guide/workload-tracing.rst | 138 +++++++++++++++++- MAINTAINERS | 6 + 2 files changed, 137 insertions(+), 7 deletions(-)
Documentation/admin-guide/workload-tracing.rst +131 -7
@@ -176,6 +176,20 @@ by three workloads we have chose for this analysis. * stress-ng * paxtest +To retain arguments, results, and calls from child processes, run the +application with its normal inputs and environment:: + + strace -f -o syscalls.log ./app + strace -f -c -o syscall-summary.txt ./app + +These are separate runs. ``-f`` follows children and threads; ``-c`` produces +a summary rather than the chronological trace. For a narrower investigation, +add ``-e trace=%file`` to the first command to select file-related calls. +``-k`` can add user-space stack traces when strace supports unwinding; it +does not expose the kernel call stack. For an application that does not exit, +stop the tracing session after a defined observation interval. Include +startup and representative error inputs, not just a successful steady state. + What is cscope and how do we use it? ====================================
@@ -588,6 +602,116 @@ times each system call is invoked, and the corresponding Linux subsystem. | arch_prctl | 2 | Process Mgmt. | sys_arch_prctl() | +-------------------+-----------+-----------------+----------------------+ +Kernel paths reached by the workload +==================================== + +To go beyond the syscall boundary, use the function graph tracer described +in :doc:`/trace/ftrace`. In a tracing-capable test system or QEMU guest, +install ``trace-cmd`` and check that the running kernel provides +``CONFIG_FTRACE``, ``CONFIG_FUNCTION_TRACER``, and +``CONFIG_FUNCTION_GRAPH_TRACER``. Enabling ``FTRACE`` alone is not sufficient. +Check availability and collect a task-filtered graph:: + + sudo trace-cmd list -t + sudo trace-cmd record -p function_graph -F -c -O nofuncgraph-irqs \ + --user "$USER" -o functions.dat ./app + trace-cmd report -i functions.dat > functions.txt + +Use an isolated measurement system: these commands change its tracing state. +``-F`` filters to the launched application, ``-c`` follows its children, and +``--user`` avoids running the workload as root just because the recorder needs +privileges. Preserve the workload's original user and environment. The option +``nofuncgraph-irqs`` excludes interrupt execution from the graph; asynchronous +work in other tasks is outside this task filter too. Check the report for lost +events before treating missing functions as unobserved. The perf examples +above provide sampled profiles, not an exhaustive list of executed functions. + +Tracing a minimal user space +============================ + +A single-binary initramfs has no shell or guest tracing tools. Initial discovery +can use the same application and libc in a full guest for the target +architecture, but that does not reproduce its launch as PID 1. The following +inspects the actual boot with QEMU's host-side GDB stub without adding tools to +the archive. + +Follow :doc:`/process/debugging/gdb-kernel-debugging` for the debug build and +matching ``vmlinux`` setup. Add ``nokaslr`` to the guest kernel command line +and ``-S -gdb tcp:127.0.0.1:1234`` to the QEMU boot command. ``-S`` pauses the +guest before boot, allowing breakpoints to be installed. Connect host GDB:: + + gdb-multiarch /path/to/build/vmlinux + (gdb) target remote localhost:1234 + (gdb) tbreak kernel_init + (gdb) continue + +For a native 64-bit arm64 workload, the following records syscall entry numbers +and the first argument from the saved user registers. It starts after PID 1's +kernel initialization, before the application executes:: + + (gdb) set pagination off + (gdb) set logging file pid1-syscalls.log + (gdb) set logging enabled on + (gdb) break do_el0_svc + (gdb) commands + > silent + > printf "syscall=%lu arg0=%#lx\n", regs->regs[8], regs->regs[0] + > continue + > end + (gdb) continue + +Interrupt GDB with Ctrl-C after the observation interval, then disable logging. +Resolve the numbers using the matching target build's syscall-number definitions. +These are entry observations, not decoded arguments or syscall results. To +inspect a particular kernel path, disable the logging breakpoint, set a +breakpoint on its implementation, and use ``bt`` or ``step`` at the hit. +Entry functions and register layouts are architecture- and revision-specific; +check them against the matching source. Once other processes exist, an entry +breakpoint can also capture their calls; GDB threads in QEMU represent vCPUs, +not Linux tasks. This is not a task-filtered whole-kernel coverage collector. + +QEMU also offers low-level logging with ``-d`` (list options with ``-d help``) +and ``-D qemu.log``. For example, ``-d in_asm`` logs translated instruction +blocks, not every execution or a workload-specific call trace. A block that is +not logged again may still have executed again from the translation cache, so +the log cannot show that a block did not run. + +Mapping observations to configuration +------------------------------------- + +Use the source revision and architecture matching the measured kernel, rather +than assuming the syscall tables above describe every build. Locate each +syscall implementation with cscope or its ``SYSCALL_DEFINE`` declaration, +follow calls into the relevant subsystem, and inspect its Makefile and Kconfig. +For example, ``eventfd2`` is implemented in ``fs/eventfd.c``; +``fs/Makefile`` builds ``eventfd.o`` under ``CONFIG_EVENTFD``. Use the +configuration help to review its dependencies before changing the option. +Other paths, such as the core ``write`` syscall, are built unconditionally +and may reach different drivers depending on the file descriptor. A syscall +does not necessarily map to one removable option. + +Retain results as well as names: a libc may probe an optional syscall, tolerate +``ENOSYS``, and take a fallback path. Observing the call alone does not prove +that the feature must remain enabled. Conversely, boot and recovery dependencies +may be absent from an application's syscall trace. Record the observed path, +source/configuration mapping, and result of re-testing after the change. + +For the distinction between built code and observed execution, use +:doc:`/dev-tools/gcov` for execution counts and :doc:`/dev-tools/kcov` for +task-scoped kernel PCs. Follow their collection and symbolization instructions +in a separate measurement build; neither strace nor a sampled perf profile +supplies those coverage results. Unobserved code remains a candidate for +investigation, not proof of an unnecessary feature. + +Keep the built-code inventory alongside the runtime observations using +``scripts/kernel-sloc --report compiled.json kernel .`` and, for the matching +debug ELF, ``scripts/kernel-sloc --report linked.json dwarf vmlinux``. See +``scripts/kernel-sloc --help`` for its modes and requirements. The +reports list compiled files and DWARF-resolved functions/source lines, not +execution. Compare full source paths as well as function names; repeated +static names and inlining make names alone insufficient. An unobserved entry +is a review candidate, not proof that its configuration can be removed. + Conclusion ==========
@@ -597,10 +721,10 @@ information on the resources in use by workloads using strace. References ========== - * `Discovery Linux Kernel Subsystems used by OpenAPS <https://elisa.tech/blog/2022/02/02/discovery-linux-kernel-subsystems-used-by-openaps>`_ - * `ELISA-White-Papers-Discovering Linux kernel subsystems used by a workload <https://github.com/elisa-tech/ELISA-White-Papers/blob/master/Processes/Discovering_Linux_kernel_subsystems_used_by_a_workload.md>`_ - * `strace <https://man7.org/linux/man-pages/man1/strace.1.html>`_ - * `perf <https://man7.org/linux/man-pages/man1/perf.1.html>`_ - * `paxtest README <https://github.com/opntr/paxtest-freebsd/blob/hardenedbsd/0.9.14-hbsd/README>`_ - * `stress-ng <https://www.mankier.com/1/stress-ng>`_ - * `Monitoring and managing system status and performance <https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8/html/monitoring_and_managing_system_status_and_performance/index>`_ + * `Discovery Linux Kernel Subsystems used by OpenAPS <https://elisa.tech/blog/2022/02/02/discovery-linux-kernel-subsystems-used-by-openaps>`__ + * `ELISA-White-Papers-Discovering Linux kernel subsystems used by a workload <https://github.com/elisa-tech/ELISA-White-Papers/blob/master/Processes/Discovering_Linux_kernel_subsystems_used_by_a_workload.md>`__ + * `strace <https://man7.org/linux/man-pages/man1/strace.1.html>`__ + * `perf <https://man7.org/linux/man-pages/man1/perf.1.html>`__ + * `paxtest README <https://github.com/opntr/paxtest-freebsd/blob/hardenedbsd/0.9.14-hbsd/README>`__ + * `stress-ng <https://www.mankier.com/1/stress-ng>`__ + * `Monitoring and managing system status and performance <https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8/html/monitoring_and_managing_system_status_and_performance/index>`__
MAINTAINERS +6 -0
@@ -28154,6 +28154,12 @@ F: sound/soc/codecs/arizona* F: sound/soc/codecs/cs47l24* F: sound/soc/codecs/wm* +WORKLOAD ANALYSIS DOCUMENTATION +M: Matthew Weber <[email protected]> +L: [email protected] +S: Maintained +F: Documentation/admin-guide/workload-tracing.rst + WORKQUEUE M: Tejun Heo <[email protected]> R: Lai Jiangshan <[email protected]>
Signature · 1 line
2.39.5
PATCH v2 4/4 Documentation: admin-guide: Add kernel minimization guide
In reply to Matthew WeberAdd kernel-minimization.rst to the Workload analysis section of the admin-guide, for application developers and system integrators who need to trim a Linux kernel for a single known workload, for example when analyzing the kernel for safety critical applications.
The guide explains how to trim a kernel for a workload running directly as PID 1, cross-compiled for QEMU arm64 with CONFIG_MODULES=n, and how to measure the resulting build. Cross-reference it from the workload tracing guide.
---
Changes in v2:
- Now follows the workload tracing update.
- Adds the cross-references from the workload tracing guide to this guide.
- Adds this file to the existing Workload analysis MAINTAINERS entry.
Documentation/admin-guide/index.rst | 1 + .../admin-guide/kernel-minimization.rst | 413 ++++++++++++++++++ .../quickly-build-trimmed-linux.rst | 4 + .../admin-guide/workload-tracing.rst | 3 +- MAINTAINERS | 1 + 5 files changed, 421 insertions(+), 1 deletion(-) create mode 100644 Documentation/admin-guide/kernel-minimization.rst
Documentation/admin-guide/index.rst +1 -0
@@ -178,6 +178,7 @@ subsystems expectations will be found here. :maxdepth: 1 workload-tracing + kernel-minimization Everything else ---------------
Documentation/admin-guide/kernel-minimization.rst new file +413 -0
413 lines not on this page · raw message
Documentation/admin-guide/quickly-build-trimmed-linux.rst +4 -0
@@ -8,6 +8,10 @@ How to quickly build a trimmed Linux kernel This guide explains how to swiftly build Linux kernels that are ideal for testing purposes, but perfectly fine for day-to-day use, too. +.. note:: To shrink a kernel down to only what one known workload needs, and + to measure the result, see :doc:`kernel-minimization`, which builds on this + guide. + The essence of the process (aka 'TL;DR') ========================================
Documentation/admin-guide/workload-tracing.rst +2 -1
@@ -706,7 +706,7 @@ investigation, not proof of an unnecessary feature. Keep the built-code inventory alongside the runtime observations using ``scripts/kernel-sloc --report compiled.json kernel .`` and, for the matching debug ELF, ``scripts/kernel-sloc --report linked.json dwarf vmlinux``. See -``scripts/kernel-sloc --help`` for its modes and requirements. The +:doc:`kernel-minimization` ("Counting kernel SLOC") for setup and scope. The reports list compiled files and DWARF-resolved functions/source lines, not execution. Compare full source paths as well as function names; repeated static names and inlining make names alone insufficient. An unobserved entry
@@ -728,3 +728,4 @@ References * `paxtest README <https://github.com/opntr/paxtest-freebsd/blob/hardenedbsd/0.9.14-hbsd/README>`__ * `stress-ng <https://www.mankier.com/1/stress-ng>`__ * `Monitoring and managing system status and performance <https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8/html/monitoring_and_managing_system_status_and_performance/index>`__ + * :doc:`Kernel minimization <kernel-minimization>`
MAINTAINERS +1 -0
@@ -28158,6 +28158,7 @@ WORKLOAD ANALYSIS DOCUMENTATION M: Matthew Weber <[email protected]> L: [email protected] S: Maintained +F: Documentation/admin-guide/kernel-minimization.rst F: Documentation/admin-guide/workload-tracing.rst WORKQUEUE
Signature · 1 line
2.39.5
Thorsten Leemhuis
maintainerRe: [PATCH v2 4/4] Documentation: admin-guide: Add kernel minimization guide
Lo! Thanks for this. Just a few things from a very quick and incomplete look at it:
Quoted 4 lines · Matthew Weber
Add
kernel-minimization.rstto the Workload analysis section of the admin-guide, for application developers and system integrators who need to trim a Linux kernel for a single known workload, for example when analyzing the kernel for safety critical applications.
I'm not a native speaker, so take the following with a grain of salt or maybe even ignore it:
"Trim" to me feels like the wrong word for what this is about, as I associate it with something rough where you don't have to be that exact -- like shaping hedges, mowing lawns, or cutting hairs/beards. So it fits for what "make localmodversion" does if you ask me.
What you do here seems to be something that is finer and more exact. So I'd use a word like "tailoring" or "custom-tailor" here. Maybe even replacing a few or most "minimize" (like in the title or the filename) with "tailoring" might be a good idea, as the word also makes clear that this is something that takes some thought and work.
Maybe that is just nitpicking, but sometimes the right words can help a lot in getting the right picture in the head of the readers.
And native speakers: please speak up if I am telling rubbish!
Quoted 1 line
[...]> +This guide builds on, rather than repeats, several existing
documents:
Documentation/admin-guide/kernel-minimization.rst line 28
Quoted 5 lines
Documentation/admin-guide/kernel-minimization.rst new file +5
-0+ +* :doc:`quickly-build-trimmed-linux` for the mechanics of getting, building, + and installing a kernel. This guide assumes you have followed it at least + once and reuses its sections by name below -- in particular its "Download the + sources" and "Define the build configuration for your kernel" steps. Note
I'd repeat those here -- either completely (with a brief note that they are copied from there or something like that) or just the core commands one has to use (with links into the other text to the more detailed explanations).
Yes, like code duplication it bears it risks. But not duplicating also has them -- and here it make things hard to follow for a relative small gain if you ask me. Maybe a few internal notes in the relevant files along the lines of "this para is copies over <to list of other files>, so when updating it, ensure to update it there, too.
Documentation/admin-guide/kernel-minimization.rst line 31
Quoted 3 lines
Documentation/admin-guide/kernel-minimization.rst new file +3
-0+ that guide targets a kernel built **natively for the machine you are on**; the + cross-compiled, boot-in-QEMU angle used here is the main thing this guide adds + on top of it (see `Building: native vs cross-compiled`_).
Maybe some of that should move over? Or to Documentation/admin-guide/verify-bugs-and-bisect-regressions.rst ? That file and quickly-build-trimmed-linux would need to me synced again anyway, but that is a different story.
Documentation/admin-guide/kernel-minimization.rst line 43
Quoted 5 lines
[...]> +Baseline scenario
+=================Documentation/admin-guide/kernel-minimization.rst new file +3
-0+ +The walkthrough assumes the simplest possible launch model, which keeps the +chain from "what the workload needs" to "what the kernel must provide" short:
This made me wonder if this document will clearly separate "What a app needs from the kernel" "what the kernel must provide to run on the hardware in question", but maybe we get to that.
Documentation/admin-guide/kernel-minimization.rst line 81
Quoted 7 lines
Documentation/admin-guide/kernel-minimization.rst new file +7
-0+Prerequisites +------------- + +Follow "Install build requirements" in :doc:`quickly-build-trimmed-linux` +for the native build tools. On a Debian/Ubuntu x86_64 host, this example adds:: + + sudo apt install gcc-aarch64-linux-gnu qemu-system-arm file
Maybe it's just me, but I hate it when software or docs assume just one distro/distro universe. My brain always reads some bias and limited testing into that. And every time I tested my own howtos on another distro universe unfamiliar to me I found important details I got wrong or missed. Which is why I think it's definitely worth at least testing and mentioning one other if this is to me merged into the kernel. I'd suggest Fedora, but that shows my bias. :-/ And maybe I'm asking to much here, maybe others don't care that much about this as I do. And it can make things more complicated, too, so maybe it's a bad idea overall.
Documentation/admin-guide/kernel-minimization.rst line 135
Quoted 12 lines
Documentation/admin-guide/kernel-minimization.rst new file +12
-0+Iterate toward minimal +---------------------- + +Pick a direction. These mirror the two bases the trimmed-build guide's "Define +the build configuration for your kernel" section describes -- starting from an +existing (large) config versus starting from scratch: + +* **Top-down** -- start from a working configuration and remove features, + re-testing after each removal. For this arm64 QEMU example, build + ``defconfig`` as the baseline:: + + make defconfig
Wondering if "make kvm_guest.config" would be better.
Quoted 1 line
+ make tinyconfig
Wondering if tinyconfig is a good idea security-wise these days: does it (and defconfig/kvm_guest.config) enable all the security features typical distros usually enable these days that you might even want in a custom-tailored kernel?
Overall it got a bit hard to follow at this point -- but that might be because I ran out of time here, too. So didn't look at the rest. But maybe that helps you somewhat.
Ciao, Thorsten