• Arnaldo Carvalho de Melo's avatar
    perf bpf examples: Fix bpf.h header include directive in 5sec.c example · 301f0203
    Arnaldo Carvalho de Melo authored
    It was looking at bpf/bpf.h, which caused this problem:
    
      # perf trace -e tools/perf/examples/bpf/5sec.c
      /home/acme/git/perf/tools/perf/examples/bpf/5sec.c:42:10: fatal error: 'bpf/bpf.h' file not found
      #include <bpf/bpf.h>
               ^~~~~~~~~~~
      1 error generated.
      ERROR:	unable to compile tools/perf/examples/bpf/5sec.c
      Hint:	Check error message shown above.
      Hint:	You can also pre-compile it into .o using:
           		clang -target bpf -O2 -c tools/perf/examples/bpf/5sec.c
           	with proper -I and -D options.
      event syntax error: 'tools/perf/examples/bpf/5sec.c'
                           \___ Failed to load tools/perf/examples/bpf/5sec.c from source: Error when compiling BPF scriptlet
      #
    
    Change that to plain bpf.h, to make it work again:
    
      # perf trace -e tools/perf/examples/bpf/5sec.c sleep 5s
           0.000 perf_bpf_probe:hrtimer_nanosleep(__probe_ip: -1776891872, rqtp: 5000000000)
      # perf trace -e tools/perf/examples/bpf/5sec.c/max-stack=16/ sleep 5s
           0.000 perf_bpf_probe:hrtimer_nanosleep(__probe_ip: -1776891872, rqtp: 5000000000)
                                             hrtimer_nanosleep ([kernel.kallsyms])
                                             common_nsleep ([kernel.kallsyms])
                                             __x64_sys_clock_nanosleep ([kernel.kallsyms])
                                             do_syscall_64 ([kernel.kallsyms])
                                             entry_SYSCALL_64_after_hwframe ([kernel.kallsyms])
                                             __clock_nanosleep_2 (/usr/lib64/libc-2.32.so)
      # perf trace -e tools/perf/examples/bpf/5sec.c sleep 4s
      #
    
    Cc: Adrian Hunter <adrian.hunter@intel.com>
    Cc: Ian Rogers <irogers@google.com>
    Cc: Jiri Olsa <jolsa@kernel.org>
    Cc: Namhyung Kim <namhyung@kernel.org>
    Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
    301f0203
5sec.c 1.95 KB