OSDN Git Service

perf script python: Remove mixed indentation
authorTony Jones <tonyj@suse.de>
Sat, 2 Mar 2019 01:18:57 +0000 (17:18 -0800)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Wed, 6 Mar 2019 21:09:14 +0000 (18:09 -0300)
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>
14 files changed:
tools/perf/scripts/python/check-perf-trace.py
tools/perf/scripts/python/compaction-times.py
tools/perf/scripts/python/event_analyzing_sample.py
tools/perf/scripts/python/failed-syscalls-by-pid.py
tools/perf/scripts/python/futex-contention.py
tools/perf/scripts/python/intel-pt-events.py
tools/perf/scripts/python/mem-phys-addr.py
tools/perf/scripts/python/net_dropmonitor.py
tools/perf/scripts/python/netdev-times.py
tools/perf/scripts/python/sched-migration.py
tools/perf/scripts/python/sctop.py
tools/perf/scripts/python/stackcollapse.py
tools/perf/scripts/python/syscall-counts-by-pid.py
tools/perf/scripts/python/syscall-counts.py

index 334599c..f4838db 100644 (file)
@@ -23,60 +23,59 @@ def trace_begin():
        pass
 
 def trace_end():
-        print_unhandled()
+       print_unhandled()
 
 def irq__softirq_entry(event_name, context, common_cpu,
-       common_secs, common_nsecs, common_pid, common_comm,
-       common_callchain, vec):
-               print_header(event_name, common_cpu, common_secs, common_nsecs,
-                       common_pid, common_comm)
+                      common_secs, common_nsecs, common_pid, common_comm,
+                      common_callchain, vec):
+       print_header(event_name, common_cpu, common_secs, common_nsecs,
+               common_pid, common_comm)
 
-                print_uncommon(context)
+       print_uncommon(context)
 
-               print "vec=%s\n" % \
-               (symbol_str("irq__softirq_entry", "vec", vec)),
+       print "vec=%s\n" % (symbol_str("irq__softirq_entry", "vec", vec)),
 
 def kmem__kmalloc(event_name, context, common_cpu,
-       common_secs, common_nsecs, common_pid, common_comm,
-       common_callchain, call_site, ptr, bytes_req, bytes_alloc,
-       gfp_flags):
-               print_header(event_name, 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,
+                 gfp_flags):
+       print_header(event_name, common_cpu, common_secs, common_nsecs,
+               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" % \
                (call_site, ptr, bytes_req, bytes_alloc,
-
                flag_str("kmem__kmalloc", "gfp_flags", gfp_flags)),
 
 def trace_unhandled(event_name, context, event_fields_dict):
-    try:
-        unhandled[event_name] += 1
-    except TypeError:
-        unhandled[event_name] = 1
+       try:
+               unhandled[event_name] += 1
+       except TypeError:
+               unhandled[event_name] = 1
 
 def print_header(event_name, cpu, secs, nsecs, pid, comm):
        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
 def print_uncommon(context):
-    print "common_preempt_count=%d, common_flags=%s, common_lock_depth=%d, " \
-        % (common_pc(context), trace_flag_str(common_flags(context)), \
-               common_lock_depth(context))
+       print "common_preempt_count=%d, common_flags=%s, " \
+               "common_lock_depth=%d, " % \
+               (common_pc(context), trace_flag_str(common_flags(context)),
+               common_lock_depth(context))
 
 def print_unhandled():
-    keys = unhandled.keys()
-    if not keys:
-        return
+       keys = unhandled.keys()
+       if not keys:
+               return
 
-    print "\nunhandled events:\n\n",
+       print "\nunhandled events:\n\n",
 
-    print "%-40s  %10s\n" % ("event", "count"),
-    print "%-40s  %10s\n" % ("----------------------------------------", \
-                                 "-----------"),
+       print "%-40s  %10s\n" % ("event", "count"),
+       print "%-40s  %10s\n" % ("----------------------------------------", \
+                               "-----------"),
 
