Skip to content

Mount binfmt_misc at the start of boot, not through its automount - #16

Closed
joshuaswarren wants to merge 1 commit into
omacom:mainfrom
joshuaswarren:fix/binfmt-eager-mount
Closed

joshuaswarren wants to merge 1 commit into
omacom:mainfrom
joshuaswarren:fix/binfmt-eager-mount

Conversation

@joshuaswarren

@joshuaswarren joshuaswarren commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

On a Mac with the qemu-user-static-binfmt formats, boot waits about one second for the binfmt_misc mount. sysinit.target waits with it, and so do the network and sshd.

systemd-binfmt registers the 33 formats right after the local file systems mount. Its first access triggers the binfmt_misc automount. That burst of mounts (/home, /var/log, /var/cache/pacman/pkg, /boot, /boot/efi, fuse) trips systemd's /proc/self/mountinfo rate limit of 5 events in 1 s (src/core/mount.c). While the limit holds, unit_start() returns -EAGAIN for every mount unit (src/core/unit.c). So the binfmt_misc mount waits until about 1 s after the burst.

I measured it on a 14-inch M2 Max (systemd 262), in 5 of 6 boots. Got automount request for /proc/sys/fs/binfmt_misc came at 4.129 s, and Mounting Arbitrary Executable File Formats at 5.094 s. The gap was 0.962 to 0.966 s, and no unit started or finished inside it. The one boot whose request came after the window mounted at once. A 16-inch M1 Max shows the same 0.965 s gap.

proc-sys-fs-binfmt_misc.mount already says WantedBy=sysinit.target. A vendor sysinit.target.wants link pulls it in as boot starts, before any burst. So systemd-binfmt finds it mounted and never waits on the automount. The automount stays as it is, and the README says why.

mac-boot-install-test.sh now also checks that every .wants link this package ships names a unit this package or systemd ships. Systemd skips a dangling link at boot without a word. A throwaway dangling link made the new check fail with "pulls a unit that neither this package nor systemd ships".

Checked at 1478b08 on main f47d3db (no newer upstream commits at the time), on a Debian host with the runtime CI pins (omacom/omarchy bf659459): .github/scripts/check-scope and check-architecture-gates exit 0. mac-boot-install-test.sh passes with the new check, and so do the other 21 test files that pass on main. Three omarchy-mac-boot test files also fail on main here, so they are not caused by this change: apple-silicon-boot-check-test.sh (exit 127, a missing tool), mac-external-displays-test.sh and update-m1n1-locale-test.sh (exit 1). shellcheck -S warning finds nothing in the files this adds; the two warnings in changed test files are already on main. CI runs the full suites in the Arch container once this is open.

On a 16-inch M1 Max, a lab test boot with the mount enabled at boot start (2026-10-07) showed no automount request in two boots. The baseline had one at 3.621 s. Userspace went from 4.70 s to 3.68 and 3.75 s. That test also raised the mount rate limit on the kernel command line (SYSTEMD_DEFAULT_MOUNT_RATE_LIMIT_BURST=64) and shortened the Limine timeout. So I cannot say how much of the 1.0 s userspace gain comes from this change alone.

The same stall likely hits any Omarchy install with this mount layout and qemu-user-static-binfmt. This change is Mac-only, because this package owns the Mac boot path.

systemd-binfmt registers Omarchy's qemu-user-static-binfmt formats right after
the local file systems mount, and its first access triggers the binfmt_misc
automount. That burst of mounts (/home, /var/log, /var/cache/pacman/pkg,
/boot, /boot/efi, fuse) puts systemd's /proc/self/mountinfo rate limit (5
events in 1 s) in effect, and unit_start() holds every mount start job with
-EAGAIN until it expires. sysinit.target, and the network and sshd behind it,
waited for that: 0.96 s on 5 of 6 M2 Max boots (automount request 4.129 s,
mount start 5.094 s; nothing else started or finished in between), and the
same 0.965 s on an M1 Max.

proc-sys-fs-binfmt_misc.mount carries WantedBy=sysinit.target for this: a
vendor .wants link pulls it in as boot starts, before any burst, and
systemd-binfmt finds it mounted. The install test now checks that every
.wants link this package ships names a unit this package or systemd ships.

@maralcbr maralcbr left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice diagnosis, and the evidence is solid. systemd's own proc-sys-fs-binfmt_misc.mount declares WantedBy=sysinit.target and systemd-binfmt orders after it, so early activation is an upstream-supported arrangement, and sharing systemd's .wants directory isn't a conflict.

But nothing in it is Mac-specific. The rate limit is tripped by Omarchy's own mount burst (/home, /var/log, the pacman cache, /boot, fuse) plus qemu-user-static-binfmt, which any Omarchy machine with those formats hits. Per CONTRIBUTING ("the fix helps other machines too → upstream"), please move this to omacom/omarchy (or wherever Omarchy ships its systemd defaults), with the boot timings. The .wants link-existence test is a good idea to bring along. Note it proves the link resolves, not the ordering or the timing.

@joshuaswarren

Copy link
Copy Markdown
Contributor Author

Both points in review 5448427284, moved upstream in omacom/omarchy#14485 (commit 4e214461):

  1. Move to omacom/omarchy with the boot timings — done. New installs get systemctl enable proc-sys-fs-binfmt_misc.mount in install/config/enable-services.sh; existing installs get a migration that enables the same unit. The PR body carries the M2 Max and M1 Max measurements from this PR. Agreed on both of your notes: WantedBy=sysinit.target makes the arrangement upstream-supported, and the rate-limit stall is not Mac-specific — it hits any Omarchy machine with those binfmt formats, which is why it belongs there.
  2. Bring the .wants link-existence test — done there as new rows in test/shell.d/systemd-test.sh. Omarchy creates the link through systemctl enable at install instead of shipping one, so the test checks the enable line, the migration, and that systemd's unit keeps WantedBy=sysinit.target; as you note, that proves the link resolves, not the ordering or the timing.

Closing this PR in favor of omacom/omarchy#14485. After that merges, omarchy-mac-boot does not need to ship the link itself: a follow-up here should drop files/usr/lib/systemd/system/sysinit.target.wants/proc-sys-fs-binfmt_misc.mount and the .wants rows added to mac-boot-install-test.sh.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants