lkml.org 
[lkml]   [2021]   [Mar]   [12]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    From
    SubjectRe: [PATCH] libbpf: Use the correct fd when attaching to perf events
    On Fri, Mar 12, 2021 at 05:31:14PM -0800, Andrii Nakryiko wrote:
    > On Fri, Mar 12, 2021 at 1:43 PM Sultan Alsawaf <sultan@kerneltoast.com> wrote:
    > >
    > > From: Sultan Alsawaf <sultan@kerneltoast.com>
    > >
    > > We should be using the program fd here, not the perf event fd.
    >
    > Why? Can you elaborate on what issue you ran into with the current code?

    bpf_link__pin() would fail with -EINVAL when using tracepoints, kprobes, or
    uprobes. The failure would happen inside the kernel, in bpf_link_get_from_fd()
    right here:
    if (f.file->f_op != &bpf_link_fops) {
    fdput(f);
    return ERR_PTR(-EINVAL);
    }

    Since bpf wasn't looking for the perf event fd, I swapped it for the program fd
    and bpf_link__pin() worked.

    Sultan

    \
     
     \ /
      Last update: 2021-03-13 03:23    [W:4.115 / U:0.000 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site