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.

Signed-off-by: Tony Jones <tonyj@suse.de>
Link: http://lkml.kernel.org/r/20190302011903.2416-2-tonyj@suse.de
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
Tony Jones 2019-03-01 17:18:57 -08:00 committed by Arnaldo Carvalho de Melo
parent c1d3e633e1
commit b504d7f687
14 changed files with 128 additions and 127 deletions

View File

@ -23,60 +23,59 @@ def trace_begin():
pass pass
def trace_end(): def trace_end():
print_unhandled() print_unhandled()
def irq__softirq_entry(event_name, context, common_cpu, def irq__softirq_entry(event_name, context, common_cpu,
common_secs, common_nsecs, common_pid, common_comm, common_secs, common_nsecs, common_pid, common_comm,
common_callchain, vec): common_callchain, vec):
print_header(event_name, common_cpu, common_secs, common_nsecs, print_header(event_name, common_cpu, common_secs, common_nsecs,
common_pid, common_comm) common_pid, common_comm)
print_uncommon(context) print_uncommon(context)
print "vec=%s\n" % \ print "vec=%s\n" % (symbol_str("irq__softirq_entry", "vec", vec)),
(symbol_str("irq__softirq_entry", "vec", vec)),
def kmem__kmalloc(event_name, context, common_cpu, def kmem__kmalloc(event_name, context, common_cpu,
common_secs, common_nsecs, common_pid, common_comm, common_secs, common_nsecs, common_pid, common_comm,
common_callchain, call_site, ptr, bytes_req, bytes_alloc, common_callchain, call_site, ptr, bytes_req, bytes_alloc,
gfp_flags): gfp_flags):
print_header(event_name, common_cpu, common_secs, common_nsecs, print_header(event_name, common_cpu, common_secs, common_nsecs,
common_pid, common_comm) common_pid, common_comm)
print_uncommon(context) print_uncommon(context)
print "call_site=%u, ptr=%u, bytes_req=%u, " \ print "call_site=%u, ptr=%u, bytes_req=%u, " \
"bytes_alloc=%u, gfp_flags=%s\n" % \ "bytes_alloc=%u, gfp_flags=%s\n" % \
(call_site, ptr, bytes_req, bytes_alloc, (call_site, ptr, bytes_req, bytes_alloc,
flag_str("kmem__kmalloc", "gfp_flags", gfp_flags)), flag_str("kmem__kmalloc", "gfp_flags", gfp_flags)),
def trace_unhandled(event_name, context, event_fields_dict): def trace_unhandled(event_name, context, event_fields_dict):
try: try:
unhandled[event_name] += 1 unhandled[event_name] += 1
except TypeError: except TypeError:
unhandled[event_name] = 1 unhandled[event_name] = 1
def print_header(event_name, cpu, secs, nsecs, pid, comm): def print_header(event_name, cpu, secs, nsecs, pid, comm):
print "%-20s %5u %05u.%09u %8u %-20s " % \ print "%-20s %5u %05u.%09u %8u %-20s " % \
(event_name, cpu, secs, nsecs, pid, comm), (event_name, cpu, secs, nsecs, pid, comm),
# print trace fields not included in handler args # print trace fields not included in handler args
def print_uncommon(context): def print_uncommon(context):
print "common_preempt_count=%d, common_flags=%s, common_lock_depth=%d, " \ print "common_preempt_count=%d, common_flags=%s, " \
% (common_pc(context), trace_flag_str(common_flags(context)), \ "common_lock_depth=%d, " % \
common_lock_depth(context)) (common_pc(context), trace_flag_str(common_flags(context)),
common_lock_depth(context))
def print_unhandled(): def print_unhandled():
keys = unhandled.keys() keys = unhandled.keys()
if not keys: if not keys:
return return
print "\nunhandled events:\n\n", print "\nunhandled events:\n\n",
print "%-40s %10s\n" % ("event", "count"), print "%-40s %10s\n" % ("event", "count"),
print "%-40s %10s\n" % ("----------------------------------------", \ print "%-40s %10s\n" % ("----------------------------------------", \
"-----------"), "-----------"),
for event_name in keys: for event_name in keys:
print "%-40s %10d\n" % (event_name, unhandled[event_name]) print "%-40s %10d\n" % (event_name, unhandled[event_name])

View File

@ -216,15 +216,15 @@ def compaction__mm_compaction_migratepages(event_name, context, common_cpu,
pair(nr_migrated, nr_failed), None, None) pair(nr_migrated, nr_failed), None, None)
def compaction__mm_compaction_isolate_freepages(event_name, context, common_cpu, def compaction__mm_compaction_isolate_freepages(event_name, context, common_cpu,
common_secs, common_nsecs, common_pid, common_comm, common_secs, common_nsecs, common_pid, common_comm,
common_callchain, start_pfn, end_pfn, nr_scanned, nr_taken): common_callchain, start_pfn, end_pfn, nr_scanned, nr_taken):
chead.increment_pending(common_pid, chead.increment_pending(common_pid,
None, pair(nr_scanned, nr_taken), None) None, pair(nr_scanned, nr_taken), None)
def compaction__mm_compaction_isolate_migratepages(event_name, context, common_cpu, def compaction__mm_compaction_isolate_migratepages(event_name, context, common_cpu,
common_secs, common_nsecs, common_pid, common_comm, common_secs, common_nsecs, common_pid, common_comm,
common_callchain, start_pfn, end_pfn, nr_scanned, nr_taken): common_callchain, start_pfn, end_pfn, nr_scanned, nr_taken):
chead.increment_pending(common_pid, chead.increment_pending(common_pid,
None, None, pair(nr_scanned, nr_taken)) None, None, pair(nr_scanned, nr_taken))

View File

@ -37,7 +37,7 @@ con = sqlite3.connect("/dev/shm/perf.db")
con.isolation_level = None con.isolation_level = None
def trace_begin(): def trace_begin():
print "In trace_begin:\n" print "In trace_begin:\n"
# #
# Will create several tables at the start, pebs_ll is for PEBS data with # Will create several tables at the start, pebs_ll is for PEBS data with
@ -102,7 +102,7 @@ def insert_db(event):
event.ip, event.status, event.dse, event.dla, event.lat)) event.ip, event.status, event.dse, event.dla, event.lat))
def trace_end(): def trace_end():
print "In trace_end:\n" print "In trace_end:\n"
# We show the basic info for the 2 type of event classes # We show the basic info for the 2 type of event classes
show_general_events() show_general_events()
show_pebs_ll() show_pebs_ll()
@ -187,4 +187,4 @@ def show_pebs_ll():
print "%32s %8d %s" % (row[0], row[1], num2sym(row[1])) print "%32s %8d %s" % (row[0], row[1], num2sym(row[1]))
def trace_unhandled(event_name, context, event_fields_dict): def trace_unhandled(event_name, context, event_fields_dict):
print ' '.join(['%s=%s'%(k,str(v))for k,v in sorted(event_fields_dict.items())]) print ' '.join(['%s=%s'%(k,str(v))for k,v in sorted(event_fields_dict.items())])

View File

