国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 數(shù)據(jù)庫 > MySQL > 正文

MySQL OOM 系統(tǒng)二 OOM Killer

2024-07-24 12:53:58
字體:
供稿:網(wǎng)友

這里就涉及到一個問題,到底Kill掉誰呢?一般稍微了解一些Linux內(nèi)核的同學第一反應是誰用的最多,就Kill掉誰。這當然是Linux內(nèi)核首先考慮的一種重要因素,但是也不完全是這樣的,我們查一些Linux的內(nèi)核方面的資料,可以知道其實Kill誰是由/proc/<pid>/oom_score來決定的,這個值每個進程一個,是由Linux內(nèi)核的oom_badness()函數(shù)負責計算的。那下面我們來仔細讀一讀badness()函數(shù)。  

在badness()函數(shù)的注釋部分,寫明了badness()函數(shù)的處理思路:

         1) we lose the minimum amount of work done
         2) we recover a large amount of memory
         3) we don't kill anything innocent of eating tons of memory
         4) we want to kill the minimum amount of processes (one)
         5) we try to kill the process the user expects us to kill, this  algorithm has been meticulously tuned to meet the principle of least surprise ... (be careful when you change it)

總的來說就是Kill掉最小數(shù)量的進程來獲取最大數(shù)量的內(nèi)存,這與我們Kill掉占用內(nèi)存最大的進程是吻合的。

        /*
         * The memory size of the process is the basis for the badness.
         */

         points = p->mm->total_vm;

分數(shù)的起始是進程實際使用的RAM內(nèi)存,注意這里不包括SWAP,即OOM Killer只會與進程實際的物理內(nèi)存有關(guān),與Swap是沒有關(guān)系的,并且我們可以看到,進程實際使用的物理內(nèi)存越多,分數(shù)就越高,分數(shù)越高就越容易被犧牲掉。

        /*
         * Processes which fork a lot of child processes are likely
         * a good choice. We add the vmsize of the childs if they
         * have an own mm. This prevents forking servers to flood the
         * machine with an endless amount of childs
         */
          ...
                  if (chld->mm != p->mm && chld->mm)
                        points += chld->mm->total_vm;

這段表示子進程占用的內(nèi)存都會計算到父進程上。

        s = int_sqrt(cpu_time);

發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 四会市| 五大连池市| 遵义县| 临漳县| 格尔木市| 沐川县| 冕宁县| 白银市| 蒙自县| 石屏县| 随州市| 峨眉山市| 睢宁县| 南召县| 乐业县| 山东省| 咸丰县| 大庆市| 绥滨县| 潮安县| 寿光市| 江城| 会昌县| 合江县| 静海县| 宜昌市| 炉霍县| 泸西县| 五大连池市| 科技| 大庆市| 腾冲县| 和平区| 澜沧| 南雄市| 临沂市| 遂昌县| 永昌县| 汉阴县| 姚安县| 青海省|