From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Ian Rogers <irogers@google.com>
Cc: Leo Yan <leo.yan@linaro.org>,
Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@redhat.com>,
Mark Rutland <mark.rutland@arm.com>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
Jiri Olsa <jolsa@kernel.org>, Namhyung Kim <namhyung@kernel.org>,
linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org,
Stephane Eranian <eranian@google.com>
Subject: Re: [PATCH v1 6/7] perf trace: 5sec fix libbpf 1.0+ compatibility
Date: Thu, 3 Nov 2022 12:52:48 -0300 [thread overview]
Message-ID: <Y2Pj0KVbbw9rMcPH@kernel.org> (raw)
In-Reply-To: <Y2Pgz7luG77Wr+Ci@kernel.org>
Em Thu, Nov 03, 2022 at 12:39:59PM -0300, Arnaldo Carvalho de Melo escreveu:
> Em Thu, Nov 03, 2022 at 12:36:36PM -0300, Arnaldo Carvalho de Melo escreveu:
> > [root@quaco ~]# perf trace -e /home/acme/git/perf/tools/perf/examples/bpf/5sec.c
> > /home/acme/git/perf/tools/perf/examples/bpf/5sec.c:42:10: fatal error: 'bpf/bpf_helpers.h' file not found
> > #include <bpf/bpf_helpers.h>
> > ^~~~~~~~~~~~~~~~~~~
> > 1 error generated.
> > ERROR: unable to compile /home/acme/git/perf/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 /home/acme/git/perf/tools/perf/examples/bpf/5sec.c
> > with proper -I and -D options.
> > event syntax error: '/home/acme/git/perf/tools/perf/examples/bpf/5sec.c'
> > \___ Failed to load /home/acme/git/perf/tools/perf/examples/bpf/5sec.c from source: Error when compiling BPF scriptlet
> >
> > (add -v to see detail)
> > Run 'perf list' for a list of valid events
> >
> > Usage: perf trace [<options>] [<command>]
> > or: perf trace [<options>] -- <command> [<options>]
> > or: perf trace record [<options>] [<command>]
> > or: perf trace record [<options>] -- <command> [<options>]
> >
> > -e, --event <event> event/syscall selector. use 'perf list' to list available events
> > [root@quaco ~]#
> >
> > It is not even finding it, in this machine I have libbpf 0.7.0, so there
> > is a /usr/include/bpf/bpf_helpers.h, but probably that isn't in the
> > include path set up to build the tools/perf/examples/bpf/ files, perhaps
> > it should use:
> >
> > -Itools/lib/ so that it gets tools/lib/bpf_helpers.h?
> >
> > Trying to get this tested...
>
> Running with -v:
>
> llvm compiling command : /usr/lib64/ccache/clang -D__KERNEL__ -D__NR_CPUS__=8 -DLINUX_VERSION_CODE=0x51310 -g -I/home/acme/lib/perf/include/bpf -nostdinc -I./arch/x86/include -I./arch/x86/include/generated -I./include -I./arch/x86/include/uapi -I./arch/x86/include/generated/uapi -I./include/uapi -I./include/generated/uapi -include ./include/linux/compiler-version.h -include ./include/linux/kconfig.h -Wno-unused-value -Wno-pointer-sign -working-directory /lib/modules/5.19.16-200.fc36.x86_64/build -c /home/acme/git/perf/tools/perf/examples/bpf/5sec.c -target bpf -g -O2 -o -
> /home/acme/git/perf/tools/perf/examples/bpf/5sec.c:42:10: fatal error: 'bpf/bpf_helpers.h' file not found
>
> There is still that -I/home/acme/lib/perf/include/bpf, I'll remove it
> from the include path and try to replace it with the libbpf path...
Ok, works with the patch below, that needs some more renaming from "perf_" to
"libbpf_", etc:
[root@quaco ~]# perf trace -e /home/acme/git/perf/tools/perf/examples/bpf/5sec.c sleep 5
0.000 sleep/160828 perf_bpf_probe:hrtimer_nanosleep(__probe_ip: -1474734416, rqtp: 5000000000)
[root@quaco ~]#
Since I have:
[root@quaco ~]# cat ~/.perfconfig
[llvm]
dump-obj = true
clang-opt = -g
#
I end up with:
[root@quaco ~]# ls -la /home/acme/git/perf/tools/perf/examples/bpf/5sec.o
-rw-r--r--. 1 root root 3696 Nov 3 12:47 /home/acme/git/perf/tools/perf/examples/bpf/5sec.o
[root@quaco ~]# file /home/acme/git/perf/tools/perf/examples/bpf/5sec.o
/home/acme/git/perf/tools/perf/examples/bpf/5sec.o: ELF 64-bit LSB relocatable, eBPF, version 1 (SYSV), with debug_info, not stripped
[root@quaco ~]#
and can test with the pre-built .o eBPF bytecode + capped backtrace:
[root@quaco ~]# perf trace -e /home/acme/git/perf/tools/perf/examples/bpf/5sec.o/max-stack=6/ sleep 5
0.000 sleep/161037 perf_bpf_probe:hrtimer_nanosleep(__probe_ip: -1474734416, 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])
__GI___clock_nanosleep (/usr/lib64/libc.so.6)
[root@quaco ~]#
I'll test the other examples with these changes after I drive Pedro to
school and get back to the office.
- Arnaldo
diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config
index d3d3c13a9f25b55c..067a6e56eeacc9fc 100644
--- a/tools/perf/Makefile.config
+++ b/tools/perf/Makefile.config
@@ -1239,7 +1239,7 @@ includedir = $(abspath $(prefix)/$(includedir_relative))
mandir = share/man
infodir = share/info
perfexecdir = libexec/perf-core
-perf_include_dir = lib/perf/include
+perf_include_dir = /usr/include
perf_examples_dir = lib/perf/examples
sharedir = $(prefix)/share
template_dir = share/perf-core/templates
diff --git a/tools/perf/util/llvm-utils.c b/tools/perf/util/llvm-utils.c
index 2dc7970074196ca8..a5cac85783d8711f 100644
--- a/tools/perf/util/llvm-utils.c
+++ b/tools/perf/util/llvm-utils.c
@@ -495,7 +495,7 @@ int llvm__compile_bpf(const char *path, void **p_obj_buf,
snprintf(linux_version_code_str, sizeof(linux_version_code_str),
"0x%x", kernel_version);
- if (asprintf(&perf_bpf_include_opts, "-I%s/bpf", perf_include_dir) < 0)
+ if (asprintf(&perf_bpf_include_opts, "-I%s/", perf_include_dir) < 0)
goto errout;
force_set_env("NR_CPUS", nr_cpus_avail_str);
force_set_env("LINUX_VERSION_CODE", linux_version_code_str);
next prev parent reply other threads:[~2022-11-03 15:52 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-03 4:54 [PATCH v1 0/7] Fix perf trace libbpf 1.0+ compatibility Ian Rogers
2022-11-03 4:54 ` [PATCH v1 1/7] perf trace: Raw augmented syscalls fix " Ian Rogers
2022-11-03 4:54 ` [PATCH v1 2/7] perf trace: Etcsnoop " Ian Rogers
2022-11-03 4:54 ` [PATCH v1 3/7] perf trace: Augmented syscalls " Ian Rogers
2022-11-03 4:54 ` [PATCH v1 4/7] perf trace: hello " Ian Rogers
2022-11-03 4:54 ` [PATCH v1 5/7] perf trace: empty " Ian Rogers
2022-11-03 4:54 ` [PATCH v1 6/7] perf trace: 5sec " Ian Rogers
2022-11-03 15:36 ` Arnaldo Carvalho de Melo
2022-11-03 15:39 ` Arnaldo Carvalho de Melo
2022-11-03 15:52 ` Arnaldo Carvalho de Melo [this message]
2022-11-03 16:04 ` Ian Rogers
2022-11-03 19:54 ` Arnaldo Carvalho de Melo
2022-11-03 21:35 ` Arnaldo Carvalho de Melo
2022-11-03 22:01 ` Ian Rogers
2022-11-04 0:21 ` Arnaldo Carvalho de Melo
2022-11-04 1:04 ` Arnaldo Carvalho de Melo
2022-11-03 4:54 ` [PATCH v1 7/7] perf bpf: Remove now unused BPF headers Ian Rogers
2022-11-11 12:09 ` [PATCH v1 0/7] Fix perf trace libbpf 1.0+ compatibility Leo Yan
2022-11-15 19:12 ` Ian Rogers
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Y2Pj0KVbbw9rMcPH@kernel.org \
--to=acme@kernel.org \
--cc=alexander.shishkin@linux.intel.com \
--cc=eranian@google.com \
--cc=irogers@google.com \
--cc=jolsa@kernel.org \
--cc=leo.yan@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
--cc=peterz@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).