-
Notifications
You must be signed in to change notification settings - Fork 202
/
kmemleak
executable file
·39 lines (31 loc) · 968 Bytes
/
kmemleak
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/usr/bin/env ruby
LKP_SRC = ENV['LKP_SRC'] || File.dirname(File.dirname(File.realpath($PROGRAM_NAME)))
RESULT_ROOT = ENV['RESULT_ROOT']
require "#{LKP_SRC}/lib/tests/stats"
stats = LKP::Stats.new
memleaks = []
memleak = {}
bts = []
while (line = $stdin.gets)
case line.chomp!
when /^unreferenced object/ # unreferenced object 0xffff9375a9b84e00 (size 128):
if !bts.empty? && memleak['type']
memleak['bt'] = bts
memleaks << memleak
end
bts = ''
memleak['type'] = 'unreferenced_object'
when /comm "(.*)"/ # comm "swapper/0", pid 1, jiffies 4294667990 (age 37.508s)
memleak['comm'] = $1
# [<(____ptrval____)>] unpack_to_rootfs+0x3d/0x304
# [<(____ptrval____)>] populate_rootfs+0x19/0x106
when /\[.*\] (.*)\+/
bts = ".#{$1}#{bts}"
end
end
if !bts.empty? && memleak['type']
memleak['bt'] = bts
memleaks << memleak
end
memleaks.uniq.each { |m| stats.add "#{m['comm']}.#{m['type']}#{m['bt']}", 1 }
stats.dump