Re: [PATCH 2/2] scripts: add kmemleak2pprof.py for slab usage analysis

From: Andrew Morton
Date: Tue Aug 28 2018 - 19:28:33 EST


On Tue, 28 Aug 2018 12:39:14 +0200 Vincent Whitchurch <vincent.whitchurch@xxxxxxxx> wrote:

> Add a script which converts /sys/kernel/debug/kmemleak_all to the pprof
> format, which can be used for analysing memory usage. See
> https://github.com/google/pprof.

Why is this better than /proc/slabinfo?

> $ ./kmemleak2pprof.py kmemleak_all
> $ pprof -text -ignore free_area_init_node -compact_labels -nodecount 10 prof

Are we missing an argument here? s/prof/kmemleak_all/?

> Showing nodes accounting for 4.85MB, 34.05% of 14.23MB total
> Dropped 3989 nodes (cum <= 0.07MB)
> Showing top 10 nodes out of 190
> flat flat% sum% cum cum%
> 1.39MB 9.78% 9.78% 1.61MB 11.29% new_inode_pseudo+0x8/0x4c
> 0.75MB 5.27% 15.04% 0.75MB 5.27% alloc_large_system_hash+0x19c/0x2b8
> 0.73MB 5.12% 20.17% 0.86MB 6.07% kernfs_new_node+0x30/0x50
> 0.66MB 4.62% 24.79% 0.66MB 4.62% __vmalloc_node.constprop.9+0x48/0x50
> 0.61MB 4.28% 29.06% 0.61MB 4.28% d_alloc+0x10/0x78
> 0.22MB 1.52% 30.58% 0.22MB 1.52% alloc_inode+0x1c/0xa4
> 0.18MB 1.28% 31.86% 0.20MB 1.42% _do_fork+0xb0/0x41c
> 0.13MB 0.88% 32.74% 0.13MB 0.88% early_trace_init+0x16c/0x374
> 0.09MB 0.66% 33.40% 0.17MB 1.17% inet_init+0x128/0x24c
> 0.09MB 0.65% 34.05% 0.09MB 0.65% __kernfs_new_node+0x34/0x1a8