Skip to content
Merged
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
7 changes: 7 additions & 0 deletions docs/log.md
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,13 @@ Masking `modprobe@drm`, which logind is ordered after, added nothing (327/345).
- the first dispatch: 0.87.

The gap is unit loading, not the transaction that 11-13's single debug-logged boot named. 96 of the units a boot lists are inactive, loaded because another unit names them in `After=`/`Wants=`: `initrd-*`, `plymouth-*`, `modprobe@*`, hibernate, cryptsetup's targets, `firewalld` and `auditd` named by docker. Masking does not spare a load (a masked unit is still looked up and loaded as masked), which is why masking 11 units moved nothing (§4).

**11-19 · image/machine · the root mount's storage path (branch `ext4-mount`, not yet on the fleet).** The kernel gap `security_initcall_late_sync` → `EXT4-fs (vda): mounted` was 6.8 ms nested and 5.0 metal (`boot:initcalls`). Three changes, from reading Linux 7.3 and the image:
- the image without `orphan_file`, a mke2fs.conf default since 1.47.0: every mount, read-only included, reads it one block at a time (`ext4_init_orphan_info`, ~73 single-block reads with no readahead). Crash correctness is the classic orphan list's;
- `lazy_itable_init=0`: `mke2fs -d` left no group `ITABLE_ZEROED`, so each overlay's first read-write mount had `ext4lazyinit` zero every inode table in the first second of the boot. After one `--init /bin/sh` boot the overlay held 16.06 MiB of zero clusters, and none with the tables zeroed at build. The thread still starts, to prefetch block bitmaps (it does not with `no_prefetch_block_bitmaps`). The image is 256 KiB smaller;
- `rootfstype=ext4`: without it the root mount tries ext3, then ext2 (`EXT4_USE_FOR_EXT2`), on the superblock before ext4.

Laptop lead only, on a host at load ~30: the gap's p50 over three alternated rounds of `TestKernelInitcalls` (8-10 boots each) was 8.8/2.8/4.3 ms with the release, 4.1/3.2/2.9 with `rootfstype` alone, and under 2.4 (below the rows printed)/1.3/1.2 with all three. Not decided until `boot:ssh-first` and `boot:restore-first` run interleaved on the bench fleet.
---

