Skip to content

systemd-oomd: user@<uid>.service is permanently dropped from the monitored set after systemctl --user daemon-reload #43174

Open

Description

@AdamClaassens

Summary

systemd-oomd permanently stops monitoring user@<uid>.service after a
systemctl --user daemon-reload is issued in that user's manager. The cgroup is
silently removed from oomd's monitored set and is never re-registered, even though
the unit keeps running with ManagedOOMMemoryPressure=kill set throughout.

Only cgroups reported by PID 1 are affected. Cgroups reported by the user
manager (e.g. transient app-*.scope units) survive the reload and continue to
register normally afterwards, which makes the loss easy to miss — oomctl still
shows entries and the service still reports Dry Run: no.

Reproduced on systemd 261 (Arch, vanilla) and systemd 259 (Ubuntu 26.04).

Steps to reproduce

Requires ManagedOOMMemoryPressure=kill on [email protected]. Ubuntu ships this by
default in /usr/lib/systemd/system/[email protected]/10-oomd-user-service-defaults.conf;
on other distributions add it manually:

# /etc/systemd/system/[email protected]/10-oomd.conf
[Service]
ManagedOOMMemoryPressure=kill
ManagedOOMMemoryPressureLimit=50%

Then:

# systemctl daemon-reload
# systemctl enable --now systemd-oomd
# useradd -m testu && loginctl enable-linger testu
# sleep 15

# oomctl | grep -A1 'Monitored CGroups'
Memory Pressure Monitored CGroups:
	Path: /user.slice/user-1000.slice/[email protected]

# runuser -u testu -- env XDG_RUNTIME_DIR=/run/user/1000 systemctl --user daemon-reload

# oomctl | grep -A1 'Monitored CGroups'
Memory Pressure Monitored CGroups:

The entry does not return. Re-checked at +5 s, +15 s and +30 s; still absent after
16 minutes on a physical host. systemctl restart systemd-oomd re-registers it
immediately, until the next --user daemon-reload.

Expected behaviour

systemd-oomd.service(8) states that oomd "retrieves information about such units
from systemd(1) when it starts and watches for subsequent changes". A unit that is
running continuously with ManagedOOMMemoryPressure=kill should remain monitored
across an unrelated reload of a user manager.

Actual behaviour

The registration is dropped and never restored.

Environment

Reproduced in a clean-room VM on current upstream:

systemd 261 (261.1-1-arch)
Arch Linux, kernel 7.1.3-arch1-3
cgroup2fs, /proc/pressure/memory present

Verbatim console output from that run:

STEP 1 -- BASELINE (before any user daemon-reload)
Memory Pressure Monitored CGroups:
	Path: /user.slice/user-1000.slice/[email protected]
		Memory Pressure Limit: 50.00%
		Memory Pressure Duration: 30s
>>> [email protected] monitored: 1   total paths: 1

STEP 2 -- TRIGGER: systemctl --user daemon-reload
  reload issued OK
  +5s   user@1000 monitored: 0   total: 0
  +15s  user@1000 monitored: 0   total: 0
  +30s  user@1000 monitored: 0   total: 0

RESULT
  before reload : 1
  after  reload : 0

Also reproduced on:

systemd 259 (259.5-0ubuntu3)
Ubuntu 26.04 LTS, kernel 7.0.0-28-generic
SDDM, loginctl Linger=yes

On that host the unit demonstrably never restarted across the loss:

$ systemctl show [email protected] -p ActiveEnterTimestamp -p NRestarts -p SubState
ActiveEnterTimestamp=Mon 2026-07-27 06:49:51 SAST
NRestarts=0
SubState=running

$ systemctl show [email protected] -p ManagedOOMMemoryPressure
ManagedOOMMemoryPressure=kill

Impact

On a desktop this is triggered by ordinary graphical login: the user manager issues a
daemon-reload shortly after session start. On the Ubuntu host above, [email protected]
was registered ~60 s after boot and lost at login, roughly four minutes later.

The failure is silent and the guardrail looks healthy afterwards:

  • systemctl is-active systemd-oomd → active
  • org.freedesktop.oom1 owned on the bus
  • oomctl reports Dry Run: no and still lists app-*.scope entries

Because user services default to ManagedOOMMemoryPressure=auto (observe-only) and
are eligible for kill only as descendants of a monitored ancestor, losing
user@<uid>.service means a runaway user service is unprotected. Any user-unit
installation that triggers a --user daemon-reload re-breaks it mid-session.

