Re: [PATCH v6 bpf-next 1/3] perf: enable branch record for software events

From: Song Liu
Date: Fri Sep 10 2021 - 15:11:39 EST




> On Sep 10, 2021, at 12:08 PM, Peter Zijlstra <peterz@xxxxxxxxxxxxx> wrote:
>
> On Fri, Sep 10, 2021 at 07:00:08PM +0000, Song Liu wrote:
>
>> Hmm.. not really. We call migrate_disable() before entering the BPF program.
>> And the helper calls snapshot_branch_stack() inside the BPF program. To move
>> it to before migrate_disable(), we will have to add a "whether to snapshot
>> branch stack" check before entering the BPF program. This check, while is
>> cheap, is added to all BPF programs on this hook, even when the program does
>> not use snapshot at all. So we would rather keep all logic inside the helper,
>> and not touch the common path.
>
> Moo :/ Because I also really don't want to expose struct rq, it's
> currently nicely squirelled away in kernel/sched/ and doesn't get
> anywhere near include/.

This matches my guess, so I didn't go too far on that direction. :-)

>
> A well, maybe we can do something clever with migrate_disable() itself.
> I'll put it on this endless todo list ;-)

Awesome!

Thanks,
Song