Re: [PATCHv4 bpf-next 6/8] libbpf: Add bpf_program__attach_kprobe_opts function

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Jul 16, 2021 at 06:41:59PM -0700, Andrii Nakryiko wrote:
> On Wed, Jul 14, 2021 at 2:45 AM Jiri Olsa <jolsa@xxxxxxxxxx> wrote:
> >
> > Adding bpf_program__attach_kprobe_opts that does the same
> > as bpf_program__attach_kprobe, but takes opts argument.
> >
> > Currently opts struct holds just retprobe bool, but we will
> > add new field in following patch.
> >
> > The function is not exported, so there's no need to add
> > size to the struct bpf_program_attach_kprobe_opts for now.
> 
> Why not exported? Please use a proper _opts struct just like others
> (e.g., bpf_object_open_opts) and add is as a public API, it's a useful
> addition. We are going to have a similar structure for attach_uprobe,
> btw. Please send a follow up patch.

there's no outside user.. ok

> 
> >
> > Signed-off-by: Jiri Olsa <jolsa@xxxxxxxxxx>
> > ---
> >  tools/lib/bpf/libbpf.c | 34 +++++++++++++++++++++++++---------
> >  1 file changed, 25 insertions(+), 9 deletions(-)
> >
> > diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
> > index 88b99401040c..d93a6f9408d1 100644
> > --- a/tools/lib/bpf/libbpf.c
> > +++ b/tools/lib/bpf/libbpf.c
> > @@ -10346,19 +10346,24 @@ static int perf_event_open_probe(bool uprobe, bool retprobe, const char *name,
> >         return pfd;
> >  }
> >
> > -struct bpf_link *bpf_program__attach_kprobe(struct bpf_program *prog,
> > -                                           bool retprobe,
> > -                                           const char *func_name)
> > +struct bpf_program_attach_kprobe_opts {
> 
> when you make it part of libbpf API, let's call it something shorter,
> like bpf_kprobe_opts, maybe? And later we'll have bpf_uprobe_opts for
> uprobes. Short and unambiguous.

ok

jirka

> 
> > +       bool retprobe;
> > +};
> > +
> > +static struct bpf_link*
> > +bpf_program__attach_kprobe_opts(struct bpf_program *prog,
> > +                               const char *func_name,
> > +                               struct bpf_program_attach_kprobe_opts *opts)
> >  {
> >         char errmsg[STRERR_BUFSIZE];
> >         struct bpf_link *link;
> >         int pfd, err;
> >
> 
> [...]
> 




[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux