1. 23 Feb, 2022 3 commits
  2. 22 Feb, 2022 3 commits
  3. 20 Feb, 2022 3 commits
    • Andrii Nakryiko's avatar
      selftests/bpf: Fix btfgen tests · b03e1946
      Andrii Nakryiko authored
      There turned out to be a few problems with btfgen selftests.
      
      First, core_btfgen tests are failing in BPF CI due to the use of
      full-featured bpftool, which has extra dependencies on libbfd, libcap,
      etc, which are present in BPF CI's build environment, but those shared
      libraries are missing in QEMU image in which test_progs is running.
      
      To fix this problem, use minimal bootstrap version of bpftool instead.
      It only depend on libelf and libz, same as libbpf, so doesn't add any
      new requirements (and bootstrap bpftool still implementes entire
      `bpftool gen` functionality, which is quite convenient).
      
      Second problem is even more interesting. Both core_btfgen and core_reloc
      reuse the same set of struct core_reloc_test_case array of test case
      definitions. That in itself is not a problem, but btfgen test replaces
      test_case->btf_src_file property with the path to temporary file into
      which minimized BTF is output by bpftool. This interferes with original
      core_reloc tests, depending on order of tests execution (core_btfgen is
      run first in sequential mode and skrews up subsequent core_reloc run by
      pointing to already deleted temporary file, instead of the original BTF
      files) and whether those two runs share the same process (in parallel
      mode the chances are high for them to run in two separate processes and
      so not interfere with each other).
      
      To prevent this interference, create and use local copy of a test
      definition. Mark original array as constant to catch accidental
      modifcations. Note that setup_type_id_case_success() and
      setup_type_id_case_success() still modify common test_case->output
      memory area, but it is ok as each setup function has to re-initialize it
      completely anyways. In sequential mode it leads to deterministic and
      correct initialization. In parallel mode they will either each have
      their own process, or if core_reloc and core_btfgen happen to be run by
      the same worker process, they will still do that sequentially within the
      worker process. If they are sharded across multiple processes, they
      don't really share anything anyways.
      
      Also, rename core_btfgen into core_reloc_btfgen, as it is indeed just
      a "flavor" of core_reloc test, not an independent set of tests. So make
      it more obvious.
      
      Last problem that needed solving was that location of bpftool differs
      between test_progs and test_progs' flavors (e.g., test_progs-no_alu32).
      To keep it simple, create a symlink to bpftool both inside
      selftests/bpf/ directory and selftests/bpf/<flavor> subdirectory. That
      way, from inside core_reloc test, location to bpftool is just "./bpftool".
      
      v2->v3:
        - fix bpftool location relative the test_progs-no_alu32;
      v1->v2:
        - fix corruption of core_reloc_test_case.
      
      Fixes: 704c91e5 ("selftests/bpf: Test "bpftool gen min_core_btf")
      Signed-off-by: default avatarAndrii Nakryiko <andrii@kernel.org>
      Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      Acked-by: default avatarYucong Sun <sunyucong@gmail.com>
      Link: https://lore.kernel.org/bpf/20220220042720.3336684-1-andrii@kernel.org
      b03e1946
    • Souptick Joarder (HPE)'s avatar
      bpf: Initialize ret to 0 inside btf_populate_kfunc_set() · d0b38229
      Souptick Joarder (HPE) authored
      Kernel test robot reported below error ->
      
      kernel/bpf/btf.c:6718 btf_populate_kfunc_set()
      error: uninitialized symbol 'ret'.
      
      Initialize ret to 0.
      
      Fixes: dee872e1 ("bpf: Populate kfunc BTF ID sets in struct btf")
      Reported-by: default avatarkernel test robot <lkp@intel.com>
      Signed-off-by: default avatarSouptick Joarder (HPE) <jrdr.linux@gmail.com>
      Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      Acked-by: default avatarKumar Kartikeya Dwivedi <memxor@gmail.com>
      Link: https://lore.kernel.org/bpf/20220219163915.125770-1-jrdr.linux@gmail.com
      d0b38229
    • Yonghong Song's avatar
      selftests/bpf: Fix a clang deprecated-declarations compilation error · a33c0c79
      Yonghong Song authored
      Build the kernel and selftest with clang compiler with LLVM=1,
        make -j LLVM=1
        make -C tools/testing/selftests/bpf -j LLVM=1
      
      I hit the following selftests/bpf compilation error:
        In file included from test_cpp.cpp:3:
        /.../tools/testing/selftests/bpf/tools/include/bpf/libbpf.h:73:8:
          error: 'relaxed_core_relocs' is deprecated: libbpf v0.6+: field has no effect [-Werror,-Wdeprecated-declarations]
        struct bpf_object_open_opts {
               ^
        test_cpp.cpp:56:2: note: in implicit move constructor for 'bpf_object_open_opts' first required here
                LIBBPF_OPTS(bpf_object_open_opts, opts);
                ^
        /.../tools/testing/selftests/bpf/tools/include/bpf/libbpf_common.h:77:3: note: expanded from macro 'LIBBPF_OPTS'
                        (struct TYPE) {                                             \
                        ^
        /.../tools/testing/selftests/bpf/tools/include/bpf/libbpf.h:90:2: note: 'relaxed_core_relocs' has been explicitly marked deprecated here
                LIBBPF_DEPRECATED_SINCE(0, 6, "field has no effect")
                ^
        /.../tools/testing/selftests/bpf/tools/include/bpf/libbpf_common.h:24:4: note: expanded from macro 'LIBBPF_DEPRECATED_SINCE'
                        (LIBBPF_DEPRECATED("libbpf v" # major "." # minor "+: " msg))
                         ^
        /.../tools/testing/selftests/bpf/tools/include/bpf/libbpf_common.h:19:47: note: expanded from macro 'LIBBPF_DEPRECATED'
        #define LIBBPF_DEPRECATED(msg) __attribute__((deprecated(msg)))
      
      There are two ways to fix the issue, one is to use GCC diagnostic ignore pragma, and the
      other is to open code bpf_object_open_opts instead of using LIBBPF_OPTS.
      Since in general LIBBPF_OPTS is preferred, the patch fixed the issue by
      adding proper GCC diagnostic ignore pragmas.
      Signed-off-by: default avatarYonghong Song <yhs@fb.com>
      Signed-off-by: default avatarAndrii Nakryiko <andrii@kernel.org>
      Link: https://lore.kernel.org/bpf/20220217194005.2765348-1-yhs@fb.com
      a33c0c79
  4. 18 Feb, 2022 27 commits
  5. 17 Feb, 2022 4 commits