Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

scripts/gdb/vmalloc: fix vmallocinfo error

The patch series "Mitigate a vmap lock contention" removes vmap_area_list,
which will break the gdb vmallocinfo command:

(gdb) lx-vmallocinfo
Python Exception <class 'gdb.error'>: No symbol "vmap_area_list" in current context.
Error occurred in Python: No symbol "vmap_area_list" in current context.

So we can instead use vmap_nodes to iterate all vmallocinfo.

Link: https://lkml.kernel.org/r/20240207085856.11190-1-Kuan-Ying.Lee@mediatek.com
Signed-off-by: Kuan-Ying Lee <Kuan-Ying.Lee@mediatek.com>
Cc: Casper Li <casper.li@mediatek.com>
Cc: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Cc: Chinwen Chang <chinwen.chang@mediatek.com>
Cc: Jan Kiszka <jan.kiszka@siemens.com>
Cc: Kieran Bingham <kbingham@kernel.org>
Cc: Matthias Brugger <matthias.bgg@gmail.com>
Cc: Qun-Wei Lin <qun-wei.lin@mediatek.com>
Cc: Uladzislau Rezki (Sony) <urezki@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Kuan-Ying Lee and committed by
Andrew Morton
0040f2c5 3956570e

+29 -27
+29 -27
scripts/gdb/linux/vmalloc.py
··· 29 29 if not constants.LX_CONFIG_MMU: 30 30 raise gdb.GdbError("Requires MMU support") 31 31 32 - vmap_area_list = gdb.parse_and_eval('vmap_area_list') 33 - for vmap_area in lists.list_for_each_entry(vmap_area_list, vmap_area_ptr_type, "list"): 34 - if not vmap_area['vm']: 35 - gdb.write("0x%x-0x%x %10d vm_map_ram\n" % (vmap_area['va_start'], vmap_area['va_end'], 36 - vmap_area['va_end'] - vmap_area['va_start'])) 37 - continue 38 - v = vmap_area['vm'] 39 - gdb.write("0x%x-0x%x %10d" % (v['addr'], v['addr'] + v['size'], v['size'])) 40 - if v['caller']: 41 - gdb.write(" %s" % str(v['caller']).split(' ')[-1]) 42 - if v['nr_pages']: 43 - gdb.write(" pages=%d" % v['nr_pages']) 44 - if v['phys_addr']: 45 - gdb.write(" phys=0x%x" % v['phys_addr']) 46 - if v['flags'] & constants.LX_VM_IOREMAP: 47 - gdb.write(" ioremap") 48 - if v['flags'] & constants.LX_VM_ALLOC: 49 - gdb.write(" vmalloc") 50 - if v['flags'] & constants.LX_VM_MAP: 51 - gdb.write(" vmap") 52 - if v['flags'] & constants.LX_VM_USERMAP: 53 - gdb.write(" user") 54 - if v['flags'] & constants.LX_VM_DMA_COHERENT: 55 - gdb.write(" dma-coherent") 56 - if is_vmalloc_addr(v['pages']): 57 - gdb.write(" vpages") 58 - gdb.write("\n") 32 + nr_vmap_nodes = gdb.parse_and_eval('nr_vmap_nodes') 33 + for i in range(0, nr_vmap_nodes): 34 + vn = gdb.parse_and_eval('&vmap_nodes[%d]' % i) 35 + for vmap_area in lists.list_for_each_entry(vn['busy']['head'], vmap_area_ptr_type, "list"): 36 + if not vmap_area['vm']: 37 + gdb.write("0x%x-0x%x %10d vm_map_ram\n" % (vmap_area['va_start'], vmap_area['va_end'], 38 + vmap_area['va_end'] - vmap_area['va_start'])) 39 + continue 40 + v = vmap_area['vm'] 41 + gdb.write("0x%x-0x%x %10d" % (v['addr'], v['addr'] + v['size'], v['size'])) 42 + if v['caller']: 43 + gdb.write(" %s" % str(v['caller']).split(' ')[-1]) 44 + if v['nr_pages']: 45 + gdb.write(" pages=%d" % v['nr_pages']) 46 + if v['phys_addr']: 47 + gdb.write(" phys=0x%x" % v['phys_addr']) 48 + if v['flags'] & constants.LX_VM_IOREMAP: 49 + gdb.write(" ioremap") 50 + if v['flags'] & constants.LX_VM_ALLOC: 51 + gdb.write(" vmalloc") 52 + if v['flags'] & constants.LX_VM_MAP: 53 + gdb.write(" vmap") 54 + if v['flags'] & constants.LX_VM_USERMAP: 55 + gdb.write(" user") 56 + if v['flags'] & constants.LX_VM_DMA_COHERENT: 57 + gdb.write(" dma-coherent") 58 + if is_vmalloc_addr(v['pages']): 59 + gdb.write(" vpages") 60 + gdb.write("\n") 59 61 60 62 LxVmallocInfo()