osandov / drgn

Programmable debugger
Other
1.78k stars 165 forks source link

contrib: Add memory related script to dump slabinfo and vmallocinfo #419

Closed kylee0215 closed 4 months ago

kylee0215 commented 4 months ago

Add scripts to dump slabinfo and vmallocinfo.

slabinfo example output:

struct kmem_cache *  |         name         | active_objs  |   num_objs   | objsize  | objperslab  | pagesperslab
-------------------- | -------------------- | ------------ | ------------ | -------- | ----------- | -------------
0xffff00000632cf40   | 9p-fcall-cache       |            0 |            0 |   131192 |           1 |            64
0xffff00000632cdc0   | p9_req_t             |            0 |           33 |      248 |          33 |             2
0xffff00000632cc40   | isp1760_qh           |            0 |            0 |      144 |          28 |             1
0xffff00000632cac0   | isp1760_qtd          |            0 |            0 |      168 |          24 |             1
0xffff00000632c940   | isp1760_urb_listite  |            0 |            0 |      120 |          34 |             1
0xffff00000632c7c0   | asd_sas_event        |            0 |            0 |      256 |          32 |             2

vmallocinfo example output:

0xffff800080000000-0xffff800080005000      20480 start_kernel pages=4 vmalloc
0xffff800080005000-0xffff800080007000       8192 ioremap_prot phys=0x8020000 ioremap
0xffff800080008000-0xffff80008000d000      20480 start_kernel pages=4 vmalloc
0xffff80008000d000-0xffff80008000f000       8192 bpf_prog_alloc_no_stats pages=1 vmalloc
0xffff800082a00000-0xffff8000833d1000   10293248 paging_init phys=0x42c00000 vmap
0xffff800083400000-0xffff800083405000      20480 start_kernel pages=4 vmalloc
0xffff800083405000-0xffff800083408000      12288 pcpu_mem_zalloc pages=2 vmalloc
0xffff800083408000-0xffff80008340d000      20480 kernel_clone pages=4 vmalloc
0xffff80008340d000-0xffff80008340f000       8192 ioremap_prot phys=0x9030000 ioremap