2016-03-04 47 views
1

有沒有什麼辦法可以確定當它被linux oom-killer殺死的時候該進程的虛擬內存大小判斷vm殺死進程的大小是否有oom-killer

我找不到文件/var/log/messages中的任何參數,這可能會告訴我總共有虛擬機大小被殺死的進程。/var/log/messages中有很多其他信息,但不是進程的總VM大小。

這是一個centos 5.7 x64機器。

以下是/var/log/messages內容:

Mar 1 18:51:45 c42 kernel: NameService invoked oom-killer: gfp_mask=0x201d2, order=0, oomkilladj=0 
Mar 1 18:51:45 c42 kernel: 
Mar 1 18:51:46 c42 kernel: Call Trace: 
Mar 1 18:51:46 c42 kernel: [<ffffffff800c9d3a>] out_of_memory+0x8e/0x2f3 
Mar 1 18:51:46 c42 kernel: [<ffffffff8002dfd7>] __wake_up+0x38/0x4f 
Mar 1 18:51:46 c42 kernel: [<ffffffff8000f677>] __alloc_pages+0x27f/0x308 
Mar 1 18:51:46 c42 kernel: [<ffffffff80013034>] __do_page_cache_readahead+0x96/0x17b 
Mar 1 18:51:46 c42 kernel: [<ffffffff80013971>] filemap_nopage+0x14c/0x360 
Mar 1 18:51:46 c42 kernel: [<ffffffff8000896c>] __handle_mm_fault+0x1fd/0x103b 
Mar 1 18:51:46 c42 kernel: [<ffffffff800671f2>] do_page_fault+0x499/0x842 
Mar 1 18:51:46 c42 kernel: [<ffffffff80031143>] do_fork+0x148/0x1c1 
Mar 1 18:51:46 c42 kernel: [<ffffffff8005dde9>] error_exit+0x0/0x84 
Mar 1 18:51:46 c42 kernel: 
Mar 1 18:51:46 c42 kernel: Mem-info: 
Mar 1 18:51:47 c42 kernel: Node 0 DMA per-cpu: 
Mar 1 18:51:48 c42 kernel: cpu 0 hot: high 0, batch 1 used:0 
Mar 1 18:51:48 c42 kernel: cpu 0 cold: high 0, batch 1 used:0 
Mar 1 18:51:48 c42 kernel: cpu 1 hot: high 0, batch 1 used:0 
Mar 1 18:51:48 c42 kernel: cpu 1 cold: high 0, batch 1 used:0 
Mar 1 18:51:48 c42 kernel: cpu 2 hot: high 0, batch 1 used:0 
Mar 1 18:51:48 c42 kernel: cpu 2 cold: high 0, batch 1 used:0 
Mar 1 18:51:48 c42 kernel: cpu 3 hot: high 0, batch 1 used:0 
Mar 1 18:51:48 c42 kernel: cpu 3 cold: high 0, batch 1 used:0 
Mar 1 18:51:48 c42 kernel: cpu 4 hot: high 0, batch 1 used:0 
Mar 1 18:51:48 c42 kernel: cpu 4 cold: high 0, batch 1 used:0 
Mar 1 18:51:48 c42 kernel: cpu 5 hot: high 0, batch 1 used:0 
Mar 1 18:51:48 c42 kernel: cpu 5 cold: high 0, batch 1 used:0 
Mar 1 18:51:48 c42 kernel: cpu 6 hot: high 0, batch 1 used:0 
Mar 1 18:51:48 c42 kernel: cpu 6 cold: high 0, batch 1 used:0 
Mar 1 18:51:48 c42 kernel: cpu 7 hot: high 0, batch 1 used:0 
Mar 1 18:51:48 c42 kernel: cpu 7 cold: high 0, batch 1 used:0 
Mar 1 18:51:48 c42 kernel: cpu 8 hot: high 0, batch 1 used:0 
Mar 1 18:51:49 c42 kernel: cpu 8 cold: high 0, batch 1 used:0 
Mar 1 18:51:49 c42 kernel: cpu 9 hot: high 0, batch 1 used:0 
Mar 1 18:51:49 c42 kernel: cpu 9 cold: high 0, batch 1 used:0 
Mar 1 18:51:49 c42 kernel: cpu 10 hot: high 0, batch 1 used:0 
Mar 1 18:51:49 c42 kernel: cpu 10 cold: high 0, batch 1 used:0 
Mar 1 18:51:49 c42 kernel: cpu 11 hot: high 0, batch 1 used:0 
Mar 1 18:51:49 c42 kernel: cpu 11 cold: high 0, batch 1 used:0 
Mar 1 18:51:49 c42 kernel: cpu 12 hot: high 0, batch 1 used:0 
Mar 1 18:51:49 c42 kernel: cpu 12 cold: high 0, batch 1 used:0 
Mar 1 18:51:49 c42 kernel: cpu 13 hot: high 0, batch 1 used:0 
Mar 1 18:51:49 c42 kernel: cpu 13 cold: high 0, batch 1 used:0 
Mar 1 18:51:49 c42 kernel: cpu 14 hot: high 0, batch 1 used:0 
Mar 1 18:51:49 c42 kernel: cpu 14 cold: high 0, batch 1 used:0 
Mar 1 18:51:49 c42 kernel: cpu 15 hot: high 0, batch 1 used:0 
Mar 1 18:51:49 c42 kernel: cpu 15 cold: high 0, batch 1 used:0 
Mar 1 18:51:49 c42 kernel: Node 0 DMA32 per-cpu: 
Mar 1 18:51:49 c42 kernel: cpu 0 hot: high 186, batch 31 used:31 
Mar 1 18:51:49 c42 kernel: cpu 0 cold: high 62, batch 15 used:35 

