hc
2024-05-14 bedbef8ad3e75a304af6361af235302bcc61d06b
kernel/tools/perf/scripts/python/powerpc-hcalls.py
....@@ -4,6 +4,8 @@
44 #
55 # Hypervisor call statisics
66
7
+from __future__ import print_function
8
+
79 import os
810 import sys
911
....@@ -149,7 +151,7 @@
149151 }
150152
151153 def hcall_table_lookup(opcode):
152
- if (hcall_table.has_key(opcode)):
154
+ if (opcode in hcall_table):
153155 return hcall_table[opcode]
154156 else:
155157 return opcode
....@@ -157,8 +159,8 @@
157159 print_ptrn = '%-28s%10s%10s%10s%10s'
158160
159161 def trace_end():
160
- print print_ptrn % ('hcall', 'count', 'min(ns)', 'max(ns)', 'avg(ns)')
161
- print '-' * 68
162
+ print(print_ptrn % ('hcall', 'count', 'min(ns)', 'max(ns)', 'avg(ns)'))
163
+ print('-' * 68)
162164 for opcode in output:
163165 h_name = hcall_table_lookup(opcode)
164166 time = output[opcode]['time']
....@@ -166,14 +168,14 @@
166168 min_t = output[opcode]['min']
167169 max_t = output[opcode]['max']
168170
169
- print print_ptrn % (h_name, cnt, min_t, max_t, time/cnt)
171
+ print(print_ptrn % (h_name, cnt, min_t, max_t, time//cnt))
170172
171173 def powerpc__hcall_exit(name, context, cpu, sec, nsec, pid, comm, callchain,
172174 opcode, retval):
173
- if (d_enter.has_key(cpu) and d_enter[cpu].has_key(opcode)):
175
+ if (cpu in d_enter and opcode in d_enter[cpu]):
174176 diff = nsecs(sec, nsec) - d_enter[cpu][opcode]
175177
176
- if (output.has_key(opcode)):
178
+ if (opcode in output):
177179 output[opcode]['time'] += diff
178180 output[opcode]['cnt'] += 1
179181 if (output[opcode]['min'] > diff):
....@@ -190,11 +192,11 @@
190192
191193 del d_enter[cpu][opcode]
192194 # else:
193
-# print "Can't find matching hcall_enter event. Ignoring sample"
195
+# print("Can't find matching hcall_enter event. Ignoring sample")
194196
195197 def powerpc__hcall_entry(event_name, context, cpu, sec, nsec, pid, comm,
196198 callchain, opcode):
197
- if (d_enter.has_key(cpu)):
199
+ if (cpu in d_enter):
198200 d_enter[cpu][opcode] = nsecs(sec, nsec)
199201 else:
200202 d_enter[cpu] = {opcode: nsecs(sec, nsec)}