Commit 8998979cc1f90da5a48b2e8a13833217c63f7c4a

Authored by Nathan Lynch
Committed by Linus Torvalds
1 parent bb8e8bcce7

fix bloat-o-meter for ppc64

bloat-o-meter assumes that a '.' anywhere in a symbol's name means that it
is static and prepends 'static.' to the first part of the symbol name,
discarding the portion of the name that follows the '.'.  However, the
names of function entry points begin with '.' in the ppc64 ABI.  This
causes all function text size changes to be accounted to a single 'static.'
entry in the output when comparing ppc64 kernels.

Change getsizes() to ignore the first character of the symbol name when
searching for '.'.

Signed-off-by: Nathan Lynch <ntl@pobox.com>
Cc: Matt Mackall <mpm@selenic.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

Showing 1 changed file with 2 additions and 1 deletions Inline Diff

scripts/bloat-o-meter
1 #!/usr/bin/python 1 #!/usr/bin/python
2 # 2 #
3 # Copyright 2004 Matt Mackall <mpm@selenic.com> 3 # Copyright 2004 Matt Mackall <mpm@selenic.com>
4 # 4 #
5 # inspired by perl Bloat-O-Meter (c) 1997 by Andi Kleen 5 # inspired by perl Bloat-O-Meter (c) 1997 by Andi Kleen
6 # 6 #
7 # This software may be used and distributed according to the terms 7 # This software may be used and distributed according to the terms
8 # of the GNU General Public License, incorporated herein by reference. 8 # of the GNU General Public License, incorporated herein by reference.
9 9
10 import sys, os, re 10 import sys, os, re
11 11
12 if len(sys.argv) != 3: 12 if len(sys.argv) != 3:
13 sys.stderr.write("usage: %s file1 file2\n" % sys.argv[0]) 13 sys.stderr.write("usage: %s file1 file2\n" % sys.argv[0])
14 sys.exit(-1) 14 sys.exit(-1)
15 15
16 def getsizes(file): 16 def getsizes(file):
17 sym = {} 17 sym = {}
18 for l in os.popen("nm --size-sort " + file).readlines(): 18 for l in os.popen("nm --size-sort " + file).readlines():
19 size, type, name = l[:-1].split() 19 size, type, name = l[:-1].split()
20 if type in "tTdDbB": 20 if type in "tTdDbB":
21 if "." in name: name = "static." + name.split(".")[0] 21 # function names begin with '.' on 64-bit powerpc
22 if "." in name[1:]: name = "static." + name.split(".")[0]
22 sym[name] = sym.get(name, 0) + int(size, 16) 23 sym[name] = sym.get(name, 0) + int(size, 16)
23 return sym 24 return sym
24 25
25 old = getsizes(sys.argv[1]) 26 old = getsizes(sys.argv[1])
26 new = getsizes(sys.argv[2]) 27 new = getsizes(sys.argv[2])
27 grow, shrink, add, remove, up, down = 0, 0, 0, 0, 0, 0 28 grow, shrink, add, remove, up, down = 0, 0, 0, 0, 0, 0
28 delta, common = [], {} 29 delta, common = [], {}
29 30
30 for a in old: 31 for a in old:
31 if a in new: 32 if a in new:
32 common[a] = 1 33 common[a] = 1
33 34
34 for name in old: 35 for name in old:
35 if name not in common: 36 if name not in common:
36 remove += 1 37 remove += 1
37 down += old[name] 38 down += old[name]
38 delta.append((-old[name], name)) 39 delta.append((-old[name], name))
39 40
40 for name in new: 41 for name in new:
41 if name not in common: 42 if name not in common:
42 add += 1 43 add += 1
43 up += new[name] 44 up += new[name]
44 delta.append((new[name], name)) 45 delta.append((new[name], name))
45 46
46 for name in common: 47 for name in common:
47 d = new.get(name, 0) - old.get(name, 0) 48 d = new.get(name, 0) - old.get(name, 0)
48 if d>0: grow, up = grow+1, up+d 49 if d>0: grow, up = grow+1, up+d
49 if d<0: shrink, down = shrink+1, down-d 50 if d<0: shrink, down = shrink+1, down-d
50 delta.append((d, name)) 51 delta.append((d, name))
51 52
52 delta.sort() 53 delta.sort()
53 delta.reverse() 54 delta.reverse()
54 55
55 print "add/remove: %s/%s grow/shrink: %s/%s up/down: %s/%s (%s)" % \ 56 print "add/remove: %s/%s grow/shrink: %s/%s up/down: %s/%s (%s)" % \
56 (add, remove, grow, shrink, up, -down, up-down) 57 (add, remove, grow, shrink, up, -down, up-down)
57 print "%-40s %7s %7s %+7s" % ("function", "old", "new", "delta") 58 print "%-40s %7s %7s %+7s" % ("function", "old", "new", "delta")
58 for d, n in delta: 59 for d, n in delta:
59 if d: print "%-40s %7s %7s %+7d" % (n, old.get(n,"-"), new.get(n,"-"), d) 60 if d: print "%-40s %7s %7s %+7d" % (n, old.get(n,"-"), new.get(n,"-"), d)
60 61