From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from atuin.qyliss.net (localhost [IPv6:::1]) by atuin.qyliss.net (Postfix) with ESMTP id BB4A8A253; Sun, 30 Aug 2026 06:45:05 +0000 (UTC) Received: by atuin.qyliss.net (Postfix, from userid 993) id 9BCCFA241; Sun, 30 Aug 2026 06:45:03 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on atuin.qyliss.net X-Spam-Level: X-Spam-Status: No, score=-0.1 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DMARC_PASS,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=4.0.1 Received: from mail-yw1-x112b.google.com (mail-yw1-x112b.google.com [IPv6:2607:f8b0:4864:20::112b]) by atuin.qyliss.net (Postfix) with ESMTPS id 9E94EA240 for ; Sun, 30 Aug 2026 06:45:01 +0000 (UTC) Received: by mail-yw1-x112b.google.com with SMTP id 00721157ae682-8549a96e93cso13322467b3.3 for ; Sat, 29 Aug 2026 23:45:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1788072300; x=1788677100; darn=spectrum-os.org; h=cc:to:references:in-reply-to:content-transfer-encoding:content-type :mime-version:message-id:date:subject:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=U9Vpp5Y0kRTWcytVNFLsXjpbz8zyhX4/y52tUx459q8=; b=rnjnbaTtP4B8tOc77BMLjS8GKk1ICIp40N5qsCf1pMPCx/P9SDPCX1MnwekR+d13Oq V4undDJp4yFiMyK0d2bCIyroT1c3QVys8C5kuEbgCbJMjRcNYJ00rclGDJ47RDrc1+6p SvxpCo718LiNGzSaj0Xyh6Fktw+NFQoekAq5AB3hfnj/QdPN3SaIa3grx7Domwd+oac9 TDVGhunVymwV+V/D1mA25OcilHu/rqmLUx4hcrn5Dv5W6n59tHOxH6zJCI89SM83xIOF 5bDWecE6VUTsrkxT/1yvJKJJW7SDv2Qu5iK3m6/cozWomMVsFn7ysBKKG0XKtP8t6xN8 iV9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788072300; x=1788677100; h=cc:to:references:in-reply-to:content-transfer-encoding:content-type :mime-version:message-id:date:subject:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=U9Vpp5Y0kRTWcytVNFLsXjpbz8zyhX4/y52tUx459q8=; b=mLqDE4lTBMeMV6jGJJPIF6AkIu0fzUJGs0vzMefJYbw05WbC65Ag4KNgUAKUMF7elv ZqbJnHCqe7Nl5/oBOo63cRp0OsaBGKKCY5B6nv2ns1r9AO7+J5jgAm4IpBTMZE5B4taQ DWozaDSUF1/L5kQ6ijpi6Nhl7szdAjpqy4spPfFFYyaCOsBdvq/VBxZsZ7TJ8hL6WDef 7DwiHLQDzNsKnT/Qdp9YhXRCEAOgf0MfZoZK8iSj0DgYuJdJIewPxsOfCKm/xkJfMLYH fUG67nsxmWwP/gEGNt05saA8JT9EuPUkigr6uKr2oibo/jDGhiUYp773a4qGqQBaW3zW 6j8Q== X-Gm-Message-State: AFuF++njhSNEok0tYBCOon1akxX8/Vi7tqbQQ+zXsJoicVloomXLURtS YwkihDYY+x3DcqqG7QRcdR9u6As1XRrn18rujjVELUooaA9UdpjAMTZNZhjNdg== X-Gm-Gg: AYBFou16wyx9w5Bs3E5+xpb7pJcqPa01KXvNtfsnP62crm8jF0AVXGOHzKn7iDquCwT FFF2FTyhLh3lY6AdLXGzKVmEF9DbI2ZCgKWOPJ7fJM3gMT9FjbCYgl+JmMRT2yGz2b+0gx+Rprr GwPx5NMqxcpDcd6TL1CRUBKC+qgM7bi4l3zeadNKOaMHJuExr0rvoKCiJKgER1yptMGtZuA6/mk oeT+RhTpHw04k9cw3yqEfXti9bIUVEgrZq1LejOqw4FAnSiQiTJuiDwX5uR5gE3eVq9A+4w0mIg 5ZXC8/7wLXEgYx7UAxwINvm0n2K6Dk/Rgvw5XJ53AQLHGVOQAkb/9f6POnY2S+lAChOeWdZKP2H 2Zv8e5mUMMIqET44rwyES8QB6XBEaWS+yXc1oBaPdr2jgCAU4IfYk3hvbNMN084eAzqEYaz/tc0 aMdr/0lV31mwAwvzlsVc9W2NVM+kqGIkZBIGVYBYSePOPoqKNqdP9hl16YgnEyY+0PVy4DeQ5DY Q== X-Received: by 2002:a05:690e:bc8:b0:66c:4ce5:834 with SMTP id 956f58d0204a3-66e4c4d18cemr5139945d50.0.1788072300038; Sat, 29 Aug 2026 23:45:00 -0700 (PDT) Received: from localhost.localdomain ([185.98.168.14]) by smtp.gmail.com with UTF8SMTPSA id 956f58d0204a3-66e4ed15430sm3592326d50.15.2026.08.29.23.44.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 29 Aug 2026 23:44:58 -0700 (PDT) From: Demi Marie Obenour Subject: [PATCH v8 00/18] Control group support Date: Sun, 30 Aug 2026 02:06:34 -0400 Message-Id: <20260830-cgroups-v8-0-239b09ba7013@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-B4-Tracking: v=1; b=H4sIAAAAAAAC/3XOTWrDMBAF4KsErasyGv2mq96jdCHJI0eliYOVm Jbgu1dOoBYuXYkH73ujGys0ZirsZXdjI0255OFUg3vasXjwp5547mpmCGhAo+OxH4frufDOwJ7 QAhm1Z7V9Hinlr/vS2/sjl2v4oHhZ+NI45HIZxu/7qUksvceqQfhdnQQXHEj7kKQWIMJrf/T58 zkOR7asTviPw+pi9ISogolOb51cnRVidbI6HYM3wiPUd+tU47BxigNXJiDplJINZut042TjdHV Bog4+7jup0taZ1TnQqzPVgTMREkDS+o+zjWv/aauzSTgLHXWUYuvmef4B9h9irAACAAA= X-Change-ID: 20260528-cgroups-d609e270e649 In-Reply-To: <20260821-cgroups-v7-0-7f1870dedefc@gmail.com> References: <20260821-cgroups-v7-0-7f1870dedefc@gmail.com> To: Spectrum OS Development X-Mailer: b4 0.15.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1788069995; l=7681; i=demiobenour@gmail.com; s=20250729; h=from:subject:message-id; bh=ps0twextSt/bHRBVrZxzTuk+vl/YJJZCNrwV8sKmoi8=; b=8aq6DUIoot0z0rRbRC2UEc54M63txUDYyFHPSC+cBMvhOhzeNNbl7qJuU7msRFMZVC30Exaep gyEsN/MghikBdSgniOhS7yhpIlfAk+uOTwQOcJMDmX0ENDKsa5xXGho X-Developer-Key: i=demiobenour@gmail.com; a=ed25519; pk=X57Q4/YQDj9t4SBeKaDwvXYKB6quZJVx/DE2Ly2out0= Message-ID-Hash: KQLAJFHFH546G7ETY2W5SYRE3FLWPR3L X-Message-ID-Hash: KQLAJFHFH546G7ETY2W5SYRE3FLWPR3L X-MailFrom: demiobenour@gmail.com X-Mailman-Rule-Hits: member-moderation X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; header-match-devel.spectrum-os.org-0; header-match-devel.spectrum-os.org-1; header-match-devel.spectrum-os.org-2; header-match-devel.spectrum-os.org-3; header-match-devel.spectrum-os.org-4; emergency CC: Demi Marie Obenour , Alyssa Ross , Valentin Gagarin X-Mailman-Version: 3.3.10 Precedence: list List-Id: Patches and low-level development discussion Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Signed-off-by: Demi Marie Obenour --- Changes in v8: - Improve naming. - Do not auto-enable controllers. - Remove assertions that paths are well-formed. - Inline check_path into its caller. - Link to v7: https://spectrum-os.org/lists/archives/spectrum-devel/20260821-cgroups-v7-0-7f1870dedefc@gmail.com Changes in v7: - Reformat comments to 83 columns.EDITME: describe what is new in this series revision. - Fix error messages to not use "make" to refer to cgroup creation. - Unconditionally enable delegation of controllers to sub-cgroups by writing to cgroup.subtree_control. - Unconditionally set the user.delegate xattr to 1. - Link to v6: https://spectrum-os.org/lists/archives/spectrum-devel/20260805-cgroups-v6-0-086c0f00f55f@gmail.com Changes in v6: - Simplify command-line argument parsing. - Place SPDX-FileCopyrightText before SPDX-License-Identifier, except in patches that already have Reviewed-by tags. - Clean up cgroup-setup. - Make openat2_simple() take an enum instead of a flags argument. - Use recursive function to remove directories. The standard library remove_dir_all() function is recursive, and the complexity of being more robust than the standard library is not worth it here. Spectrum does not allow code running as non-root to create cgroups, so there is no security concern. - Link to v5: https://spectrum-os.org/lists/archives/spectrum-devel/20260731-cgroups-v5-0-b325bac9d34f@gmail.com Changes in v5: - Rename open_subtree_raw() to open_beneath(). - Use consistent file modes. - Avoid using O_NOFOLLOW when RESOLVE_NO_SYMLINKS is also used. - Drop tracking of specific cgroup paths (at the cost of worse error messages). - Have functions take &dyn AsFd where that makes sense. - Drop exclusive vs shared lock tracking. - Remove vm-service-run wrapper script. - Use explicit cgroup names in VM service run and finish scripts. - Use sed to write to cgroup.subtree_control in the root cgroup, avoiding a special case in cgroup-setup. - Avoid mutating the Cgroup struct when creating child cgroups. - Avoid mutating the Cgroup struct when purging cgroups. - Improve documentation. - Drop cgroup-s6-finish and call cgroup-purge directly. - Remove support for operating on . or / in cgroup-setup. - Fix comments. - Link to v4: https://spectrum-os.org/lists/archives/spectrum-devel/20260721-cgroups-v4-0-46b2e5fff7b6@gmail.com Changes in v4: - Implement proper locking to make concurrent operations safe. - Purge VMM cgroup in vmm service finish script. - Delete /run/vsock/${VM}/vsock before running Cloud Hypervisor. - Massively refactor cgroup-setup tool. - Link to v3: https://spectrum-os.org/lists/archives/spectrum-devel/20260711-cgroups-v3-1-5cba61a20cba@gmail.com Changes in v3: - Remove the implicit .service suffix on leaf control groups. - Make cgroup-setup acts as an s6 finish script when called as "finish". - Put the VMMs in the same cgroups as the per-VM services. - Add common helper script for the per-VM services. - Significantly refactor the Rust code. - Link to v2: https://spectrum-os.org/lists/archives/spectrum-devel/20260620-cgroups-v2-1-ccae224b6c85@gmail.com Changes in v2: - Omit resource control support. It was completely broken, and the way Spectrum run scripts work means that it is better to setup resource controls just before the execve() into the final service process. This will be done by a separate tool. - Link to v1: https://spectrum-os.org/lists/archives/spectrum-devel/20260620-cgroups-v1-1-0e5abf35101b@gmail.com --- Demi Marie Obenour (18): host/rootfs: Mount filesystems before s6-rc-init tools: Add control group manager Documentation: Mention control groups Mount cgroup2 filesystem at /sys/fs/cgroup host/rootfs: Add comments where cgroups are intentionally not used host/rootfs: serial-getty-generator: Use cgroups host/rootfs: systemd-udevd: Run in cgroup host/rootfs: weston: Run in cgroup host/rootfs: Set up parent cgroup for all per-VM services host/rootfs: Create per-VM cgroup for all of the VM's services host/rootfs: run-vmm: Create per-VM cgroup host/rootfs: run-appimage: Purge the per-VM cgroup host/rootfs: run-flatpak: Purge the per-VM cgroup host/rootfs: dbus: Run in cgroup host/rootfs: vhost-user-fs: Run in cgroup host/rootfs: vhost-user-gpu: Run in cgroup host/rootfs: xdg-desktop-portal-spectrum-host: Run in cgroup host/rootfs: spectrum-router: Run in cgroup .codespellrc | 2 +- Documentation/doc/development/control-groups.adoc | 108 +++++++++ host/rootfs/default.nix | 6 +- host/rootfs/file-list.mk | 10 + host/rootfs/image/etc/fstab | 1 + host/rootfs/image/etc/init | 11 +- .../s6-linux-init/run-image/service/getty-tty2/run | 1 + .../s6-linux-init/run-image/service/getty-tty3/run | 1 + .../s6-linux-init/run-image/service/getty-tty4/run | 1 + .../run-image/service/root-terminal/run | 1 + .../run-image/service/s6-linux-init-shutdownd/run | 1 + .../run-image/service/s6-svscan-log/run | 1 + .../service/serial-getty-generator/finish | 5 + .../run-image/service/serial-getty-generator/run | 4 +- .../run-image/service/serial-getty/run | 1 + .../run-image/service/serial-getty/template/run | 1 + .../run-image/service/vm-services/run | 3 + .../vm-services/template/data/service/dbus/finish | 5 + .../vm-services/template/data/service/dbus/run | 2 + .../template/data/service/spectrum-router/finish | 5 + .../template/data/service/spectrum-router/run | 2 + .../template/data/service/vhost-user-fs/finish | 5 + .../template/data/service/vhost-user-fs/run | 2 + .../template/data/service/vhost-user-gpu/finish | 5 + .../template/data/service/vhost-user-gpu/run | 2 + .../xdg-desktop-portal-spectrum-host/finish | 5 + .../service/xdg-desktop-portal-spectrum-host/run | 2 + .../run-image/service/vm-services/template/finish | 5 + .../run-image/service/vm-services/template/run | 4 + .../run-image/service/vmm/template/finish | 5 + .../rootfs/image/etc/s6-linux-init/scripts/rc.init | 7 - host/rootfs/image/etc/s6-rc/systemd-udevd/finish | 5 + host/rootfs/image/etc/s6-rc/systemd-udevd/run | 5 +- host/rootfs/image/etc/s6-rc/weston/finish | 5 + host/rootfs/image/etc/s6-rc/weston/run | 4 + host/rootfs/image/usr/bin/run-appimage | 7 +- host/rootfs/image/usr/bin/run-flatpak | 7 +- host/rootfs/image/usr/bin/run-vmm | 4 + host/rootfs/image/usr/bin/vm-stop | 5 +- pkgs/default.nix | 1 + tools/cgroup-setup/Cargo.lock | 67 ++++++ tools/cgroup-setup/Cargo.lock.license | 2 + tools/cgroup-setup/Cargo.toml | 10 + tools/cgroup-setup/default.nix | 22 ++ tools/cgroup-setup/src/cgroup.rs | 253 +++++++++++++++++++++ tools/cgroup-setup/src/main.rs | 144 ++++++++++++ 46 files changed, 736 insertions(+), 19 deletions(-) --- base-commit: 77d2389874bb092b8dbf05ecc5b1030372e80e98 change-id: 20260528-cgroups-d609e270e649 -- Sincerely, Demi Marie Obenour (she/her/hers)