检查磁盘空间
// 查看文件系统的磁盘空间使用情况(总空间用 1K-blocks 的数量来表示) $ df /dev/sda1 Filesystem 1K-blocks Used Available Use% Mounted on /dev/sda1 30308240 3167020 27124836 11% / // 通过 -h 选项,以获得更好的可读性 $ df -h /dev/sda1 Filesystem Size Used Avail Use% Mounted on /dev/sda1 29G 3.1G 26G 11% /
检查索引节点
// 检查 索引节点 的使用情况 $ df -i /dev/sda1 Filesystem Inodes IUsed IFree IUse% Mounted on /dev/sda1 3870720 157460 3713260 5% /
检查 inode/dentry 缓存
Linux Kernel 使用 Slab 机制,管理 dentry 和 inode 的缓存;
/proc/meminfo 仅显示 Slab 的整体大小,具体到每一种 Slab 缓存,还要查看 /proc/slabinfo 文件;
slabtop
/proc/slabinfo 并不易阅读,在实际性能分析中,我们更常使用 slabtop ,来找到占用内存最多的缓存类型;
# slabtop Active / Total Objects (% used) : 1448105 / 1884228 (76.9%) Active / Total Slabs (% used) : 56703 / 56703 (100.0%) Active / Total Caches (% used) : 113 / 158 (71.5%) Active / Total Size (% used) : 361280.20K / 669058.59K (54.0%) Minimum / Average / Maximum Object : 0.01K / 0.35K / 9.62K OBJS ACTIVE USE OBJ SIZE SLABS OBJ/SLAB CACHE SIZE NAME 316050 62089 19% 1.06K 10535 30 337120K nfs_inode_cache 216239 206662 95% 0.20K 11381 19 45524K vm_area_struct 165888 152120 91% 0.06K 2592 64 10368K anon_vma_chain 113536 91552 80% 0.03K 887 128 3548K kmalloc-32 112380 110482 98% 0.13K 3746 30 14984K kernfs_node_cache ... // 按下 c 按照缓存大小排序, // 按下 a 按照活跃对象数排序
该结果显示,在我们的系统中,nfs_inode_cache 占用最多的 Slab 缓存,共计 337MB 左右