PSI auto-decision loop (voltron-psid)

Per-node load gossip and the PSI auto-decision loop.

Implements the **auto** migration mode: when an eligible cgroup's pressure crosses its threshold, Voltron decides to migrate it to a less-loaded node.

Per the project's design, the decision loop runs in userspace (keeps the kernel module small) and uses the kernel's native PSI trigger mechanism (poll(POLLPRI) on a cgroup pressure file). Decisions are delivered back to the kernel for the migration engine to execute.

 cgroup under pressure
        │  (PSI trigger fires)
        ▼
 voltron-psid ── reads policy ──▶ /sys/kernel/voltron/policy/cgroups/<id>/{mode,psi_*}
        │     ── reads nodes  ──▶ /sys/kernel/voltron/cluster/nodes/*/{state,fs_eligible}
        │     ── picks target node (eligible, round-robin for now)
        ▼
 writes decision ──▶ /sys/kernel/voltron/decisions/request  "<cgroup_id> <node_id>"
                          │
                          ▼  (future) migration engine: CRIU + agent + RDMA

1What the daemon does

  1. Scans /sys/kernel/voltron/policy/cgroups/<id>/ for entries with mode=auto, reading psi_metric, psi_threshold (permille), and min_residency_ms.
  2. Builds a cgroup-id → cgroupfs-path index by walking /sys/fs/cgroup (cgroup-v2 id == directory inode).
  3. Arms a PSI trigger on the matching pressure file:
    • psi_metric -> file/line: cpu→cpu.pressure some, memory→memory.pressure some, io→io.pressure some, full→memory.pressure full.
    • threshold -> stall: stall_us = psi_threshold/1000 * window_us (e.g. 400 over a 1s window = "stalled >= 400 ms per second").
  4. poll(POLLPRI)s all triggers. On a fire, enforces min_residency_ms (anti-thrash), picks an eligible target node, and writes the decision to /sys/kernel/voltron/decisions/request.
  5. Re-scans policy + nodes every --rescan-sec (default 5s), arming/closing triggers as cgroups and policy change. Vanished cgroups are swept (trigger POLLERR).

2Kernel side: /sys/kernel/voltron/decisions/

FileModeMeaning
requestw"<cgroup_id> <node_id>" — record a migration decision
logrrecent decisions (oldest first): ts=… cgroup=… node=…
countrtotal decisions recorded since load

This is the integration point the migration engine (CRIU + agent over RDMA) will consume; today decisions are logged (dmesg + decisions/log) for observability.

3Build & run

cd userspace/voltron-psid && make      # -> voltron-psid
sudo ./voltron-psid --local-id 1       # defaults: /sys/kernel/voltron, /sys/fs/cgroup
#   --window-ms N    PSI window (default 1000)
#   --rescan-sec N   policy/node rescan (default 5)
#   --dry-run        log decisions instead of writing them

Mark a cgroup auto (via either policy surface):

CGID=$(stat -c %i /sys/fs/cgroup/compute.slice)
echo "$CGID" | sudo tee /sys/kernel/voltron/policy/add_cgroup
echo auto | sudo tee /sys/kernel/voltron/policy/cgroups/$CGID/mode
echo cpu  | sudo tee /sys/kernel/voltron/policy/cgroups/$CGID/psi_metric
echo 400  | sudo tee /sys/kernel/voltron/policy/cgroups/$CGID/psi_threshold
# or, with the cgroup-fs livepatch loaded:
echo "mode auto"         | sudo tee /sys/fs/cgroup/compute.slice/voltron.policy
echo "psi_threshold 400" | sudo tee /sys/fs/cgroup/compute.slice/voltron.policy

Watch decisions:

cat /sys/kernel/voltron/decisions/log

4Notes & limits