Chengdong Li
51d0bf99b8
perf session: Fix Intel LBR callstack entries and nr print message
When generating callstack information from branch_stack(Intel LBR), the
actual number of callstack entry should be bigger than the number of
branch_stack, for example:
branch_stack records:
B() -> C()
A() -> B()
converted callstack records should be:
C()
B()
A()
though, the number of callstack equals
to the number of branch stack plus 1.
This patch fixes above issue in branch_stack__printf(). For example,
# echo 'scale=2000; 4*a(1)' > cmd
# perf record --call-graph lbr bc -l < cmd
Before applying this patch, `perf script -D` output:
1220022677386876 0x2a40 [0xd8]: PERF_RECORD_SAMPLE(IP, 0x4002): 17990/17990: 0x40a6d6 period: 894172 addr: 0
... LBR call chain: nr:8
..... 0: fffffffffffffe00
..... 1: 000000000040a410
..... 2: 000000000040573c
..... 3: 0000000000408650
..... 4: 00000000004022f2
..... 5: 00000000004015f5
..... 6: 00007f5ed6dcb553
..... 7: 0000000000401698
... FP chain: nr:2
..... 0: fffffffffffffe00
..... 1: 000000000040a6d8
... branch callstack: nr:6 # which is not consistent with LBR records.
..... 0: 000000000040a410
..... 1: 0000000000408650 # ditto
..... 2: 00000000004022f2
..... 3: 00000000004015f5
..... 4: 00007f5ed6dcb553
..... 5: 0000000000401698
... thread: bc:17990
...... dso: /usr/bin/bc
bc 17990 1220022.677386: 894172 cycles:
40a410 [unknown] (/usr/bin/bc)
40573c [unknown] (/usr/bin/bc)
408650 [unknown] (/usr/bin/bc)
4022f2 [unknown] (/usr/bin/bc)
4015f5 [unknown] (/usr/bin/bc)
7f5ed6dcb553 __libc_start_main+0xf3 (/usr/lib64/libc-2.17.so)
401698 [unknown] (/usr/bin/bc)
After applied:
1220022677386876 0x2a40 [0xd8]: PERF_RECORD_SAMPLE(IP, 0x4002): 17990/17990: 0x40a6d6 period: 894172 addr: 0
... LBR call chain: nr:8
..... 0: fffffffffffffe00
..... 1: 000000000040a410
..... 2: 000000000040573c
..... 3: 0000000000408650
..... 4: 00000000004022f2
..... 5: 00000000004015f5
..... 6: 00007f5ed6dcb553
..... 7: 0000000000401698
... FP chain: nr:2
..... 0: fffffffffffffe00
..... 1: 000000000040a6d8
... branch callstack: nr:7
..... 0: 000000000040a410
..... 1: 000000000040573c
..... 2: 0000000000408650
..... 3: 00000000004022f2
..... 4: 00000000004015f5
..... 5: 00007f5ed6dcb553
..... 6: 0000000000401698
... thread: bc:17990
...... dso: /usr/bin/bc
bc 17990 1220022.677386: 894172 cycles:
40a410 [unknown] (/usr/bin/bc)
40573c [unknown] (/usr/bin/bc)
408650 [unknown] (/usr/bin/bc)
4022f2 [unknown] (/usr/bin/bc)
4015f5 [unknown] (/usr/bin/bc)
7f5ed6dcb553 __libc_start_main+0xf3 (/usr/lib64/libc-2.17.so)
401698 [unknown] (/usr/bin/bc)
Change from v1:
- refined code style according to Jiri's review comments.
Signed-off-by: Chengdong Li <chengdongli@tencent.com>
Acked-by: Namhyung Kim <namhyung@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Alexey Bayduraev <alexey.v.bayduraev@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: German Gomez <german.gomez@arm.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Riccardo Mancini <rickyman7@gmail.com>
Cc: likexu@tencent.com
Link: https://lore.kernel.org/r/20220517015726.96131-1-chengdongli@tencent.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2022-05-21 14:56:24 -03:00
..
2022-05-21 14:45:19 -03:00
2022-05-21 14:45:19 -03:00
2021-12-16 12:18:11 -03:00
2022-04-09 14:20:59 -03:00
2021-08-11 09:35:24 -03:00
2022-03-18 11:43:51 -03:00
2022-04-01 16:19:35 -03:00
2022-02-15 17:15:07 -03:00
2022-05-21 14:54:21 -03:00
2022-04-01 16:19:34 -03:00
2022-01-10 15:47:30 -03:00
2022-05-21 14:56:24 -03:00
2021-11-08 11:33:35 -08:00
2022-02-16 10:38:55 -03:00
2021-12-16 12:18:11 -03:00
2022-01-15 17:41:25 -03:00
2021-08-02 10:06:51 -03:00
2022-03-26 10:55:57 -03:00
2021-10-08 15:14:50 -03:00
2022-02-22 21:23:08 -03:00
2021-08-02 10:06:51 -03:00
2021-08-02 10:06:51 -03:00
2022-04-01 16:19:35 -03:00
2022-02-11 14:31:22 -03:00
2022-03-26 10:55:57 -03:00
2022-03-26 10:55:57 -03:00
2021-10-25 13:47:42 -03:00
2022-03-26 10:55:57 -03:00
2022-03-26 10:55:57 -03:00
2022-02-11 14:31:22 -03:00
2022-04-14 09:05:11 -03:00
2022-04-22 18:39:34 -03:00
2022-03-26 10:55:57 -03:00
2022-04-22 18:39:34 -03:00
2022-04-01 16:19:35 -03:00
2022-03-26 10:55:57 -03:00
2022-04-01 16:19:35 -03:00
2022-02-17 18:40:54 -03:00
2022-03-26 10:53:45 -03:00
2021-04-20 08:40:20 -03:00
2021-11-13 18:11:50 -03:00
2021-04-20 08:43:58 -03:00
2022-05-20 09:45:41 -03:00
2022-04-01 16:19:35 -03:00
2021-11-07 15:39:28 -03:00
2021-04-20 08:40:20 -03:00
2022-04-09 14:21:00 -03:00