我通过将inotify放入大量文件夹(~2 000 000)来面对一个问题。 我将max_user_watches更改为8388608:
echo 8388608 > /proc/sys/fs/inotify/max_user_watches
为了支持这一数量的手表,服务器具有3Gb可用内存。 但是当我启动inotify脚本时,经过几个小时(~15h),它就被杀了。这是/ var / log / messages trace:
inotify.sh invoked oom-killer: gfp_mask=0xd0, order=1, oom_adj=0
inotify.sh cpuset=/ mems_allowed=0
Pid: 12488, comm: inotify.sh Not tainted 2.6.32-5-686 #1
Call Trace:
[<c1089534>] ? oom_kill_process+0x60/0x201
[<c1089ab1>] ? __out_of_memory+0xf4/0x107
[<c1089b1e>] ? out_of_memory+0x5a/0x7c
[<c108c3c9>] ? __alloc_pages_nodemask+0x3ef/0x4d9
[<c108c4bf>] ? __get_free_pages+0xc/0x17
[<c102f06c>] ? copy_process+0xb7/0xf28
[<c11028ad>] ? security_file_alloc+0xc/0xd
[<c1030017>] ? do_fork+0x13a/0x2bc
[<c10b182d>] ? fd_install+0x1e/0x3c
[<c103b996>] ? recalc_sigpending+0xf/0x2e
[<c103bcae>] ? sigprocmask+0x9d/0xbc
[<c1001dae>] ? sys_clone+0x21/0x27
[<c10030fb>] ? sysenter_do_call+0x12/0x28
Mem-Info:
DMA per-cpu:
CPU 0: hi: 0, btch: 1 usd: 0
CPU 1: hi: 0, btch: 1 usd: 0
Normal per-cpu:
CPU 0: hi: 186, btch: 31 usd: 0
CPU 1: hi: 186, btch: 31 usd: 41
HighMem per-cpu:
CPU 0: hi: 186, btch: 31 usd: 0
CPU 1: hi: 186, btch: 31 usd: 34
active_anon:53061 inactive_anon:13287 isolated_anon:0
active_file:2006 inactive_file:4143 isolated_file:0
unevictable:0 dirty:272 writeback:0 unstable:0
free:499244 slab_reclaimable:174921 slab_unreclaimable:25041
mapped:1892 shmem:42 pagetables:240 bounce:0
DMA free:3492kB min:64kB low:80kB high:96kB active_anon:0kB inactive_anon:0kB active_file:0kB inactive_file:0kB unevictable:0kB isolated(anon):0kB isolated(file):0kB present:15804kB mlocked:0kB dirty:0kB writeback:0kB mapped:0kB shmem:0kB slab_reclaimable:12080kB slab_unreclaimable:332kB kernel_stack:0kB pagetables:0kB unstable:0kB bounce:0kB writeback_tmp:0kB pages_scanned:0 all_unreclaimable? yes
lowmem_reserve[]: 0 861 3032 3032
Normal free:59488kB min:3720kB low:4648kB high:5580kB active_anon:0kB inactive_anon:0kB active_file:1092kB inactive_file:3380kB unevictable:0kB isolated(anon):0kB isolated(file):0kB present:881880kB mlocked:0kB dirty:1088kB writeback:0kB mapped:4kB shmem:0kB slab_reclaimable:687604kB slab_unreclaimable:99832kB kernel_stack:952kB pagetables:0kB unstable:0kB bounce:0kB writeback_tmp:0kB pages_scanned:1211 all_unreclaimable? yes
lowmem_reserve[]: 0 0 17366 17366
HighMem free:1933996kB min:512kB low:2856kB high:5200kB active_anon:212244kB inactive_anon:53148kB active_file:6932kB inactive_file:13192kB unevictable:0kB isolated(anon):0kB isolated(file):0kB present:2222948kB mlocked:0kB dirty:0kB writeback:0kB mapped:7564kB shmem:168kB slab_reclaimable:0kB slab_unreclaimable:0kB kernel_stack:0kB pagetables:960kB unstable:0kB bounce:0kB writeback_tmp:0kB pages_scanned:0 all_unreclaimable? no
lowmem_reserve[]: 0 0 0 0
DMA: 19*4kB 43*8kB 16*16kB 6*32kB 17*64kB 12*128kB 0*256kB 0*512kB 0*1024kB 0*2048kB 0*4096kB = 3492kB
Normal: 14406*4kB 99*8kB 1*16kB 3*32kB 1*64kB 1*128kB 1*256kB 1*512kB 0*1024kB 0*2048kB 0*4096kB = 59488kB
HighMem: 31*4kB 14*8kB 8*16kB 2*32kB 2*64kB 1*128kB 2*256kB 1*512kB 1*1024kB 1*2048kB 471*4096kB = 1933996kB
6194 total pagecache pages
0 pages in swap cache
Swap cache stats: add 0, delete 0, find 0/0
Free swap = 1951736kB
Total swap = 1951736kB
786416 pages RAM
560130 pages HighMem
7712 pages reserved
7694 pages shared
275891 pages non-shared
当剧本被杀时,我几乎有2Gb的可用内存。所以我真的不明白这个OOM。有人能帮我吗 ? 脚本非常简单:
#!/bin/bash
INOTIFY_DIR="/data"
inotifywait -rme modify,attrib,move,close_write,create,delete,delete_self $INOTIFY_DIR 2>> /datatest/inotify.log
答案 0 :(得分:3)
OOM杀手与page_fault_handler()
相关联。如果page_fault_handler由于不可用而无法分配页面,它将通过内核调用page_fault_out_of_memory()
调用OOM杀手。然后OOM杀手逻辑将启动并选择最佳候选进程来杀死和清理内存。逻辑遵循启发式方法来找到最可杀戮的进程,以便它可以释放内存并使系统保持活动状态。
为什么OOM杀手正在开始纯粹基于免费页面的可用性。这可能是来自任何内存区域的页面分配失败。您有足够大的高内存可用并不意味着您在所有其他区域中都有可用内存。等ZONE_DMA,低记忆等。
查看page_fault_out_of_memory()
中的oom_kill.c
了解有关oom杀手算法的详细信息