Skip to content
Snippets Groups Projects
  1. Feb 21, 2020
  2. Feb 20, 2020
    • Andrii Nakryiko's avatar
      libbpf: Relax check whether BTF is mandatory · 53276446
      Andrii Nakryiko authored
      
      If BPF program is using BTF-defined maps, BTF is required only for
      libbpf itself to process map definitions. If after that BTF fails to
      be loaded into kernel (e.g., if it doesn't support BTF at all), this
      shouldn't prevent valid BPF program from loading. Existing
      retry-without-BTF logic for creating maps will succeed to create such
      maps without any problems. So, presence of .maps section shouldn't make
      BTF required for kernel. Update the check accordingly.
      
      Validated by ensuring simple BPF program with BTF-defined maps is still
      loaded on old kernel without BTF support and map is correctly parsed and
      created.
      
      Fixes: abd29c93 ("libbpf: allow specifying map definitions using BTF")
      Reported-by: default avatarJulia Kartseva <hex@fb.com>
      Signed-off-by: default avatarAndrii Nakryiko <andriin@fb.com>
      Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      Link: https://lore.kernel.org/bpf/20200220062635.1497872-1-andriin@fb.com
      53276446
    • Alexei Starovoitov's avatar
      selftests/bpf: Fix build of sockmap_ktls.c · 50089780
      Alexei Starovoitov authored
      
      The selftests fails to build with:
      tools/testing/selftests/bpf/prog_tests/sockmap_ktls.c: In function ‘test_sockmap_ktls_disconnect_after_delete’:
      tools/testing/selftests/bpf/prog_tests/sockmap_ktls.c:72:37: error: ‘TCP_ULP’ undeclared (first use in this function)
         72 |  err = setsockopt(cli, IPPROTO_TCP, TCP_ULP, "tls", strlen("tls"));
            |                                     ^~~~~~~
      
      Similar to commit that fixes build of sockmap_basic.c on systems with old
      /usr/include fix the build of sockmap_ktls.c
      
      Fixes: d1ba1204 ("selftests/bpf: Test unhashing kTLS socket after removing from map")
      Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      Acked-by: default avatarJohn Fastabend <john.fastabend@gmail.com>
      Link: https://lore.kernel.org/bpf/20200219205514.3353788-1-ast@kernel.org
      50089780
    • Yonghong Song's avatar
      selftests/bpf: Change llvm flag -mcpu=probe to -mcpu=v3 · 83250f2b
      Yonghong Song authored
      
      The latest llvm supports cpu version v3, which is cpu version v1
      plus some additional 64bit jmp insns and 32bit jmp insn support.
      
      In selftests/bpf Makefile, the llvm flag -mcpu=probe did runtime
      probe into the host system. Depending on compilation environments,
      it is possible that runtime probe may fail, e.g., due to
      memlock issue. This will cause generated code with cpu version v1.
      This may cause confusion as the same compiler and the same C code
      generates different byte codes in different environment.
      
      Let us change the llvm flag -mcpu=probe to -mcpu=v3 so the
      generated code will be the same regardless of the compilation
      environment.
      
      Signed-off-by: default avatarYonghong Song <yhs@fb.com>
      Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      Acked-by: default avatarAndrii Nakryiko <andriin@fb.com>
      Link: https://lore.kernel.org/bpf/20200219004236.2291125-1-yhs@fb.com
      83250f2b
    • Alexei Starovoitov's avatar
      Merge branch 'bpf_read_branch_records' · 03aa3955
      Alexei Starovoitov authored
      
      Daniel Xu says:
      
      ====================
      Branch records are a CPU feature that can be configured to record
      certain branches that are taken during code execution. This data is
      particularly interesting for profile guided optimizations. perf has had
      branch record support for a while but the data collection can be a bit
      coarse grained.
      
      We (Facebook) have seen in experiments that associating metadata with
      branch records can improve results (after postprocessing). We generally
      use bpf_probe_read_*() to get metadata out of userspace. That's why bpf
      support for branch records is useful.
      
      Aside from this particular use case, having branch data available to bpf
      progs can be useful to get stack traces out of userspace applications
      that omit frame pointers.
      
      Changes in v8:
      - Use globals instead of perf buffer
      - Call test_perf_branches__detach() before destroying skeleton
      - Fix typo in docs
      
      Changes in v7:
      - Const-ify and static-ify local var
      - Documentation formatting
      
      Changes in v6:
      - Move #ifdef a little to avoid unused variable warnings on !x86
      - Test negative condition in selftest (-EINVAL on improperly configured
        perf event)
      - Skip positive condition selftest on setups that don't support branch
        records
      
      Changes in v5:
      - Rename bpf_perf_prog_read_branches() -> bpf_read_branch_records()
      - Rename BPF_F_GET_BR_SIZE -> BPF_F_GET_BRANCH_RECORDS_SIZE
      - Squash tools/ bpf.h sync into selftest commit
      
      Changes in v4:
      - Add BPF_F_GET_BR_SIZE flag
      - Return -ENOENT on unsupported architectures
      - Only accept initialized memory in helper
      - Check buffer size is multiple of sizeof(struct perf_branch_entry)
      - Use bpf skeleton in selftest
      - Add commit messages
      - Spelling and formatting
      
      Changes in v3:
      - Document filling unused buffer with zero
      - Formatting fixes
      - Rebase
      
      Changes in v2:
      - Change to a bpf helper instead of context access
      - Avoid mentioning Intel specific things
      ====================
      
      Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      03aa3955
    • Daniel Xu's avatar
      selftests/bpf: Add bpf_read_branch_records() selftest · 67306f84
      Daniel Xu authored
      
      Add a selftest to test:
      
      * default bpf_read_branch_records() behavior
      * BPF_F_GET_BRANCH_RECORDS_SIZE flag behavior
      * error path on non branch record perf events
      * using helper to write to stack
      * using helper to write to global
      
      On host with hardware counter support:
      
          # ./test_progs -t perf_branches
          #27/1 perf_branches_hw:OK
          #27/2 perf_branches_no_hw:OK
          #27 perf_branches:OK
          Summary: 1/2 PASSED, 0 SKIPPED, 0 FAILED
      
      On host without hardware counter support (VM):
      
          # ./test_progs -t perf_branches
          #27/1 perf_branches_hw:OK
          #27/2 perf_branches_no_hw:OK
          #27 perf_branches:OK
          Summary: 1/2 PASSED, 1 SKIPPED, 0 FAILED
      
      Also sync tools/include/uapi/linux/bpf.h.
      
      Signed-off-by: default avatarDaniel Xu <dxu@dxuuu.xyz>
      Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      Acked-by: default avatarAndrii Nakryiko <andriin@fb.com>
      Link: https://lore.kernel.org/bpf/20200218030432.4600-3-dxu@dxuuu.xyz
      67306f84
  3. Feb 19, 2020
  4. Feb 18, 2020
  5. Feb 17, 2020
Loading