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

Configure Feed

Select the types of activity you want to include in your feed.

perf script python: Add Python3 support to mem-phys-addr.py

Support both Python2 and Python3 in the mem-phys-addr.py script

There may be differences in the ordering of output lines due to
differences in dictionary ordering etc. However the format within lines
should be unchanged.

The use of 'from __future__' implies the minimum supported Python2 version
is now v2.6

Signed-off-by: Tony Jones <tonyj@suse.de>
Link: http://lkml.kernel.org/r/20190222230619.17887-8-tonyj@suse.de
Signed-off-by: Seeteena Thoufeek <s1seetee@linux.vnet.ibm.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Tony Jones and committed by
Arnaldo Carvalho de Melo
e4d053dd 9b2700ef

+14 -10
+14 -10
tools/perf/scripts/python/mem-phys-addr.py
··· 4 4 # Copyright (c) 2018, Intel Corporation. 5 5 6 6 from __future__ import division 7 + from __future__ import print_function 8 + 7 9 import os 8 10 import sys 9 11 import struct ··· 33 31 for i, j in enumerate(f): 34 32 m = re.split('-|:',j,2) 35 33 if m[2].strip() == 'System RAM': 36 - system_ram.append(long(m[0], 16)) 37 - system_ram.append(long(m[1], 16)) 34 + system_ram.append(int(m[0], 16)) 35 + system_ram.append(int(m[1], 16)) 38 36 if m[2].strip() == 'Persistent Memory': 39 - pmem.append(long(m[0], 16)) 40 - pmem.append(long(m[1], 16)) 37 + pmem.append(int(m[0], 16)) 38 + pmem.append(int(m[1], 16)) 41 39 42 40 def print_memory_type(): 43 - print "Event: %s" % (event_name) 44 - print "%-40s %10s %10s\n" % ("Memory type", "count", "percentage"), 45 - print "%-40s %10s %10s\n" % ("----------------------------------------", \ 41 + print("Event: %s" % (event_name)) 42 + print("%-40s %10s %10s\n" % ("Memory type", "count", "percentage"), end='') 43 + print("%-40s %10s %10s\n" % ("----------------------------------------", 46 44 "-----------", "-----------"), 45 + end=''); 47 46 total = sum(load_mem_type_cnt.values()) 48 47 for mem_type, count in sorted(load_mem_type_cnt.most_common(), \ 49 - key = lambda(k, v): (v, k), reverse = True): 50 - print "%-40s %10d %10.1f%%\n" % (mem_type, count, 100 * count / total), 48 + key = lambda kv: (kv[1], kv[0]), reverse = True): 49 + print("%-40s %10d %10.1f%%\n" % (mem_type, count, 100 * count / total), 50 + end='') 51 51 52 52 def trace_begin(): 53 53 parse_iomem() ··· 84 80 f.seek(0, 0) 85 81 for j in f: 86 82 m = re.split('-|:',j,2) 87 - if long(m[0], 16) <= phys_addr <= long(m[1], 16): 83 + if int(m[0], 16) <= phys_addr <= int(m[1], 16): 88 84 return m[2] 89 85 return "N/A" 90 86