-    for event_name in keys:
-       print "%-40s  %10d\n" % (event_name, unhandled[event_name])
+       for event_name in keys:
+               print "%-40s  %10d\n" % (event_name, unhandled[event_name])
index 239cb05..2560a04 100644 (file)
@@ -216,15 +216,15 @@ def compaction__mm_compaction_migratepages(event_name, context, common_cpu,
                pair(nr_migrated, nr_failed), None, None)
 
 def compaction__mm_compaction_isolate_freepages(event_name, context, common_cpu,
-        common_secs, common_nsecs, common_pid, common_comm,
-        common_callchain, start_pfn, end_pfn, nr_scanned, nr_taken):
+       common_secs, common_nsecs, common_pid, common_comm,
+       common_callchain, start_pfn, end_pfn, nr_scanned, nr_taken):
 
        chead.increment_pending(common_pid,
                None, pair(nr_scanned, nr_taken), None)
 
 def compaction__mm_compaction_isolate_migratepages(event_name, context, common_cpu,
-        common_secs, common_nsecs, common_pid, common_comm,
-        common_callchain, start_pfn, end_pfn, nr_scanned, nr_taken):
+       common_secs, common_nsecs, common_pid, common_comm,
+       common_callchain, start_pfn, end_pfn, nr_scanned, nr_taken):
 
        chead.increment_pending(common_pid,
                None, None, pair(nr_scanned, nr_taken))
index 4e843b9..2ec8915 100644 (file)
@@ -37,7 +37,7 @@ con = sqlite3.connect("/dev/shm/perf.db")
 con.isolation_level = None
 
 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
@@ -102,7 +102,7 @@ def insert_db(event):
                                 event.ip, event.status, event.dse, event.dla, event.lat))
 
 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
         show_general_events()
         show_pebs_ll()
@@ -187,4 +187,4 @@ def show_pebs_ll():
              print "%32s %8d     %s" % (row[0], row[1], num2sym(row[1]))
 
 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())])
index 3648e8b..310efe5 100644 (file)
@@ -58,22 +58,22 @@ def syscalls__sys_exit(event_name, context, common_cpu,
        raw_syscalls__sys_exit(**locals())
 
 def print_error_totals():
-    if for_comm is not None:
-           print("\nsyscall errors for %s:\n" % (for_comm))
-    else:
-           print("\nsyscall errors:\n")
-
-    print("%-30s  %10s" % ("comm [pid]", "count"))
-    print("%-30s  %10s" % ("------------------------------", "----------"))
-
-    comm_keys = syscalls.keys()
-    for comm in comm_keys:
-           pid_keys = syscalls[comm].keys()
-           for pid in pid_keys:
-                   print("\n%s [%d]" % (comm, pid))
-                   id_keys = syscalls[comm][pid].keys()
-                   for id in id_keys:
-                           print("  syscall: %-16s" % syscall_name(id))
-                           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):
-                                   print("    err = %-20s  %10d" % (strerror(ret), val))
+       if for_comm is not None:
+               print("\nsyscall errors for %s:\n" % (for_comm))
+       else:
+               print("\nsyscall errors:\n")
+
+       print("%-30s  %10s" % ("comm [pid]", "count"))
+       print("%-30s  %10s" % ("------------------------------", "----------"))
+
+       comm_keys = syscalls.keys()
+       for comm in comm_keys:
+               pid_keys = syscalls[comm].keys()
+               for pid in pid_keys:
+                       print("\n%s [%d]" % (comm, pid))
+                       id_keys = syscalls[comm][pid].keys()
+                       for id in id_keys:
+                               print("  syscall: %-16s" % syscall_name(id))
+                               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):
+                                       print("    err = %-20s  %10d" % (strerror(ret), val))
index 0f5cf43..f221c62 100644 (file)
@@ -46,5 +46,5 @@ def trace_end():
        for (tid, lock) in lock_waits:
                min, max, avg, count = lock_waits[tid, lock]
                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)
 
index b19172d..2177722 100644 (file)
@@ -85,22 +85,22 @@ def print_common_ip(sample, symbol, dso):
        print "%16x %s (%s)" % (ip, symbol, dso)
 
 def process_event(param_dict):
