OSDN Git Service

perf script: Better align register values in dump
authorPaul A. Clarke <pc@us.ibm.com>
Tue, 19 May 2020 17:58:22 +0000 (12:58 -0500)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Thu, 28 May 2020 13:03:27 +0000 (10:03 -0300)
Before:

  $ perf script --dump-raw-trace
  [...]
  2492031077254920 0x1e08 [0x308]: PERF_RECORD_SAMPLE(IP, 0x1): 47557/47557: 0xc00000000012eeb0 period: 1 addr: 0
  ... user regs: mask 0x1fffffffffff ABI 64-bit
  .... r0    0xb
  .... r1    0x7ffff3b90fa0
  .... r2    0x7fffbabf7300
  .... r3    0x7ffff3b9ed60
  .... r4    0x7ffff3b95cc0
  .... r5    0x1000c5a2940
  .... r6    0xfefefefefefefeff
  .... r7    0x7f7f7f7f7f7f7f7f
  .... r8    0x7ffff3b9ed60
  .... r9    0x0
  [...]

After:

  [...]
  2492031077254920 0x1e08 [0x308]: PERF_RECORD_SAMPLE(IP, 0x1): 47557/47557: 0xc00000000012eeb0 period: 1 addr: 0
  ... user regs: mask 0x1fffffffffff ABI 64-bit
  .... r0    0x000000000000000b
  .... r1    0x00007ffff3b90fa0
  .... r2    0x00007fffbabf7300
  .... r3    0x00007ffff3b9ed60
  .... r4    0x00007ffff3b95cc0
  .... r5    0x000001000c5a2940
  .... r6    0xfefefefefefefeff
  .... r7    0x7f7f7f7f7f7f7f7f
  .... r8    0x00007ffff3b9ed60
  .... r9    0x0000000000000000
  [...]

Committer testing:

Full set of instructions, testing on x86_64:

  # perf record -I
  ^C[ perf record: Woken up 1 times to write data ]
  [ perf record: Captured and wrote 2.855 MB perf.data (4902 samples) ]
  # perf evlist -v
  cycles: size: 120, { sample_period, sample_freq }: 4000, sample_type: IP|TID|TIME|ID|CPU|PERIOD|REGS_INTR, read_format: ID, disabled: 1, inherit: 1, freq: 1, precise_ip: 3, sample_id_all: 1, exclude_guest: 1, sample_regs_intr: 0xff0fff
  dummy:HG: type: 1, size: 120, config: 0x9, { sample_period, sample_freq }: 4000, sample_type: IP|TID|TIME|ID|CPU|PERIOD|REGS_INTR, read_format: ID, inherit: 1, mmap: 1, comm: 1, freq: 1, task: 1, sample_id_all: 1, mmap2: 1, comm_exec: 1, ksymbol: 1, bpf_event: 1, sample_regs_intr: 0xff0fff
  #

Before:

  # perf script --dump-raw-trace
  [...]
  0 1542674658099675 0x1cb700 [0xe0]: PERF_RECORD_SAMPLE(IP, 0x4001): 1825/1825: 0xffffffff9506e544 period: 1 addr: 0
  ... intr regs: mask 0xff0fff ABI 64-bit
  .... AX    0xf
  .... BX    0xffff96e1064125a0
  .... CX    0x38f
  .... DX    0x7
  .... SI    0xf
  .... DI    0x38f
  .... BP    0x1
  .... SP    0xfffffe000000bdf0
  .... IP    0xffffffff9506e544
  .... FLAGS 0xa
  .... CS    0x10
  .... SS    0x18
  .... R8    0x0
  .... R9    0x0
  .... R10   0xfffffe00000260c8
  .... R11   0xfffffe000000bef8
  .... R12   0x1
  .... R13   0x64
  .... R14   0x390
  .... R15   0xffff96e1064125a0
   ... thread: perf:1825
   ...... dso: /proc/kcore
              perf  1825 [000] 1542674.658099:          1   cycles:  ffffffff9506e544 native_write_msr+0x4 (vmlinux
  [...]

After:

  # perf script --dump-raw-trace
  [...]
  0 1542674658096068 0x1cb620 [0xe0]: PERF_RECORD_SAMPLE(IP, 0x4001): 1825/1825: 0xffffffff9506e544 period: 1 addr: 0
  ... intr regs: mask 0xff0fff ABI 64-bit
  .... AX    0x000000000000000f
  .... BX    0xffff96e1064125a0
  .... CX    0x000000000000038f
  .... DX    0x0000000000000007
  .... SI    0x000000000000000f
  .... DI    0x000000000000038f
  .... BP    0x0000000000000000
  .... SP    0xffffb3e788fb7c20
  .... IP    0xffffffff9506e544
  .... FLAGS 0x000000000000000a
  .... CS    0x0000000000000010
  .... SS    0x0000000000000018
  .... R8    0x00057b0deeffdfe3
  .... R9    0xffff96e106432480
  .... R10   0x0000000000000000
  .... R11   0xffff96e106412cc0
  .... R12   0xffffb3e788fb7d00
  .... R13   0xffff96e106432408
  .... R14   0xffff96e106432400
  .... R15   0xffff96e0e09a4800
   ... thread: perf:1825
   ...... dso: /proc/kcore
              perf  1825 [000] 1542674.658096:          1   cycles:  ffffffff9506e544 native_write_msr+0x4 (vmlinux)
  [...]

Signed-off-by: Paul Clarke <pc@us.ibm.com>
Reviewed-by: Andi Kleen <ak@linux.intel.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Jin Yao <yao.jin@linux.intel.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Namhyung Kim <namhyung@kernel.org>
LPU-Reference: 1589911102-9460-1-git-send-email-pc@us.ibm.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/util/session.c

index b860f9f..d53cf06 100644 (file)
@@ -1104,7 +1104,7 @@ static void regs_dump__printf(u64 mask, u64 *regs)
        for_each_set_bit(rid, (unsigned long *) &mask, sizeof(mask) * 8) {
                u64 val = regs[i++];
 
-               printf(".... %-5s 0x%" PRIx64 "\n",
+               printf(".... %-5s 0x%016" PRIx64 "\n",
                       perf_reg_name(rid), val);
        }
 }