[英]Could anyone explain about oom_badness() score in OOM killer?
/*
* If any of p's children has a different mm and is eligible for kill,
* the one with the highest oom_badness() score is sacrificed for its
* parent. This attempts to lose the minimal amount of work done while
* still freeing memory.
*/
我認為源代碼中的注釋已經很好地解釋了它:
/**
* oom_badness - heuristic function to determine which candidate task to kill
* @p: task struct of which task we should calculate
* @totalpages: total present RAM allowed for page allocation
*
* The heuristic for determining which task to kill is made to be as simple and
* predictable as possible. The goal is to return the highest value for the
* task consuming the most memory to avoid subsequent oom failures.
*/
oom_badness()
函數由out_of_memory()
間接調用,該函數負責處理嚴重的內存不足狀態。 當out_of_memory()
被調用時(例如被頁面分配器或頁面錯誤處理程序),它遍歷所有任務以確定它們的“壞處”,並且具有最高值的任務被強行殺死(實際的調用鏈是select_bad_process()
→oom_evaluate_task()
→ oom_badness()
)。
任務的“劣勢”取決於多種因素:
在較舊的內核版本中, oom_badness()
函數曾經更復雜,例如考慮不同的縮放因子和特權進程的“獎金” ,但它已更新以使其“盡可能簡單和可預測”。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.