現象:為什麼還沒 OOM 就開始卡? / Symptom: Why does Linux stall before OOM? 你是否遇過這種情況:記憶體還有剩、CPU 也沒有 100%,但 SSH 變慢、服務延遲突然拉高,甚至工作負載尚未被 OOM Killer 終止就已經「像死機」?這不是單看使用率就能回答的問題。Linux Pressure Stall Information(PSI)量的是工作真的因資源不足而等待了多久,讓「還能跑」與「已經在浪費時間」分開。 Have you seen a Linux host become sluggish while memory is still available and CPU is below 100%? PSI addresses the missing signal: not how full a resource looks, but how long runnable work is actually delayed by contention. A machine can be operational and already wasting latency before the OOM killer appears. PSI 的核心不是額外的效能計數器,而是把資源競爭轉成「停滯時間」。核心分別在 /proc/pressure/cpu、memory、io 匯出資料;some 表示至少一部分工作正在等待,full 則表示所有非閒置工作同時卡住。memory full 或 io full 長時間上升,比單獨看到 free 變少更接近「系統正在失去生產力」的現象。 PSI turns contention into stall time. The kernel exports cpu, memory, and io pressure files under /proc/pressure. “some” means at least some work is stalled; “full” means all non-idle work is stalled at once. A sustained memory-full or io-full signal is often more actionable tha...
【Linux 排程機制】從 CFS 到 EEVDF:虛擬截止時間如何給 Linux 排程帶來延遲保證 / [Linux Scheduling] From CFS to EEVDF: How Earliest Eligible Virtual Deadline First Brings Latency Guarantees to Linux
你有沒有遇過這種情況:開著幾個重度應用,滑鼠游標明明沒動,系統卻突然停頓半秒,播放的影片掉幀、遊戲瞬間卡住?這往往不是記憶體不足,而是「排程延遲」——核心決定哪個進程下次使用 CPU 的時間點,沒有給即時工作負載足夠的保證。舊版 Linux 預設排程器 CFS(完全公平排程)追求整體公平,但對「這個任務必須在多久內執行」的延遲上限,缺乏明確承諾。 Have you ever experienced this: several heavy applications running, the mouse cursor sits still, yet the system suddenly freezes for half a second, video stutters, or a game hitches? This is often not memory exhaustion, but "scheduling latency" — the kernel's decision of which process gets the CPU next fails to guarantee timing for latency-sensitive workloads. The default Linux scheduler CFS (Completely Fair Scheduler) pursues overall fairness, but lacks a clear upper-bound commitment on "this task must run within how long." struct sched_entity (排程實體) Linux 6.18.55 · kernel/sched/fair.c · include/linux/sched.h EEVDF 決策欄位 load struct load_weight — 加權負載,決定分攤時間比例 run_node struct rb_node — 掛在 CFS 紅黑樹 tasks_timeline 上的節點 vrun...