1. 30 Nov, 2021 3 commits
  2. 29 Nov, 2021 4 commits
  3. 26 Nov, 2021 1 commit
    • Tiezhu Yang's avatar
      bpf, mips: Fix build errors about __NR_bpf undeclared · e32cb12f
      Tiezhu Yang authored
      Add the __NR_bpf definitions to fix the following build errors for mips:
      
        $ cd tools/bpf/bpftool
        $ make
        [...]
        bpf.c:54:4: error: #error __NR_bpf not defined. libbpf does not support your arch.
         #  error __NR_bpf not defined. libbpf does not support your arch.
            ^~~~~
        bpf.c: In function ‘sys_bpf’:
        bpf.c:66:17: error: ‘__NR_bpf’ undeclared (first use in this function); did you mean ‘__NR_brk’?
          return syscall(__NR_bpf, cmd, attr, size);
                         ^~~~~~~~
                         __NR_brk
        [...]
        In file included from gen_loader.c:15:0:
        skel_internal.h: In function ‘skel_sys_bpf’:
        skel_internal.h:53:17: error: ‘__NR_bpf’ undeclared (first use in this function); did you mean ‘__NR_brk’?
          return syscall(__NR_bpf, cmd, attr, size);
                         ^~~~~~~~
                         __NR_brk
      
      We can see the following generated definitions:
      
        $ grep -r "#define __NR_bpf" arch/mips
        arch/mips/include/generated/uapi/asm/unistd_o32.h:#define __NR_bpf (__NR_Linux + 355)
        arch/mips/include/generated/uapi/asm/unistd_n64.h:#define __NR_bpf (__NR_Linux + 315)
        arch/mips/include/generated/uapi/asm/unistd_n32.h:#define __NR_bpf (__NR_Linux + 319)
      
      The __NR_Linux is defined in arch/mips/include/uapi/asm/unistd.h:
      
        $ grep -r "#define __NR_Linux" arch/mips
        arch/mips/include/uapi/asm/unistd.h:#define __NR_Linux	4000
        arch/mips/include/uapi/asm/unistd.h:#define __NR_Linux	5000
        arch/mips/include/uapi/asm/unistd.h:#define __NR_Linux	6000
      
      That is to say, __NR_bpf is:
      
        4000 + 355 = 4355 for mips o32,
        6000 + 319 = 6319 for mips n32,
        5000 + 315 = 5315 for mips n64.
      
      So use the GCC pre-defined macro _ABIO32, _ABIN32 and _ABI64 [1] to define
      the corresponding __NR_bpf.
      
      This patch is similar with commit bad1926d ("bpf, s390: fix build for
      libbpf and selftest suite").
      
        [1] https://gcc.gnu.org/git/?p=gcc.git;a=blob;f=gcc/config/mips/mips.h#l549Signed-off-by: default avatarTiezhu Yang <yangtiezhu@loongson.cn>
      Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      Link: https://lore.kernel.org/bpf/1637804167-8323-1-git-send-email-yangtiezhu@loongson.cn
      e32cb12f
  4. 25 Nov, 2021 18 commits
  5. 23 Nov, 2021 1 commit
  6. 19 Nov, 2021 4 commits
  7. 18 Nov, 2021 1 commit
  8. 17 Nov, 2021 7 commits
  9. 16 Nov, 2021 1 commit
    • Andrii Nakryiko's avatar
      selftests/bpf: Add uprobe triggering overhead benchmarks · d41bc48b
      Andrii Nakryiko authored
      Add benchmark to measure overhead of uprobes and uretprobes. Also have
      a baseline (no uprobe attached) benchmark.
      
      On my dev machine, baseline benchmark can trigger 130M user_target()
      invocations. When uprobe is attached, this falls to just 700K. With
      uretprobe, we get down to 520K:
      
        $ sudo ./bench trig-uprobe-base -a
        Summary: hits  131.289 ± 2.872M/s
      
        # UPROBE
        $ sudo ./bench -a trig-uprobe-without-nop
        Summary: hits    0.729 ± 0.007M/s
      
        $ sudo ./bench -a trig-uprobe-with-nop
        Summary: hits    1.798 ± 0.017M/s
      
        # URETPROBE
        $ sudo ./bench -a trig-uretprobe-without-nop
        Summary: hits    0.508 ± 0.012M/s
      
        $ sudo ./bench -a trig-uretprobe-with-nop
        Summary: hits    0.883 ± 0.008M/s
      
      So there is almost 2.5x performance difference between probing nop vs
      non-nop instruction for entry uprobe. And 1.7x difference for uretprobe.
      
      This means that non-nop uprobe overhead is around 1.4 microseconds for uprobe
      and 2 microseconds for non-nop uretprobe.
      
      For nop variants, uprobe and uretprobe overhead is down to 0.556 and
      1.13 microseconds, respectively.
      
      For comparison, just doing a very low-overhead syscall (with no BPF
      programs attached anywhere) gives:
      
        $ sudo ./bench trig-base -a
        Summary: hits    4.830 ± 0.036M/s
      
      So uprobes are about 2.67x slower than pure context switch.
      Signed-off-by: default avatarAndrii Nakryiko <andrii@kernel.org>
      Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      Link: https://lore.kernel.org/bpf/20211116013041.4072571-1-andrii@kernel.org
      d41bc48b