Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion docs/boot-time.md
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ them for boot time.
|---|---|---|---|---|
| Kernel patches 0001-0005, 0007, 0008, 0010 | kernel/patches | cold +67.5 [+62.5, +72.4], with 0006, 0009 and 0011 (since deleted, worth nothing) | group A | lab 44818953987 |
| Kernel 0012 (vmlinux BTF parsed on first use) and 0013 (the verifier asks for it only where a kernel type enters a program) | kernel/patches | cold −6.4 [−9.4, −1.0] at 60 a side (lab 45118194310, the kernel carried); before the review's fixes −10.0 [−12.7, −3.3] at 60 and −6.3 [−9.1, −4.6] at 120 (labs 45114405201, 45115330128); restored −1.0 [−6.0, +4.2] evicted, the state 1.3 MiB smaller (lab 45115341056) | measured | lab 45118194310 |
| Kernel 0021-0025, the boot's device-setup exits as one change (#627): the IOAPIC table read once (#590), the state save at add only where error recovery can restore it (#591 a), virtio-pci's vendor capabilities walked once (#591 b), `queue_select` written only on a change and an unchanged MSI message not rewritten (#592). 0022's gate has to grow with whatever calls error handlers next (its changelog). Alone each was within noise ("Measured and rejected") | kernel/patches | first login −9.2 [−12.2, −6.0], sshd accepting −9.0 [−12.4, −6.7], 120 a side (lab 45231943664); restored −0.6 [−2.3, +1.6] evicted and −0.7 [−1.5, +0.8] cached, the state +0.3 MiB [−0.1, +0.6], 30 a side (lab 45232800577); 838 exits fewer, 366 of them MMIO (3 a side, lab 45114428660) | measured | labs 45231943664, 45232800577 |
| `BLK_DEV_LOOP_MIN_COUNT=0`, `SERIAL_8250_RUNTIME_UARTS=1` | kernel/config-7.3-x86_64 | cold +5.3 [−3.2, +15.0]: inside the noise, but the upper bound does not rule out its ~2-4 ms ceiling | measured, 40 a side | lab 44839538785 |
| `KERNEL_LZ4` | kernel/config-7.3-x86_64 | the alternatives lost: an uncompressed payload, on QEMU 0007, −4.0 [−7.9, +0.3] at 40 a side, within noise, and QEMU's RSS +32 MiB (lab 45183618987); before 0007, +9 ms in copies (laptop) | measured, 40 a side | lab 45183618987, #326 |
| `VT=n`, `X86_MSR=n`, `X86_CPUID=n` | kernel/config-7.3-x86_64 | function: dead code, less surface | - | kernel/Dockerfile |
Expand Down Expand Up @@ -348,7 +349,7 @@ and a row measured in another shape than spin's has such a reason.
| x86's `msi_set_affinity` skips the message write when the vector and destination did not change (#592 lever 2, a kernel patch on branch `exp/592-l2-msix-once`) | 56 MMIO exits fewer (`__pci_write_msi_msg` 168 → 112, 3 a side, lab 45113437048), the first login −0.1 [−3.1, +4.5] at 60 a side (lab 45114405201) | spin | labs 45113437048, 45114405201 | 11-23 |
| `pci_save_state()` at a device's add kept only where an error handler can restore it (#591 a, a kernel patch on branch `exp/591a-no-save-state`) | 128 MMIO exits fewer, the host's handling −3.3 [−6.2, −2.1] ms (3 a side, lab 45113437048), but the first login −4.3 [−6.8, +0.5] at 60 a side (lab 45114405201) and −1.3 [−3.5, +1.3] at 120 (lab 45115330128). Its gate has to grow by hand: upstream a2f1e22390ac took out `pci_restore_state()`'s refusal of a state never saved | spin | labs 45113437048, 45114405201, 45115330128 | 11-23 |
| virtio-pci's vendor capabilities walked once per device (#591 b, a kernel patch on branch `exp/591b-virtio-caps-once`) | 114 MMIO exits fewer (3 a side, lab 45113437048). The first login −5.8 [−8.2, −0.6] at 60 a side (lab 45114405201), three times what 114 exits can cost, and +0.9 [−1.8, +2.7] at 120 (lab 45115330128) | spin | labs 45113437048, 45114405201, 45115330128 | 11-23 |
| The IOAPIC's redirection table read once at boot, and written back only where it was masked (#590, a kernel patch on branch `exp/590-ioapic-once`) | IOAPIC accesses 589 → 205 and the host's handling −3.1 [−6.2, −1.1] ms (3 a side, lab 45113437048), but the first login −4.5 [−7.8, +0.4] at 60 a side (lab 45114405201) and −2.0 [−4.3, +0.6] at 120 (lab 45115330128). With the four other exit patches of #591 and #592, as a bound, −7.4 [−12.1, −2.8] (#627) | spin | labs 45113437048, 45114405201, 45115330128 | 11-23 |
| The IOAPIC's redirection table read once at boot, and written back only where it was masked (#590, a kernel patch on branch `exp/590-ioapic-once`) | IOAPIC accesses 589 → 205 and the host's handling −3.1 [−6.2, −1.1] ms (3 a side, lab 45113437048), but the first login −4.5 [−7.8, +0.4] at 60 a side (lab 45114405201) and −2.0 [−4.3, +0.6] at 120 (lab 45115330128). With the four other exit patches of #591 and #592, as a bound, −7.4 [−12.1, −2.8], and as one change −9.2 [−12.2, −6.0] at 120 a side: carried as 0021-0025 (#627, "What the machine carries") | spin | labs 45113437048, 45114405201, 45115330128 | 11-23 |

### Firmware, QEMU and the machine

Expand Down
1 change: 1 addition & 0 deletions docs/log.md
Original file line number Diff line number Diff line change
Expand Up @@ -666,6 +666,7 @@ Checked against the probe it replaced on the bench fleet, `lab dispatch ssh-firs
**11-23 · qemu · a bzImage mapped, not read into QEMU's heap (#646, labs 45182382388, 45182382864, 45183618987, this change).** `x86_load_linux` read the whole 16.7 MB bzImage into a buffer that only fw_cfg reads, 6.2-6.9 ms of QEMU's init traced (labs 45177818419, 45177817516, #611), and qboot copies the same bytes again by fw_cfg DMA. `qemu/patches/0007` maps the file read-only (`g_mapped_file_new_from_fd`), as upstream has mapped the initrd since 4.2; a kernel with a dtb appended keeps its buffer. The setup header QEMU patches is already a copy of its own, so nothing writes to the mapping. The QEMU build asserts that a held TCG machine's maps name a stub bzImage given to it; the published QEMU fails that check. *Prior art* is in docs/boot-time.md's row: Garzarella's 2019 series mapped the ELF kernel and the initrd but not the bzImage. *Measured* (bench, nested, spin's shape and login, v20261123.05 against the same release with the patched QEMU, parts run 45180746171, 40 a side, interleaved): first login 380 → 367, −13.4 [−16.9, −7.3], sshd accepting −13.3 [−18.7, −7.5], the console prompt −10.6 [−14.2, −6.3]; QEMU's anonymous RSS −15.9 MiB and its file RSS +16.1, total unmoved (lab 45182382388). Restored, 40 a side: login −9.3 [−11.2, −6.1] evicted and −7.7 [−8.9, −5.1] cached, `running` −8.8 and −7.9, the state unmoved (lab 45182382864): a restore starts QEMU, which loads the kernel into fw_cfg there too. The gain is twice the traced read; what else the anonymous buffer cost nested (its page faults, presumably) was not measured. *A lead, not a decision:* an uncompressed payload (#326's kernel patch, renumbered, branch `exp/646-uncompressed`, parts run 45180892535) against LZ4, both on the patched QEMU: first login −4.0 [−7.9, +0.3], within noise at 40, QEMU's RSS +32 MiB (lab 45183618987). The mapping removes the "+6-7 in QEMU's start" half of #326's rejection; whether the rest is a gain needs more boots, which is #645's. *Status:* in place; the record does not move, as the kernel reaches the guest through fw_cfg.

**11-23 · machine, qemu · QEMU's start and the held start's QMP, split and rejected (#647, #649, labs 45177818419, 45230790902, 45231358105, #669, this change).** #611's split left two cold phases without an owner. *#649, the held start's 14 commands, 6.1 ms on bench:* QEMU waited 4.5 ms p50 for the client, 0.9 of it busy with the probe's plug monitor (the memory spin sizes right after the start), so spin-machine's own share is ~3.6 ms, ~0.28 ms a round trip (24 boots, lab 45177818419). The candidate sent the bind ahead of its answers (`qmp.Send`): the run state with the places, every serial at once, each image's two nodes together, the reopen with the placeholder's delete, 13 round trips to 9; add-fd still holds the connection until its answer and `cont` waits for the bind. *Measured* (bench, nested, spin's shape and login, v20261123.06's parts, spin-machine main at f273377 against the candidate at c966407, 60 a side): first login −1.7 [−5.6, +2.6], sshd accepting −2.4 [−5.5, +2.8] (lab 45230790902); restored login −0.3 [−3.8, +3.7] evicted, +0.9 [−10.6, +7.5] cached (lab 45231358105). Rejected: the four round trips it removes are ~1.1 ms (inferred), and even all of spin-machine's 3.6 ms is under what 60 boots a side resolve. The code is on `archive/exp-649-held-start`. *#647, QEMU's exec to its first trace event, 9.7 ms on bench:* the release's QEMU is static-pie on musl, so there is no dynamic loader and `LD_DEBUG` has nothing to report; musl relocates its 59,700 relative relocations itself. The split, on the laptop as a lead (exec to the first `flatview_new`, 40 starts a row, 4.7-5.4 ms p50): a trivial static-pie binary 0.23, QEMU's `-version` 2.0, `-sandbox` −0.7 to −0.9, the rest option parsing, trace and main-loop start and the machine object. perf on an unstripped build of the same Dockerfile: relocation 7% of `-version`, page faults ~15%, nothing else over 2%. No candidate's ceiling is over ~2 ms on bench (inferred at ~2× the laptop): a seccomp filter compiled at build time (Firecracker's seccompiler), a non-PIE binary (which gives up ASLR), DT_RELR. None was built. The allocator, musl's mallocng, is ~2.3 of the 17 ms of CPU QEMU's main thread spends from exec to held, a lead across QEMU's whole start, opened as #669. *Status:* rejected, both.
**11-23 · kernel · the boot's device-setup exits as one change: kernel 0021-0025 (#627, parts run 45228777973, labs 45231943664, 45232800577, this change).** *Why:* five patches each removed the VM exits their changelogs counted (#590, #591, #592), and none moved the first login alone; as a bound the five read −7.4 [−12.1, −2.8] at 60 a side (lab 45114405201, 11-23 above). #627 asked whether "the boot's MMIO exits in device setup" is one change and, if so, for one arm at 120 a side, the set chosen before the run. *Changed:* the bound's five, from `archive/exp-batch2-bound`, applied to 7.3.5 unchanged and remade with `git format-patch` as 0021-0025 (0014-0020 are #645's). The build asserts each on its vmlinux (kernel/README.md); checkpatch `--strict` and sparse pass. 0022 keeps the risk #627 named: upstream a2f1e22390ac took out `pci_restore_state()`'s refusal of a state never saved, so its gate (AER, EEH, s390, Xen pcifront, `reset_root_port`) has to grow by hand with whatever calls error handlers next; it was kept in the set because the set was fixed before the run. *Measured* (bench, nested, spin's shape and login, against v20261123.06, interleaved): first login −9.2 [−12.2, −6.0], sshd accepting −9.0 [−12.4, −6.7], console prompt −11.9 [−15.2, −8.1], second login −0.0 [−0.3, +0.3], QEMU RSS +0.1 MiB within noise, 120 a side (lab 45231943664). `restore-first`, 30 a side (lab 45232800577): restored login −0.6 [−2.3, +1.6] evicted and −0.7 [−1.5, +0.8] cached, the state +0.3 MiB [−0.1, +0.6], all within noise; its cold row −17.1 [−23.6, −10.8]. *Status:* in place; reaches the goal number with the next release.

## 2. Rework cycles

Expand Down
27 changes: 26 additions & 1 deletion kernel/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,8 @@ RUN <<EOT
dis() { objdump -d --no-show-raw-insn --disassemble="$1" vmlinux; }
lost() { echo "ERROR: patches/$1 is not in this vmlinux: $2"; failed=1; }
for f in vfs_read ftrace_check_for_weak_functions trace_eval_init trace_format_open \
raw_pci_read raw_pci_write pci_setup_device early_quirks btf_vmlinux_defer; do
raw_pci_read raw_pci_write pci_setup_device early_quirks btf_vmlinux_defer \
enable_IO_APIC pci_bus_add_device vp_modern_probe; do
dis "$f" | grep -q "<$f>:" || { echo "ERROR: no function $f in vmlinux; the check that names it reads nothing"; failed=1; }
done

Expand Down Expand Up @@ -513,6 +514,30 @@ RUN <<EOT
# that was compiled is read.
grep -qF 'need_btf_vmlinux(env)' kernel/bpf/verifier.c || lost 0013 "bpf_check parses vmlinux BTF for every program"

# 0021: enable_IO_APIC() clears each pin from the read its ExtINT search made, so it no
# longer reads the whole redirection table again through clear_IO_APIC().
! dis enable_IO_APIC | grep -q '<clear_IO_APIC>' || lost 0021 "enable_IO_APIC still reads every pin again through clear_IO_APIC"

# 0022: a device's state is saved at add only where something can restore it unsaved; the
# check of the root bus's host bridge is the gate's, and the call is there only with it.
dis pci_bus_add_device | grep -q '<pci_find_host_bridge>' || lost 0022 "pci_bus_add_device saves every device's state"

# 0023: virtio-pci's vendor capabilities are walked once, not once for each of four types,
# so vp_modern_probe starts one walk.
[ "$(dis vp_modern_probe | grep -c '<pci_find_capability>')" = 1 ] ||
lost 0023 "vp_modern_probe walks the vendor capabilities once for each type"

# 0024: queue_select is written only when the queue changes. The helper is static and
# inlined into every accessor, so the source that was compiled is read.
grep -qF 'mdev->selected_queue == index' drivers/virtio/virtio_pci_modern_dev.c ||
lost 0024 "virtio-pci writes queue_select before every queue field"

# 0025: msi_set_affinity() returns before the message write when the vector and the
# destination did not change. A comparison in its machine code looks like any other, so the
# source that was compiled is read.
grep -qF 'cfg->dest_apicid == old_cfg.dest_apicid' arch/x86/kernel/apic/msi.c ||
lost 0025 "msi_set_affinity writes an unchanged message"

[ "$failed" = 0 ] || exit 1
echo "kernel patches: each is in this vmlinux"
EOT
Expand Down
5 changes: 5 additions & 0 deletions kernel/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,11 @@ every kernel bump.
| 0010 | `early_quirks` calls `kvm_para_available` before its scan |
| 0012 | `btf_vmlinux_defer` is in the vmlinux, and the compiled `kernel/bpf/btf.c` defers registrations through it |
| 0013 | the compiled `kernel/bpf/verifier.c` asks for vmlinux BTF through `need_btf_vmlinux(env)` |
| 0021 | `enable_IO_APIC` does not call `clear_IO_APIC`: each pin is cleared from the read its ExtINT search made |
| 0022 | `pci_bus_add_device` calls `pci_find_host_bridge`, the gate on its state save |
| 0023 | `vp_modern_probe` calls `pci_find_capability` once |
| 0024 | the compiled `drivers/virtio/virtio_pci_modern_dev.c` writes `queue_select` only when `selected_queue` differs |
| 0025 | the compiled `arch/x86/kernel/apic/msi.c` compares the vector and the destination before the message write |

None of them is a guest check. What the patches save is CPU and VM exits, which a guest cannot
count, and the format files 0003 defers are behind lockdown. What 0012 and 0013 save is a parse of
Expand Down
Loading