Add machine_pid and vcpu to the intel-pt-events.py script.
Showing the changes to tools/perf/scripts/python (1 of 1 file). Show all
Unified · Split
| @@ -197,7 +197,12 @@ def common_start_str(comm, sample): · 196 unmodified lines | ||
| 197 | 197 | cpu = sample["cpu"] |
| 198 | 198 | pid = sample["pid"] |
| 199 | 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 | |
| 202 | 207 | def print_common_start(comm, sample, name): |
| 203 | 208 | flags_disp = get_optional_null(sample, "flags_disp") |
| @@ -379,9 +384,19 @@ def process_event(param_dict): · 175 unmodified lines | ||
| 379 | 384 | sys.exit(1) |
| 380 | 385 | |
| 381 | 386 | def 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 | 393 | try: |
| 383 | − print("%16s %5u/%-5u [%03u] %9u.%09u error type %u code %u: %s ip 0x%16x" % | |
| 384 | − ("Trace error", pid, tid, cpu, ts / 1000000000, ts %1000000000, typ, code, msg, ip)) | |
| 394 | + if machine_pid: | |
| 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 | 400 | except broken_pipe_exception: |
| 386 | 401 | # Stop python printing broken pipe errors and traceback |
| 387 | 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 | 411 | preempt_str = "preempt" |
| 397 | 412 | else: |
| 398 | 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 | 419 | if machine_pid == -1: |
| 400 | 420 | machine_str = "" |
| 401 | − else: | |
| 421 | + elif vcpu is None: | |
| 402 | 422 | machine_str = "machine PID %d" % machine_pid |
| 423 | + else: | |
| 424 | + machine_str = "machine PID %d VCPU %d" % (machine_pid, vcpu) | |
| 403 | 425 | switch_str = "%16s %5d/%-5d [%03u] %9u.%09u %5d/%-5d %s %s" % \ |
| 404 | 426 | (out_str, pid, tid, cpu, ts / 1000000000, ts %1000000000, np_pid, np_tid, machine_str, preempt_str) |
| 405 | 427 | if glb_args.all_switch_events: |
| 406 | − print(switch_str); | |
| 428 | + print(switch_str) | |
| 407 | 429 | else: |
| 408 | 430 | global glb_switch_str |
| 409 | 431 | glb_switch_str[cpu] = switch_str |