簡體   English   中英

誰能解釋一下 OOM 殺手中的 oom_badness() 分數?

[英]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() )。

任務的“劣勢”取決於多種因素:

  • 它的虛擬內存中有多少頁。
  • 它擁有多少 SWAP 條目。
  • 進程使用了​​多少內存(總字節數/頁面大小)。
  • 如果它已經標記為被殺死,因為它負責 OOM,它會獲得盡可能高的分數。
  • 如果是 init 進程或內核線程,則忽略它。

在較舊的內核版本中, oom_badness()函數曾經更復雜,例如考慮不同的縮放因子和特權進程的“獎金” ,但它已更新以使其“盡可能簡單和可預測”。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM