Skip to content
Snippets Groups Projects
  1. Jan 15, 2023
    • Daniel T. Lee's avatar
      samples/bpf: replace broken overhead microbenchmark with fib_table_lookup · 58e975d0
      Daniel T. Lee authored
      
      The test_overhead bpf program is designed to compare performance
      between tracepoint and kprobe. Initially it used task_rename and
      urandom_read tracepoint.
      
      However, commit 14c17463 ("random: remove unused tracepoints")
      removed urandom_read tracepoint, and for this reason the test_overhead
      got broken.
      
      This commit introduces new microbenchmark using fib_table_lookup.
      This microbenchmark sends UDP packets to localhost in order to invoke
      fib_table_lookup.
      
      In a nutshell:
      fd = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
      addr.sin_addr.s_addr = inet_addr(DUMMY_IP);
      addr.sin_port = htons(DUMMY_PORT);
      for() {
          sendto(fd, buf, strlen(buf), 0,
                  (struct sockaddr *)&addr, sizeof(addr));
      }
      
      on 4 cpus in parallel:
                                                  lookup per sec
      base (no tracepoints, no kprobes)               381k
      with kprobe at fib_table_lookup()               325k
      with tracepoint at fib:fib_table_lookup         330k
      with raw_tracepoint at fib:fib_table_lookup     365k
      
      Fixes: 14c17463 ("random: remove unused tracepoints")
      
      Signed-off-by: default avatarDaniel T. Lee <danieltimlee@gmail.com>
      Link: https://lore.kernel.org/r/20230115071613.125791-6-danieltimlee@gmail.com
      
      
      Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      58e975d0
  2. Apr 11, 2022
  3. Dec 03, 2020
  4. Nov 27, 2020
  5. May 30, 2019
  6. Jul 05, 2018
  7. May 15, 2018
  8. Mar 28, 2018
  9. Apr 08, 2016
    • Alexei Starovoitov's avatar
      samples/bpf: add tracepoint vs kprobe performance tests · e3edfdec
      Alexei Starovoitov authored
      
      the first microbenchmark does
      fd=open("/proc/self/comm");
      for() {
        write(fd, "test");
      }
      and on 4 cpus in parallel:
                                            writes per sec
      base (no tracepoints, no kprobes)         930k
      with kprobe at __set_task_comm()          420k
      with tracepoint at task:task_rename       730k
      
      For kprobe + full bpf program manully fetches oldcomm, newcomm via bpf_probe_read.
      For tracepint bpf program does nothing, since arguments are copied by tracepoint.
      
      2nd microbenchmark does:
      fd=open("/dev/urandom");
      for() {
        read(fd, buf);
      }
      and on 4 cpus in parallel:
                                             reads per sec
      base (no tracepoints, no kprobes)         300k
      with kprobe at urandom_read()             279k
      with tracepoint at random:urandom_read    290k
      
      bpf progs attached to kprobe and tracepoint are noop.
      
      Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      e3edfdec
  10. Apr 06, 2016
    • Naveen N. Rao's avatar
      samples/bpf: Fix build breakage with map_perf_test_user.c · 77e63534
      Naveen N. Rao authored
      
      Building BPF samples is failing with the below error:
      
      samples/bpf/map_perf_test_user.c: In function ‘main’:
      samples/bpf/map_perf_test_user.c:134:9: error: variable ‘r’ has
      initializer but incomplete type
        struct rlimit r = {RLIM_INFINITY, RLIM_INFINITY};
               ^
      samples/bpf/map_perf_test_user.c:134:21: error: ‘RLIM_INFINITY’
      undeclared (first use in this function)
        struct rlimit r = {RLIM_INFINITY, RLIM_INFINITY};
                           ^
      samples/bpf/map_perf_test_user.c:134:21: note: each undeclared
      identifier is reported only once for each function it appears in
      samples/bpf/map_perf_test_user.c:134:9: warning: excess elements in
      struct initializer [enabled by default]
        struct rlimit r = {RLIM_INFINITY, RLIM_INFINITY};
               ^
      samples/bpf/map_perf_test_user.c:134:9: warning: (near initialization
      for ‘r’) [enabled by default]
      samples/bpf/map_perf_test_user.c:134:9: warning: excess elements in
      struct initializer [enabled by default]
      samples/bpf/map_perf_test_user.c:134:9: warning: (near initialization
      for ‘r’) [enabled by default]
      samples/bpf/map_perf_test_user.c:134:16: error: storage size of ‘r’
      isn’t known
        struct rlimit r = {RLIM_INFINITY, RLIM_INFINITY};
                      ^
      samples/bpf/map_perf_test_user.c:139:2: warning: implicit declaration of
      function ‘setrlimit’ [-Wimplicit-function-declaration]
        setrlimit(RLIMIT_MEMLOCK, &r);
        ^
      samples/bpf/map_perf_test_user.c:139:12: error: ‘RLIMIT_MEMLOCK’
      undeclared (first use in this function)
        setrlimit(RLIMIT_MEMLOCK, &r);
                  ^
      samples/bpf/map_perf_test_user.c:134:16: warning: unused variable ‘r’
      [-Wunused-variable]
        struct rlimit r = {RLIM_INFINITY, RLIM_INFINITY};
                      ^
      make[2]: *** [samples/bpf/map_perf_test_user.o] Error 1
      
      Fix this by including the necessary header file.
      
      Cc: Alexei Starovoitov <ast@fb.com>
      Cc: Daniel Borkmann <daniel@iogearbox.net>
      Cc: David S. Miller <davem@davemloft.net>
      Cc: Ananth N Mavinakayanahalli <ananth@in.ibm.com>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Acked-by: default avatarAlexei Starovoitov <ast@kernel.org>
      Signed-off-by: default avatarNaveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      77e63534
  11. Mar 09, 2016
Loading