Re: [PATCHv4 bpf-next 3/4] selftests/bpf: Add bpf_vma_build_id_parse find_vma callback test

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

 



On Mon, Nov 28, 2022 at 11:25:02AM -0800, Hao Luo wrote:
> On Mon, Nov 28, 2022 at 5:30 AM Jiri Olsa <jolsa@xxxxxxxxxx> wrote:
> >
> > Adding tests for using new bpf_vma_build_id_parse kfunc in find_vma
> > callback function.
> >
> > On bpf side the test finds the vma of the test_progs text through the
> > test function pointer and reads its build id with the new kfunc.
> >
> > On user side the test uses readelf to get test_progs build id and
> > compares it with the one from bpf side.
> >
> > Signed-off-by: Jiri Olsa <jolsa@xxxxxxxxxx>
> > ---
> <...>
> > diff --git a/tools/testing/selftests/bpf/progs/bpf_vma_build_id_parse.c b/tools/testing/selftests/bpf/progs/bpf_vma_build_id_parse.c
> > new file mode 100644
> > index 000000000000..8937212207db
> > --- /dev/null
> > +++ b/tools/testing/selftests/bpf/progs/bpf_vma_build_id_parse.c
> <...>
> > +
> > +SEC("fentry/bpf_fentry_test1")
> > +int BPF_PROG(test1, int a)
> > +{
> > +       struct task_struct *task = bpf_get_current_task_btf();
> > +
> > +       if (task->pid != target_pid)
> > +               return 0;
> 
> I think here we should use task->tgid. IIRC, task->pid corresponds to
> thread id in the userspace. task->tgid is the process id.

right, will change

thanks,
jirka

> 
> > +
> > +       ret = bpf_find_vma(task, addr, check_vma, NULL, 0);
> > +       return 0;
> > +}
> <...>
> > --
> > 2.38.1
> >



[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