Categories
SysOps

How to display kernel slab cache information

You can directly inspect kernel slab allocator statistics (/proc/slabinfo file) for detailed information on buffer, inode, dentry, or other caches in the Linux kernel, though slabtop utility will sort and pretty-print information in real-time.

Display kernel slab cache information in real-time.

$ sudo slabtop
  Active / Total Objects (% used)    : 5574868 / 8454157 (65.9%)
  Active / Total Slabs (% used)      : 212861 / 212861 (100.0%)
  Active / Total Caches (% used)     : 163 / 213 (76.5%)
  Active / Total Size (% used)       : 1521776.41K / 2139878.34K (71.1%)

  Minimum / Average / Maximum Object : 0.01K / 0.25K / 16.75K
 OBJS ACTIVE  USE OBJ SIZE  SLABS OBJ/SLAB CACHE SIZE NAME                   
 872640 275998  31%    0.06K  13635       64     54540K kmalloc-64             
 580839 467151  80%    0.19K  27659       21    110636K dentry                 
 497370 312123  62%    0.13K  16579       30     66316K kernfs_node_cache      
 476160 227988  47%    0.01K    930      512      3720K kmalloc-8              
 367536 199830  54%    0.32K  15314       24    122512K arc_buf_hdr_t_full     
 359096 135329  37%    0.50K  11224       32    179584K kmalloc-512            
 331149 293965  88%    0.10K   8491       39     33964K buffer_head            
 309952 307060  99%    0.06K   4843       64     19372K anon_vma_chain         
 262210  93833  35%    0.30K  10086       26     80688K dmu_buf_impl_t         
 249942  73835  29%    0.09K   5951       42     23804K kmalloc-96             
 248076 245056  98%    0.20K   6364       39     50912K vm_area_struct         
 234906  96505  41%    0.04K   2303      102      9212K abd_t                  
 192675  83164  43%    0.57K   6885       28    110160K radix_tree_node        
 189016 122528  64%    0.89K   5404       35    172928K dnode_t                
 187266 186347  99%    0.09K   4071       46     16284K anon_vma               
 148208 142719  96%    0.25K   4632       32     37056K filp                   
 135072  64696  47%    0.07K   2412       56      9648K range_seg_cache        
 126464 111974  88%    0.06K   1976       64      7904K kmalloc-rcl-64         
  98566  94311  95%    0.59K   3791       26     60656K inode_cache            
  97020  58211  59%    0.24K   2940       33     23520K sa_cache               
  92423  56600  61%    1.08K   3187       29    101984K zfs_znode_cache        
  70434  65366  92%    0.09K   1677       42      6708K kmalloc-rcl-96         
  67328  65750  97%    0.02K    263      256      1052K kmalloc-16             
  57420  42423  73%    1.07K   1980       29     63360K ext4_inode_cache       
  55440  54669  98%    0.19K   2640       21     10560K kmalloc-192 
[...]

Display kernel slab cache information once, sorted by the cache size, and print the first twenty lines.

$ sudo slabtop --once --sort c | head -20
  Active / Total Objects (% used)    : 5571460 / 8454136 (65.9%)
  Active / Total Slabs (% used)      : 212830 / 212830 (100.0%)
  Active / Total Caches (% used)     : 163 / 213 (76.5%)
  Active / Total Size (% used)       : 1521610.64K / 2139599.28K (71.1%)

  Minimum / Average / Maximum Object : 0.01K / 0.25K / 16.75K
 OBJS ACTIVE  USE OBJ SIZE  SLABS OBJ/SLAB CACHE SIZE NAME                   
 359096 135798  37%    0.50K  11224       32    179584K kmalloc-512            
 189016 122601  64%    0.89K   5404       35    172928K dnode_t                
   9230   7718  83%   16.00K   4615        2    147680K zio_buf_16384          
 367536 199836  54%    0.32K  15314       24    122512K arc_buf_hdr_t_full     
 580839 467091  80%    0.19K  27659       21    110636K dentry                 
 192675  83190  43%    0.57K   6885       28    110160K radix_tree_node        
  92423  56600  61%    1.08K   3187       29    101984K zfs_znode_cache        
  20320  19887  97%    4.00K   2540        8     81280K kmalloc-4k             
 262210  93870  35%    0.30K  10086       26     80688K dmu_buf_impl_t         
   9857   6965  70%    8.00K   2465        4     78880K kmalloc-8k             
 497370 312123  62%    0.13K  16579       30     66316K kernfs_node_cache      
  57420  42423  73%    1.07K   1980       29     63360K ext4_inode_cache       
  98566  94311  95%    0.59K   3791       26     60656K inode_cache 

Display usage information.

$ slabtop --help
Usage:
 slabtop [options]

Options:
 -d, --delay <secs>  delay updates
 -o, --once          only display once, then exit
 -s, --sort <char>   specify sort criteria by character (see below)

 -h, --help     display this help and exit
 -V, --version  output version information and exit

The following are valid sort criteria:
 a: sort by number of active objects
 b: sort by objects per slab
 c: sort by cache size
 l: sort by number of slabs
 v: sort by number of active slabs
 n: sort by name
 o: sort by number of objects (the default)
 p: sort by pages per slab
 s: sort by object size
 u: sort by cache utilization

For more details see slabtop(1).