SLAB info 解析

pi@raspberrypi:~$ sudo cat /proc/slabinfo
slabinfo - version: 2.1
# name            <active_objs> <num_objs> <objsize> <objperslab> <pagesperslab> : tunables <limit> <batchcount> <sharedfactor> : slabdata <active_slabs> <num_slabs> <sharedavail>
fuse_request         156    156    104   39    1 : tunables    0    0    0 : slabdata      4      4      0
fuse_inode            56     56    576   28    4 : tunables    0    0    0 : slabdata      2      2      0
RAWv6                 36     36    896   18    4 : tunables    0    0    0 : slabdata      2      2      0
UDPv6                 48     48   1024   16    4 : tunables    0    0    0 : slabdata      3      3      0
tw_sock_TCPv6         21     21    192   21    1 : tunables    0    0    0 : slabdata      1      1      0
request_sock_TCPv6     17     17    240   17    1 : tunables    0    0    0 : slabdata      1      1      0
TCPv6                 68     68   1920   17    8 : tunables    0    0    0 : slabdata      4      4      0
ext4_groupinfo_4k    252    252    112   36    1 : tunables    0    0    0 : slabdata      7      7      0
sgpool-64             16     16   1024   16    4 : tunables    0    0    0 : slabdata      1      1      0
sgpool-32             16     16    512   16    2 : tunables    0    0    0 : slabdata      1      1      0
mqueue_inode_cache     25     25    640   25    4 : tunables    0    0    0 : slabdata      1      1      0
discard_entry          0      0     80   51    1 : tunables    0    0    0 : slabdata      0      0      0
nat_entry              0      0     24  170    1 : tunables    0    0    0 : slabdata      0      0      0
f2fs_inode_cache       0      0    760   21    4 : tunables    0    0    0 : slabdata      0      0      0
nfs_direct_cache       0      0    136   30    1 : tunables    0    0    0 : slabdata      0      0      0
nfs_inode_cache        0      0    744   22    4 : tunables    0    0    0 : slabdata      0      0      0
fat_inode_cache       16     16    504   16    2 : tunables    0    0    0 : slabdata      1      1      0
fat_cache            340    340     24  170    1 : tunables    0    0    0 : slabdata      2      2      0
jbd2_inode           408    408     40  102    1 : tunables    0    0    0 : slabdata      4      4      0
jbd2_journal_head    256    256     64   64    1 : tunables    0    0    0 : slabdata      4      4      0
ext4_inode_cache    4557   4557    752   21    4 : tunables    0    0    0 : slabdata    217    217      0
ext4_allocation_context    156    156    104   39    1 : tunables    0    0    0 : slabdata      4      4      0
ext4_prealloc_space    224    224     72   56    1 : tunables    0    0    0 : slabdata      4      4      0
ext4_io_end          340    340     48   85    1 : tunables    0    0    0 : slabdata      4      4      0
ext4_pending_reservation    256    256     16  256    1 : tunables    0    0    0 : slabdata      1      1      0
ext4_extent_status   4096   4096     32  128    1 : tunables    0    0    0 : slabdata     32     32      0
mbcache              408    408     40  102    1 : tunables    0    0    0 : slabdata      4      4      0
pid_namespace          0      0    120   34    1 : tunables    0    0    0 : slabdata      0      0      0
posix_timers_cache     22     22    184   22    1 : tunables    0    0    0 : slabdata      1      1      0
rpc_inode_cache       18     18    448   18    2 : tunables    0    0    0 : slabdata      1      1      0
rpc_buffers           16     16   2048   16    8 : tunables    0    0    0 : slabdata      1      1      0
ip4-frags              0      0    136   30    1 : tunables    0    0    0 : slabdata      0      0      0
xfrm_state            56     56    576   28    4 : tunables    0    0    0 : slabdata      2      2      0
RAW                   42     42    768   21    4 : tunables    0    0    0 : slabdata      2      2      0
UDP                  162    162    896   18    4 : tunables    0    0    0 : slabdata      9      9      0
tw_sock_TCP            0      0    192   21    1 : tunables    0    0    0 : slabdata      0      0      0
request_sock_TCP      51     51    240   17    1 : tunables    0    0    0 : slabdata      3      3      0
TCP                   54     54   1792   18    8 : tunables    0    0    0 : slabdata      3      3      0
cachefiles_object_jar      0      0    256   16    1 : tunables    0    0    0 : slabdata      0      0      0
fscache_cookie_jar     42     42     96   42    1 : tunables    0    0    0 : slabdata      1      1      0
dquot                 84     84    192   21    1 : tunables    0    0    0 : slabdata      4      4      0
eventpoll_pwq        408    408     40  102    1 : tunables    0    0    0 : slabdata      4      4      0
inotify_inode_mark    340    340     48   85    1 : tunables    0    0    0 : slabdata      4      4      0
request_queue         69     69   1400   23    8 : tunables    0    0    0 : slabdata      3      3      0
blkdev_ioc           256    256     64   64    1 : tunables    0    0    0 : slabdata      4      4      0
biovec-max           130    130   3072   10    8 : tunables    0    0    0 : slabdata     13     13      0
biovec-128            84     84   1536   21    8 : tunables    0    0    0 : slabdata      4      4      0
biovec-64             84     84    768   21    4 : tunables    0    0    0 : slabdata      4      4      0
user_namespace         0      0    376   21    2 : tunables    0    0    0 : slabdata      0      0      0
audit_buffer         256    256     16  256    1 : tunables    0    0    0 : slabdata      1      1      0
sock_inode_cache     550    550    640   25    4 : tunables    0    0    0 : slabdata     22     22      0
skbuff_fclone_cache     84     84    384   21    2 : tunables    0    0    0 : slabdata      4      4      0
skbuff_head_cache   1029   1029    192   21    1 : tunables    0    0    0 : slabdata     49     49      0
configfs_dir_cache     73     73     56   73    1 : tunables    0    0    0 : slabdata      1      1      0
file_lock_cache      128    128    128   32    1 : tunables    0    0    0 : slabdata      4      4      0
fsnotify_mark_connector    680    680     24  170    1 : tunables    0    0    0 : slabdata      4      4      0
net_namespace          9      9   3456    9    8 : tunables    0    0    0 : slabdata      1      1      0
task_delay_info      459    459     80   51    1 : tunables    0    0    0 : slabdata      9      9      0
taskstats             92     92    344   23    2 : tunables    0    0    0 : slabdata      4      4      0
proc_dir_entry      1760   1760    128   32    1 : tunables    0    0    0 : slabdata     55     55      0
pde_opener           680    680     24  170    1 : tunables    0    0    0 : slabdata      4      4      0
proc_inode_cache    4100   4176    448   18    2 : tunables    0    0    0 : slabdata    232    232      0
seq_file             184    184     88   46    1 : tunables    0    0    0 : slabdata      4      4      0
bdev_cache           112    112    576   28    4 : tunables    0    0    0 : slabdata      4      4      0
shmem_inode_cache   1207   1207    464   17    2 : tunables    0    0    0 : slabdata     71     71      0
kernfs_iattrs_cache    392    392     72   56    1 : tunables    0    0    0 : slabdata      7      7      0
kernfs_node_cache  18648  18648     96   42    1 : tunables    0    0    0 : slabdata    444    444      0
filp                4621   5040    192   21    1 : tunables    0    0    0 : slabdata    240    240      0
inode_cache        11980  11980    408   20    2 : tunables    0    0    0 : slabdata    599    599      0
dentry             25620  25620    136   30    1 : tunables    0    0    0 : slabdata    854    854      0
names_cache           40     40   4096    8    8 : tunables    0    0    0 : slabdata      5      5      0
key_jar              966    966    192   21    1 : tunables    0    0    0 : slabdata     46     46      0
buffer_head        13504  13504     64   64    1 : tunables    0    0    0 : slabdata    211    211      0
uts_namespace          0      0    416   19    2 : tunables    0    0    0 : slabdata      0      0      0
vm_area_struct     14742  14742     96   42    1 : tunables    0    0    0 : slabdata    351    351      0
mm_struct            112    112    512   16    2 : tunables    0    0    0 : slabdata      7      7      0
files_cache          144    144    256   16    1 : tunables    0    0    0 : slabdata      9      9      0
signal_cache         588    588    768   21    4 : tunables    0    0    0 : slabdata     28     28      0
sighand_cache        216    216   1344   24    8 : tunables    0    0    0 : slabdata      9      9      0
task_struct          321    328   3904    8    8 : tunables    0    0    0 : slabdata     41     41      0
cred_jar             832    832    128   32    1 : tunables    0    0    0 : slabdata     26     26      0
anon_vma_chain     10574  11392     32  128    1 : tunables    0    0    0 : slabdata     89     89      0
anon_vma            6716   6716     56   73    1 : tunables    0    0    0 : slabdata     92     92      0
pid                  576    576     64   64    1 : tunables    0    0    0 : slabdata      9      9      0
trace_event_file    1360   1360     48   85    1 : tunables    0    0    0 : slabdata     16     16      0
pool_workqueue        64     64    256   16    1 : tunables    0    0    0 : slabdata      4      4      0
radix_tree_node     2964   2964    304   26    2 : tunables    0    0    0 : slabdata    114    114      0
task_group            90     90    448   18    2 : tunables    0    0    0 : slabdata      5      5      0
vmap_area           4352   4352     32  128    1 : tunables    0    0    0 : slabdata     34     34      0
kmalloc-rcl-8k         0      0   8192    4    8 : tunables    0    0    0 : slabdata      0      0      0
kmalloc-rcl-4k         0      0   4096    8    8 : tunables    0    0    0 : slabdata      0      0      0
kmalloc-rcl-2k         0      0   2048   16    8 : tunables    0    0    0 : slabdata      0      0      0
kmalloc-rcl-1k         0      0   1024   16    4 : tunables    0    0    0 : slabdata      0      0      0
kmalloc-rcl-512        0      0    512   16    2 : tunables    0    0    0 : slabdata      0      0      0
kmalloc-rcl-256        0      0    256   16    1 : tunables    0    0    0 : slabdata      0      0      0
kmalloc-rcl-192        0      0    192   21    1 : tunables    0    0    0 : slabdata      0      0      0
kmalloc-rcl-128      480    480    128   32    1 : tunables    0    0    0 : slabdata     15     15      0
kmalloc-rcl-64       704    704     64   64    1 : tunables    0    0    0 : slabdata     11     11      0
kmalloc-8k            40     40   8192    4    8 : tunables    0    0    0 : slabdata     10     10      0
kmalloc-4k            80     80   4096    8    8 : tunables    0    0    0 : slabdata     10     10      0
kmalloc-2k           368    368   2048   16    8 : tunables    0    0    0 : slabdata     23     23      0
kmalloc-1k           720    752   1024   16    4 : tunables    0    0    0 : slabdata     47     47      0
kmalloc-512         1536   1552    512   16    2 : tunables    0    0    0 : slabdata     97     97      0
kmalloc-256          512    512    256   16    1 : tunables    0    0    0 : slabdata     32     32      0
kmalloc-192          693    693    192   21    1 : tunables    0    0    0 : slabdata     33     33      0
kmalloc-128         2016   2016    128   32    1 : tunables    0    0    0 : slabdata     63     63      0
kmalloc-64         16640  16640     64   64    1 : tunables    0    0    0 : slabdata    260    260      0
kmem_cache_node      192    192     64   64    1 : tunables    0    0    0 : slabdata      3      3      0
kmem_cache           128    128    256   16    1 : tunables    0    0    0 : slabdata      8      8      0
pi@raspberrypi:~$

