systemd-oomd & PSI Pressure Tuning Prompt
Configure systemd-oomd and Pressure Stall Information (PSI) to kill the right cgroup under memory or I/O pressure before the kernel OOM killer fires arbitrarily.
- Target user
- Linux admins who want graceful, policy-driven OOM handling instead of random kernel kills
- Difficulty
- Intermediate
- Tools
- Claude, ChatGPT
The prompt
You are a Linux reliability engineer who has replaced unpredictable kernel OOM kills with deterministic, cgroup-aware reclaim policy using systemd-oomd and PSI. You tune thresholds with data, not guesses, and you know oomd acts on cgroups — not on individual runaway processes inside a shared slice. I will provide: - Distro and systemd version, and confirmation of cgroup v2 (`stat -fc %T /sys/fs/cgroup` → cgroup2fs) - The slice/service layout (which workloads live in which slices) - The symptom: random kernel OOM kills, the wrong process getting killed, swap thrash, or latency spikes under load - Current `oomd.conf` / drop-ins and any `ManagedOOM*` settings - PSI samples: `cat /proc/pressure/memory` and `/proc/pressure/io` during the event, if captured Your job: 1. **Confirm the mechanism** — verify PSI is enabled (`psi=1` or kernel default), cgroup v2 unified hierarchy, and that systemd-oomd is running and seeing your slices. 2. **Explain PSI** — interpret `some` vs `full`, the avg10/avg60/avg300 windows, and how to pick a meaningful pressure %; distinguish memory pressure from I/O pressure (reclaim thrash often shows as I/O `full`). 3. **Design the policy** — set `ManagedOOMMemoryPressure=kill` and `ManagedOOMMemoryPressureLimit` on the slices you want oomd to police, plus `ManagedOOMSwap=kill`; explain `DefaultMemoryPressureDurationSec`. 4. **Pick targets correctly** — oomd kills a whole cgroup based on pressure + swap; structure slices so the killable unit is the right blast radius, and protect critical units (`ManagedOOMPreference=avoid`/`omit`). 5. **Tune thresholds** — derive memory-pressure-limit and duration from the captured PSI samples so oomd fires before the kernel does, but not on benign spikes. 6. **Validate** — induce controlled pressure (stress-ng), confirm oomd logs the intended kill, and that critical services survive. Output as: (a) the slice/drop-in config with each setting justified, (b) the PSI interpretation for the provided samples, (c) recommended thresholds with rationale, (d) the validation procedure, (e) a rollback. Anti-patterns to avoid: tuning oomd without cgroup v2, setting pressure limits so low oomd kills on every spike, expecting oomd to target a single PID, leaving critical units killable, ignoring I/O pressure when the real problem is reclaim thrash.
Run this prompt with AI
Test it, get an AI-improved version, or compare models — live in the Prompt Workspace. No copy-paste.
Related prompts
-
Linux OOM Kill & Memory Pressure Investigation Prompt
Diagnose OOM kills, memory pressure, swap thrashing, slab bloat, and cgroup memory limit failures on Linux servers from dmesg OOM banners and /proc data.
-
Linux KSM / ksmtuned Memory Dedup Tuning Prompt
Decide whether Kernel Samepage Merging (KSM) helps your VM or container density workload, tune ksmtuned aggressiveness against CPU cost, and weigh the security and latency trade-offs before enabling it in production.
-
Linux Swap Sizing & Capacity Planning Prompt
Decide how much swap a server needs and whether to use a swap file, partition, or zswap, based on RAM, workload, and hibernation needs, without inviting thrash or surprise OOM kills.
-
Linux CPU & Memory Hotplug Management Prompt
Safely online, offline, and troubleshoot CPU and memory hotplug on physical and virtual hosts — VM right-sizing, isolating a flaky core, balloon/memory-block operations, and the sysfs interfaces that make it deterministic.
More Linux Admins prompts & error guides
Browse every Linux Admins prompt and troubleshooting guide in one place.
Reading prompts? Get all 500 in one free PDF
500 battle-tested, copy-paste AI prompts engineered by a senior systems engineer — every one with fill-in placeholders and safety/back-out notes. Drop your email and it's yours.
- 500 prompts: Linux · Kubernetes · Terraform · OpenStack · GitLab · Docker · Monitoring · Incident Response
- Instant PDF download — yours free, forever
- Plus one practical AI-workflow email a week (no spam)
Single opt-in · unsubscribe anytime · no spam.