History

perf script python: intel-pt-events: Add machine_pid and vcpu

Add machine_pid and vcpu to the intel-pt-events.py script.

Adrian Hunter committed 4 years ago

Commit 13a133b1 parent 6de306b1 file · +27 −5Browse files

Showing the changes to tools/perf/scripts/python (1 of 1 file). Show all

Unified · Split

tools/perf/scripts/python/intel-pt-events.py+27−5
@@ -197,7 +197,12 @@ def common_start_str(comm, sample): · 196 unmodified lines
197 cpu = sample["cpu"]197 cpu = sample["cpu"]
198 pid = sample["pid"]198 pid = sample["pid"]
199 tid = sample["tid"]199 tid = sample["tid"]
200 return "%16s %5u/%-5u [%03u] %9u.%09u " % (comm, pid, tid, cpu, ts / 1000000000, ts %1000000000)200 if "machine_pid" in sample:
201 machine_pid = sample["machine_pid"]
202 vcpu = sample["vcpu"]
203 return "VM:%5d VCPU:%03d %16s %5u/%-5u [%03u] %9u.%09u " % (machine_pid, vcpu, comm, pid, tid, cpu, ts / 1000000000, ts %1000000000)
204 else:
205 return "%16s %5u/%-5u [%03u] %9u.%09u " % (comm, pid, tid, cpu, ts / 1000000000, ts %1000000000)
201 206
202def print_common_start(comm, sample, name):207def print_common_start(comm, sample, name):
203 flags_disp = get_optional_null(sample, "flags_disp")208 flags_disp = get_optional_null(sample, "flags_disp")
@@ -379,9 +384,19 @@ def process_event(param_dict): · 175 unmodified lines
379 sys.exit(1)384 sys.exit(1)
380 385
381def auxtrace_error(typ, code, cpu, pid, tid, ip, ts, msg, cpumode, *x):386def auxtrace_error(typ, code, cpu, pid, tid, ip, ts, msg, cpumode, *x):
387 if len(x) >= 2 and x[0]:
388 machine_pid = x[0]
389 vcpu = x[1]
390 else:
391 machine_pid = 0
392 vcpu = -1
382 try:393 try:
383 print("%16s %5u/%-5u [%03u] %9u.%09u error type %u code %u: %s ip 0x%16x" %394 if machine_pid:
384 ("Trace error", pid, tid, cpu, ts / 1000000000, ts %1000000000, typ, code, msg, ip))395 print("VM:%5d VCPU:%03d %16s %5u/%-5u [%03u] %9u.%09u error type %u code %u: %s ip 0x%16x" %
396 (machine_pid, vcpu, "Trace error", pid, tid, cpu, ts / 1000000000, ts %1000000000, typ, code, msg, ip))
397 else:
398 print("%16s %5u/%-5u [%03u] %9u.%09u error type %u code %u: %s ip 0x%16x" %
399 ("Trace error", pid, tid, cpu, ts / 1000000000, ts %1000000000, typ, code, msg, ip))
385 except broken_pipe_exception:400 except broken_pipe_exception:
386 # Stop python printing broken pipe errors and traceback401 # Stop python printing broken pipe errors and traceback
387 sys.stdout = open(os.devnull, 'w')402 sys.stdout = open(os.devnull, 'w')
@@ -396,14 +411,21 @@ def context_switch(ts, cpu, pid, tid, np_pid, np_tid, machine_pid, out, out_pree · 8 unmodified lines
396 preempt_str = "preempt"411 preempt_str = "preempt"
397 else:412 else:
398 preempt_str = ""413 preempt_str = ""
414 if len(x) >= 2 and x[0]:
415 machine_pid = x[0]
416 vcpu = x[1]
417 else:
418 vcpu = None;
399 if machine_pid == -1:419 if machine_pid == -1:
400 machine_str = ""420 machine_str = ""
401 else:421 elif vcpu is None:
402 machine_str = "machine PID %d" % machine_pid422 machine_str = "machine PID %d" % machine_pid
423 else:
424 machine_str = "machine PID %d VCPU %d" % (machine_pid, vcpu)
403 switch_str = "%16s %5d/%-5d [%03u] %9u.%09u %5d/%-5d %s %s" % \425 switch_str = "%16s %5d/%-5d [%03u] %9u.%09u %5d/%-5d %s %s" % \
404 (out_str, pid, tid, cpu, ts / 1000000000, ts %1000000000, np_pid, np_tid, machine_str, preempt_str)426 (out_str, pid, tid, cpu, ts / 1000000000, ts %1000000000, np_pid, np_tid, machine_str, preempt_str)
405 if glb_args.all_switch_events:427 if glb_args.all_switch_events:
406 print(switch_str);428 print(switch_str)
407 else:429 else:
408 global glb_switch_str430 global glb_switch_str
409 glb_switch_str[cpu] = switch_str431 glb_switch_str[cpu] = switch_str

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t