From d6ea2bd9ae3a7654b26e73633103a53aaa88060d Mon Sep 17 00:00:00 2001 From: Manuel de Brito Fontes Date: Thu, 12 Nov 2026 02:37:57 -0300 Subject: [PATCH] image: the hot-add rule onlines CPUs only; the kernel onlines memory memhp_default_state=online is always on the command line (machine/cmdline.go), so the kernel onlines every virtio-mem block itself. The block's add uevent leaves before that, udev read it offline and wrote "online" after the kernel had, and udevd logged an EINVAL failure for every block a workspace grew by. The CPU line stays: nothing else onlines a hot-added core. Closes #230 Co-Authored-By: Claude Opus 5.5 --- .../usr/local/lib/spin-base/optimize-systemd.sh | 4 ++-- .../rootfs/etc/udev/rules.d/40-spin-hotadd.rules | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/image/mkosi.extra/usr/local/lib/spin-base/optimize-systemd.sh b/image/mkosi.extra/usr/local/lib/spin-base/optimize-systemd.sh index 1c33c2c..73ca092 100755 --- a/image/mkosi.extra/usr/local/lib/spin-base/optimize-systemd.sh +++ b/image/mkosi.extra/usr/local/lib/spin-base/optimize-systemd.sh @@ -26,8 +26,8 @@ MASK_UNITS=( # What masking cost was everything that needs a .device unit to exist. # # * serial-getty@ttyS0 carries BindsTo=dev-%i.device and could not start. - # * A hot-plugged CPU or memory block never produced an add event, so nothing could - # act on one — see 40-spin-hotadd.rules, which is the thing that acts on it. + # * A hot-plugged CPU never produced an add event, so nothing could act on one — + # see 40-spin-hotadd.rules, which is the thing that acts on it. # Time sync - handled by host systemd-timesyncd.service diff --git a/image/mkosi.extra/usr/local/lib/spin-base/rootfs/etc/udev/rules.d/40-spin-hotadd.rules b/image/mkosi.extra/usr/local/lib/spin-base/rootfs/etc/udev/rules.d/40-spin-hotadd.rules index 3d1de4e..cb35d0e 100644 --- a/image/mkosi.extra/usr/local/lib/spin-base/rootfs/etc/udev/rules.d/40-spin-hotadd.rules +++ b/image/mkosi.extra/usr/local/lib/spin-base/rootfs/etc/udev/rules.d/40-spin-hotadd.rules @@ -1,4 +1,4 @@ -# Bring a hot-plugged CPU or memory block online, on this machine. +# Bring a hot-plugged CPU online, on this machine. # # The distribution ships a rule for exactly this, 40-vm-hotadd.rules, and it does nothing # here: it opens by checking the DMI vendor for Microsoft Hyper-V or Xen and jumps past @@ -15,9 +15,9 @@ # reach into the guest over RPC to online each core it just attached, which is a second # mechanism doing what the guest's own event handling does, and one that stops being # reachable the moment the guest's init hands over to something else. +# +# Memory has no rule: the kernel onlines each block itself, because memhp_default_state=online +# is always on the command line (machine/cmdline.go). The block's add uevent leaves before the +# kernel onlines it, so a rule here reads it offline, writes after the kernel has, and udevd +# logs EINVAL for every block a workspace grows by. SUBSYSTEM=="cpu", ACTION=="add", DEVPATH=="/devices/system/cpu/cpu[0-9]*", TEST=="online", ATTR{online}!="1", ATTR{online}="1" - -# Memory arrives through virtio-mem rather than as ACPI DIMMs, and the kernel command line -# already carries memhp_default_state=online — so this is the belt to that braces: a block -# the kernel did not online for itself still gets onlined here. -SUBSYSTEM=="memory", ACTION=="add", DEVPATH=="/devices/system/memory/memory[0-9]*", TEST=="state", ATTR{state}!="online", ATTR{state}="online"