什么是slab分配器?

想象内核内存就像一个大型乐高仓库:

  • 普通分配:每次要零件都去大箱子里翻找(效率低)

  • slab分配:把常用零件预先分类放在小盒子里(高效)

2. 输出格式详解(以dentry行为例):

 

复制

dentry 25620 25620 136 30 1 : tunables 0 0 0 : slabdata 854 854 0

第一部分:基础信息
字段解释类比dentry示例
name缓存类型名称乐高盒子标签"dentry"(目录项)
active_objs正在使用的对象数正在使用的乐高零件25,620个
num_objs总对象数盒子里的所有零件25,620个
objsize每个对象大小单个零件尺寸136字节
objperslab每"板"放多少对象每个小盒子放多少零件30个
pagesperslab每"板"占用内存页数(1页=4KB)每个小盒子占用的货架空间1页(4KB)
第二部分:可调参数(tunables)
字段解释类比
limit最大缓存限制盒子容量上限
batchcount批量操作数量每次补充/回收的零件量
sharedfactor共享程度多个工人共用盒子的程度
第三部分:slab数据
字段解释类比
active_slabs活跃的slab板数正在使用的小盒子数量
num_slabs总slab板数所有小盒子数量
sharedavail可共享对象数可借给其他工人的零件

3. 关键缓存类型说明:

  1. dentry:目录项缓存(相当于"文件地址簿")
  2. inode_cache:文件元数据缓存(相当于"文件属性便签")
  3. kmalloc-*:内核通用内存池(相当于"各种尺寸的零件盒")
  4. TCP/UDP:网络连接控制块(相当于"通话记录本")

4. 如何查看更直观的信息?

建议运行这个命令查看内存概况:

执行终端命令

cat /proc/meminfo | grep -e Slab -e SReclaimable

根据反馈的内存数据,我来帮您解读这些数字的含义:

思考过程

1. 关键指标解释

 

复制

Slab: 222648 kB # 内核slab分配器总共使用的内存 SReclaimable: 117788 kB # 其中可回收的内存(如文件系统缓存)

  • Slab总量:222MB(相当于您家仓库总共用了222个储物箱)
  • 可回收内存:117MB(其中117个储物箱装的是可以临时清空的季节性物品)

2. 当前状态分析

  • 内存利用率:约53%的slab内存是可回收的(117/222)
  • 健康程度:这是正常现象,说明系统正在:
    • 有效缓存文件数据(提高性能)
    • 合理利用空闲内存(不用白不用)

3. 优化建议

  1. 手动回收缓存(临时需要内存时):

echo 3 > /proc/sys/vm/drop_caches

  1. 自动回收调整(长期优化):

# 提缓存回收积极性(默认100) echo 120 > /proc/sys/vm/vfs_cache_pressure

  1. 查看详细分类(想了解具体哪些缓存占内存):
 

bash

sudo slabtop -o

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值