diff options
Diffstat (limited to 'tools/perf/scripts/python')
| -rw-r--r-- | tools/perf/scripts/python/check-perf-trace.py | 65 | ||||
| -rw-r--r-- | tools/perf/scripts/python/compaction-times.py | 8 | ||||
| -rw-r--r-- | tools/perf/scripts/python/event_analyzing_sample.py | 6 | ||||
| -rw-r--r-- | tools/perf/scripts/python/failed-syscalls-by-pid.py | 38 | ||||
| -rw-r--r-- | tools/perf/scripts/python/futex-contention.py | 2 | ||||
| -rw-r--r-- | tools/perf/scripts/python/intel-pt-events.py | 32 | ||||
| -rw-r--r-- | tools/perf/scripts/python/mem-phys-addr.py | 7 | ||||
| -rwxr-xr-x | tools/perf/scripts/python/net_dropmonitor.py | 2 | ||||
| -rw-r--r-- | tools/perf/scripts/python/netdev-times.py | 12 | ||||
| -rw-r--r-- | tools/perf/scripts/python/sched-migration.py | 6 | ||||
| -rw-r--r-- | tools/perf/scripts/python/sctop.py | 13 | ||||
| -rwxr-xr-x | tools/perf/scripts/python/stackcollapse.py | 2 | ||||
| -rw-r--r-- | tools/perf/scripts/python/syscall-counts-by-pid.py | 47 | ||||
| -rw-r--r-- | tools/perf/scripts/python/syscall-counts.py | 31 |
14 files changed, 136 insertions, 135 deletions
diff --git a/tools/perf/scripts/python/check-perf-trace.py b/tools/perf/scripts/python/check-perf-trace.py index 334599c6032c..f4838db3e518 100644 --- a/tools/perf/scripts/python/check-perf-trace.py +++ b/tools/perf/scripts/python/check-perf-trace.py | |||
| @@ -23,60 +23,59 @@ def trace_begin(): | |||
| 23 | pass | 23 | pass |
| 24 | 24 | ||
| 25 | def trace_end(): | 25 | def trace_end(): |
| 26 | print_unhandled() | 26 | print_unhandled() |
| 27 | 27 | ||
| 28 | def irq__softirq_entry(event_name, context, common_cpu, | 28 | def irq__softirq_entry(event_name, context, common_cpu, |
| 29 | common_secs, common_nsecs, common_pid, common_comm, | 29 | common_secs, common_nsecs, common_pid, common_comm, |
| 30 | common_callchain, vec): | 30 | common_callchain, vec): |
| 31 | print_header(event_name, common_cpu, common_secs, common_nsecs, | 31 | print_header(event_name, common_cpu, common_secs, common_nsecs, |
| 32 | common_pid, common_comm) | 32 | common_pid, common_comm) |
| 33 | 33 | ||
| 34 | print_uncommon(context) | 34 | print_uncommon(context) |
| 35 | 35 | ||
| 36 | print "vec=%s\n" % \ | 36 | print "vec=%s\n" % (symbol_str("irq__softirq_entry", "vec", vec)), |
| 37 | (symbol_str("irq__softirq_entry", "vec", vec)), | ||
| 38 | 37 | ||
| 39 | def kmem__kmalloc(event_name, context, common_cpu, | 38 | def kmem__kmalloc(event_name, context, common_cpu, |
| 40 | common_secs, common_nsecs, common_pid, common_comm, | 39 | common_secs, common_nsecs, common_pid, common_comm, |
| 41 | common_callchain, call_site, ptr, bytes_req, bytes_alloc, | 40 | common_callchain, call_site, ptr, bytes_req, bytes_alloc, |
| 42 | gfp_flags): | 41 | gfp_flags): |
| 43 | print_header(event_name, common_cpu, common_secs, common_nsecs, | 42 | print_header(event_name, common_cpu, common_secs, common_nsecs, |
| 44 | common_pid, common_comm) | 43 | common_pid, common_comm) |
| 45 | 44 | ||
| 46 | print_uncommon(context) | 45 | print_uncommon(context) |
| 47 | 46 | ||
| 48 | print "call_site=%u, ptr=%u, bytes_req=%u, " \ | 47 | print "call_site=%u, ptr=%u, bytes_req=%u, " \ |
| 49 | "bytes_alloc=%u, gfp_flags=%s\n" % \ | 48 | "bytes_alloc=%u, gfp_flags=%s\n" % \ |
| 50 | (call_site, ptr, bytes_req, bytes_alloc, | 49 | (call_site, ptr, bytes_req, bytes_alloc, |
| 51 | |||
| 52 | flag_str("kmem__kmalloc", "gfp_flags", gfp_flags)), | 50 | flag_str("kmem__kmalloc", "gfp_flags", gfp_flags)), |
| 53 | 51 | ||
| 54 | def trace_unhandled(event_name, context, event_fields_dict): | 52 | def trace_unhandled(event_name, context, event_fields_dict): |
| 55 | try: | 53 | try: |
| 56 | unhandled[event_name] += 1 | 54 | unhandled[event_name] += 1 |
| 57 | except TypeError: | 55 | except TypeError: |
| 58 | unhandled[event_name] = 1 | 56 | unhandled[event_name] = 1 |
| 59 | 57 | ||
| 60 | def print_header(event_name, cpu, secs, nsecs, pid, comm): | 58 | def print_header(event_name, cpu, secs, nsecs, pid, comm): |
| 61 | print "%-20s %5u %05u.%09u %8u %-20s " % \ | 59 | print "%-20s %5u %05u.%09u %8u %-20s " % \ |
| 62 | (event_name, cpu, secs, nsecs, pid, comm), | 60 | (event_name, cpu, secs, nsecs, pid, comm), |
| 63 | 61 | ||
| 64 | # print trace fields not included in handler args | 62 | # print trace fields not included in handler args |
| 65 | def print_uncommon(context): | 63 | def print_uncommon(context): |
| 66 | print "common_preempt_count=%d, common_flags=%s, common_lock_depth=%d, " \ | 64 | print "common_preempt_count=%d, common_flags=%s, " \ |
| 67 | % (common_pc(context), trace_flag_str(common_flags(context)), \ | 65 | "common_lock_depth=%d, " % \ |
| 68 | common_lock_depth(context)) | 66 | (common_pc(context), trace_flag_str(common_flags(context)), |
| 67 | common_lock_depth(context)) | ||
| 69 | 68 | ||
| 70 | def print_unhandled(): | 69 | def print_unhandled(): |
| 71 | keys = unhandled.keys() | 70 | keys = unhandled.keys() |
| 72 | if not keys: | 71 | if not keys: |
| 73 | return | 72 | return |
| 74 | 73 | ||
| 75 | print "\nunhandled events:\n\n", | 74 | print "\nunhandled events:\n\n", |
| 76 | 75 | ||
| 77 | print "%-40s %10s\n" % ("event", "count"), | 76 | print "%-40s %10s\n" % ("event", "count"), |
| 78 | print "%-40s %10s\n" % ("----------------------------------------", \ | 77 | print "%-40s %10s\n" % ("----------------------------------------", \ |
| 79 | "-----------"), | 78 | "-----------"), |
| 80 | 79 | ||
| 81 | for event_name in keys: | 80 | for event_name in keys: |
| 82 | print "%-40s %10d\n" % (event_name, unhandled[event_name]) | 81 | print "%-40s %10d\n" % (event_name, unhandled[event_name]) |
diff --git a/tools/perf/scripts/python/compaction-times.py b/tools/perf/scripts/python/compaction-times.py index 239cb0568ec3..2560a042dc6f 100644 --- a/tools/perf/scripts/python/compaction-times.py +++ b/tools/perf/scripts/python/compaction-times.py | |||
| @@ -216,15 +216,15 @@ def compaction__mm_compaction_migratepages(event_name, context, common_cpu, | |||
| 216 | pair(nr_migrated, nr_failed), None, None) | 216 | pair(nr_migrated, nr_failed), None, None) |
| 217 | 217 | ||
| 218 | def compaction__mm_compaction_isolate_freepages(event_name, context, common_cpu, | 218 | def compaction__mm_compaction_isolate_freepages(event_name, context, common_cpu, |
| 219 | common_secs, common_nsecs, common_pid, common_comm, | 219 | common_secs, common_nsecs, common_pid, common_comm, |
| 220 | common_callchain, start_pfn, end_pfn, nr_scanned, nr_taken): | 220 | common_callchain, start_pfn, end_pfn, nr_scanned, nr_taken): |
| 221 | 221 | ||
| 222 | chead.increment_pending(common_pid, | 222 | chead.increment_pending(common_pid, |
| 223 | None, pair(nr_scanned, nr_taken), None) | 223 | None, pair(nr_scanned, nr_taken), None) |
| 224 | 224 | ||
| 225 | def compaction__mm_compaction_isolate_migratepages(event_name, context, common_cpu, | 225 | def compaction__mm_compaction_isolate_migratepages(event_name, context, common_cpu, |
| 226 | common_secs, common_nsecs, common_pid, common_comm, | 226 | common_secs, common_nsecs, common_pid, common_comm, |
| 227 | common_callchain, start_pfn, end_pfn, nr_scanned, nr_taken): | 227 | common_callchain, start_pfn, end_pfn, nr_scanned, nr_taken): |
| 228 | 228 | ||
| 229 | chead.increment_pending(common_pid, | 229 | chead.increment_pending(common_pid, |
| 230 | None, None, pair(nr_scanned, nr_taken)) | 230 | None, None, pair(nr_scanned, nr_taken)) |
diff --git a/tools/perf/scripts/python/event_analyzing_sample.py b/tools/perf/scripts/python/event_analyzing_sample.py index 4e843b9864ec..2ec8915b74c5 100644 --- a/tools/perf/scripts/python/event_analyzing_sample.py +++ b/tools/perf/scripts/python/event_analyzing_sample.py | |||
| @@ -37,7 +37,7 @@ con = sqlite3.connect("/dev/shm/perf.db") | |||
| 37 | con.isolation_level = None | 37 | con.isolation_level = None |
| 38 | 38 | ||
| 39 | def trace_begin(): | 39 | def trace_begin(): |
| 40 | print "In trace_begin:\n" | 40 | print "In trace_begin:\n" |
| 41 | 41 | ||
| 42 | # | 42 | # |
| 43 | # Will create several tables at the start, pebs_ll is for PEBS data with | 43 | # Will create several tables at the start, pebs_ll is for PEBS data with |
| @@ -102,7 +102,7 @@ def insert_db(event): | |||
| 102 | event.ip, event.status, event.dse, event.dla, event.lat)) | 102 | event.ip, event.status, event.dse, event.dla, event.lat)) |
| 103 | 103 | ||
| 104 | def trace_end(): | 104 | def trace_end(): |
| 105 | print "In trace_end:\n" | 105 | print "In trace_end:\n" |
| 106 | # We show the basic info for the 2 type of event classes | 106 | # We show the basic info for the 2 type of event classes |
| 107 | show_general_events() | 107 | show_general_events() |
| 108 | show_pebs_ll() | 108 | show_pebs_ll() |
| @@ -187,4 +187,4 @@ def show_pebs_ll(): | |||
| 187 | print "%32s %8d %s" % (row[0], row[1], num2sym(row[1])) | 187 | print "%32s %8d %s" % (row[0], row[1], num2sym(row[1])) |
| 188 | 188 | ||
| 189 | def trace_unhandled(event_name, context, event_fields_dict): | 189 | 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())]) |
diff --git a/tools/perf/scripts/python/failed-syscalls-by-pid.py b/tools/perf/scripts/python/failed-syscalls-by-pid.py index 3648e8b986ec..310efe5e7e23 100644 --- a/tools/perf/scripts/python/failed-syscalls-by-pid.py +++ b/tools/perf/scripts/python/failed-syscalls-by-pid.py | |||
| @@ -58,22 +58,22 @@ def syscalls__sys_exit(event_name, context, common_cpu, | |||
| 58 | raw_syscalls__sys_exit(**locals()) | 58 | raw_syscalls__sys_exit(**locals()) |
| 59 | 59 | ||
| 60 | def print_error_totals(): | 60 | def print_error_totals(): |
| 61 | if for_comm is not None: | 61 | if for_comm is not None: |
| 62 | print("\nsyscall errors for %s:\n" % (for_comm)) | 62 | print("\nsyscall errors for %s:\n" % (for_comm)) |
| 63 | else: | 63 | else: |
| 64 | print("\nsyscall errors:\n") | 64 | print("\nsyscall errors:\n") |
| 65 | 65 | ||
| 66 | print("%-30s %10s" % ("comm [pid]", "count")) | 66 | print("%-30s %10s" % ("comm [pid]", "count")) |
| 67 | print("%-30s %10s" % ("------------------------------", "----------")) | 67 | print("%-30s %10s" % ("------------------------------", "----------")) |
| 68 | 68 | ||
| 69 | comm_keys = syscalls.keys() | 69 | comm_keys = syscalls.keys() |
| 70 | for comm in comm_keys: | 70 | for comm in comm_keys: |
| 71 | pid_keys = syscalls[comm].keys() | 71 | pid_keys = syscalls[comm].keys() |
| 72 | for pid in pid_keys: | 72 | for pid in pid_keys: |
| 73 | print("\n%s [%d]" % (comm, pid)) | 73 | print("\n%s [%d]" % (comm, pid)) |
| 74 | id_keys = syscalls[comm][pid].keys() | 74 | id_keys = syscalls[comm][pid].keys() |
| 75 | for id in id_keys: | 75 | for id in id_keys: |
| 76 | print(" syscall: %-16s" % syscall_name(id)) | 76 | print(" syscall: %-16s" % syscall_name(id)) |
| 77 | ret_keys = syscalls[comm][pid][id].keys() | 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): | 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)) | 79 | print(" err = %-20s %10d" % (strerror(ret), val)) |
diff --git a/tools/perf/scripts/python/futex-contention.py b/tools/perf/scripts/python/futex-contention.py index 0f5cf437b602..f221c62e0a10 100644 --- a/tools/perf/scripts/python/futex-contention.py +++ b/tools/perf/scripts/python/futex-contention.py | |||
| @@ -46,5 +46,5 @@ def trace_end(): | |||
| 46 | for (tid, lock) in lock_waits: | 46 | for (tid, lock) in lock_waits: |
| 47 | min, max, avg, count = lock_waits[tid, lock] | 47 | min, max, avg, count = lock_waits[tid, lock] |
| 48 | print "%s[%d] lock %x contended %d times, %d avg ns" % \ | 48 | 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) |
| 50 | 50 | ||
diff --git a/tools/perf/scripts/python/intel-pt-events.py b/tools/perf/scripts/python/intel-pt-events.py index b19172d673af..2177722f509e 100644 --- a/tools/perf/scripts/python/intel-pt-events.py +++ b/tools/perf/scripts/python/intel-pt-events.py | |||
| @@ -85,22 +85,22 @@ def print_common_ip(sample, symbol, dso): | |||
| 85 | print "%16x %s (%s)" % (ip, symbol, dso) | 85 | print "%16x %s (%s)" % (ip, symbol, dso) |
| 86 | 86 | ||
| 87 | def process_event(param_dict): | 87 | def process_event(param_dict): |
| 88 | event_attr = param_dict["attr"] | 88 | event_attr = param_dict["attr"] |
| 89 | sample = param_dict["sample"] | 89 | sample = param_dict["sample"] |
| 90 | raw_buf = param_dict["raw_buf"] | 90 | raw_buf = param_dict["raw_buf"] |
| 91 | comm = param_dict["comm"] | 91 | comm = param_dict["comm"] |
| 92 | name = param_dict["ev_name"] | 92 | name = param_dict["ev_name"] |
| 93 | 93 | ||
| 94 | # Symbol and dso info are not always resolved | 94 | # Symbol and dso info are not always resolved |
| 95 | if (param_dict.has_key("dso")): | 95 | if (param_dict.has_key("dso")): |
| 96 | dso = param_dict["dso"] | 96 | dso = param_dict["dso"] |
| 97 | else: | 97 | else: |
| 98 | dso = "[unknown]" | 98 | dso = "[unknown]" |
| 99 | 99 | ||
| 100 | if (param_dict.has_key("symbol")): | 100 | if (param_dict.has_key("symbol")): |
| 101 | symbol = param_dict["symbol"] | 101 | symbol = param_dict["symbol"] |
| 102 | else: | 102 | else: |
| 103 | symbol = "[unknown]" | 103 | symbol = "[unknown]" |
| 104 | 104 | ||
| 105 | if name == "ptwrite": | 105 | if name == "ptwrite": |
| 106 | print_common_start(comm, sample, name) | 106 | print_common_start(comm, sample, name) |
diff --git a/tools/perf/scripts/python/mem-phys-addr.py b/tools/perf/scripts/python/mem-phys-addr.py index fb0bbcbfa0f0..1f332e72b9b0 100644 --- a/tools/perf/scripts/python/mem-phys-addr.py +++ b/tools/perf/scripts/python/mem-phys-addr.py | |||
| @@ -44,12 +44,13 @@ def print_memory_type(): | |||
| 44 | print("%-40s %10s %10s\n" % ("Memory type", "count", "percentage"), end='') | 44 | print("%-40s %10s %10s\n" % ("Memory type", "count", "percentage"), end='') |
| 45 | print("%-40s %10s %10s\n" % ("----------------------------------------", | 45 | print("%-40s %10s %10s\n" % ("----------------------------------------", |
| 46 | "-----------", "-----------"), | 46 | "-----------", "-----------"), |
| 47 | end=''); | 47 | end=''); |
| 48 | total = sum(load_mem_type_cnt.values()) | 48 | total = sum(load_mem_type_cnt.values()) |
| 49 | for mem_type, count in sorted(load_mem_type_cnt.most_common(), \ | 49 | for mem_type, count in sorted(load_mem_type_cnt.most_common(), \ |
| 50 | key = lambda kv: (kv[1], kv[0]), reverse = True): | 50 | key = lambda kv: (kv[1], kv[0]), reverse = True): |
| 51 | print("%-40s %10d %10.1f%%\n" % (mem_type, count, 100 * count / total), | 51 | print("%-40s %10d %10.1f%%\n" % |
| 52 | end='') | 52 | (mem_type, count, 100 * count / total), |
| 53 | end='') | ||
| 53 | 54 | ||
| 54 | def trace_begin(): | 55 | def trace_begin(): |
| 55 | parse_iomem() | 56 | parse_iomem() |
diff --git a/tools/perf/scripts/python/net_dropmonitor.py b/tools/perf/scripts/python/net_dropmonitor.py index 212557a02c50..101059971738 100755 --- a/tools/perf/scripts/python/net_dropmonitor.py +++ b/tools/perf/scripts/python/net_dropmonitor.py | |||
| @@ -7,7 +7,7 @@ import os | |||
| 7 | import sys | 7 | import sys |
| 8 | 8 | ||
| 9 | sys.path.append(os.environ['PERF_EXEC_PATH'] + \ | 9 | 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') |
| 11 | 11 | ||
| 12 | from perf_trace_context import * | 12 | from perf_trace_context import * |
| 13 | from Core import * | 13 | from Core import * |
diff --git a/tools/perf/scripts/python/netdev-times.py b/tools/perf/scripts/python/netdev-times.py index 267bda49325d..ea0c8b90a783 100644 --- a/tools/perf/scripts/python/netdev-times.py +++ b/tools/perf/scripts/python/netdev-times.py | |||
| @@ -124,14 +124,16 @@ def print_receive(hunk): | |||
| 124 | event = event_list[i] | 124 | event = event_list[i] |
| 125 | if event['event_name'] == 'napi_poll': | 125 | if event['event_name'] == 'napi_poll': |
| 126 | print(PF_NAPI_POLL % | 126 | 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'])) | ||
| 128 | if i == len(event_list) - 1: | 129 | if i == len(event_list) - 1: |
| 129 | print("") | 130 | print("") |
| 130 | else: | 131 | else: |
| 131 | print(PF_JOINT) | 132 | print(PF_JOINT) |
| 132 | else: | 133 | else: |
| 133 | print(PF_NET_RECV % | 134 | 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'], | ||
| 135 | event['len'])) | 137 | event['len'])) |
| 136 | if 'comm' in event.keys(): | 138 | if 'comm' in event.keys(): |
| 137 | print(PF_WJOINT) | 139 | print(PF_WJOINT) |
| @@ -256,7 +258,7 @@ def irq__irq_handler_exit(name, context, cpu, sec, nsec, pid, comm, callchain, i | |||
| 256 | all_event_list.append(event_info) | 258 | all_event_list.append(event_info) |
| 257 | 259 | ||
| 258 | def napi__napi_poll(name, context, cpu, sec, nsec, pid, comm, callchain, napi, | 260 | 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): |
| 260 | event_info = (name, context, cpu, nsecs(sec, nsec), pid, comm, | 262 | event_info = (name, context, cpu, nsecs(sec, nsec), pid, comm, |
| 261 | napi, dev_name, work, budget) | 263 | napi, dev_name, work, budget) |
| 262 | all_event_list.append(event_info) | 264 | all_event_list.append(event_info) |
| @@ -353,7 +355,7 @@ def handle_irq_softirq_exit(event_info): | |||
| 353 | if irq_list == [] or event_list == 0: | 355 | if irq_list == [] or event_list == 0: |
| 354 | return | 356 | return |
| 355 | rec_data = {'sirq_ent_t':sirq_ent_t, 'sirq_ext_t':time, | 357 | 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} |
| 357 | # merge information realted to a NET_RX softirq | 359 | # merge information realted to a NET_RX softirq |
| 358 | receive_hunk_list.append(rec_data) | 360 | receive_hunk_list.append(rec_data) |
| 359 | 361 | ||
| @@ -390,7 +392,7 @@ def handle_netif_receive_skb(event_info): | |||
| 390 | skbaddr, skblen, dev_name) = event_info | 392 | skbaddr, skblen, dev_name) = event_info |
| 391 | if cpu in net_rx_dic.keys(): | 393 | if cpu in net_rx_dic.keys(): |
| 392 | rec_data = {'event_name':'netif_receive_skb', | 394 | rec_data = {'event_name':'netif_receive_skb', |
| 393 | 'event_t':time, 'skbaddr':skbaddr, 'len':skblen} | 395 | 'event_t':time, 'skbaddr':skbaddr, 'len':skblen} |
| 394 | event_list = net_rx_dic[cpu]['event_list'] | 396 | event_list = net_rx_dic[cpu]['event_list'] |
| 395 | event_list.append(rec_data) | 397 | event_list.append(rec_data) |
| 396 | rx_skb_list.insert(0, rec_data) | 398 | rx_skb_list.insert(0, rec_data) |
diff --git a/tools/perf/scripts/python/sched-migration.py b/tools/perf/scripts/python/sched-migration.py index 3984bf51f3c5..8196e3087c9e 100644 --- a/tools/perf/scripts/python/sched-migration.py +++ b/tools/perf/scripts/python/sched-migration.py | |||
| @@ -14,10 +14,10 @@ import sys | |||
| 14 | 14 | ||
| 15 | from collections import defaultdict | 15 | from collections import defaultdict |
| 16 | try: | 16 | try: |
| 17 | from UserList import UserList | 17 | from UserList import UserList |
| 18 | except ImportError: | 18 | except ImportError: |
| 19 | # Python 3: UserList moved to the collections package | 19 | # Python 3: UserList moved to the collections package |
| 20 | from collections import UserList | 20 | from collections import UserList |
| 21 | 21 | ||
| 22 | sys.path.append(os.environ['PERF_EXEC_PATH'] + \ | 22 | sys.path.append(os.environ['PERF_EXEC_PATH'] + \ |
| 23 | '/scripts/python/Perf-Trace-Util/lib/Perf/Trace') | 23 | '/scripts/python/Perf-Trace-Util/lib/Perf/Trace') |
diff --git a/tools/perf/scripts/python/sctop.py b/tools/perf/scripts/python/sctop.py index 987ffae7c8ca..6e0278dcb092 100644 --- a/tools/perf/scripts/python/sctop.py +++ b/tools/perf/scripts/python/sctop.py | |||
| @@ -13,9 +13,9 @@ from __future__ import print_function | |||
| 13 | import os, sys, time | 13 | import os, sys, time |
| 14 | 14 | ||
| 15 | try: | 15 | try: |
| 16 | import thread | 16 | import thread |
| 17 | except ImportError: | 17 | except ImportError: |
| 18 | import _thread as thread | 18 | import _thread as thread |
| 19 | 19 | ||
| 20 | sys.path.append(os.environ['PERF_EXEC_PATH'] + \ | 20 | sys.path.append(os.environ['PERF_EXEC_PATH'] + \ |
| 21 | '/scripts/python/Perf-Trace-Util/lib/Perf/Trace') | 21 | '/scripts/python/Perf-Trace-Util/lib/Perf/Trace') |
| @@ -75,11 +75,12 @@ def print_syscall_totals(interval): | |||
| 75 | 75 | ||
| 76 | print("%-40s %10s" % ("event", "count")) | 76 | print("%-40s %10s" % ("event", "count")) |
| 77 | print("%-40s %10s" % | 77 | print("%-40s %10s" % |
| 78 | ("----------------------------------------", | 78 | ("----------------------------------------", |
| 79 | "----------")) | 79 | "----------")) |
| 80 | 80 | ||
| 81 | for id, val in sorted(syscalls.items(), key = lambda kv: (kv[1], kv[0]), \ | 81 | for id, val in sorted(syscalls.items(), |
| 82 | reverse = True): | 82 | key = lambda kv: (kv[1], kv[0]), |
| 83 | reverse = True): | ||
| 83 | try: | 84 | try: |
| 84 | print("%-40s %10d" % (syscall_name(id), val)) | 85 | print("%-40s %10d" % (syscall_name(id), val)) |
| 85 | except TypeError: | 86 | except TypeError: |
diff --git a/tools/perf/scripts/python/stackcollapse.py b/tools/perf/scripts/python/stackcollapse.py index 5e703efaddcc..b1c4def1410a 100755 --- a/tools/perf/scripts/python/stackcollapse.py +++ b/tools/perf/scripts/python/stackcollapse.py | |||
| @@ -27,7 +27,7 @@ from collections import defaultdict | |||
| 27 | from optparse import OptionParser, make_option | 27 | from optparse import OptionParser, make_option |
| 28 | 28 | ||
| 29 | sys.path.append(os.environ['PERF_EXEC_PATH'] + \ | 29 | 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') |
| 31 | 31 | ||
| 32 | from perf_trace_context import * | 32 | from perf_trace_context import * |
| 33 | from Core import * | 33 | from Core import * |
diff --git a/tools/perf/scripts/python/syscall-counts-by-pid.py b/tools/perf/scripts/python/syscall-counts-by-pid.py index 42782487b0e9..f254e40c6f0f 100644 --- a/tools/perf/scripts/python/syscall-counts-by-pid.py +++ b/tools/perf/scripts/python/syscall-counts-by-pid.py | |||
| @@ -39,11 +39,10 @@ def trace_end(): | |||
| 39 | print_syscall_totals() | 39 | print_syscall_totals() |
| 40 | 40 | ||
| 41 | def raw_syscalls__sys_enter(event_name, context, common_cpu, | 41 | def raw_syscalls__sys_enter(event_name, context, common_cpu, |
| 42 | common_secs, common_nsecs, common_pid, common_comm, | 42 | common_secs, common_nsecs, common_pid, common_comm, |
| 43 | common_callchain, id, args): | 43 | common_callchain, id, args): |
| 44 | |||
| 45 | if (for_comm and common_comm != for_comm) or \ | 44 | 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 ): |
| 47 | return | 46 | return |
| 48 | try: | 47 | try: |
| 49 | syscalls[common_comm][common_pid][id] += 1 | 48 | syscalls[common_comm][common_pid][id] += 1 |
| @@ -51,26 +50,26 @@ def raw_syscalls__sys_enter(event_name, context, common_cpu, | |||
| 51 | syscalls[common_comm][common_pid][id] = 1 | 50 | syscalls[common_comm][common_pid][id] = 1 |
| 52 | 51 | ||
| 53 | def syscalls__sys_enter(event_name, context, common_cpu, | 52 | def syscalls__sys_enter(event_name, context, common_cpu, |
| 54 | common_secs, common_nsecs, common_pid, common_comm, | 53 | common_secs, common_nsecs, common_pid, common_comm, |
| 55 | id, args): | 54 | id, args): |
| 56 | raw_syscalls__sys_enter(**locals()) | 55 | raw_syscalls__sys_enter(**locals()) |
| 57 | 56 | ||
| 58 | def print_syscall_totals(): | 57 | def print_syscall_totals(): |
| 59 | if for_comm is not None: | 58 | if for_comm is not None: |
| 60 | print("\nsyscall events for %s:\n" % (for_comm)) | 59 | print("\nsyscall events for %s:\n" % (for_comm)) |
| 61 | else: | 60 | else: |
| 62 | print("\nsyscall events by comm/pid:\n") | 61 | print("\nsyscall events by comm/pid:\n") |
| 63 | 62 | ||
| 64 | print("%-40s %10s" % ("comm [pid]/syscalls", "count")) | 63 | print("%-40s %10s" % ("comm [pid]/syscalls", "count")) |
| 65 | print("%-40s %10s" % ("----------------------------------------", | 64 | print("%-40s %10s" % ("----------------------------------------", |
| 66 | "----------")) | 65 | "----------")) |
| 67 | 66 | ||
| 68 | comm_keys = syscalls.keys() | 67 | comm_keys = syscalls.keys() |
| 69 | for comm in comm_keys: | 68 | for comm in comm_keys: |
| 70 | pid_keys = syscalls[comm].keys() | 69 | pid_keys = syscalls[comm].keys() |
| 71 | for pid in pid_keys: | 70 | for pid in pid_keys: |
| 72 | print("\n%s [%d]" % (comm, pid)) | 71 | print("\n%s [%d]" % (comm, pid)) |
| 73 | id_keys = syscalls[comm][pid].keys() | 72 | id_keys = syscalls[comm][pid].keys() |
| 74 | for id, val in sorted(syscalls[comm][pid].items(), \ | 73 | for id, val in sorted(syscalls[comm][pid].items(), |
| 75 | key = lambda kv: (kv[1], kv[0]), reverse = True): | 74 | key = lambda kv: (kv[1], kv[0]), reverse = True): |
| 76 | print(" %-38s %10d" % (syscall_name(id), val)) | 75 | print(" %-38s %10d" % (syscall_name(id), val)) |
diff --git a/tools/perf/scripts/python/syscall-counts.py b/tools/perf/scripts/python/syscall-counts.py index 0ebd89cfd42c..8adb95ff1664 100644 --- a/tools/perf/scripts/python/syscall-counts.py +++ b/tools/perf/scripts/python/syscall-counts.py | |||
| @@ -36,8 +36,8 @@ def trace_end(): | |||
| 36 | print_syscall_totals() | 36 | print_syscall_totals() |
| 37 | 37 | ||
| 38 | def raw_syscalls__sys_enter(event_name, context, common_cpu, | 38 | def raw_syscalls__sys_enter(event_name, context, common_cpu, |
| 39 | common_secs, common_nsecs, common_pid, common_comm, | 39 | common_secs, common_nsecs, common_pid, common_comm, |
| 40 | common_callchain, id, args): | 40 | common_callchain, id, args): |
| 41 | if for_comm is not None: | 41 | if for_comm is not None: |
| 42 | if common_comm != for_comm: | 42 | if common_comm != for_comm: |
| 43 | return | 43 | return |
| @@ -47,20 +47,19 @@ def raw_syscalls__sys_enter(event_name, context, common_cpu, | |||
| 47 | syscalls[id] = 1 | 47 | syscalls[id] = 1 |
| 48 | 48 | ||
| 49 | def syscalls__sys_enter(event_name, context, common_cpu, | 49 | def syscalls__sys_enter(event_name, context, common_cpu, |
| 50 | common_secs, common_nsecs, common_pid, common_comm, | 50 | common_secs, common_nsecs, common_pid, common_comm, id, args): |
| 51 | id, args): | ||
| 52 | raw_syscalls__sys_enter(**locals()) | 51 | raw_syscalls__sys_enter(**locals()) |
| 53 | 52 | ||
| 54 | def print_syscall_totals(): | 53 | def print_syscall_totals(): |
| 55 | if for_comm is not None: | 54 | if for_comm is not None: |
| 56 | print("\nsyscall events for %s:\n" % (for_comm)) | 55 | print("\nsyscall events for %s:\n" % (for_comm)) |
| 57 | else: | 56 | else: |
| 58 | print("\nsyscall events:\n") | 57 | print("\nsyscall events:\n") |
| 59 | 58 | ||
| 60 | print("%-40s %10s" % ("event", "count")) | 59 | print("%-40s %10s" % ("event", "count")) |
| 61 | print("%-40s %10s" % ("----------------------------------------", | 60 | print("%-40s %10s" % ("----------------------------------------", |
| 62 | "-----------")) | 61 | "-----------")) |
| 63 | 62 | ||
| 64 | for id, val in sorted(syscalls.items(), key = lambda kv: (kv[1], kv[0]), \ | 63 | for id, val in sorted(syscalls.items(), |
| 65 | reverse = True): | 64 | key = lambda kv: (kv[1], kv[0]), reverse = True): |
| 66 | print("%-40s %10d" % (syscall_name(id), val)) | 65 | print("%-40s %10d" % (syscall_name(id), val)) |
