【问题标题】:is kernel panic an expected behavior in extreme memory pressure situation as shown in example?如示例所示,内核恐慌是极端内存压力情况下的预期行为吗?
【发布时间】:2015-05-30 07:18:14
【问题描述】:

kernel panic 是操作系统在检测到无法安全恢复的内部致命错误时采取的操作。

我尝试了一个实验,在该实验中,我通过分叉和分配一块几 MB 的块并无限休眠来在设备上制造人为的内存压力。我将分叉进程的oom_adj_score 设置为-1000,这样LMK 就无法杀死它们。

分享ps | grep artificial_mem_pressure的输出。查看RSS 字段,您可以看到每个process 都在消耗大量内存。

注意:我只是sn-p了几个进程,不是全部。

[ 5086]     0  5086    67990    12001      36     2881         -1000 artificial_mem_pressure
[ 5092]     0  5092    67990    11897      35     2853         -1000 artificial_mem_pressure
[ 5098]     0  5098    67990    11590      35     2969         -1000 artificial_mem_pressure
[ 5104]     0  5104    67990    11446      35     2983         -1000 artificial_mem_pressure
[ 5110]     0  5110    67990    11276      34     2954         -1000 artificial_mem_pressure
[ 5116]     0  5116    67990    11175      33     2924         -1000 artificial_mem_pressure
[ 5122]     0  5122    67990    11002      35     2900         -1000 artificial_mem_pressure
[ 5129]     0  5129    67990    10889      33     2879         -1000 artificial_mem_pressure
[ 5137]     0  5137    67990    10646      33     2927         -1000 artificial_mem_pressure
[ 5143]     0  5143    67990    10507      32     2932         -1000 artificial_mem_pressure
[ 5149]     0  5149    67990    10293      32     2949         -1000 artificial_mem_pressure
[ 5155]     0  5155    67990    10231      32     2879         -1000 artificial_mem_pressure
[ 5202]     0  5202    67990    10196      32     2778         -1000 artificial_mem_pressure
[ 5216]     0  5216    67990     9960      31     2818         -1000 artificial_mem_pressure
[ 5329]     0  5329    67990     9891      31     2752         -1000 artificial_mem_pressure
[ 5337]     0  5337    67990     9917      30     2590         -1000 artificial_mem_pressure
[ 5343]     0  5343    67990     9794      31     2515         -1000 artificial_mem_pressure
[ 5350]     0  5350    67990     9764      29     2413         -1000 artificial_mem_pressure
[ 5356]     0  5356    67990     9550      29     2428         -1000 artificial_mem_pressure
[ 5362]     0  5362    67990     9335      30     2512         -1000 artificial_mem_pressure
[ 5368]     0  5368    67990     9193      29     2465         -1000 artificial_mem_pressure
[ 5374]     0  5374    67990     9039      28     2487         -1000 artificial_mem_pressure
[ 5380]     0  5380    67990     8787      28     2540         -1000 artificial_mem_pressure
[ 5386]     0  5386    67990     8735      28     2465         -1000 artificial_mem_pressure
[ 5392]     0  5392    67990     8602      28     2385         -1000 artificial_mem_pressure
[ 5398]     0  5398    67990     8662      27     2207         -1000 artificial_mem_pressure
[ 5404]     0  5404    67990     8476      26     2181         -1000 artificial_mem_pressure
[ 5410]     0  5410    67990     8425      26     2104         -1000 artificial_mem_pressure
[ 5416]     0  5416    67990     8396      26     1995         -1000 artificial_mem_pressure
[ 5422]     0  5422    67990     8483      26     1724         -1000 artificial_mem_pressure
[ 5428]     0  5428    67990     8350      25     1709         -1000 artificial_mem_pressure
[ 5434]     0  5434    67990     8374      26     1531         -1000 artificial_mem_pressure

我知道对设备造成如此巨大的压力会导致内存不足。结果Memory reclamation algorithm 将尝试杀死一些可杀死的进程。现在就我而言,因为我拥有 oom_score_adj=-1000 的所有进程,因此 LMK 无法杀死这样的进程。

结果我看到了这条消息:

Kernel panic - not syncing: Out of memory and no killable processes...

我的问题: 在这种情况下是预期的行为吗?如果是,请解释。

【问题讨论】:

  • @AlexHoppus 是内核恐慌,这是在没有内存可回收的情况下的预期行为吗?如果是,那为什么?意味着不能回收算法超越杀死我们明确设置为 -1000 分数的用户空间进程。
  • 是的,因为内核说“没有可杀死的进程”
  • 好的,谢谢。但是,不能回收算法超越杀死我们明确设置为 -1000 分数的用户空间进程。
  • 我从您的日志中看到 - 它不能。您是否要更改内核以终止此类进程或有什么意义?为什么不能不设置 oom_score_adj=-1000?
  • 故意将 oom_score_adj 设置为 -1000。您是否要更改内核以终止此类进程。是的,如果可能的话。我在问为什么android不处理这种情况。如果这样的过程可以造成这种情况,那么内存管理应该足够智能来处理这种情况?

标签: android linux-kernel out-of-memory android-memory


【解决方案1】:

来自男人:

lowest possible value, -1000, is equivalent to disabling OOM-killing

如果您故意说“不要杀死它们”,为什么内核应该杀死它们?在这种情况下,内核别无选择——它会恐慌。即使这意味着所有进程的死亡,内核也会诚实地执行您的命令。 如果您需要避免这种情况 - 只需更改 oom_score_adj

【讨论】:

    猜你喜欢
    • 2015-12-19
    • 2013-12-12
    • 1970-01-01
    • 2020-01-28
    • 1970-01-01
    • 1970-01-01
    • 2021-09-21
    • 2012-02-08
    • 2015-12-11
    相关资源
    最近更新 更多