linux系统slab缓存proc_node_cache使用率过大

linux系统slab缓存proc_node_cache使用率过大

我的系统仅运行 Java 程序,有时内存使用量会迅速增加到很高的百分比:

java的内存使用情况:

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND                                                                                                                                       
23046 admin     18   0 2115m 427m  13m S 14.7 10.8   1609:58 java 

但系统内存使用情况是:

[root@AY130716093217935dfdZ ~]# free -m
             total       used       free     shared    buffers     cached
Mem:          3959       3709        249          0         93        122
-/+ buffers/cache:       3493        465
Swap:            0          0          0

然后我知道排除 java 的用法是系统内核的 slab:

[root@AY130716093217935dfdZ ~]# cat /proc/meminfo | grep slab -i
Slab:          3092688 kB

因此,我使用 slabtop 检查了 slab 的详细用法:

 Active / Total Objects (% used)    : 9509520 / 9545651 (99.6%)
 Active / Total Slabs (% used)      : 771723 / 771725 (100.0%)
 Active / Total Caches (% used)     : 94 / 138 (68.1%)
 Active / Total Size (% used)       : 2751436.50K / 2761816.41K (99.6%)
 Minimum / Average / Maximum Object : 0.02K / 0.29K / 128.00K

  OBJS ACTIVE  USE OBJ SIZE  SLABS OBJ/SLAB CACHE SIZE NAME                   
3140784 3140358  99%    0.08K  65433       48    261732K selinux_inode_security
3127590 3127260  99%    0.21K 173755       18    695020K dentry_cache
3108264 3108182  99%    0.58K 518044        6   2072176K proc_inode_cache

可以发现,proc_node_cache,entry_cache都非常大。

所以,我假设有一些程序扫描/proc 目录?

但是java程序不应该做这种事。

当我重新启动 java 程序时,slab 缩小到很低。

顺便说一句,我的系统挂载了 nfs,并且 java 程序将日志写入 nfs 上的文件:

[root@AY130716093217935dfdZ ~]# mount
/dev/hda1 on / type ext3 (rw)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
tmpfs on /dev/shm type tmpfs (rw)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
//42.121.111.155/server23 on /mnt/server23 type cifs (rw,mand)
//10.161.143.83/fulllogs on /mnt/newlogs type cifs (rw,mand)

我的内核是:

Linux AY130716093217935dfdZ 2.6.18-308.el5 #1 SMP Tue Feb 21 20:06:06 EST 2012 x86_64 x86_64 x86_64 GNU/Linux

操作系统:

CentOS release 5.8 (Final)

机器由 XEN 创建。作为 XEN 客户机。

我想知道什么情况会产生 proc_inode_cache 如此大的 slab 内存使用量?

我的服务器可能出现什么问题?

谢谢 !

更新:

通过查看2.6.18内核的源代码,在exit.c中:

do_exit -> release_task ->proc_flush_task(p);

函数proc_flush_task:

/**                                                                                                                                                                                                         
 * proc_flush_task -  Remove dcache entries for @task from the /proc dcache. 

这意味着当任务退出时,proc 将被收获,所以,这可以解释为什么当我停止 java 进程时 slab 会缩小。

现在有一个问题,因为java的线程是600,相当于其他时间,为什么它持有那么多的proc_inode?

相关内容