-        event_attr = param_dict["attr"]
-        sample     = param_dict["sample"]
-        raw_buf    = param_dict["raw_buf"]
-        comm       = param_dict["comm"]
-        name       = param_dict["ev_name"]
-
-        # Symbol and dso info are not always resolved
-        if (param_dict.has_key("dso")):
-                dso = param_dict["dso"]
-        else:
-                dso = "[unknown]"
-
-        if (param_dict.has_key("symbol")):
-                symbol = param_dict["symbol"]
-        else:
-                symbol = "[unknown]"
+       event_attr = param_dict["attr"]
+       sample   = param_dict["sample"]
+       raw_buf = param_dict["raw_buf"]
+       comm       = param_dict["comm"]
+       name       = param_dict["ev_name"]
+
+       # Symbol and dso info are not always resolved
+       if (param_dict.has_key("dso")):
+               dso = param_dict["dso"]
+       else:
+               dso = "[unknown]"
+
+       if (param_dict.has_key("symbol")):
+               symbol = param_dict["symbol"]
+       else:
+               symbol = "[unknown]"
 
        if name == "ptwrite":
                print_common_start(comm, sample, name)
index fb0bbcb..1f332e7 100644 (file)
@@ -44,12 +44,13 @@ def print_memory_type():
        print("%-40s  %10s  %10s\n" % ("Memory type", "count", "percentage"), end='')
        print("%-40s  %10s  %10s\n" % ("----------------------------------------",
                                        "-----------", "-----------"),
-                                        end='');
+                                       end='');
        total = sum(load_mem_type_cnt.values())
        for mem_type, count in sorted(load_mem_type_cnt.most_common(), \
                                        key = lambda kv: (kv[1], kv[0]), reverse = True):
-               print("%-40s  %10d  %10.1f%%\n" % (mem_type, count, 100 * count / total),
-                        end='')
+               print("%-40s  %10d  %10.1f%%\n" %
+                       (mem_type, count, 100 * count / total),
+                       end='')
 
 def trace_begin():
        parse_iomem()
index 212557a..1010599 100755 (executable)
@@ -7,7 +7,7 @@ import os
 import sys
 
 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 Core import *
index 267bda4..ea0c8b9 100644 (file)
@@ -124,14 +124,16 @@ def print_receive(hunk):
                event = event_list[i]
                if event['event_name'] == '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:
                                print("")
                        else:
                                print(PF_JOINT)
                else:
                        print(PF_NET_RECV %
-                           (diff_msec(base_t, event['event_t']), event['skbaddr'],
+                               (diff_msec(base_t, event['event_t']),
+                               event['skbaddr'],
                                event['len']))
                        if 'comm' in event.keys():
                                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)
 
 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,
                        napi, dev_name, work, budget)
        all_event_list.append(event_info)
@@ -353,7 +355,7 @@ def handle_irq_softirq_exit(event_info):
        if irq_list == [] or event_list == 0:
                return
        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
        receive_hunk_list.append(rec_data)
 
@@ -390,7 +392,7 @@ def handle_netif_receive_skb(event_info):
                skbaddr, skblen, dev_name) = event_info
        if cpu in net_rx_dic.keys():
                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.append(rec_data)
                rx_skb_list.insert(0, rec_data)
index 3984bf5..8196e30 100644 (file)
@@ -14,10 +14,10 @@ import sys
 
 from collections import defaultdict
 try:
-    from UserList import UserList
+       from UserList import UserList
 except ImportError:
-    # Python 3: UserList moved to the collections package
-    from collections import UserList
+       # Python 3: UserList moved to the collections package
+       from collections import UserList
 
 sys.path.append(os.environ['PERF_EXEC_PATH'] + \
        '/scripts/python/Perf-Trace-Util/lib/Perf/Trace')
index 987ffae..6e0278d 100644 (file)
@@ -13,9 +13,9 @@ from __future__ import print_function
 import os, sys, time
 
 try:
-        import thread
+       import thread
 except ImportError:
-        import _thread as thread
+       import _thread as thread
 
 sys.path.append(os.environ['PERF_EXEC_PATH'] + \
        '/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" %
-                        ("----------------------------------------",
-                        "----------"))
+                       ("----------------------------------------",
+                       "----------"))
 
-               for id, val in sorted(syscalls.items(), key = lambda kv: (kv[1], kv[0]), \
-                                             reverse = True):
+               for id, val in sorted(syscalls.items(),
+                               key = lambda kv: (kv[1], kv[0]),
+                               reverse = True):
                        try:
                                print("%-40s  %10d" % (syscall_name(id), val))
                        except TypeError:
index 5e703ef..b1c4def 100755 (executable)
@@ -27,7 +27,7 @@ from collections import defaultdict
 from optparse import OptionParser, make_option
 
 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 Core import *
