Re: [PATCH bpf-next v5 2/2] selftests/bpf: Add selftest for fill_link_info

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

 



On Sat, Aug 12, 2023 at 4:07 AM Jiri Olsa <olsajiri@xxxxxxxxx> wrote:
>
> On Fri, Aug 11, 2023 at 02:36:47AM +0000, Yafang Shao wrote:
>
> SNIP
>
> > +void test_fill_link_info(void)
> > +{
> > +     struct test_fill_link_info *skel;
> > +     int i;
> > +
> > +     skel = test_fill_link_info__open_and_load();
> > +     if (!ASSERT_OK_PTR(skel, "skel_open"))
> > +             return;
> > +
> > +     /* load kallsyms to compare the addr */
> > +     if (!ASSERT_OK(load_kallsyms_refresh(), "load_kallsyms_refresh"))
> > +             goto cleanup;
> > +
> > +     kprobe_addr = ksym_get_addr(KPROBE_FUNC);
> > +     if (test__start_subtest("kprobe_link_info"))
> > +             test_kprobe_fill_link_info(skel, BPF_PERF_EVENT_KPROBE, false);
> > +     if (test__start_subtest("kretprobe_link_info"))
> > +             test_kprobe_fill_link_info(skel, BPF_PERF_EVENT_KRETPROBE, false);
> > +     if (test__start_subtest("kprobe_invalid_ubuff"))
> > +             test_kprobe_fill_link_info(skel, BPF_PERF_EVENT_KPROBE, true);
> > +     if (test__start_subtest("tracepoint_link_info"))
> > +             test_tp_fill_link_info(skel);
> > +
> > +     uprobe_offset = get_uprobe_offset(&uprobe_func);
> > +     if (test__start_subtest("uprobe_link_info"))
> > +             test_uprobe_fill_link_info(skel, BPF_PERF_EVENT_UPROBE);
> > +     if (test__start_subtest("uretprobe_link_info"))
> > +             test_uprobe_fill_link_info(skel, BPF_PERF_EVENT_URETPROBE);
> > +
> > +     qsort(kmulti_syms, KMULTI_CNT, sizeof(kmulti_syms[0]), symbols_cmp_r);
>
> hum, what's the reason for sorting the symbols?

Kernel will sort the kprobe_multi symbols, and then store the
corresponding addresses in the same order into kmulti_link->addr. In
order to compare the addresses, we should sort them and then get the
addresses.

>
> other than that it looks good to me
>
> Acked-by: Jiri Olsa <jolsa@xxxxxxxxxx>
>
> jirka
>
> > +     for (i = 0; i < KMULTI_CNT; i++)
> > +             kmulti_addrs[i] = ksym_get_addr(kmulti_syms[i]);
> > +     if (test__start_subtest("kprobe_multi_link_info"))
> > +             test_kprobe_multi_fill_link_info(skel, false, false);
> > +     if (test__start_subtest("kretprobe_multi_link_info"))
> > +             test_kprobe_multi_fill_link_info(skel, true, false);
> > +     if (test__start_subtest("kprobe_multi_invalid_ubuff"))
> > +             test_kprobe_multi_fill_link_info(skel, true, true);
> > +
> > +cleanup:
> > +     test_fill_link_info__destroy(skel);
> > +}
>
> SNIP



-- 
Regards
Yafang





[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