跳到主要內容

發表文章

目前顯示的是有「AI系統」標籤的文章

Linux OOM Killer 不只看 RAM 用量:從 oom_score_adj 到 cgroup 邊界的排查路徑 / Linux OOM Killer: Beyond RAM Usage

現象: 服務明明還有一些可用記憶體,Linux 卻突然結束程序,甚至讓容器內的 AI 推論中斷。這不一定是整台機器的 RAM 用光;配置範圍、swap、memcg 限制與保護分數都可能讓核心進入 OOM 路徑。 Phenomenon: Linux may terminate a process even when the machine appears to have free memory. The trigger can be a cgroup, NUMA policy, swap, or allocation scope—not only total RAM. Linux OOM decision path allocation cannot reclaim enough scope: system / memcg / NUMA score memory + oom_score_adj kill selected task; continue 圖 1|Linux OOM killer 的簡化決策路徑:先確認耗盡範圍,再以記憶體用量與 oom_score_adj 評分。 Figure 1 | Simplified Linux OOM-killer path: identify the exhausted scope, then score candidates using memory usage and oom_score_adj. 機制:OOM 先看耗盡範圍,再挑候選者 / Mechanism: scope first, victim second 核心在無法透過 reclaim 或 compaction 滿足配置時,才會進入 OOM killer。 mm/oom_kill.c 的 oom_badness() 依候選程序記憶體用量與 oom_score_adj 計算分數; -1000 代表強力保護。允許使用的記憶體集合取決於當次 OOM 上下文,因此 memcg OOM 不等同於整機 OOM。 The kernel enters the OOM path only after reclaim and compaction cannot satisfy the allocation. In mm/oom_kill.c , oom_badness() ...