Ruled out

  • systemd-oomd.socket fails on new user session without pressure support  #27690 (systemd-oomd.socket trigger-limit loop when /proc/pressure/memory is
    missing) — no Trigger limit hit messages; socket healthy; memory.pressure present
    on the user slice in both environments.
  • oomd fails during pid1 daemon-reexec #20330 (oomd loses its varlink connection to PID 1 on daemon-reexec) — closed
    for v252; no varlink errors logged in either environment; the trigger here is a
    user manager reload, not a PID 1 re-exec.
  • Strange oomd behavior with user services #21684 (oomd kills the wrong user service) — different failure mode.
  • Start ordering — on the Ubuntu host oomd started at 06:49:42 and
    [email protected] at 06:49:51, i.e. oomd was already running, and registration
    demonstrably succeeded before being lost.
  • oomd replacing rather than merging its set — tested directly: starting an
    additional user unit with ManagedOOMMemoryPressure=kill added to the monitored
    set (4 → 5 paths) with [email protected] still present. Merging works; only
    daemon-reload triggers the loss.

Additional notes

No varlink or ManagedOOM errors appear in the journal at any point, on either system.

In the VM the monitored set drops to zero paths, since no app-*.scope units exist.
On a desktop those scopes remain and mask the loss, which is likely why this is not
more widely reported.

Activity

  1. added
    bug 🐛
    on Aug 11, 2026
  2. WingedGuardian commented on Nov 3, 2026

    @WingedGuardian

    Reproduced on systemd 255 (Ubuntu 24.04 packaging), and I think the cause is a path collision between two reporters rather than anything specific to the reload itself.

    The user manager's root slice, -.slice, has as its cgroup path the cgroup of user@<uid>.service itself (systemctl --user show -p ControlGroup -- -.slice prints /user.slice/user-<uid>.slice/user@<uid>.service). So two managers report on the same cgroup path:

    • PID 1 reports user@<uid>.service with ManagedOOMMemoryPressure=kill (from the vendor drop-in).
    • The user manager reports its own -.slice, whose mode is the default auto.

    On systemctl --user daemon-reload, the user manager re-loads its units. After deserialization -.slice goes through a state change to active, and unit_notify() calls manager_varlink_send_managed_oom_update() for it unconditionally on that transition (src/core/unit.c, the "indiscriminately send an update" block). That sends {"mode":"auto","path":"/user.slice/user-<uid>.slice/user@<uid>.service","property":"ManagedOOMMemoryPressure"} over io.systemd.oom.ReportManagedOOMCGroups.

    In process_managed_oom_message() (src/oom/oomd-manager.c) the owner check passes, because the sender uid owns that cgroup. Then mode == MANAGED_OOM_AUTO removes the entry for that path from monitored_mem_pressure_cgroup_contexts, and that entry is the one PID 1 registered. Nothing re-sends PID 1's entry until user@<uid>.service itself changes state or oomd re-subscribes, which matches the report: it comes back on systemctl restart systemd-oomd and nowhere else.

    Two consequences that fit the observations above:

    • Cgroups the user manager reports for its own child units are unaffected, because their paths differ from the user@ path.
    • The bug is invisible in oomctl output except as a missing line.

    A workaround that holds across user reloads, confirmed with oomctl after repeated systemctl --user daemon-reload: give the user manager's root slice the same policy, so its own report says kill for that path:

    # ~/.config/systemd/user/-.slice.d/oomd.conf
    [Slice]
    ManagedOOMMemoryPressure=kill
    ManagedOOMMemoryPressureLimit=50%

    Keep the limit equal to the one on [email protected]: both reports target one path, and the last message received sets the limit.

    Possible fixes: have the user manager skip ManagedOOM reports for its root slice (its cgroup belongs to the unit PID 1 manages), or have oomd key entries by reporter as well as path, so that one reporter's auto cannot remove another reporter's kill.

  3. partymola commented on Nov 25, 2026

    @partymola

    Same here on 262.2 (Arch, 262.2-1-arch). On Arch it is also set off by package upgrades: the pacman hook 30-systemd-daemon-reload-user.hook runs systemctl reload 'user@*.service' after any transaction that touches usr/lib/systemd/user/*, and the session then stays out of oomd until [email protected] restarts.

    The -.slice workaround from the comment above works for me system-wide in /etc/systemd/user/-.slice.d/. With it, [email protected] stays listed in oomctl after systemctl reload 'user@*.service'.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug 🐛oomd

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions