在linux系统中可以通过/proc/slabinfo获取slab的统计数据,crash提供了kmem来实现这个功能。
查看系统每个kmem_cache的概要信息
crash> kmem -s
CACHE OBJSIZE ALLOCATED TOTAL SLABS SSIZE NAME
ffff888141e12000 131072 0 0 0 128k 9p-fcall-cache
ffff888140834f00 312 800 806 31 8k ext4_groupinfo_4k
ffff888140834e00 216 0 216 6 8k p9_req_t
ffff888140834d00 304 0 0 0 8k ip6-frags
ffff888140834c00 1984 0 32 2 32k UDPv6
ffff888140834b00 312 0 0 0 8k tw_sock_TCPv6
ffff888140834a00 352 0 0 0 8k request_sock_TCPv6
ffff888140834900 3176 3 20 2 32k TCPv6
...
ffff888005842900 256 1348 1696 53 8k kmalloc-256
ffff888005842800 192 1014 2961 141 4k kmalloc-192
ffff888005842700 128 883 1184 37 4k kmalloc-128
ffff888005842600 96 664 1806 43 4k kmalloc-96
ffff888005842500 64 4175 4992 78 4k kmalloc-64
ffff888005842400 32 3387 4480 35 4k kmalloc-32
ffff888005842300 16 2436 3840 15 4k kmalloc-16
ffff888005842200 8 2283 5120 10 4k kmalloc-8
ffff888005842100 128 652 864 27 4k kmem_cache_node
ffff888005842000 224 163 288 9 8k kmem_cache
查看某个kmem_cache的详细信息
比如想查看kmalloc-8k为例:
crash> kmem -S kmalloc-8k
CACHE OBJSIZE ALLOCATED TOTAL SLABS SSIZE NAME
ffff888005842e00 8192 33 60 15 32k kmalloc-8k
CPU 0 KMEM_CACHE_CPU:
ffff88807f802db0
CPU 0 SLAB:
SLAB MEMORY NODE TOTAL ALLOCATED FREE
ffffea000019ba00 ffff8880066e8000 0 4 0 4
FREE / [ALLOCATED]
ffff8880066e8000 (cpu 0 cache)
ffff8880066ea000 (cpu 0 cache)
ffff8880066ec000 (cpu 0 cache)
ffff8880066ee000 (cpu 0 cache)
CPU 0 PARTIAL:
(empty)
CPU 1 KMEM_CACHE_CPU:
ffff88807fc02db0
CPU 1 SLAB:
(empty)
CPU 1 PARTIAL:
(empty)
CPU 2 KMEM_CACHE_CPU:
ffff88813d802db0
CPU 2 SLAB:
SLAB MEMORY NODE TOTAL ALLOCATED FREE
ffffea0004068600 ffff888101a18000 1 4 2 2
FREE / [ALLOCATED]
[ffff888101a18000]
[ffff888101a1a000]
ffff888101a1c000 (cpu 2 cache)
ffff888101a1e000 (cpu 2 cache)
CPU 2 PARTIAL:
(empty)
CPU 3 KMEM_CACHE_CPU:
ffff88813dc02db0
CPU 3 SLAB:
SLAB MEMORY NODE TOTAL ALLOCATED FREE
ffffea0004108200 ffff888104208000 1 4 0 4
FREE / [ALLOCATED]
ffff888104208000 (cpu 3 cache)
ffff88810420a000 (cpu 3 cache)
ffff88810420c000 (cpu 3 cache)
ffff88810420e000 (cpu 3 cache)
CPU 3 PARTIAL:
(empty)
...
KMEM_CACHE_NODE NODE SLABS PARTIAL PER-CPU
ffff888005840700 0 3 1 1
NODE 0 PARTIAL:
SLAB MEMORY NODE TOTAL ALLOCATED FREE
ffffea00001f7e00 ffff888007df8000 0 4 2 2
NODE 0 FULL:
(not tracked)
KMEM_CACHE_NODE NODE SLABS PARTIAL PER-CPU
ffff888100000700 1 2 0 2
NODE 1 PARTIAL:
(empty)
NODE 1 FULL:
(not tracked)
KMEM_CACHE_NODE NODE SLABS PARTIAL PER-CPU
ffff888140000700 2 3 0 2
NODE 2 PARTIAL:
(empty)
NODE 2 FULL:
(not tracked)
KMEM_CACHE_NODE NODE SLABS PARTIAL PER-CPU
ffff8881c0000700 3 7 0 2
NODE 3 PARTIAL:
(empty)
NODE 3 FULL:
(not tracked)
标签:NODE,8k,crash,kmalloc,cache,slub,PARTIAL,详细信息,CPU
From: https://www.cnblogs.com/pengdonglin137/p/17726197.html