On Mon, Jun 15, 2020 at 9:45 AM Hao Luo <haoluo@xxxxxxxxxx> wrote: > > Andrii, a couple of general comments on fixed_percpu_data. > > I think it would be better to check the existence of fixed_percpu_data in kallsyms first. If it's not there, just skip, or maybe warn but not fail. fixed_percpu_data is always there, but I missed the fact that it's x86-specific one. I'll switch to some bpf-specific symbol (e.g., like bpf_prog_fops or something along those lines). > > Further, if we really want to be sure that fixed_percpu_data is the first percpu var, we can read the value of __per_cpu_start, which marks the beginning address of the percpu section. Checking the address of fixed_percpu_data against __per_cpu_start rather than 0 should be more robust, I think, given that fixed_percpu_data exists. There are assertions in Linux sources that fixed_percpu_data is 0, so I don't think that it necessary. But it's a moot point, as I'll use something less x86-specific. > > Hao > > On Fri, Jun 12, 2020 at 3:35 PM Andrii Nakryiko <andriin@xxxxxx> wrote: >> >> Validate libbpf is able to handle weak and strong kernel symbol externs in BPF >> code correctly. >> >> Signed-off-by: Andrii Nakryiko <andriin@xxxxxx> >> --- >> .../testing/selftests/bpf/prog_tests/ksyms.c | 71 +++++++++++++++++++ >> .../testing/selftests/bpf/progs/test_ksyms.c | 32 +++++++++ >> 2 files changed, 103 insertions(+) >> create mode 100644 tools/testing/selftests/bpf/prog_tests/ksyms.c >> create mode 100644 tools/testing/selftests/bpf/progs/test_ksyms.c >> [...]