History

perf script python: Remove mixed indentation

Remove mixed indentation in Python scripts. Revert to either all tabs (most common form) or all spaces (4 or 8) depending on what was the intent of the original commit. This is necessary to complete Python3 support as it will flag an error if it encounters mixed indentation.

Tony Jones committed 7 years ago

Commit b504d7f1 parent c1d3e6314 files · +136 −135Browse files

Showing the changes to tools/perf/scripts/python (14 of 14 files). Show all

Unified · Split

14 files
  1. tools/perf/scripts/python/check-perf-trace.py +32 −33
  2. tools/perf/scripts/python/compaction-times.py +4 −4
  3. tools/perf/scripts/python/event_analyzing_sample.py +3 −3
  4. tools/perf/scripts/python/failed-syscalls-by-pid.py +19 −19
  5. tools/perf/scripts/python/futex-contention.py +1 −1
  6. tools/perf/scripts/python/intel-pt-events.py +16 −16
  7. tools/perf/scripts/python/mem-phys-addr.py +4 −3
  8. tools/perf/scripts/python/net_dropmonitor.py +1 −1
  9. tools/perf/scripts/python/netdev-times.py +7 −5
  10. tools/perf/scripts/python/sched-migration.py +3 −3
  11. tools/perf/scripts/python/sctop.py +7 −6
  12. tools/perf/scripts/python/stackcollapse.py +1 −1
  13. tools/perf/scripts/python/syscall-counts-by-pid.py +23 −24
  14. tools/perf/scripts/python/syscall-counts.py +15 −16
tools/perf/scripts/python/check-perf-trace.py+32−33
@@ -23,60 +23,59 @@ def trace_begin(): · 22 unmodified lines
2323 pass
2424
2525 def trace_end():
26− print_unhandled()
26+ print_unhandled()
2727
2828 def irq__softirq_entry(event_name, context, common_cpu,
29− common_secs, common_nsecs, common_pid, common_comm,
30− common_callchain, vec):
31− print_header(event_name, common_cpu, common_secs, common_nsecs,
32− common_pid, common_comm)
29+ common_secs, common_nsecs, common_pid, common_comm,
30+ common_callchain, vec):
31+ print_header(event_name, common_cpu, common_secs, common_nsecs,
32+ common_pid, common_comm)
3333
34− print_uncommon(context)
34+ print_uncommon(context)
3535
36− print "vec=%s\n" % \
37− (symbol_str("irq__softirq_entry", "vec", vec)),
36+ print "vec=%s\n" % (symbol_str("irq__softirq_entry", "vec", vec)),
3837
3938 def kmem__kmalloc(event_name, context, common_cpu,
40− common_secs, common_nsecs, common_pid, common_comm,
41− common_callchain, call_site, ptr, bytes_req, bytes_alloc,
42− gfp_flags):
43− print_header(event_name, common_cpu, common_secs, common_nsecs,
44− common_pid, common_comm)
39+ common_secs, common_nsecs, common_pid, common_comm,
40+ common_callchain, call_site, ptr, bytes_req, bytes_alloc,
41+ gfp_flags):
42+ print_header(event_name, common_cpu, common_secs, common_nsecs,
43+ common_pid, common_comm)
4544
46− print_uncommon(context)
45+ print_uncommon(context)
4746
48− print "call_site=%u, ptr=%u, bytes_req=%u, " \
47+ print "call_site=%u, ptr=%u, bytes_req=%u, " \
4948 "bytes_alloc=%u, gfp_flags=%s\n" % \
5049 (call_site, ptr, bytes_req, bytes_alloc,
51−
5250 flag_str("kmem__kmalloc", "gfp_flags", gfp_flags)),
5351
5452 def trace_unhandled(event_name, context, event_fields_dict):
55− try:
56− unhandled[event_name] += 1
57− except TypeError:
58− unhandled[event_name] = 1
53+ try:
54+ unhandled[event_name] += 1
55+ except TypeError:
56+ unhandled[event_name] = 1
5957
6058 def print_header(event_name, cpu, secs, nsecs, pid, comm):
6159 print "%-20s %5u %05u.%09u %8u %-20s " % \
62− (event_name, cpu, secs, nsecs, pid, comm),
60+ (event_name, cpu, secs, nsecs, pid, comm),
6361
6462 # print trace fields not included in handler args
6563 def print_uncommon(context):
66− print "common_preempt_count=%d, common_flags=%s, common_lock_depth=%d, " \
67− % (common_pc(context), trace_flag_str(common_flags(context)), \
68− common_lock_depth(context))
64+ print "common_preempt_count=%d, common_flags=%s, " \
65+ "common_lock_depth=%d, " % \
66+ (common_pc(context), trace_flag_str(common_flags(context)),
67+ common_lock_depth(context))
6968
7069 def print_unhandled():
71− keys = unhandled.keys()
72− if not keys:
73− return
70+ keys = unhandled.keys()
71+ if not keys:
72+ return
7473
75− print "\nunhandled events:\n\n",
74+ print "\nunhandled events:\n\n",
7675
77− print "%-40s %10s\n" % ("event", "count"),
78− print "%-40s %10s\n" % ("----------------------------------------", \
79− "-----------"),
76+ print "%-40s %10s\n" % ("event", "count"),
77+ print "%-40s %10s\n" % ("----------------------------------------", \
78+ "-----------"),
8079
81− for event_name in keys:
82− print "%-40s %10d\n" % (event_name, unhandled[event_name])
80+ for event_name in keys:
81+ print "%-40s %10d\n" % (event_name, unhandled[event_name])
tools/perf/scripts/python/compaction-times.py+4−4
@@ -216,15 +216,15 @@ def compaction__mm_compaction_migratepages(event_name, context, common_cpu, · 215 unmodified lines
216216 pair(nr_migrated, nr_failed), None, None)
217217
218218 def compaction__mm_compaction_isolate_freepages(event_name, context, common_cpu,
219− common_secs, common_nsecs, common_pid, common_comm,
220− common_callchain, start_pfn, end_pfn, nr_scanned, nr_taken):
219+ common_secs, common_nsecs, common_pid, common_comm,
220+ common_callchain, start_pfn, end_pfn, nr_scanned, nr_taken):
221221
222222 chead.increment_pending(common_pid,
223223 None, pair(nr_scanned, nr_taken), None)
224224
225225 def compaction__mm_compaction_isolate_migratepages(event_name, context, common_cpu,
226− common_secs, common_nsecs, common_pid, common_comm,
227− common_callchain, start_pfn, end_pfn, nr_scanned, nr_taken):
226+ common_secs, common_nsecs, common_pid, common_comm,
227+ common_callchain, start_pfn, end_pfn, nr_scanned, nr_taken):
228228
229229 chead.increment_pending(common_pid,
230230 None, None, pair(nr_scanned, nr_taken))
tools/perf/scripts/python/event_analyzing_sample.py+3−3
@@ -37,7 +37,7 @@ con = sqlite3.connect("/dev/shm/perf.db") · 36 unmodified lines
3737 con.isolation_level = None
3838
3939 def trace_begin():
40− print "In trace_begin:\n"
40+ print "In trace_begin:\n"
4141
4242 #
4343 # Will create several tables at the start, pebs_ll is for PEBS data with
@@ -102,7 +102,7 @@ def insert_db(event): · 58 unmodified lines
102102 event.ip, event.status, event.dse, event.dla, event.lat))
103103
104104 def trace_end():
105− print "In trace_end:\n"
105+ print "In trace_end:\n"
106106 # We show the basic info for the 2 type of event classes
107107 show_general_events()
108108 show_pebs_ll()
@@ -187,4 +187,4 @@ def show_pebs_ll(): · 78 unmodified lines
187187 print "%32s %8d %s" % (row[0], row[1], num2sym(row[1]))
188188
189189 def trace_unhandled(event_name, context, event_fields_dict):
190− print ' '.join(['%s=%s'%(k,str(v))for k,v in sorted(event_fields_dict.items())])
190+ print ' '.join(['%s=%s'%(k,str(v))for k,v in sorted(event_fields_dict.items())])
tools/perf/scripts/python/failed-syscalls-by-pid.py+19−19
@@ -58,22 +58,22 @@ def syscalls__sys_exit(event_name, context, common_cpu, · 57 unmodified lines
5858 raw_syscalls__sys_exit(**locals())
5959
6060 def print_error_totals():
61− if for_comm is not None:
62− print("\nsyscall errors for %s:\n" % (for_comm))
63− else:
64− print("\nsyscall errors:\n")
65−
66− print("%-30s %10s" % ("comm [pid]", "count"))
67− print("%-30s %10s" % ("------------------------------", "----------"))
68−
69− comm_keys = syscalls.keys()
70− for comm in comm_keys:
71− pid_keys = syscalls[comm].keys()
72− for pid in pid_keys:
73− print("\n%s [%d]" % (comm, pid))
74− id_keys = syscalls[comm][pid].keys()
75− for id in id_keys:
76− print(" syscall: %-16s" % syscall_name(id))
77− ret_keys = syscalls[comm][pid][id].keys()
78− for ret, val in sorted(syscalls[comm][pid][id].items(), key = lambda kv: (kv[1], kv[0]), reverse = True):
79− print(" err = %-20s %10d" % (strerror(ret), val))
61+ if for_comm is not None:
62+ print("\nsyscall errors for %s:\n" % (for_comm))
63+ else:
64+ print("\nsyscall errors:\n")
65+
66+ print("%-30s %10s" % ("comm [pid]", "count"))
67+ print("%-30s %10s" % ("------------------------------", "----------"))
68+
69+ comm_keys = syscalls.keys()
70+ for comm in comm_keys:
71+ pid_keys = syscalls[comm].keys()
72+ for pid in pid_keys:
73+ print("\n%s [%d]" % (comm, pid))
74+ id_keys = syscalls[comm][pid].keys()
75+ for id in id_keys:
76+ print(" syscall: %-16s" % syscall_name(id))
77+ ret_keys = syscalls[comm][pid][id].keys()
78+ for ret, val in sorted(syscalls[comm][pid][id].items(), key = lambda kv: (kv[1], kv[0]), reverse = True):
79+ print(" err = %-20s %10d" % (strerror(ret), val))
tools/perf/scripts/python/futex-contention.py+1−1
@@ -46,5 +46,5 @@ def trace_end(): · 45 unmodified lines
4646 for (tid, lock) in lock_waits:
4747 min, max, avg, count = lock_waits[tid, lock]
4848 print "%s[%d] lock %x contended %d times, %d avg ns" % \
49− (process_names[tid], tid, lock, count, avg)
49+ (process_names[tid], tid, lock, count, avg)
5050
tools/perf/scripts/python/intel-pt-events.py+16−16
@@ -85,22 +85,22 @@ def print_common_ip(sample, symbol, dso): · 84 unmodified lines
8585 print "%16x %s (%s)" % (ip, symbol, dso)
8686
8787 def process_event(param_dict):
88− event_attr = param_dict["attr"]
89− sample = param_dict["sample"]
90− raw_buf = param_dict["raw_buf"]
91− comm = param_dict["comm"]
92− name = param_dict["ev_name"]
93−
94− # Symbol and dso info are not always resolved
95− if (param_dict.has_key("dso")):
96− dso = param_dict["dso"]
97− else:
98− dso = "[unknown]"
99−
100− if (param_dict.has_key("symbol")):
101− symbol = param_dict["symbol"]
102− else:
103− symbol = "[unknown]"
88+ event_attr = param_dict["attr"]
89+ sample = param_dict["sample"]
90+ raw_buf = param_dict["raw_buf"]
91+ comm = param_dict["comm"]
92+ name = param_dict["ev_name"]
93+
94+ # Symbol and dso info are not always resolved
95+ if (param_dict.has_key("dso")):
96+ dso = param_dict["dso"]
97+ else:
98+ dso = "[unknown]"
99+
100+ if (param_dict.has_key("symbol")):
101+ symbol = param_dict["symbol"]
102+ else:
103+ symbol = "[unknown]"
104104
105105 if name == "ptwrite":
106106 print_common_start(comm, sample, name)
tools/perf/scripts/python/mem-phys-addr.py+4−3
@@ -44,12 +44,13 @@ def print_memory_type(): · 43 unmodified lines
4444 print("%-40s %10s %10s\n" % ("Memory type", "count", "percentage"), end='')
4545 print("%-40s %10s %10s\n" % ("----------------------------------------",
4646 "-----------", "-----------"),
47− end='');
47+ end='');
4848 total = sum(load_mem_type_cnt.values())
4949 for mem_type, count in sorted(load_mem_type_cnt.most_common(), \
5050 key = lambda kv: (kv[1], kv[0]), reverse = True):
51− print("%-40s %10d %10.1f%%\n" % (mem_type, count, 100 * count / total),
52− end='')
51+ print("%-40s %10d %10.1f%%\n" %
52+ (mem_type, count, 100 * count / total),
53+ end='')
5354
5455 def trace_begin():
5556 parse_iomem()
tools/perf/scripts/python/net_dropmonitor.py+1−1
@@ -7,7 +7,7 @@ import os · 6 unmodified lines
77 import sys
88
99 sys.path.append(os.environ['PERF_EXEC_PATH'] + \
10− '/scripts/python/Perf-Trace-Util/lib/Perf/Trace')
10+ '/scripts/python/Perf-Trace-Util/lib/Perf/Trace')
1111
1212 from perf_trace_context import *
1313 from Core import *
tools/perf/scripts/python/netdev-times.py+7−5
@@ -124,14 +124,16 @@ def print_receive(hunk): · 123 unmodified lines
124124 event = event_list[i]
125125 if event['event_name'] == 'napi_poll':
126126 print(PF_NAPI_POLL %
127− (diff_msec(base_t, event['event_t']), event['dev']))
127+ (diff_msec(base_t, event['event_t']),
128+ event['dev']))
128129 if i == len(event_list) - 1:
129130 print("")
130131 else:
131132 print(PF_JOINT)
132133 else:
133134 print(PF_NET_RECV %
134− (diff_msec(base_t, event['event_t']), event['skbaddr'],
135+ (diff_msec(base_t, event['event_t']),
136+ event['skbaddr'],
135137 event['len']))
136138 if 'comm' in event.keys():
137139 print(PF_WJOINT)
@@ -256,7 +258,7 @@ def irq__irq_handler_exit(name, context, cpu, sec, nsec, pid, comm, callchain, i · 118 unmodified lines
256258 all_event_list.append(event_info)
257259
258260 def napi__napi_poll(name, context, cpu, sec, nsec, pid, comm, callchain, napi,
259− dev_name, work=None, budget=None):
261+ dev_name, work=None, budget=None):
260262 event_info = (name, context, cpu, nsecs(sec, nsec), pid, comm,
261263 napi, dev_name, work, budget)
262264 all_event_list.append(event_info)
@@ -353,7 +355,7 @@ def handle_irq_softirq_exit(event_info): · 90 unmodified lines
353355 if irq_list == [] or event_list == 0:
354356 return
355357 rec_data = {'sirq_ent_t':sirq_ent_t, 'sirq_ext_t':time,
356− 'irq_list':irq_list, 'event_list':event_list}
358+ 'irq_list':irq_list, 'event_list':event_list}
357359 # merge information realted to a NET_RX softirq
358360 receive_hunk_list.append(rec_data)
359361
@@ -390,7 +392,7 @@ def handle_netif_receive_skb(event_info): · 30 unmodified lines
390392 skbaddr, skblen, dev_name) = event_info
391393 if cpu in net_rx_dic.keys():
392394 rec_data = {'event_name':'netif_receive_skb',
393− 'event_t':time, 'skbaddr':skbaddr, 'len':skblen}
395+ 'event_t':time, 'skbaddr':skbaddr, 'len':skblen}
394396 event_list = net_rx_dic[cpu]['event_list']
395397 event_list.append(rec_data)
396398 rx_skb_list.insert(0, rec_data)
tools/perf/scripts/python/sched-migration.py+3−3
@@ -14,10 +14,10 @@ import sys · 13 unmodified lines
1414
1515 from collections import defaultdict
1616 try:
17− from UserList import UserList
17+ from UserList import UserList
1818 except ImportError:
19− # Python 3: UserList moved to the collections package
20− from collections import UserList
19+ # Python 3: UserList moved to the collections package
20+ from collections import UserList
2121
2222 sys.path.append(os.environ['PERF_EXEC_PATH'] + \
2323 '/scripts/python/Perf-Trace-Util/lib/Perf/Trace')
tools/perf/scripts/python/sctop.py+7−6
@@ -13,9 +13,9 @@ from __future__ import print_function · 12 unmodified lines
1313 import os, sys, time
1414
1515 try:
16− import thread
16+ import thread
1717 except ImportError:
18− import _thread as thread
18+ import _thread as thread
1919
2020 sys.path.append(os.environ['PERF_EXEC_PATH'] + \
2121 '/scripts/python/Perf-Trace-Util/lib/Perf/Trace')
@@ -75,11 +75,12 @@ def print_syscall_totals(interval): · 53 unmodified lines
7575
7676 print("%-40s %10s" % ("event", "count"))
7777 print("%-40s %10s" %
78− ("----------------------------------------",
79− "----------"))
78+ ("----------------------------------------",
79+ "----------"))
8080
81− for id, val in sorted(syscalls.items(), key = lambda kv: (kv[1], kv[0]), \
82− reverse = True):
81+ for id, val in sorted(syscalls.items(),
82+ key = lambda kv: (kv[1], kv[0]),
83+ reverse = True):
8384 try:
8485 print("%-40s %10d" % (syscall_name(id), val))
8586 except TypeError:
tools/perf/scripts/python/stackcollapse.py+1−1
@@ -27,7 +27,7 @@ from collections import defaultdict · 26 unmodified lines
2727 from optparse import OptionParser, make_option
2828
2929 sys.path.append(os.environ['PERF_EXEC_PATH'] + \
30− '/scripts/python/Perf-Trace-Util/lib/Perf/Trace')
30+ '/scripts/python/Perf-Trace-Util/lib/Perf/Trace')
3131
3232 from perf_trace_context import *
3333 from Core import *
tools/perf/scripts/python/syscall-counts-by-pid.py+23−24
@@ -39,11 +39,10 @@ def trace_end(): · 38 unmodified lines
3939 print_syscall_totals()
4040
4141 def raw_syscalls__sys_enter(event_name, context, common_cpu,
42− common_secs, common_nsecs, common_pid, common_comm,
43− common_callchain, id, args):
44−
42+ common_secs, common_nsecs, common_pid, common_comm,
43+ common_callchain, id, args):
4544 if (for_comm and common_comm != for_comm) or \
46− (for_pid and common_pid != for_pid ):
45+ (for_pid and common_pid != for_pid ):
4746 return
4847 try:
4948 syscalls[common_comm][common_pid][id] += 1
@@ -51,26 +50,26 @@ def raw_syscalls__sys_enter(event_name, context, common_cpu, · 1 unmodified line
5150 syscalls[common_comm][common_pid][id] = 1
5251
5352 def syscalls__sys_enter(event_name, context, common_cpu,
54− common_secs, common_nsecs, common_pid, common_comm,
55− id, args):
53+ common_secs, common_nsecs, common_pid, common_comm,
54+ id, args):
5655 raw_syscalls__sys_enter(**locals())
5756
5857 def print_syscall_totals():
59− if for_comm is not None:
60− print("\nsyscall events for %s:\n" % (for_comm))
61− else:
62− print("\nsyscall events by comm/pid:\n")
63−
64− print("%-40s %10s" % ("comm [pid]/syscalls", "count"))
65− print("%-40s %10s" % ("----------------------------------------",
66− "----------"))
67−
68− comm_keys = syscalls.keys()
69− for comm in comm_keys:
70− pid_keys = syscalls[comm].keys()
71− for pid in pid_keys:
72− print("\n%s [%d]" % (comm, pid))
73− id_keys = syscalls[comm][pid].keys()
74− for id, val in sorted(syscalls[comm][pid].items(), \
75− key = lambda kv: (kv[1], kv[0]), reverse = True):
76− print(" %-38s %10d" % (syscall_name(id), val))
58+ if for_comm is not None:
59+ print("\nsyscall events for %s:\n" % (for_comm))
60+ else:
61+ print("\nsyscall events by comm/pid:\n")
62+
63+ print("%-40s %10s" % ("comm [pid]/syscalls", "count"))
64+ print("%-40s %10s" % ("----------------------------------------",
65+ "----------"))
66+
67+ comm_keys = syscalls.keys()
68+ for comm in comm_keys:
69+ pid_keys = syscalls[comm].keys()
70+ for pid in pid_keys:
71+ print("\n%s [%d]" % (comm, pid))
72+ id_keys = syscalls[comm][pid].keys()
73+ for id, val in sorted(syscalls[comm][pid].items(),
74+ key = lambda kv: (kv[1], kv[0]), reverse = True):
75+ print(" %-38s %10d" % (syscall_name(id), val))
tools/perf/scripts/python/syscall-counts.py+15−16
@@ -36,8 +36,8 @@ def trace_end(): · 35 unmodified lines
3636 print_syscall_totals()
3737
3838 def raw_syscalls__sys_enter(event_name, context, common_cpu,
39− common_secs, common_nsecs, common_pid, common_comm,
40− common_callchain, id, args):
39+ common_secs, common_nsecs, common_pid, common_comm,
40+ common_callchain, id, args):
4141 if for_comm is not None:
4242 if common_comm != for_comm:
4343 return
@@ -47,20 +47,19 @@ def raw_syscalls__sys_enter(event_name, context, common_cpu, · 3 unmodified lines
4747 syscalls[id] = 1
4848
4949 def syscalls__sys_enter(event_name, context, common_cpu,
50− common_secs, common_nsecs, common_pid, common_comm,
51− id, args):
50+ common_secs, common_nsecs, common_pid, common_comm, id, args):
5251 raw_syscalls__sys_enter(**locals())
5352
5453 def print_syscall_totals():
55− if for_comm is not None:
56− print("\nsyscall events for %s:\n" % (for_comm))
57− else:
58− print("\nsyscall events:\n")
59−
60− print("%-40s %10s" % ("event", "count"))
61− print("%-40s %10s" % ("----------------------------------------",
62− "-----------"))
63−
64− for id, val in sorted(syscalls.items(), key = lambda kv: (kv[1], kv[0]), \
65− reverse = True):
66− print("%-40s %10d" % (syscall_name(id), val))
54+ if for_comm is not None:
55+ print("\nsyscall events for %s:\n" % (for_comm))
56+ else:
57+ print("\nsyscall events:\n")
58+
59+ print("%-40s %10s" % ("event", "count"))
60+ print("%-40s %10s" % ("----------------------------------------",
61+ "-----------"))
62+
63+ for id, val in sorted(syscalls.items(),
64+ key = lambda kv: (kv[1], kv[0]), reverse = True):
65+ print("%-40s %10d" % (syscall_name(id), val))