............ 

Mar 1 18:51:58 c42 kernel: cpu 14 cold: high 62, batch 15 used:18 
Mar 1 18:51:58 c42 kernel: cpu 15 hot: high 186, batch 31 used:6 
Mar 1 18:51:59 c42 kernel: cpu 15 cold: high 62, batch 15 used:14 
Mar 1 18:51:59 c42 kernel: Node 1 HighMem per-cpu: empty 
Mar 1 18:51:59 c42 kernel: Free pages:  50396kB (0kB HighMem) 
Mar 1 18:51:59 c42 kernel: Active:1559270 inactive:2490421 dirty:0 writeback:0 unstable:0 free:12599 slab:8740 mapped-file:1186 mapped-anon:4051463 pagetables:16277 
Mar 1 18:51:59 c42 kernel: Node 0 DMA free:10068kB min:8kB low:8kB high:12kB active:0kB inactive:0kB present:9660kB pages_scanned:0 all_unreclaimable? yes 
Mar 1 18:51:59 c42 kernel: lowmem_reserve[]: 0 1965 8025 8025 
Mar 1 18:51:59 c42 kernel: Node 0 DMA32 free:26176kB min:1980kB low:2472kB high:2968kB active:1020328kB inactive:922224kB present:2012496kB pages_scanned:4075359 all_unreclaimable? yes 
Mar 1 18:51:59 c42 kernel: lowmem_reserve[]: 0 0 6060 6060 
Mar 1 18:51:59 c42 kernel: Node 0 Normal free:6060kB min:6108kB low:7632kB high:9160kB active:490800kB inactive:5569172kB present:6205440kB pages_scanned:21679912 all_unreclaimable? yes 
Mar 1 18:51:59 c42 kernel: lowmem_reserve[]: 0 0 0 0 
Mar 1 18:51:59 c42 kernel: Node 0 HighMem free:0kB min:128kB low:128kB high:128kB active:0kB inactive:0kB present:0kB pages_scanned:0 all_unreclaimable? no 
Mar 1 18:52:00 c42 kernel: lowmem_reserve[]: 0 0 0 0 
Mar 1 18:52:00 c42 kernel: Node 1 DMA free:0kB min:0kB low:0kB high:0kB active:0kB inactive:0kB present:0kB pages_scanned:0 all_unreclaimable? no 
Mar 1 18:52:00 c42 kernel: lowmem_reserve[]: 0 0 8080 8080 
Mar 1 18:52:00 c42 kernel: Node 1 DMA32 free:0kB min:0kB low:0kB high:0kB active:0kB inactive:0kB present:0kB pages_scanned:0 all_unreclaimable? no 
Mar 1 18:52:00 c42 kernel: lowmem_reserve[]: 0 0 8080 8080 
Mar 1 18:52:00 c42 kernel: Node 1 Normal free:8092kB min:8144kB low:10180kB high:12216kB active:4725952kB inactive:3470288kB present:8273920kB pages_scanned:15611005 all_unreclaimable? yes 
Mar 1 18:52:00 c42 kernel: lowmem_reserve[]: 0 0 0 0 
Mar 1 18:52:00 c42 kernel: Node 1 HighMem free:0kB min:128kB low:128kB high:128kB active:0kB inactive:0kB present:0kB pages_scanned:0 all_unreclaimable? no 
Mar 1 18:52:01 c42 kernel: lowmem_reserve[]: 0 0 0 0 
Mar 1 18:52:02 c42 kernel: Node 0 DMA: 5*4kB 2*8kB 5*16kB 5*32kB 5*64kB 2*128kB 0*256kB 0*512kB 1*1024kB 0*2048kB 2*4096kB = 10068kB 
Mar 1 18:52:02 c42 kernel: Node 0 DMA32: 30*4kB 1*8kB 0*16kB 0*32kB 1*64kB 1*128kB 1*256kB 0*512kB 1*1024kB 0*2048kB 6*4096kB = 26176kB 
Mar 1 18:52:02 c42 kernel: Node 0 Normal: 9*4kB 7*8kB 3*16kB 1*32kB 0*64kB 0*128kB 1*256kB 1*512kB 1*1024kB 0*2048kB 1*4096kB = 6060kB 
Mar 1 18:52:02 c42 kernel: Node 0 HighMem: empty 
Mar 1 18:52:03 c42 kernel: Node 1 DMA: empty 
Mar 1 18:52:03 c42 kernel: Node 1 DMA32: empty 
Mar 1 18:52:03 c42 kernel: Node 1 Normal: 49*4kB 3*8kB 0*16kB 0*32kB 1*64kB 1*128kB 0*256kB 1*512kB 1*1024kB 1*2048kB 1*4096kB = 8092kB 
Mar 1 18:52:03 c42 kernel: Node 1 HighMem: empty 
Mar 1 18:52:03 c42 kernel: 1624 pagecache pages 
Mar 1 18:52:04 c42 kernel: Swap cache: add 2581210, delete 2580953, find 6957/9192, race 0+16 
Mar 1 18:52:04 c42 kernel: Free swap = 0kB 
Mar 1 18:52:04 c42 kernel: Total swap = 10241428kB 
Mar 1 18:52:04 c42 kernel: Free swap:   0kB 
Mar 1 18:52:06 c42 kernel: 4718592 pages of RAM 
Mar 1 18:52:06 c42 kernel: 616057 reserved pages 
Mar 1 18:52:07 c42 kernel: 17381 pages shared 
Mar 1 18:52:08 c42 kernel: 260 pages swap cached 
Mar 1 18:52:09 c42 kernel: Out of memory: Killed process 16727, UID 501, (ApplicationMoni). 
+0

[This](http://unix.stackexchange.com/a/153586/112913)可能有關係。 –

+0

@SamProtsenko上面的鏈接沒有提及VM大小。 –

+0

@ ArpitAggarwal,你的意思是,這個過程在什麼記憶中被殺死了? –

回答

2

作爲每Linux中,總存儲器是物理存儲器和虛擬存儲器即RAM + SWAP的總和。

當你的進程被殺死時,你會給進程的得分在kern日誌中死亡。

通過觀察過程的頂部命令和oom_score。我想的是,

oom_score <= to percent it used in total memory

例如:具有16GB的RAM和SWAP的1GB,所以總的存儲器我的系統是17GB。 Tomcat進程被oom評分'602'殺死,那麼tomcat的使用率大於或等於總內存的60.2%,即tomcat佔用了10.23 + GB的內存。

下面是另一個例子: enter image description here enter image description here

得分是249即,存儲器使用率24.9+%

+0

但OOM Killer在殺死進程時不打印該進程的oom_score。我怎麼知道這一點。 –

0

這報道於dmesg的,導致崩潰堆棧跟蹤之後(通常是一個存儲器分配請求)