Re: Getting empty callchain from perf_callchain_kernel()

From: Song Liu
Date: Fri May 17 2019 - 12:35:14 EST




> On May 17, 2019, at 1:10 AM, Peter Zijlstra <peterz@xxxxxxxxxxxxx> wrote:
>
> On Fri, May 17, 2019 at 09:46:00AM +0200, Peter Zijlstra wrote:
>> On Thu, May 16, 2019 at 11:51:55PM +0000, Song Liu wrote:
>>> Hi,
>>>
>>> We found a failure with selftests/bpf/tests_prog in test_stacktrace_map (on bpf/master
>>> branch).
>>>
>>> After digging into the code, we found that perf_callchain_kernel() is giving empty
>>> callchain for tracepoint sched/sched_switch. And it seems related to commit
>>>
>>> d15d356887e770c5f2dcf963b52c7cb510c9e42d
>>> ("perf/x86: Make perf callchains work without CONFIG_FRAME_POINTER")
>>>
>>> Before this commit, perf_callchain_kernel() returns callchain with regs->ip. With
>>> this commit, regs->ip is not sent for !perf_hw_regs(regs) case.
>>
>> So while I think the below is indeed right; we should store regs->ip
>> regardless of the unwind path chosen, I still think there's something
>> fishy if this results in just the 1 entry.
>>
>> The sched/sched_switch event really should have a non-trivial stack.
>>
>> Let me see if I can reproduce with just perf.
>
> $ perf record -g -e "sched:sched_switch" -- make clean
> $ perf report -D
>
> 12 904071759467 0x1790 [0xd0]: PERF_RECORD_SAMPLE(IP, 0x1): 7236/7236: 0xffffffff81c29562 period: 1 addr: 0
> ... FP chain: nr:10
> ..... 0: ffffffffffffff80
> ..... 1: ffffffff81c29562
> ..... 2: ffffffff81c29933
> ..... 3: ffffffff8111f688
> ..... 4: ffffffff81120b9d
> ..... 5: ffffffff81120ce5
> ..... 6: ffffffff8100254a
> ..... 7: ffffffff81e0007d
> ..... 8: fffffffffffffe00
> ..... 9: 00007f9b6cd9682a
> ... thread: sh:7236
> ...... dso: /lib/modules/5.1.0-12177-g41bbb9129767/build/vmlinux
>

Hmm... I also get this FP chain even with CONFIG_UNWINDER_ORC=y.
I guess it is actually from ORC?

Thanks,
Song