@ -58,22 +58,22 @@ def syscalls__sys_exit(event_name, context, common_cpu,
raw_syscalls__sys_exit(**locals()) raw_syscalls__sys_exit(**locals())
def print_error_totals(): def print_error_totals():
if for_comm is not None: if for_comm is not None:
print("\nsyscall errors for %s:\n" % (for_comm)) print("\nsyscall errors for %s:\n" % (for_comm))
else: else:
print("\nsyscall errors:\n") print("\nsyscall errors:\n")
print("%-30s %10s" % ("comm [pid]", "count")) print("%-30s %10s" % ("comm [pid]", "count"))
print("%-30s %10s" % ("------------------------------", "----------")) print("%-30s %10s" % ("------------------------------", "----------"))
comm_keys = syscalls.keys() comm_keys = syscalls.keys()
for comm in comm_keys: for comm in comm_keys:
pid_keys = syscalls[comm].keys() pid_keys = syscalls[comm].keys()
for pid in pid_keys: for pid in pid_keys:
print("\n%s [%d]" % (comm, pid)) print("\n%s [%d]" % (comm, pid))
id_keys = syscalls[comm][pid].keys() id_keys = syscalls[comm][pid].keys()
for id in id_keys: for id in id_keys:
print(" syscall: %-16s" % syscall_name(id)) print(" syscall: %-16s" % syscall_name(id))
ret_keys = syscalls[comm][pid][id].keys() ret_keys = syscalls[comm][pid][id].keys()
for ret, val in sorted(syscalls[comm][pid][id].items(), key = lambda kv: (kv[1], kv[0]), reverse = True): for ret, val in sorted(syscalls[comm][pid][id].items(), key = lambda kv: (kv[1], kv[0]), reverse = True):
print(" err = %-20s %10d" % (strerror(ret), val)) print(" err = %-20s %10d" % (strerror(ret), val))

View File

@ -46,5 +46,5 @@ def trace_end():
for (tid, lock) in lock_waits: for (tid, lock) in lock_waits:
min, max, avg, count = lock_waits[tid, lock] min, max, avg, count = lock_waits[tid, lock]
print "%s[%d] lock %x contended %d times, %d avg ns" % \ print "%s[%d] lock %x contended %d times, %d avg ns" % \
(process_names[tid], tid, lock, count, avg) (process_names[tid], tid, lock, count, avg)

View File

@ -85,22 +85,22 @@ def print_common_ip(sample, symbol, dso):
print "%16x %s (%s)" % (ip, symbol, dso) print "%16x %s (%s)" % (ip, symbol, dso)
def process_event(param_dict): def process_event(param_dict):
event_attr = param_dict["attr"] event_attr = param_dict["attr"]
sample = param_dict["sample"] sample = param_dict["sample"]
raw_buf = param_dict["raw_buf"] raw_buf = param_dict["raw_buf"]
comm = param_dict["comm"] comm = param_dict["comm"]
name = param_dict["ev_name"] name = param_dict["ev_name"]
# Symbol and dso info are not always resolved # Symbol and dso info are not always resolved
if (param_dict.has_key("dso")): if (param_dict.has_key("dso")):
dso = param_dict["dso"] dso = param_dict["dso"]
else: else:
dso = "[unknown]" dso = "[unknown]"
if (param_dict.has_key("symbol")): if (param_dict.has_key("symbol")):
symbol = param_dict["symbol"] symbol = param_dict["symbol"]
else: else:
symbol = "[unknown]" symbol = "[unknown]"
if name == "ptwrite": if name == "ptwrite":
print_common_start(comm, sample, name) print_common_start(comm, sample, name)

View File

@ -44,12 +44,13 @@ def print_memory_type():
print("%-40s %10s %10s\n" % ("Memory type", "count", "percentage"), end='') print("%-40s %10s %10s\n" % ("Memory type", "count", "percentage"), end='')
print("%-40s %10s %10s\n" % ("----------------------------------------", print("%-40s %10s %10s\n" % ("----------------------------------------",
"-----------", "-----------"), "-----------", "-----------"),
end=''); end='');
total = sum(load_mem_type_cnt.values()) total = sum(load_mem_type_cnt.values())
for mem_type, count in sorted(load_mem_type_cnt.most_common(), \ for mem_type, count in sorted(load_mem_type_cnt.most_common(), \
key = lambda kv: (kv[1], kv[0]), reverse = True): key = lambda kv: (kv[1], kv[0]), reverse = True):
print("%-40s %10d %10.1f%%\n" % (mem_type, count, 100 * count / total), print("%-40s %10d %10.1f%%\n" %
end='') (mem_type, count, 100 * count / total),
end='')
def trace_begin(): def trace_begin():
parse_iomem() parse_iomem()

View File

@ -7,7 +7,7 @@ import os
import sys import sys
sys.path.append(os.environ['PERF_EXEC_PATH'] + \ sys.path.append(os.environ['PERF_EXEC_PATH'] + \
'/scripts/python/Perf-Trace-Util/lib/Perf/Trace') '/scripts/python/Perf-Trace-Util/lib/Perf/Trace')
from perf_trace_context import * from perf_trace_context import *
from Core import * from Core import *

View File

@ -124,14 +124,16 @@ def print_receive(hunk):
event = event_list[i] event = event_list[i]
if event['event_name'] == 'napi_poll': if event['event_name'] == 'napi_poll':
print(PF_NAPI_POLL % print(PF_NAPI_POLL %
(diff_msec(base_t, event['event_t']), event['dev'])) (diff_msec(base_t, event['event_t']),
event['dev']))
if i == len(event_list) - 1: if i == len(event_list) - 1:
print("") print("")
else: else:
print(PF_JOINT) print(PF_JOINT)
else: else:
print(PF_NET_RECV % print(PF_NET_RECV %
(diff_msec(base_t, event['event_t']), event['skbaddr'], (diff_msec(base_t, event['event_t']),
event['skbaddr'],
event['len'])) event['len']))
if 'comm' in event.keys(): if 'comm' in event.keys():
print(PF_WJOINT) print(PF_WJOINT)
@ -256,7 +258,7 @@ def irq__irq_handler_exit(name, context, cpu, sec, nsec, pid, comm, callchain, i
all_event_list.append(event_info) all_event_list.append(event_info)
def napi__napi_poll(name, context, cpu, sec, nsec, pid, comm, callchain, napi, def napi__napi_poll(name, context, cpu, sec, nsec, pid, comm, callchain, napi,
dev_name, work=None, budget=None): dev_name, work=None, budget=None):
event_info = (name, context, cpu, nsecs(sec, nsec), pid, comm, event_info = (name, context, cpu, nsecs(sec, nsec), pid, comm,
napi, dev_name, work, budget) napi, dev_name, work, budget)
all_event_list.append(event_info) all_event_list.append(event_info)
@ -353,7 +355,7 @@ def handle_irq_softirq_exit(event_info):
if irq_list == [] or event_list == 0: if irq_list == [] or event_list == 0:
return return
rec_data = {'sirq_ent_t':sirq_ent_t, 'sirq_ext_t':time, rec_data = {'sirq_ent_t':sirq_ent_t, 'sirq_ext_t':time,
'irq_list':irq_list, 'event_list':event_list} 'irq_list':irq_list, 'event_list':event_list}
# merge information realted to a NET_RX softirq # merge information realted to a NET_RX softirq
receive_hunk_list.append(rec_data) receive_hunk_list.append(rec_data)
@ -390,7 +392,7 @@ def handle_netif_receive_skb(event_info):
skbaddr, skblen, dev_name) = event_info skbaddr, skblen, dev_name) = event_info
if cpu in net_rx_dic.keys(): if cpu in net_rx_dic.keys():
rec_data = {'event_name':'netif_receive_skb', rec_data = {'event_name':'netif_receive_skb',
'event_t':time, 'skbaddr':skbaddr, 'len':skblen} 'event_t':time, 'skbaddr':skbaddr, 'len':skblen}
event_list = net_rx_dic[cpu]['event_list'] event_list = net_rx_dic[cpu]['event_list']
event_list.append(rec_data) event_list.append(rec_data)
rx_skb_list.insert(0, rec_data) rx_skb_list.insert(0, rec_data)

