lkml.org 
[lkml]   [2021]   [Sep]   [3]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: [PATCH v5 bpf-next 2/3] bpf: introduce helper bpf_get_branch_snapshot
Date


> On Sep 3, 2021, at 1:28 AM, Peter Zijlstra <peterz@infradead.org> wrote:
>
> On Thu, Sep 02, 2021 at 09:57:05AM -0700, Song Liu wrote:
>> +BPF_CALL_3(bpf_get_branch_snapshot, void *, buf, u32, size, u64, flags)
>> +{
>> +#ifndef CONFIG_X86
>> + return -ENOENT;
>> +#else
>> + static const u32 br_entry_size = sizeof(struct perf_branch_entry);
>> + u32 entry_cnt = size / br_entry_size;
>> +
>> + if (unlikely(flags))
>> + return -EINVAL;
>> +
>> + if (!buf || (size % br_entry_size != 0))
>> + return -EINVAL;
>> +
>> + entry_cnt = static_call(perf_snapshot_branch_stack)(buf, entry_cnt);
>> +
>> + if (!entry_cnt)
>> + return -ENOENT;
>> +
>> + return entry_cnt * br_entry_size;
>> +#endif
>> +}
>
> Do we really need that CONFIG_X86 thing? Seems rather bad practise.

The ifndef will save a few cycles on architectures that do not support
branch stack. I personally don't have very strong preference on either
way.

Thanks,
Song

\
 
 \ /
  Last update: 2021-09-03 18:59    [W:0.141 / U:0.564 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site