国产探花免费观看_亚洲丰满少妇自慰呻吟_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ā)表
主站蜘蛛池模板: 绵竹市| 景泰县| 嘉善县| 阜康市| 阿拉善盟| 高要市| 南澳县| 昌都县| 金乡县| 无锡市| 镇安县| 铜山县| 济宁市| 博白县| 通化县| 东海县| 齐河县| 遵义县| 两当县| 于田县| 石楼县| 二连浩特市| 綦江县| 中山市| 云阳县| 彰武县| 白沙| 从江县| 万年县| 体育| 鄄城县| 江油市| 昭苏县| 南城县| 武邑县| 漳平市| 句容市| 丽水市| 霞浦县| 三都| 白朗县|