View File

@ -14,10 +14,10 @@ import sys
from collections import defaultdict from collections import defaultdict
try: try:
from UserList import UserList from UserList import UserList
except ImportError: except ImportError:
# Python 3: UserList moved to the collections package # Python 3: UserList moved to the collections package
from collections import UserList from collections import UserList
sys.path.append(os.environ['PERF_EXEC_PATH'] + \ sys.path.append(os.environ['PERF_EXEC_PATH'] + \
'/scripts/python/Perf-Trace-Util/lib/Perf/Trace') '/scripts/python/Perf-Trace-Util/lib/Perf/Trace')

View File

@ -13,9 +13,9 @@ from __future__ import print_function
import os, sys, time import os, sys, time
try: try:
import thread import thread
except ImportError: except ImportError:
import _thread as thread import _thread as thread
sys.path.append(os.environ['PERF_EXEC_PATH'] + \ sys.path.append(os.environ['PERF_EXEC_PATH'] + \
'/scripts/python/Perf-Trace-Util/lib/Perf/Trace') '/scripts/python/Perf-Trace-Util/lib/Perf/Trace')
@ -75,11 +75,12 @@ def print_syscall_totals(interval):
print("%-40s %10s" % ("event", "count")) print("%-40s %10s" % ("event", "count"))
print("%-40s %10s" % print("%-40s %10s" %
("----------------------------------------", ("----------------------------------------",
"----------")) "----------"))
for id, val in sorted(syscalls.items(), key = lambda kv: (kv[1], kv[0]), \ for id, val in sorted(syscalls.items(),
reverse = True): key = lambda kv: (kv[1], kv[0]),
reverse = True):
try: try:
print("%-40s %10d" % (syscall_name(id), val)) print("%-40s %10d" % (syscall_name(id), val))
except TypeError: except TypeError:

View File

@ -27,7 +27,7 @@ from collections import defaultdict
from optparse import OptionParser, make_option from optparse import OptionParser, make_option
sys.path.append(os.environ['PERF_EXEC_PATH'] + \ sys.path.append(os.environ['PERF_EXEC_PATH'] + \
'/scripts/python/Perf-Trace-Util/lib/Perf/Trace') '/scripts/python/Perf-Trace-Util/lib/Perf/Trace')
from perf_trace_context import * from perf_trace_context import *
from Core import * from Core import *

View File

