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 futex-contention.py

Support both Python2 and Python3 in the futex-contention.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/20190302011903.2416-3-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
de2ec16b b504d7f6

+6 -4
+6 -4
tools/perf/scripts/python/futex-contention.py
··· 10 10 # 11 11 # Measures futex contention 12 12 13 + from __future__ import print_function 14 + 13 15 import os, sys 14 16 sys.path.append(os.environ['PERF_EXEC_PATH'] + '/scripts/python/Perf-Trace-Util/lib/Perf/Trace') 15 17 from Util import * ··· 35 33 36 34 def syscalls__sys_exit_futex(event, ctxt, cpu, s, ns, tid, comm, callchain, 37 35 nr, ret): 38 - if thread_blocktime.has_key(tid): 36 + if tid in thread_blocktime: 39 37 elapsed = nsecs(s, ns) - thread_blocktime[tid] 40 38 add_stats(lock_waits, (tid, thread_thislock[tid]), elapsed) 41 39 del thread_blocktime[tid] 42 40 del thread_thislock[tid] 43 41 44 42 def trace_begin(): 45 - print "Press control+C to stop and show the summary" 43 + print("Press control+C to stop and show the summary") 46 44 47 45 def trace_end(): 48 46 for (tid, lock) in lock_waits: 49 47 min, max, avg, count = lock_waits[tid, lock] 50 - print "%s[%d] lock %x contended %d times, %d avg ns" % \ 51 - (process_names[tid], tid, lock, count, avg) 48 + print("%s[%d] lock %x contended %d times, %d avg ns" % 49 + (process_names[tid], tid, lock, count, avg)) 52 50