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: Autopep8 futex-contention

10 years leaves its mark! Python has evolved and so has its style guide.
Even with vim it is getting hard to follow the no longer valid
guidelines (spaces vs. tabs).

Autopep8 this code to modernize it!

Signed-off-by: Hagen Paul Pfeifer <hagen@jauu.net>
Link: http://lore.kernel.org/lkml/20200921201928.799498-1-hagen@jauu.net
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Hagen Paul Pfeifer and committed by
Arnaldo Carvalho de Melo
2a684fcb 002a3d69

+28 -23
+28 -23
tools/perf/scripts/python/futex-contention.py
··· 12 12 13 13 from __future__ import print_function 14 14 15 - import os, sys 16 - sys.path.append(os.environ['PERF_EXEC_PATH'] + '/scripts/python/Perf-Trace-Util/lib/Perf/Trace') 15 + import os 16 + import sys 17 + sys.path.append(os.environ['PERF_EXEC_PATH'] + 18 + '/scripts/python/Perf-Trace-Util/lib/Perf/Trace') 17 19 from Util import * 18 20 19 21 process_names = {} 20 22 thread_thislock = {} 21 23 thread_blocktime = {} 22 24 23 - lock_waits = {} # long-lived stats on (tid,lock) blockage elapsed time 24 - process_names = {} # long-lived pid-to-execname mapping 25 + lock_waits = {} # long-lived stats on (tid,lock) blockage elapsed time 26 + process_names = {} # long-lived pid-to-execname mapping 27 + 25 28 26 29 def syscalls__sys_enter_futex(event, ctxt, cpu, s, ns, tid, comm, callchain, 27 - nr, uaddr, op, val, utime, uaddr2, val3): 28 - cmd = op & FUTEX_CMD_MASK 29 - if cmd != FUTEX_WAIT: 30 - return # we don't care about originators of WAKE events 30 + nr, uaddr, op, val, utime, uaddr2, val3): 31 + cmd = op & FUTEX_CMD_MASK 32 + if cmd != FUTEX_WAIT: 33 + return # we don't care about originators of WAKE events 31 34 32 - process_names[tid] = comm 33 - thread_thislock[tid] = uaddr 34 - thread_blocktime[tid] = nsecs(s, ns) 35 + process_names[tid] = comm 36 + thread_thislock[tid] = uaddr 37 + thread_blocktime[tid] = nsecs(s, ns) 38 + 35 39 36 40 def syscalls__sys_exit_futex(event, ctxt, cpu, s, ns, tid, comm, callchain, 37 - nr, ret): 38 - if tid in thread_blocktime: 39 - elapsed = nsecs(s, ns) - thread_blocktime[tid] 40 - add_stats(lock_waits, (tid, thread_thislock[tid]), elapsed) 41 - del thread_blocktime[tid] 42 - del thread_thislock[tid] 41 + nr, ret): 42 + if tid in thread_blocktime: 43 + elapsed = nsecs(s, ns) - thread_blocktime[tid] 44 + add_stats(lock_waits, (tid, thread_thislock[tid]), elapsed) 45 + del thread_blocktime[tid] 46 + del thread_thislock[tid] 47 + 43 48 44 49 def trace_begin(): 45 - print("Press control+C to stop and show the summary") 50 + print("Press control+C to stop and show the summary") 51 + 46 52 47 53 def trace_end(): 48 - for (tid, lock) in lock_waits: 49 - 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)) 52 - 54 + for (tid, lock) in lock_waits: 55 + min, max, avg, count = lock_waits[tid, lock] 56 + print("%s[%d] lock %x contended %d times, %d avg ns" % 57 + (process_names[tid], tid, lock, count, avg))