index 4278248..f254e40 100644 (file)
@@ -39,11 +39,10 @@ def trace_end():
        print_syscall_totals()
 
 def raw_syscalls__sys_enter(event_name, context, common_cpu,
-       common_secs, common_nsecs, common_pid, common_comm,
-       common_callchain, id, args):
-
+               common_secs, common_nsecs, common_pid, common_comm,
+               common_callchain, id, args):
        if (for_comm and common_comm != for_comm) or \
-          (for_pid  and common_pid  != for_pid ):
+               (for_pid and common_pid != for_pid ):
                return
        try:
                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
 
 def syscalls__sys_enter(event_name, context, common_cpu,
-       common_secs, common_nsecs, common_pid, common_comm,
-       id, args):
+               common_secs, common_nsecs, common_pid, common_comm,
+               id, args):
        raw_syscalls__sys_enter(**locals())
 
 def print_syscall_totals():
-    if for_comm is not None:
-           print("\nsyscall events for %s:\n" % (for_comm))
-    else:
-           print("\nsyscall events by comm/pid:\n")
-
-    print("%-40s  %10s" % ("comm [pid]/syscalls", "count"))
-    print("%-40s  %10s" % ("----------------------------------------",
-                            "----------"))
-
-    comm_keys = syscalls.keys()
-    for comm in comm_keys:
-           pid_keys = syscalls[comm].keys()
-           for pid in pid_keys:
-                   print("\n%s [%d]" % (comm, pid))
-                   id_keys = syscalls[comm][pid].keys()
-                   for id, val in sorted(syscalls[comm][pid].items(), \
-                                 key = lambda kv: (kv[1], kv[0]),  reverse = True):
-                           print("  %-38s  %10d" % (syscall_name(id), val))
+       if for_comm is not None:
+               print("\nsyscall events for %s:\n" % (for_comm))
+       else:
+               print("\nsyscall events by comm/pid:\n")
+
+       print("%-40s  %10s" % ("comm [pid]/syscalls", "count"))
+       print("%-40s  %10s" % ("----------------------------------------",
+                               "----------"))
+
+       comm_keys = syscalls.keys()
+       for comm in comm_keys:
+               pid_keys = syscalls[comm].keys()
+               for pid in pid_keys:
+                       print("\n%s [%d]" % (comm, pid))
+                       id_keys = syscalls[comm][pid].keys()
+                       for id, val in sorted(syscalls[comm][pid].items(),
+                               key = lambda kv: (kv[1], kv[0]), reverse = True):
+                               print("  %-38s  %10d" % (syscall_name(id), val))
index 0ebd89c..8adb95f 100644 (file)
@@ -36,8 +36,8 @@ def trace_end():
        print_syscall_totals()
 
 def raw_syscalls__sys_enter(event_name, context, common_cpu,
-       common_secs, common_nsecs, common_pid, common_comm,
-       common_callchain, id, args):
+               common_secs, common_nsecs, common_pid, common_comm,
+               common_callchain, id, args):
        if for_comm is not None:
                if common_comm != for_comm:
                        return
@@ -47,20 +47,19 @@ def raw_syscalls__sys_enter(event_name, context, common_cpu,
                syscalls[id] = 1
 
 def syscalls__sys_enter(event_name, context, common_cpu,
-       common_secs, common_nsecs, common_pid, common_comm,
-       id, args):
+               common_secs, common_nsecs, common_pid, common_comm, id, args):
        raw_syscalls__sys_enter(**locals())
 
 def print_syscall_totals():
-    if for_comm is not None:
-           print("\nsyscall events for %s:\n" % (for_comm))
-    else:
-           print("\nsyscall events:\n")
-
-    print("%-40s  %10s" % ("event", "count"))
-    print("%-40s  %10s" % ("----------------------------------------",
-                              "-----------"))
-
-    for id, val in sorted(syscalls.items(), key = lambda kv: (kv[1], kv[0]), \
-                                 reverse = True):
-           print("%-40s  %10d" % (syscall_name(id), val))
+       if for_comm is not None:
+               print("\nsyscall events for %s:\n" % (for_comm))
+       else:
+               print("\nsyscall events:\n")
+
+       print("%-40s  %10s" % ("event", "count"))
+       print("%-40s  %10s" % ("----------------------------------------",
+                               "-----------"))
+
+       for id, val in sorted(syscalls.items(),
+                       key = lambda kv: (kv[1], kv[0]), reverse = True):
+               print("%-40s  %10d" % (syscall_name(id), val))