1. 26 Oct, 2017 3 commits
  2. 25 Oct, 2017 1 commit
  3. 24 Oct, 2017 5 commits
    • Martin KaFai Lau's avatar
      Introduce BPF Program Snapshot helper (bps) · f89cb40b
      Martin KaFai Lau authored
      A simple program to list all bpf programs of a system.
      
      [root@arch-fb-vm1 bcc]# ./build/introspection/bps -h
      BPF Program Snapshot (bps):
      List of all BPF programs loaded into the system.
      
      Usage: bps [bpf-prog-id]
          [bpf-prog-id] If specified, it shows the details info of the bpf-prog
      
      * List all bpf programs *
      [root@arch-fb-vm1 bcc]# ./build/introspection/bps
            BID TYPE                 UID  #MAPS LoadTime     NAME
             82 kprobe                 0      1 Oct19/23:52  map_perf_test
             83 kprobe                 0      1 Oct19/23:52  map_perf_test
             84 kprobe                 0      1 Oct19/23:52  map_perf_test
             85 kprobe                 0      1 Oct19/23:52  map_perf_test
             86 kprobe                 0      4 Oct19/23:52  map_perf_test
             87 kprobe                 0      1 Oct19/23:52  map_perf_test
             88 kprobe                 0      1 Oct19/23:52  map_perf_test
             89 kprobe                 0      1 Oct19/23:52  map_perf_test
      
      * List a particular bpf program *
      [root@arch-fb-vm1 bcc]# ./build/introspection/bps 86
            BID TYPE                 UID  #MAPS LoadTime     NAME
             86 kprobe                 0      4 Oct19/23:52  map_perf_test
      
           MID TYPE            FLAGS         KeySz  ValueSz  MaxEnts NAME
           120 lru hash        0x0               4        8    10000 lru_hash_map
           129 lru hash        0x0               4        8       43 lru_hash_lookup
           123 array of maps   0x0               4        4     1024 array_of_lru_ha
           121 lru hash        0x2               4        8    10000 nocommon_lru_ha
      
      * JIT disabled *
      [root@arch-fb-vm1 bpf]# sysctl -w net.core.bpf_jit_enable=0
      [root@arch-fb-vm1 bpf]# ./test_progs
      [root@arch-fb-vm1 bcc]# ./build/introspection/bps
            BID TYPE                 UID  #MAPS LoadTime     NAME
            94- socket filter          0      1 Oct19/23:55  test_obj_id
            95- socket filter          0      1 Oct19/23:55  test_obj_id
      
      * Run without CAP_SYS_ADMIN *
      [kafai@arch-fb-vm1 ~]$ ./bps 1
      Require CAP_SYS_ADMIN capability.  Please retry as root
      
      * Older kernel *
      [root@arch-fb-vm2 build]# uname -r
      4.12.14
      [root@arch-fb-vm2 build]# ./introspection/bps 1
      Kernel does not support BPF introspection
      Signed-off-by: default avatarMartin KaFai Lau <kafai@fb.com>
      f89cb40b
    • Martin KaFai Lau's avatar
      Add a few introspection helpers · 3c24ad96
      Martin KaFai Lau authored
      This patch adds the following helpers to libbpf:
      int bpf_prog_get_next_id(uint32_t start_id, uint32_t *next_id);
      int bpf_prog_get_fd_by_id(uint32_t id);
      int bpf_map_get_fd_by_id(uint32_t id);
      
      It also changes the info_len arg of the existing bpf_obj_get_info()
      from int to uint32_t.
      Signed-off-by: default avatarMartin KaFai Lau <kafai@fb.com>
      3c24ad96
    • Martin KaFai Lau's avatar
      bpf: Add support for prog_name and map_name · df36816a
      Martin KaFai Lau authored
      This patch adds support for prog_name and map_name.
      
      For libbpf.{h,c}, the new functions, bpf_prog_load_name()
      and bpf_create_map_name() is created to avoid breaking the
      existing libbpf.{a,so} user.
      
      libbcc.py is also modified accordingly to reflect the
      availability of the new functions in libbpf.
      
      clang/b_frontend_action.cc, b/codegen_llvm.cc and BPF.cc are
      modified to take advantage of the prog and map name also.
      
      Run the following tests in new and old kernel (old kernel
      in the sense that it does not support the prog/map name):
      
      1) tools/trace.py -K sys_clone
      2) examples/cpp/HelloWorld
      
      Here is the output of the bpf (BPF Snapshot) that
      will be introduced in the later patch:
      [root@arch-fb-vm1 bcc]# ./tools/biosnoop.py
      
      [root@arch-fb-vm1 bcc]# ./build/introspection/bps
            BID TYPE                 UID  #MAPS LoadTime     NAME
            113 kprobe                 0      1 Oct20/13:11  trace_pid_start
            114 kprobe                 0      1 Oct20/13:11  trace_req_start
            115 kprobe                 0      3 Oct20/13:11  trace_req_compl
      
      [root@arch-fb-vm1 bcc]# ./build/introspection/bps 113
            BID TYPE                 UID  #MAPS LoadTime     NAME
            113 kprobe                 0      1 Oct20/13:11  trace_pid_start
      
           MID TYPE            FLAGS         KeySz  ValueSz  MaxEnts NAME
           186 hash            0x0               8       20    10240 infobyreq
      Signed-off-by: default avatarMartin KaFai Lau <kafai@fb.com>
      df36816a
    • yonghong-song's avatar
      Merge pull request #1408 from afiskon/master · ae194a1e
      yonghong-song authored
      Explain possible reason of an error in scripts that rely on /proc/kallsyms (fixes #1391)
      ae194a1e
    • Yonghong Song's avatar
      bpf: fix a couple of issues related to arm64 · 7abe63a0
      Yonghong Song authored
      The linux arm64 header linux:arch/arm64/include/asm/sysreg.h
      contains asm statement outside the function,
      
      ========
      asm(
      "       .irp    num,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30\n"
      "       .equ    .L__reg_num_x\\num, \\num\n"
      "       .endr\n"
      "       .equ    .L__reg_num_xzr, 31\n"
      "\n"
      "       .macro  mrs_s, rt, sreg\n"
              __emit_inst(0xd5200000|(\\sreg)|(.L__reg_num_\\rt))
      "       .endm\n"
      "\n"
      "       .macro  msr_s, sreg, rt\n"
              __emit_inst(0xd5000000|(\\sreg)|(.L__reg_num_\\rt))
      "       .endm\n"
      );
      ========
      
      The compiler cannot remove them since they are file scope.
      This patch adds bpf asm parser to handle this, otherwise,
      llvm will complain with compilation failure. Since none of
      macros/defines are used in bpf program, there is no impact
      in compilation result.
      
      Another change is to add AARCH64 value to ld_cache processing.
      The value is taken from glibc:sysdeps/generic/ldconfig.h.
      Signed-off-by: default avatarYonghong Song <yhs@fb.com>
      7abe63a0
  4. 23 Oct, 2017 1 commit
  5. 20 Oct, 2017 2 commits
  6. 19 Oct, 2017 1 commit
  7. 18 Oct, 2017 4 commits
  8. 17 Oct, 2017 1 commit
  9. 16 Oct, 2017 3 commits
    • 4ast's avatar
      Merge pull request #1390 from iovisor/yhs_dev · e6e66272
      4ast authored
      attempt to compile with system bpf.h if default compile failed
      e6e66272
    • Yonghong Song's avatar
      bpf: print out the src debug info to a temporary file · dd3e7eaf
      Yonghong Song authored
      Currently, for C++ API and for each func, the original src
      and the rewritten source has been stored in
      BCC_PROG_TAG_DIR directory. This patch allows the
      source debug info (bytecode embedded by source code)
      also stored in the same BCC_PROG_TAG_DIR directory.
      
      This feature is not turned on by default now.
      It requires non-zero (debug_flag & DEBUG_SOURCE).
      The DEBUG_SOURCE enables "-g", with which a lot of more
      llvm insns executed and it may increase application
      RSS overhead by 4M (in my test).
      
      As an example, if you modify examples/cpp/RandomRead.cc
      to enable DEBUG_SOURCE, as below
      -  bpf = new ebpf::BPF();
      +  bpf = new ebpf::BPF(8);
      
      After running the application, you can see:
      -bash-4.3$ ls /var/tmp/bcc/bpf_prog_7f01346289a53cc3/
      on_urandom_read.c  on_urandom_read.dis.txt  on_urandom_read.rewritten.c
      -bash-4.3$ cat /var/tmp/bcc/bpf_prog_7f01346289a53cc3/on_urandom_read.dis.txt
      ; int on_urandom_read(struct urandom_read_args* attr) { // Line  23
         0:	bf 16 00 00 00 00 00 00 	r6 = r1
         1:	b7 01 00 00 00 00 00 00 	r1 = 0
      ; struct event_t event = {}; // Line  24
         2:	63 1a f8 ff 00 00 00 00 	*(u32 *)(r10 - 8) = r1
         3:	63 1a f4 ff 00 00 00 00 	*(u32 *)(r10 - 12) = r1
      .....
      Signed-off-by: default avatarYonghong Song <yhs@fb.com>
      dd3e7eaf
    • Yonghong Song's avatar
      attempt to compile with system bpf.h if default compile failed · c53d8ae7
      Yonghong Song authored
      Currently, bcc uses its own version of bpf.h which tries to
      sync with upstream header regularly. If the host bpf.h version
      is lower, bcc can still compile as some bcc codes may requires
      a higher version of bpf.h.
      
      Such an approach does have a drawback. Suppose service A,
      statically linked with bcc, runs on kernel version X.
      Now, the kernel upgrades to version Y. After kernel upgrade/reboot,
      service A may not be able to compile since old bcc bpf.h
      may not align with the new kernel headers.
      For such cases, new version of service A needs rollout.
      
      This patch addresses this issue by attempting a second
      compilation using system bpf.h instead. The feature is not on
      by default. To enable it, pass -DBCC_BACKUP_COMPILE=1
      in cmake setup stage.
      Signed-off-by: default avatarYonghong Song <yhs@fb.com>
      c53d8ae7
  10. 14 Oct, 2017 1 commit
  11. 12 Oct, 2017 5 commits
  12. 11 Oct, 2017 4 commits
  13. 10 Oct, 2017 3 commits
  14. 08 Oct, 2017 2 commits
    • Paul Chaignon's avatar
      Fix segfault with enumerations · f7f873a2
      Paul Chaignon authored
      When serializing map types to JSON, if it encounters an enumeration,
      the rewriter goes into an infinite loop until it segfaults.  This fix
      properly serializes enumerations in the same way unions and structs
      are.
      
          enum a {
            CHOICE_A,
            CHOICE_B,
          };
          BPF_HASH(m, u32, enum a);
      
      is serialized as:
      
          ["a", ["CHOICE_A","CHOICE_B"], "enum"]
      f7f873a2
    • yonghong-song's avatar
      Merge pull request #1382 from palmtenor/vdso · 54a5b4d1
      yonghong-song authored
      Support resolve vDSO symbols
      54a5b4d1
  15. 07 Oct, 2017 4 commits