Re: [PATCH v2 bpf-next 10/10] selftests/bpf: add build ID tests

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

 



On Thu, Jul 25, 2024 at 5:04 AM Jiri Olsa <olsajiri@xxxxxxxxx> wrote:
>
> On Wed, Jul 24, 2024 at 03:52:10PM -0700, Andrii Nakryiko wrote:
>
> SNIP
>
> > +extern char build_id_start[];
> > +extern char build_id_end[];
> > +
> > +int __attribute__((weak)) trigger_uprobe(bool build_id_resident)
> > +{
> > +     int page_sz = sysconf(_SC_PAGESIZE);
> > +     void *addr;
> > +
> > +     /* page-align build ID start */
> > +     addr = (void *)((uintptr_t)&build_id_start & ~(page_sz - 1));
> > +
> > +     /* to guarantee MADV_PAGEOUT work reliably, we need to ensure that
> > +      * memory range is mapped into current process, so we unconditionally
> > +      * do MADV_POPULATE_READ, and then MADV_PAGEOUT, if necessary
> > +      */
> > +     madvise(addr, page_sz, MADV_POPULATE_READ);
> > +     if (!build_id_resident)
> > +             madvise(addr, page_sz, MADV_PAGEOUT);
>
> could this fail? should we at least print the error,
> might be tricky to display that becase it's called through system() ?

I don't think it should, given the correct addr and page_sz. If it
fails, then some selftest that relies on it will fail.
I can add printf(), though, and it will be printed in logs, I think.

>
> jirka
>
> > +
> > +     (void)uprobe();
> > +
> > +     return 0;
> > +}
> > +
> >  int main(int argc, char **argv)
> >  {
> >       if (argc != 2)
> > @@ -84,6 +121,10 @@ int main(int argc, char **argv)
> >               return bench();
> >       if (!strcmp("usdt", argv[1]))
> >               return usdt();
> > +     if (!strcmp("uprobe-paged-out", argv[1]))
> > +             return trigger_uprobe(false /* page-out build ID */);
> > +     if (!strcmp("uprobe-paged-in", argv[1]))
> > +             return trigger_uprobe(true /* page-in build ID */);
> >
> >  error:
> >       fprintf(stderr, "usage: %s <bench|usdt>\n", argv[0]);
> > diff --git a/tools/testing/selftests/bpf/uprobe_multi.ld b/tools/testing/selftests/bpf/uprobe_multi.ld
> > new file mode 100644
> > index 000000000000..a2e94828bc8c
> > --- /dev/null
> > +++ b/tools/testing/selftests/bpf/uprobe_multi.ld
> > @@ -0,0 +1,11 @@
> > +SECTIONS
> > +{
> > +     . = ALIGN(4096);
> > +     .note.gnu.build-id : { *(.note.gnu.build-id) }
> > +     . = ALIGN(4096);
> > +}
> > +INSERT AFTER .text;
> > +
> > +build_id_start = ADDR(.note.gnu.build-id);
> > +build_id_end = ADDR(.note.gnu.build-id) + SIZEOF(.note.gnu.build-id);
> > +
> > --
> > 2.43.0
> >
> >





[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux