1. 12 11月, 2021 1 次提交
  2. 04 11月, 2021 1 次提交
  3. 26 10月, 2021 3 次提交
    • Q
      bpftool: Switch to libbpf's hashmap for PIDs/names references · d6699f8e
      Quentin Monnet 提交于
      In order to show PIDs and names for processes holding references to BPF
      programs, maps, links, or BTF objects, bpftool creates hash maps to
      store all relevant information. This commit is part of a set that
      transitions from the kernel's hash map implementation to the one coming
      with libbpf.
      
      The motivation is to make bpftool less dependent of kernel headers, to
      ease the path to a potential out-of-tree mirror, like libbpf has.
      
      This is the third and final step of the transition, in which we convert
      the hash maps used for storing the information about the processes
      holding references to BPF objects (programs, maps, links, BTF), and at
      last we drop the inclusion of tools/include/linux/hashtable.h.
      
      Note: Checkpatch complains about the use of __weak declarations, and the
      missing empty lines after the bunch of empty function declarations when
      compiling without the BPF skeletons (none of these were introduced in
      this patch). We want to keep things as they are, and the reports should
      be safe to ignore.
      Signed-off-by: NQuentin Monnet <quentin@isovalent.com>
      Signed-off-by: NAndrii Nakryiko <andrii@kernel.org>
      Link: https://lore.kernel.org/bpf/20211023205154.6710-6-quentin@isovalent.com
      d6699f8e
    • Q
      bpftool: Switch to libbpf's hashmap for pinned paths of BPF objects · 8f184732
      Quentin Monnet 提交于
      In order to show pinned paths for BPF programs, maps, or links when
      listing them with the "-f" option, bpftool creates hash maps to store
      all relevant paths under the bpffs. So far, it would rely on the
      kernel implementation (from tools/include/linux/hashtable.h).
      
      We can make bpftool rely on libbpf's implementation instead. The
      motivation is to make bpftool less dependent of kernel headers, to ease
      the path to a potential out-of-tree mirror, like libbpf has.
      
      This commit is the first step of the conversion: the hash maps for
      pinned paths for programs, maps, and links are converted to libbpf's
      hashmap.{c,h}. Other hash maps used for the PIDs of process holding
      references to BPF objects are left unchanged for now. On the build side,
      this requires adding a dependency to a second header internal to libbpf,
      and making it a dependency for the bootstrap bpftool version as well.
      The rest of the changes are a rather straightforward conversion.
      Signed-off-by: NQuentin Monnet <quentin@isovalent.com>
      Signed-off-by: NAndrii Nakryiko <andrii@kernel.org>
      Link: https://lore.kernel.org/bpf/20211023205154.6710-4-quentin@isovalent.com
      8f184732
    • Q
      bpftool: Do not expose and init hash maps for pinned path in main.c · 46241271
      Quentin Monnet 提交于
      BPF programs, maps, and links, can all be listed with their pinned paths
      by bpftool, when the "-f" option is provided. To do so, bpftool builds
      hash maps containing all pinned paths for each kind of objects.
      
      These three hash maps are always initialised in main.c, and exposed
      through main.h. There appear to be no particular reason to do so: we can
      just as well make them static to the files that need them (prog.c,
      map.c, and link.c respectively), and initialise them only when we want
      to show objects and the "-f" switch is provided.
      
      This may prevent unnecessary memory allocations if the implementation of
      the hash maps was to change in the future.
      Signed-off-by: NQuentin Monnet <quentin@isovalent.com>
      Signed-off-by: NAndrii Nakryiko <andrii@kernel.org>
      Link: https://lore.kernel.org/bpf/20211023205154.6710-3-quentin@isovalent.com
      46241271
  4. 23 10月, 2021 1 次提交
  5. 09 10月, 2021 1 次提交
  6. 07 10月, 2021 1 次提交
  7. 31 7月, 2021 3 次提交
  8. 30 7月, 2021 2 次提交
  9. 25 5月, 2021 1 次提交
  10. 19 5月, 2021 1 次提交
    • A
      bpftool: Use syscall/loader program in "prog load" and "gen skeleton" command. · d510296d
      Alexei Starovoitov 提交于
      Add -L flag to bpftool to use libbpf gen_trace facility and syscall/loader program
      for skeleton generation and program loading.
      
      "bpftool gen skeleton -L" command will generate a "light skeleton" or "loader skeleton"
      that is similar to existing skeleton, but has one major difference:
      $ bpftool gen skeleton lsm.o > lsm.skel.h
      $ bpftool gen skeleton -L lsm.o > lsm.lskel.h
      $ diff lsm.skel.h lsm.lskel.h
      @@ -5,34 +4,34 @@
       #define __LSM_SKEL_H__
      
       #include <stdlib.h>
      -#include <bpf/libbpf.h>
      +#include <bpf/bpf.h>
      
      The light skeleton does not use majority of libbpf infrastructure.
      It doesn't need libelf. It doesn't parse .o file.
      It only needs few sys_bpf wrappers. All of them are in bpf/bpf.h file.
      In future libbpf/bpf.c can be inlined into bpf.h, so not even libbpf.a would be
      needed to work with light skeleton.
      
      "bpftool prog load -L file.o" command is introduced for debugging of syscall/loader
      program generation. Just like the same command without -L it will try to load
      the programs from file.o into the kernel. It won't even try to pin them.
      
      "bpftool prog load -L -d file.o" command will provide additional debug messages
      on how syscall/loader program was generated.
      Also the execution of syscall/loader program will use bpf_trace_printk() for
      each step of loading BTF, creating maps, and loading programs.
      The user can do "cat /.../trace_pipe" for further debug.
      
      An example of fexit_sleep.lskel.h generated from progs/fexit_sleep.c:
      struct fexit_sleep {
      	struct bpf_loader_ctx ctx;
      	struct {
      		struct bpf_map_desc bss;
      	} maps;
      	struct {
      		struct bpf_prog_desc nanosleep_fentry;
      		struct bpf_prog_desc nanosleep_fexit;
      	} progs;
      	struct {
      		int nanosleep_fentry_fd;
      		int nanosleep_fexit_fd;
      	} links;
      	struct fexit_sleep__bss {
      		int pid;
      		int fentry_cnt;
      		int fexit_cnt;
      	} *bss;
      };
      Signed-off-by: NAlexei Starovoitov <ast@kernel.org>
      Signed-off-by: NDaniel Borkmann <daniel@iogearbox.net>
      Acked-by: NAndrii Nakryiko <andrii@kernel.org>
      Link: https://lore.kernel.org/bpf/20210514003623.28033-18-alexei.starovoitov@gmail.com
      d510296d
  11. 02 4月, 2021 1 次提交
  12. 11 2月, 2021 1 次提交
  13. 20 11月, 2020 1 次提交
    • Y
      bpftool: Add {i,d}tlb_misses support for bpftool profile · 450d060e
      Yonghong Song 提交于
      Commit 47c09d6a("bpftool: Introduce "prog profile" command")
      introduced "bpftool prog profile" command which can be used
      to profile bpf program with metrics like # of instructions,
      
      This patch added support for itlb_misses and dtlb_misses.
      During an internal bpf program performance evaluation,
      I found these two metrics are also very useful. The following
      is an example output:
      
       $ bpftool prog profile id 324 duration 3 cycles itlb_misses
      
                 1885029 run_cnt
              5134686073 cycles
                  306893 itlb_misses
      
       $ bpftool prog profile id 324 duration 3 cycles dtlb_misses
      
                 1827382 run_cnt
              4943593648 cycles
                 5975636 dtlb_misses
      
       $ bpftool prog profile id 324 duration 3 cycles llc_misses
      
                 1836527 run_cnt
              5019612972 cycles
                 4161041 llc_misses
      
      From the above, we can see quite some dtlb misses, 3 dtlb misses
      perf prog run. This might be something worth further investigation.
      Signed-off-by: NYonghong Song <yhs@fb.com>
      Signed-off-by: NDaniel Borkmann <daniel@iogearbox.net>
      Acked-by: NSong Liu <songliubraving@fb.com>
      Link: https://lore.kernel.org/bpf/20201119073039.4060095-1-yhs@fb.com
      450d060e
  14. 06 11月, 2020 1 次提交
  15. 16 9月, 2020 1 次提交
  16. 04 9月, 2020 1 次提交
  17. 14 8月, 2020 1 次提交
  18. 28 7月, 2020 1 次提交
  19. 18 7月, 2020 1 次提交
  20. 25 6月, 2020 1 次提交
  21. 23 6月, 2020 2 次提交
  22. 02 6月, 2020 1 次提交
  23. 20 5月, 2020 1 次提交
  24. 12 5月, 2020 1 次提交
  25. 14 3月, 2020 1 次提交
    • Q
      tools: bpftool: Restore message on failure to guess program type · 6ae32b29
      Quentin Monnet 提交于
      In commit 4a3d6c6a ("libbpf: Reduce log level for custom section
      names"), log level for messages for libbpf_attach_type_by_name() and
      libbpf_prog_type_by_name() was downgraded from "info" to "debug". The
      latter function, in particular, is used by bpftool when attempting to
      load programs, and this change caused bpftool to exit with no hint or
      error message when it fails to detect the type of the program to load
      (unless "-d" option was provided).
      
      To help users understand why bpftool fails to load the program, let's do
      a second run of the function with log level in "debug" mode in case of
      failure.
      
      Before:
      
          # bpftool prog load sample_ret0.o /sys/fs/bpf/sample_ret0
          # echo $?
          255
      
      Or really verbose with -d flag:
      
          # bpftool -d prog load sample_ret0.o /sys/fs/bpf/sample_ret0
          libbpf: loading sample_ret0.o
          libbpf: section(1) .strtab, size 134, link 0, flags 0, type=3
          libbpf: skip section(1) .strtab
          libbpf: section(2) .text, size 16, link 0, flags 6, type=1
          libbpf: found program .text
          libbpf: section(3) .debug_abbrev, size 55, link 0, flags 0, type=1
          libbpf: skip section(3) .debug_abbrev
          libbpf: section(4) .debug_info, size 75, link 0, flags 0, type=1
          libbpf: skip section(4) .debug_info
          libbpf: section(5) .rel.debug_info, size 32, link 14, flags 0, type=9
          libbpf: skip relo .rel.debug_info(5) for section(4)
          libbpf: section(6) .debug_str, size 150, link 0, flags 30, type=1
          libbpf: skip section(6) .debug_str
          libbpf: section(7) .BTF, size 155, link 0, flags 0, type=1
          libbpf: section(8) .BTF.ext, size 80, link 0, flags 0, type=1
          libbpf: section(9) .rel.BTF.ext, size 32, link 14, flags 0, type=9
          libbpf: skip relo .rel.BTF.ext(9) for section(8)
          libbpf: section(10) .debug_frame, size 40, link 0, flags 0, type=1
          libbpf: skip section(10) .debug_frame
          libbpf: section(11) .rel.debug_frame, size 16, link 14, flags 0, type=9
          libbpf: skip relo .rel.debug_frame(11) for section(10)
          libbpf: section(12) .debug_line, size 74, link 0, flags 0, type=1
          libbpf: skip section(12) .debug_line
          libbpf: section(13) .rel.debug_line, size 16, link 14, flags 0, type=9
          libbpf: skip relo .rel.debug_line(13) for section(12)
          libbpf: section(14) .symtab, size 96, link 1, flags 0, type=2
          libbpf: looking for externs among 4 symbols...
          libbpf: collected 0 externs total
          libbpf: failed to guess program type from ELF section '.text'
          libbpf: supported section(type) names are: socket sk_reuseport kprobe/ [...]
      
      After:
      
          # bpftool prog load sample_ret0.o /sys/fs/bpf/sample_ret0
          libbpf: failed to guess program type from ELF section '.text'
          libbpf: supported section(type) names are: socket sk_reuseport kprobe/ [...]
      Signed-off-by: NQuentin Monnet <quentin@isovalent.com>
      Signed-off-by: NAlexei Starovoitov <ast@kernel.org>
      Acked-by: NJohn Fastabend <john.fastabend@gmail.com>
      Link: https://lore.kernel.org/bpf/20200311021205.9755-1-quentin@isovalent.comSigned-off-by: NAlexei Starovoitov <ast@kernel.org>
      6ae32b29
  26. 13 3月, 2020 2 次提交
  27. 10 3月, 2020 1 次提交
    • S
      bpftool: Introduce "prog profile" command · 47c09d6a
      Song Liu 提交于
      With fentry/fexit programs, it is possible to profile BPF program with
      hardware counters. Introduce bpftool "prog profile", which measures key
      metrics of a BPF program.
      
      bpftool prog profile command creates per-cpu perf events. Then it attaches
      fentry/fexit programs to the target BPF program. The fentry program saves
      perf event value to a map. The fexit program reads the perf event again,
      and calculates the difference, which is the instructions/cycles used by
      the target program.
      
      Example input and output:
      
        ./bpftool prog profile id 337 duration 3 cycles instructions llc_misses
      
              4228 run_cnt
           3403698 cycles                                              (84.08%)
           3525294 instructions   #  1.04 insn per cycle               (84.05%)
                13 llc_misses     #  3.69 LLC misses per million isns  (83.50%)
      
      This command measures cycles and instructions for BPF program with id
      337 for 3 seconds. The program has triggered 4228 times. The rest of the
      output is similar to perf-stat. In this example, the counters were only
      counting ~84% of the time because of time multiplexing of perf counters.
      
      Note that, this approach measures cycles and instructions in very small
      increments. So the fentry/fexit programs introduce noticeable errors to
      the measurement results.
      
      The fentry/fexit programs are generated with BPF skeletons. Therefore, we
      build bpftool twice. The first time _bpftool is built without skeletons.
      Then, _bpftool is used to generate the skeletons. The second time, bpftool
      is built with skeletons.
      Signed-off-by: NSong Liu <songliubraving@fb.com>
      Signed-off-by: NDaniel Borkmann <daniel@iogearbox.net>
      Reviewed-by: NQuentin Monnet <quentin@isovalent.com>
      Acked-by: NYonghong Song <yhs@fb.com>
      Link: https://lore.kernel.org/bpf/20200309173218.2739965-2-songliubraving@fb.com
      47c09d6a
  28. 26 2月, 2020 1 次提交
  29. 08 2月, 2020 1 次提交
  30. 21 1月, 2020 1 次提交
  31. 16 12月, 2019 2 次提交
  32. 11 12月, 2019 1 次提交