## 3. Rework cycles
Expand Down
4 changes: 2 additions & 2 deletions image/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ true and useless.
It is `spin-machine boot` with no `--disk`: this QEMU and this kernel over `rootfs.qcow2`
under a throwaway overlay (QEMU's `-snapshot`), with the serial console on stdio.

It boots with no initrd at all: `root=/dev/vda rw init=/sbin/init`, which the kernel can
serve because virtio-blk and ext4 are built in and `build.sh` writes a partitionless
It boots with no initrd at all: `root=/dev/vda rw rootfstype=ext4 init=/sbin/init`, which the
kernel can serve because virtio-blk and ext4 are built in and `build.sh` writes a partitionless
filesystem. There is no debug initramfs: one that mounted the API filesystems, found the
root disk and exec'd would be a second init, doing what the init a consumer brings already
does. What removes the need for one is `systemd-udevd` being on.
Expand Down
35 changes: 33 additions & 2 deletions image/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -177,10 +177,28 @@ done < "$SHARE/packages.txt"
# costs the image almost nothing, since mke2fs does not zero it — an empty 974 MiB filesystem
# converts to 1540 KiB of qcow2 with it and 1220 KiB without — and an overlay at most 64 MiB,
# once the guest has cycled through it (all measured 2026-09-14).
#
# No orphan_file, which mke2fs.conf turns on for ext4 since 1.47.0. Every mount, read-only
# included, loads the orphan file into memory one block at a time (ext4_init_orphan_info,
# fs/ext4/orphan.c in 7.3): about 73 sequential single-block reads with no readahead, each a
# virtio round trip, inside the root mount the whole boot waits for. What the feature buys is
# scale for a filesystem unlinking many open files at once from many CPUs, where the classic
# orphan list in the superblock serialises on one lock; a workspace is not that. Crash
# correctness is the same either way - an inode unlinked while open is recorded in the classic
# list and the journal, and released at the next mount, as on every ext4 before 1.47.
#
# lazy_itable_init=0: the inode tables are zeroed here and every group is marked so
# (ITABLE_ZEROED). Without it - mke2fs -d left every group unmarked - the first read-write mount
# of each overlay set ext4lazyinit to zero every inode table, in the first second of the boot,
# while the machine is reaching its first login: 16.06 MiB of zero clusters in the overlay after
# one boot, and none with the tables zeroed here (`--init /bin/sh`, laptop, 2026-11-19). The
# thread itself still starts, to prefetch block bitmaps, which only reads. Zeros cost the image
# nothing, because qemu-img does not allocate a cluster of them: with both changes it came out
# 256 KiB smaller than the build before it.
mkbase() {
rm -f /work/base.raw
"$bin/mkfs.ext4" -q -F -L "" -U clear -J size=64 -m 0 -b 4096 -E root_owner=0:0 \
-d "$tree" /work/base.raw "${1}k"
"$bin/mkfs.ext4" -q -F -L "" -U clear -J size=64 -m 0 -b 4096 -O ^orphan_file \
-E root_owner=0:0,lazy_itable_init=0 -d "$tree" /work/base.raw "${1}k"
}
# The size is given in KiB with its unit spelled. A bare number is KiB only until -b is on the
# command line, after which mke2fs reads it as a count of blocks: adding -b 4096 made this image
Expand Down Expand Up @@ -222,6 +240,19 @@ grep -q '^Filesystem features:.* has_journal' <<<"$header" || { echo "ERROR: the
grep -q '^Filesystem features:.* needs_recovery' <<<"$header" && { echo "ERROR: the filesystem's journal needs recovery" >&2; exit 1; }
grep -q '^Total journal size: *64M$' <<<"$header" || { echo "ERROR: the journal is not 64M: $(grep '^Total journal size' <<<"$header")" >&2; exit 1; }
grep -q '^Filesystem state: *clean$' <<<"$header" || { echo "ERROR: the filesystem is not clean" >&2; exit 1; }
# The two choices mkbase makes against mke2fs.conf's defaults, read back: an e2fsprogs bump whose
# mke2fs ignored one would build a filesystem that mounts and boots, only slower.
grep -q '^Filesystem features:.* orphan_file' <<<"$header" && {
echo "ERROR: the filesystem has orphan_file; every mount reads it block by block" >&2; exit 1; }
# Every group, from the group descriptors: dumpe2fs prints one "Group N:" line each, with
# ITABLE_ZEROED among its flags when the mark is there. The count is compared with the header's
# group count rather than only looking for a group without it, so that output dumpe2fs did not
# print, or printed differently, fails rather than passes.
groups=$("$bin/dumpe2fs" /work/base.raw 2>/dev/null | grep '^Group [0-9]*:')
want=$(awk -F: '/^Block count:/ { b = $2 } /^Blocks per group:/ { g = $2 } END { printf "%d\n", (b + g - 1) / g }' <<<"$header")
zeroed=$(grep -c 'ITABLE_ZEROED' <<<"$groups" || true)
test "$want" -gt 0 && test "$zeroed" = "$want" || {
echo "ERROR: $zeroed of $want groups have zeroed inode tables; each overlay would run ext4lazyinit" >&2; exit 1; }

# debugfs is asked and its *output* is read, not its exit status: `debugfs -R` exits 0
# whether or not the request succeeded, printing "File not found by ext2_lookup" to stderr
Expand Down
11 changes: 11 additions & 0 deletions machine/cmdline.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,17 @@ func (c Cmdline) String() string {
mode = "ro"
}
parts = append(parts, "root="+c.Root, mode)

// The root is an ext4 (image/build.sh), and saying so is one mount instead of
// three. Without rootfstype the kernel tries every block filesystem in the order
// it registered them (init/do_mounts.c), and ext4's init registers ext3 and,
// with EXT4_USE_FOR_EXT2, ext2 ahead of ext4 itself: the root mount reads the
// superblock as an ext3, is refused for its features, reads it again as an
// ext2, and only then mounts it, each attempt a superblock read over virtio
// after a block size change. A disk handed in with --disk is an overlay of the
// same image, so it is the same filesystem; a root that is not one says so with
// its own rootfstype= in Extra, which comes later and is the one the kernel keeps.
parts = append(parts, "rootfstype=ext4")
}

// Scan PCI bus 0 and stop.
Expand Down
3 changes: 2 additions & 1 deletion machine/machine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -654,7 +654,8 @@ func TestCmdline(t *testing.T) {
}, {
name: "root",
c: withRoot,
want: []string{"root=/dev/vda rw"},
// Named, or the root mount tries ext3 and ext2 on the superblock first.
want: []string{"root=/dev/vda rw rootfstype=ext4"},
}, {
name: "no console",
c: noConsole,
Expand Down