Add the ability to choose in-kernel frame pointer unwinding of the user stack
The ability to use frame pointer unwinding landed in ab3bf51c8300eb01b00c5d0029a87f1d34dfba40. But as far as I can tell this still copies the user stack bytes and does the unwinding in user-land, which is slow (copies a lot of memory) and which leads to truncated stacks because it can only unwind the top 64KB of the stack.
https://github.com/google/perfetto/blob/0ce5e90e79f04dbd589146d06b83af4a3a3f9975/src/profiling/perf/event_config.cc#L623-L638
I would like to have a path which asks the kernel to do the unwinding of the user stack, i.e. which uses PERF_SAMPLE_CALLCHAIN, and which does not drop the user frames (exclude_callchain_user = false). This path would not set PERF_SAMPLE_STACK_USER, i.e. it would skip the copying of the stack bytes.
Could such a path be added? cc @LalitMaganti
Thanks for filing! It's a lot more clear now what you're asking for, sorry for the confusion on the bug :)
I would like to have a path which asks the kernel to do the unwinding of the user stack, i.e. which uses PERF_SAMPLE_CALLCHAIN, and which does not drop the user frames (exclude_callchain_user = false). This path would not set PERF_SAMPLE_STACK_USER, i.e. it would skip the copying of the stack bytes.
I would say that this makes sense as a feature for us to have in Perfetto. However, it's also not something we would use ourselves (as Android does not do frame pointer unwinding and I don't have any hope of that changing). So I think this is one of those PRs we might get to our of personal curiousity but not otherwise.
To anyone reading: if you're interested in this, by far the most reliable way to make this happen is sending us a PR. We're happy to guide on how this should be designed and review the code.
However, I'm by no means the authority on the recording code of Perfetto so will defer to @KirillTim and @rsavitski to be have the final say.
+1 that the request makes sense, but would need to be a contribution since the profiler primarily targets whole-system profiling on Android, where the lowest common denominator requires userspace stacks + DWARF unwinding.
Fwiw I've seen this option in a pending contribution from ARM (https://github.com/google/perfetto/pull/1984), so we'll probably address this request as part of that PR.
I was looking at this out of personal interest and ended up writing https://github.com/google/perfetto/pull/5706 to add support for this.