@ -39,11 +39,10 @@ def trace_end():
print_syscall_totals() print_syscall_totals()
def raw_syscalls__sys_enter(event_name, context, common_cpu, def raw_syscalls__sys_enter(event_name, context, common_cpu,
common_secs, common_nsecs, common_pid, common_comm, common_secs, common_nsecs, common_pid, common_comm,
common_callchain, id, args): common_callchain, id, args):
if (for_comm and common_comm != for_comm) or \ if (for_comm and common_comm != for_comm) or \
(for_pid and common_pid != for_pid ): (for_pid and common_pid != for_pid ):
return return
try: try:
syscalls[common_comm][common_pid][id] += 1 syscalls[common_comm][common_pid][id] += 1
@ -51,26 +50,26 @@ def raw_syscalls__sys_enter(event_name, context, common_cpu,
syscalls[common_comm][common_pid][id] = 1 syscalls[common_comm][common_pid][id] = 1
def syscalls__sys_enter(event_name, context, common_cpu, def syscalls__sys_enter(event_name, context, common_cpu,
common_secs, common_nsecs, common_pid, common_comm, common_secs, common_nsecs, common_pid, common_comm,
id, args): id, args):
raw_syscalls__sys_enter(**locals()) raw_syscalls__sys_enter(**locals())
def print_syscall_totals(): def print_syscall_totals():
if for_comm is not None: if for_comm is not None:
print("\nsyscall events for %s:\n" % (for_comm)) print("\nsyscall events for %s:\n" % (for_comm))
else: else:
print("\nsyscall events by comm/pid:\n") print("\nsyscall events by comm/pid:\n")
print("%-40s %10s" % ("comm [pid]/syscalls", "count")) print("%-40s %10s" % ("comm [pid]/syscalls", "count"))
print("%-40s %10s" % ("----------------------------------------", print("%-40s %10s" % ("----------------------------------------",
"----------")) "----------"))
comm_keys = syscalls.keys() comm_keys = syscalls.keys()
for comm in comm_keys: for comm in comm_keys:
pid_keys = syscalls[comm].keys() pid_keys = syscalls[comm].keys()
for pid in pid_keys: for pid in pid_keys:
print("\n%s [%d]" % (comm, pid)) print("\n%s [%d]" % (comm, pid))
id_keys = syscalls[comm][pid].keys() id_keys = syscalls[comm][pid].keys()
for id, val in sorted(syscalls[comm][pid].items(), \ for id, val in sorted(syscalls[comm][pid].items(),
key = lambda kv: (kv[1], kv[0]), reverse = True): key = lambda kv: (kv[1], kv[0]), reverse = True):
print(" %-38s %10d" % (syscall_name(id), val)) print(" %-38s %10d" % (syscall_name(id), val))

View File

@ -36,8 +36,8 @@ def trace_end():
print_syscall_totals() print_syscall_totals()
def raw_syscalls__sys_enter(event_name, context, common_cpu, def raw_syscalls__sys_enter(event_name, context, common_cpu,
common_secs, common_nsecs, common_pid, common_comm, common_secs, common_nsecs, common_pid, common_comm,
common_callchain, id, args): common_callchain, id, args):
if for_comm is not None: if for_comm is not None:
if common_comm != for_comm: if common_comm != for_comm:
return return
@ -47,20 +47,19 @@ def raw_syscalls__sys_enter(event_name, context, common_cpu,
syscalls[id] = 1 syscalls[id] = 1
def syscalls__sys_enter(event_name, context, common_cpu, def syscalls__sys_enter(event_name, context, common_cpu,
common_secs, common_nsecs, common_pid, common_comm, common_secs, common_nsecs, common_pid, common_comm, id, args):
id, args):
raw_syscalls__sys_enter(**locals()) raw_syscalls__sys_enter(**locals())
def print_syscall_totals(): def print_syscall_totals():
if for_comm is not None: if for_comm is not None:
print("\nsyscall events for %s:\n" % (for_comm)) print("\nsyscall events for %s:\n" % (for_comm))
else: else:
print("\nsyscall events:\n") print("\nsyscall events:\n")
print("%-40s %10s" % ("event", "count")) print("%-40s %10s" % ("event", "count"))
print("%-40s %10s" % ("----------------------------------------", print("%-40s %10s" % ("----------------------------------------",
"-----------")) "-----------"))
for id, val in sorted(syscalls.items(), key = lambda kv: (kv[1], kv[0]), \ for id, val in sorted(syscalls.items(),
reverse = True): key = lambda kv: (kv[1], kv[0]), reverse = True):
print("%-40s %10d" % (syscall_name(id), val)) print("%-40s %10d" % (syscall_name(id), val))