Skip to contentSkip to conversation

LBR unwinding for user defined dynamic trace point

DISCUSSION Milian Wolff 2 participants 6 messages Sep 15, 2015 – Apr 7, 2016

lore
Share & tools
lore
#0 lore raw

Hey all,

I just tried to use LBR with a user defined dynamic trace point and get a strange error message:

$ sudo perf probe -x /lib64/libc.so.6 malloc
$ sudo perf record -e probe_libc:malloc --call-graph lbr -F 1000 ./foo
Error:
The sys_perf_event_open() syscall returned with 95 (Operation not supported) 
for event (probe_libc:malloc).
/bin/dmesg may provide additional information.
No CONFIG_PERF_EVENTS=y kernel support configured?

When I do the same with the Dwarf unwinder, it works just fine. Using the LBR unwinder with a performance counter like instructions also works fine. Does anyone know what the issue is here?

Signature · 4 lines
Milian Wolff | [email protected] | Software Engineer
KDAB (Deutschland) GmbH&Co KG, a KDAB Group company
Tel: +49-30-521325470
KDAB - The Qt Experts
#1 lore raw
Quoted 4 lines · Milian Wolff

When I do the same with the Dwarf unwinder, it works just fine. Using the LBR unwinder with a performance counter like instructions also works fine. Does anyone know what the issue is here?

LBR is only supported for PMU sampling at this point.

-Andi

Signature · 1 line
[email protected] -- Speaking for myself only
#2 lore raw
Quoted 6 lines · CEST Andi Kleen
Quoted 3 lines · Milian Wolff

When I do the same with the Dwarf unwinder, it works just fine. Using the LBR unwinder with a performance counter like instructions also works fine. Does anyone know what the issue is here?

LBR is only supported for PMU sampling at this point.

OK, thanks. Can you give me some more information on why that is? Is it fundamentally not possible, or simply not yet implemented?

Thanks

Signature · 4 lines
Milian Wolff | [email protected] | Software Engineer
KDAB (Deutschland) GmbH&Co KG, a KDAB Group company
Tel: +49-30-521325470
KDAB - The Qt Experts
#3 lore raw
Quoted 10 lines · Milian Wolff
Quoted 6 lines · CEST Andi Kleen
Quoted 3 lines · Milian Wolff

When I do the same with the Dwarf unwinder, it works just fine. Using the LBR unwinder with a performance counter like instructions also works fine. Does anyone know what the issue is here?

LBR is only supported for PMU sampling at this point.

OK, thanks. Can you give me some more information on why that is? Is it fundamentally not possible, or simply not yet implemented?

For LBR callgraph it could be implemented. For some other LBR usages there would be limitations, as there is no LBR freezing for software trace points.

-Andi

Signature · 1 line
[email protected] -- Speaking for myself only.
#4 lore raw
Quoted 8 lines · CEST Andi Kleen
Quoted 7 lines · Milian Wolff
Quoted 6 lines · CEST Andi Kleen
Quoted 4 lines · Milian Wolff

When I do the same with the Dwarf unwinder, it works just fine. Using the
LBR unwinder with a performance counter like instructions also works fine. Does anyone know what the issue is here?

Quoted 8 lines
Quoted 4 lines
Quoted 1 line

LBR is only supported for PMU sampling at this point.

OK, thanks. Can you give me some more information on why that is? Is it fundamentally not possible, or simply not yet implemented?

For LBR callgraph it could be implemented. For some other LBR usages there would be limitations, as there is no LBR freezing for software trace points.

Hey Andi,

I read your articles on LBR on LWN, thanks a lot for that! I want to revive this older thread though:

Could you tell me what would be required to get LBR callgraphs supported for trace points? I noticed that it also does not work with static tracepoints or software events:

~~~~~~~~~~~~~~~~~~~~~~~

$ perf record -e faults --call-graph lbr ls
Error:
The sys_perf_event_open() syscall returned with 95 (Operation not supported) 
for event (faults).
/bin/dmesg may provide additional information.
No CONFIG_PERF_EVENTS=y kernel support configured?
$ perf record -e raw_syscalls:sys_enter --call-graph lbr ls
Error:
The sys_perf_event_open() syscall returned with 95 (Operation not supported) 
for event (raw_syscalls:sys_enter).
/bin/dmesg may provide additional information.
No CONFIG_PERF_EVENTS=y kernel support configured?
~~~~~~~~~~~~~~~~~~~~~~~

It does work fine for hardware events though:

~~~~~~~~~~~~~~~~~~~~~~~

$ perf record -e cache-misses --call-graph lbr ls
WARNING: No sample_id_all support, falling back to unordered processing
...
[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 0.017 MB perf.data (6 samples) ]
~~~~~~~~~~~~~~~~~~~~~~~

Due to the reasons and advantages you point out in your article for LBR callgraphs, I'd love to see it supported for the above use-cases as well, if possible. If you can guide me, and it does not require me to patch the kernel itself, then I'm also willing to come up with a patch for perf.

Thanks

Signature · 4 lines
Milian Wolff | [email protected] | Software Engineer
KDAB (Deutschland) GmbH&Co KG, a KDAB Group company
Tel: +49-30-521325470
KDAB - The Qt Experts
#5 lore raw
Quoted 3 lines

Could you tell me what would be required to get LBR callgraphs supported for trace points? I noticed that it also does not work with static tracepoints or software events:

The perf trace point handler code would need to know how to read the LBR registers and dump them into the trace stream. Right now that's only implemented for the PMU overflow code. In principle it is not very complicated, see arch/x86/kernel/cpu/perf_event_intel_lbr.c:intel_pmu_lbr_read() Basically would need to call that, but save the information somewhere else (not the cpuc), and then dump it into the trace buffer.

For kernel LBRs it would also need to stop/restart them to avoid pollution, but for the case you're likely interested in (LBR with ring 3 filter for user programs), that's not needed.

Quoted 4 lines

Due to the reasons and advantages you point out in your article for LBR callgraphs, I'd love to see it supported for the above use-cases as well, if possible. If you can guide me, and it does not require me to patch the kernel itself, then I'm also willing to come up with a patch for perf.

It requires patching the kernel.

-Andi