[34006.619601] Memory cgroup out of memory: Killed process 6041 (pause) total-vm:1024kB, anon-rss:4kB, file-rss:0kB, shmem-rss:0kB
[34006.711098] Memory cgroup out of memory: Killed process 6183 (harmonize_log) total-vm:464104kB, anon-rss:7316kB, file-rss:6452kB, shmem-rss:0kB
[34007.013063] Memory cgroup out of memory: Killed process 10396 (pause) total-vm:1024kB, anon-rss:4kB, file-rss:0kB, shmem-rss:0kB
[34007.104973] Memory cgroup out of memory: Killed process 10567 (harmonize_log) total-vm:464104kB, anon-rss:9348kB, file-rss:6464kB, shmem-rss:0kB
rss 的含义:Resident Set Size // 驻留内存大小(分配给进程,同时在内存中的)
pr_err("Killed process %d (%s) total-vm:%lukB, anon-rss:%lukB, file-rss:%lukB, shmem-rss:%lukB\n",
task_pid_nr(victim), victim->comm, K(victim->mm->total_vm),
K(get_mm_counter(victim->mm, MM_ANONPAGES)), //Resident anonymous pages
K(get_mm_counter(victim->mm, MM_FILEPAGES)), //Resident file mapping pages
K(get_mm_counter(victim->mm, MM_SHMEMPAGES))); //Resident shared memory pages
/mm/oom_kill.c
if (oc->chosen && oc->chosen != (void )-1UL) {
oom_kill_process(oc, !is_memcg_oom(oc) ? “Out of memory” :
“Memory cgroup out of memory”);
/
* Give the killed process a good chance to exit before trying
* to allocate memory again.
*/
schedule_timeout_killable(1);
}
mem_cgroup_oom_synchronize(bool handle)
{
根据当前线程里的current->memcg_in_oom 来做判断; 这个值是怎么来的?
}
发生page fault之后会尝试通过kill process来释放内存,防止系统宕机。
Jun 8 04:19:29 all-in-one-01 kernel: abc.py cpuset=docker-09802cffb93b38777f36ca1bca03c6499cd5b10ea6667a8bc77e74fe75e1b989.scope mems_allowed=0
Jun 8 04:19:29 all-in-one-01 kernel: CPU: 3 PID: 28006 Comm: abc.py Kdump: loaded Not tainted 4.18.0-147.5.1.el8_1.x86_64 #1
Jun 8 04:19:29 all-in-one-01 kernel: Hardware name: RDO OpenStack Compute, BIOS 1.11.0-2.el7 04/01/2014
Jun 8 04:19:29 all-in-one-01 kernel: Call Trace:
Jun 8 04:19:29 all-in-one-01 kernel: dump_stack+0x5c/0x80
Jun 8 04:19:29 all-in-one-01 kernel: dump_header+0x6e/0x27a
Jun 8 04:19:29 all-in-one-01 kernel: oom_kill_process.cold.29+0xb/0x10
Jun 8 04:19:29 all-in-one-01 kernel: out_of_memory+0x1ba/0x490
Jun 8 04:19:29 all-in-one-01 kernel: mem_cgroup_out_of_memory+0x49/0x80
Jun 8 04:19:29 all-in-one-01 kernel: try_charge+0x6fa/0x780
Jun 8 04:19:29 all-in-one-01 kernel: ? __alloc_pages_nodemask+0xef/0x280
Jun 8 04:19:29 all-in-one-01 kernel: mem_cgroup_try_charge+0x8b/0x1a0
Jun 8 04:19:29 all-in-one-01 kernel: mem_cgroup_try_charge_delay+0x1c/0x40
Jun 8 04:19:29 all-in-one-01 kernel: do_fault+0x8e/0x3e0
Jun 8 04:19:29 all-in-one-01 kernel: __handle_mm_fault+0x539/0x6b0
Jun 8 04:19:29 all-in-one-01 kernel: handle_mm_fault+0xda/0x200
Jun 8 04:19:29 all-in-one-01 kernel: __do_page_fault+0x22b/0x4e0
Jun 8 04:19:29 all-in-one-01 kernel: do_page_fault+0x32/0x110
Jun 8 04:19:29 all-in-one-01 kernel: ? async_page_fault+0x8/0x30
Jun 8 04:19:29 all-in-one-01 kernel: async_page_fault+0x1e/0x30
Jun 8 04:19:29 all-in-one-01 kernel: RIP: 0033:0x7f82f4815a2a
Nov 4 08:32:16 in-one-01 kernel: containerd invoked oom-killer: gfp_mask=0x6200ca(GFP_HIGHUSER_MOVABLE), nodemask=(null), order=0, oom_score_adj=-999
Nov 4 08:32:16 in-one-01 kernel: containerd cpuset=/ mems_allowed=0
Nov 4 08:32:16 in-one-01 kernel: CPU: 8 PID: 5278 Comm: containerd Kdump: loaded Not tainted 4.18.0-147.5.1.el8_1.x86_64 #1
Nov 4 08:32:16 in-one-01 kernel: Hardware name: RDO OpenStack Compute, BIOS 1.11.0-2.el7 04/01/2014
Nov 4 08:32:16 in-one-01 kernel: Call Trace:
Nov 4 08:32:16 in-one-01 kernel: dump_stack+0x5c/0x80
Nov 4 08:32:16 in-one-01 kernel: dump_header+0x6e/0x27a
Nov 4 08:32:16 in-one-01 kernel: oom_kill_process.cold.29+0xb/0x10
Nov 4 08:32:16 in-one-01 kernel: out_of_memory+0x1ba/0x490
inline __alloc_pages_may_oom 如果尝试申请内存 两次,还是没有申请到,就会走到这个函数尝试kill
Nov 4 08:32:16 in-one-01 kernel: __alloc_pages_slowpath+0xc0f/0xce0
Nov 4 08:32:16 in-one-01 kernel: __alloc_pages_nodemask+0x245/0x280
Nov 4 08:32:16 in-one-01 kernel: alloc_pages_vma+0x74/0x1d0
Nov 4 08:32:16 in-one-01 kernel: do_fault+0x69/0x3e0
Nov 4 08:32:16 in-one-01 kernel: __handle_mm_fault+0x539/0x6b0
Nov 4 08:32:16 in-one-01 kernel: handle_mm_fault+0xda/0x200
Nov 4 08:32:16 in-one-01 kernel: __do_page_fault+0x22b/0x4e0
Nov 4 08:32:16 in-one-01 kernel: do_page_fault+0x32/0x110
Nov 4 08:32:16 in-one-01 kernel: async_page_fault+0x1e/0x30
Nov 4 08:32:16 in-one-01 kernel: RIP: 0010:__clear_user+0x1a/0x50
#引用:
https://stackoverflow.com/questions/7880784/what-is-rss-and-vsz-in-linux-memory-management#:~:text=RSS%20is%20the%20Resident%20Set%20Size%20and%20is,It%20does%20include%20all%20stack%20and%20heap%20memory.