Alexander Gordeev
4ff17c448a
libperf: Fix install_pkgconfig target
...
Commit 47e02b94a4 ("tools lib perf: Add dependency test to install_headers")
misses the notion of $(DESTDIR_SQ) for install_pkgconfig target, which leads to
error:
install: cannot create regular file '/usr/lib64/pkgconfig/libperf.pc': Permission denied
make: *** [Makefile:210: install_pkgconfig] Error 1
Signed-off-by: Alexander Gordeev <agordeev@linux.ibm.com >
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com >
Cc: Ian Rogers <irogers@google.com >
Cc: Jiri Olsa <jolsa@kernel.org >
Cc: Josh Poimboeuf <jpoimboe@kernel.org >
Cc: Mark Rutland <mark.rutland@arm.com >
Cc: Masahiro Yamada <masahiroy@kernel.org >
Cc: Namhyung Kim <namhyung@kernel.org >
Cc: Nathan Chancellor <nathan@kernel.org >
Cc: Nick Desaulniers <ndesaulniers@google.com >
Cc: Nicolas Schier <nicolas@fjasle.eu >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Stephane Eranian <eranian@google.com >
Cc: Tom Rix <trix@redhat.com >
Cc: bpf@vger.kernel.org
Cc: llvm@lists.linux.dev
Link: http://lore.kernel.org/lkml/Y5w/cWKyb8vpNMfA@li-4a3a4a4c-28e5-11b2-a85c-a8d192c6f089.ibm.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2022-12-16 10:04:06 -03:00
Arnaldo Carvalho de Melo
1a931707ad
Merge remote-tracking branch 'torvalds/master' into perf/core
...
To resolve a trivial merge conflict with c302378bc1 ("libbpf:
Hashmap interface update to allow both long and void* keys/values"),
where a function present upstream was removed in the perf tools
development tree.
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2022-12-16 09:53:53 -03:00
Ian Rogers
4171925aa9
tools lib traceevent: Remove libtraceevent
...
libtraceevent is now out-of-date and it is better to depend on the
system version. Remove this code that is no longer depended upon by
any builds.
Committer notes:
Removed the removed tools/lib/traceevent/ from tools/perf/MANIFEST, so
that 'make perf-tar-src-pkg' works.
Signed-off-by: Ian Rogers <irogers@google.com >
Acked-by: Steven Rostedt (VMware) <rostedt@goodmis.org >
Cc: Adrian Hunter <adrian.hunter@intel.com >
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com >
Cc: Jiri Olsa <jolsa@kernel.org >
Cc: Kan Liang <kan.liang@linux.intel.com >
Cc: Leo Yan <leo.yan@linaro.org >
Cc: Mark Rutland <mark.rutland@arm.com >
Cc: Masami Hiramatsu <mhiramat@kernel.org >
Cc: Namhyung Kim <namhyung@kernel.org >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Stephane Eranian <eranian@google.com >
Link: http://lore.kernel.org/lkml/20221130062935.2219247-5-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2022-12-14 11:16:12 -03:00
Ian Rogers
113bb39642
tools lib symbol: Add dependency test to install_headers
...
Compute the headers to be installed from their source headers and make
each have its own build target to install it. Using dependencies
avoids headers being reinstalled and getting a new timestamp which
then causes files that depend on the header to be rebuilt.
Signed-off-by: Ian Rogers <irogers@google.com >
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com >
Cc: Ingo Molnar <mingo@redhat.com >
Cc: Jiri Olsa <jolsa@kernel.org >
Cc: Josh Poimboeuf <jpoimboe@kernel.org >
Cc: Mark Rutland <mark.rutland@arm.com >
Cc: Masahiro Yamada <masahiroy@kernel.org >
Cc: Namhyung Kim <namhyung@kernel.org >
Cc: Nathan Chancellor <nathan@kernel.org >
Cc: Nick Desaulniers <ndesaulniers@google.com >
Cc: Nicolas Schier <nicolas@fjasle.eu >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Stephane Eranian <eranian@google.com >
Cc: Tom Rix <trix@redhat.com >
Cc: bpf@vger.kernel.org
Cc: llvm@lists.linux.dev
Link: https://lore.kernel.org/r/20221202045743.2639466-5-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2022-12-14 11:16:12 -03:00
Ian Rogers
5d890591db
tools lib subcmd: Add dependency test to install_headers
...
Compute the headers to be installed from their source headers and make
each have its own build target to install it. Using dependencies
avoids headers being reinstalled and getting a new timestamp which
then causes files that depend on the header to be rebuilt.
Signed-off-by: Ian Rogers <irogers@google.com >
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com >
Cc: Ingo Molnar <mingo@redhat.com >
Cc: Jiri Olsa <jolsa@kernel.org >
Cc: Josh Poimboeuf <jpoimboe@kernel.org >
Cc: Mark Rutland <mark.rutland@arm.com >
Cc: Masahiro Yamada <masahiroy@kernel.org >
Cc: Namhyung Kim <namhyung@kernel.org >
Cc: Nathan Chancellor <nathan@kernel.org >
Cc: Nick Desaulniers <ndesaulniers@google.com >
Cc: Nicolas Schier <nicolas@fjasle.eu >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Stephane Eranian <eranian@google.com >
Cc: Tom Rix <trix@redhat.com >
Cc: bpf@vger.kernel.org
Cc: llvm@lists.linux.dev
Link: https://lore.kernel.org/r/20221202045743.2639466-4-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2022-12-14 11:16:12 -03:00
Ian Rogers
47e02b94a4
tools lib perf: Add dependency test to install_headers
...
Compute the headers to be installed from their source headers and make
each have its own build target to install it. Using dependencies
avoids headers being reinstalled and getting a new timestamp which
then causes files that depend on the header to be rebuilt.
Signed-off-by: Ian Rogers <irogers@google.com >
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com >
Cc: Ingo Molnar <mingo@redhat.com >
Cc: Jiri Olsa <jolsa@kernel.org >
Cc: Josh Poimboeuf <jpoimboe@kernel.org >
Cc: Mark Rutland <mark.rutland@arm.com >
Cc: Masahiro Yamada <masahiroy@kernel.org >
Cc: Namhyung Kim <namhyung@kernel.org >
Cc: Nathan Chancellor <nathan@kernel.org >
Cc: Nick Desaulniers <ndesaulniers@google.com >
Cc: Nicolas Schier <nicolas@fjasle.eu >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Stephane Eranian <eranian@google.com >
Cc: Tom Rix <trix@redhat.com >
Cc: bpf@vger.kernel.org
Cc: llvm@lists.linux.dev
Link: https://lore.kernel.org/r/20221202045743.2639466-3-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2022-12-14 11:16:12 -03:00
Ian Rogers
1849f9f009
tools lib api: Add dependency test to install_headers
...
Compute the headers to be installed from their source headers and make
each have its own build target to install it. Using dependencies
avoids headers being reinstalled and getting a new timestamp which
then causes files that depend on the header to be rebuilt.
Signed-off-by: Ian Rogers <irogers@google.com >
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com >
Cc: Ingo Molnar <mingo@redhat.com >
Cc: Jiri Olsa <jolsa@kernel.org >
Cc: Josh Poimboeuf <jpoimboe@kernel.org >
Cc: Mark Rutland <mark.rutland@arm.com >
Cc: Masahiro Yamada <masahiroy@kernel.org >
Cc: Namhyung Kim <namhyung@kernel.org >
Cc: Nathan Chancellor <nathan@kernel.org >
Cc: Nick Desaulniers <ndesaulniers@google.com >
Cc: Nicolas Schier <nicolas@fjasle.eu >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Stephane Eranian <eranian@google.com >
Cc: Tom Rix <trix@redhat.com >
Cc: bpf@vger.kernel.org
Cc: llvm@lists.linux.dev
Link: https://lore.kernel.org/r/20221202045743.2639466-2-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2022-12-14 11:16:12 -03:00
Timo Hunziker
c21dc529ba
libbpf: Parse usdt args without offset on x86 (e.g. 8@(%rsp))
...
Parse USDT arguments like "8@(%rsp)" on x86. These are emmited by
SystemTap. The argument syntax is similar to the existing "memory
dereference case" but the offset left out as it's zero (i.e. read
the value from the address in the register). We treat it the same
as the the "memory dereference case", but set the offset to 0.
I've tested that this fixes the "unrecognized arg #N spec: 8@(%rsp).."
error I've run into when attaching to a probe with such an argument.
Attaching and reading the correct argument values works.
Something similar might be needed for the other supported
architectures.
[0] Closes: https://github.com/libbpf/libbpf/issues/559
Signed-off-by: Timo Hunziker <timo.hunziker@gmx.ch >
Signed-off-by: Andrii Nakryiko <andrii@kernel.org >
Link: https://lore.kernel.org/bpf/20221203123746.2160-1-timo.hunziker@eclipso.ch
2022-12-06 16:16:50 -08:00
Xin Liu
7068194959
libbpf: Improve usability of libbpf Makefile
...
Current libbpf Makefile does not contain the help command, which
is inconvenient to use. Similar to the Makefile help command of the
perf, a help command is provided to list the commands supported by
libbpf make and the functions of the commands.
Signed-off-by: Xin Liu <liuxin350@huawei.com >
Signed-off-by: Andrii Nakryiko <andrii@kernel.org >
Link: https://lore.kernel.org/bpf/20221202081738.128513-1-liuxin350@huawei.com
2022-12-02 16:30:34 -08:00
Andrii Nakryiko
b42693415b
libbpf: Avoid enum forward-declarations in public API in C++ mode
...
C++ enum forward declarations are fundamentally not compatible with pure
C enum definitions, and so libbpf's use of `enum bpf_stats_type;`
forward declaration in libbpf/bpf.h public API header is causing C++
compilation issues.
More details can be found in [0], but it comes down to C++ supporting
enum forward declaration only with explicitly specified backing type:
enum bpf_stats_type: int;
In C (and I believe it's a GCC extension also), such forward declaration
is simply:
enum bpf_stats_type;
Further, in Linux UAPI this enum is defined in pure C way:
enum bpf_stats_type { BPF_STATS_RUN_TIME = 0; }
And even though in both cases backing type is int, which can be
confirmed by looking at DWARF information, for C++ compiler actual enum
definition and forward declaration are incompatible.
To eliminate this problem, for C++ mode define input argument as int,
which makes enum unnecessary in libbpf public header. This solves the
issue and as demonstrated by next patch doesn't cause any unwanted
compiler warnings, at least with default warnings setting.
[0] https://stackoverflow.com/questions/42766839/c11-enum-forward-causes-underlying-type-mismatch
[1] Closes: https://github.com/libbpf/libbpf/issues/249
Signed-off-by: Andrii Nakryiko <andrii@kernel.org >
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net >
Link: https://lore.kernel.org/bpf/20221130200013.2997831-1-andrii@kernel.org
2022-11-30 22:56:47 +01:00
Jakub Kicinski
f2bb566f5c
Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net
...
tools/lib/bpf/ringbuf.c
927cbb478a ("libbpf: Handle size overflow for ringbuf mmap")
b486d19a0a ("libbpf: checkpatch: Fixed code alignments in ringbuf.c")
https://lore.kernel.org/all/20221121122707.44d1446a@canb.auug.org.au/
Signed-off-by: Jakub Kicinski <kuba@kernel.org >
2022-11-29 13:04:52 -08:00
Alexei Starovoitov
dc79f035b2
selftests/bpf: Workaround for llvm nop-4 bug
...
Currently LLVM fails to recognize .data.* as data section and defaults to .text
section. Later BPF backend tries to emit 4-byte NOP instruction which doesn't
exist in BPF ISA and aborts.
The fix for LLVM is pending:
https://reviews.llvm.org/D138477
While waiting for the fix lets workaround the linked_list test case
by using .bss.* prefix which is properly recognized by LLVM as BSS section.
Fix libbpf to support .bss. prefix and adjust tests.
Signed-off-by: Alexei Starovoitov <ast@kernel.org >
2022-11-22 13:34:08 -08:00
Ian Rogers
e664f31e21
tools lib traceevent: Make install_headers clearer
...
Add libtraceevent to the name so that this install_headers build
appears different to similar targets in different libraries. Add ;
after kbuffer.h install target for consistency.
Signed-off-by: Ian Rogers <irogers@google.com >
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com >
Cc: Alexei Starovoitov <ast@kernel.org >
Cc: Andrii Nakryiko <andrii@kernel.org >
Cc: Daniel Borkmann <daniel@iogearbox.net >
Cc: Hao Luo <haoluo@google.com >
Cc: Ingo Molnar <mingo@redhat.com >
Cc: Jiri Olsa <jolsa@kernel.org >
Cc: John Fastabend <john.fastabend@gmail.com >
Cc: KP Singh <kpsingh@kernel.org >
Cc: Mark Rutland <mark.rutland@arm.com >
Cc: Martin KaFai Lau <martin.lau@linux.dev >
Cc: Masahiro Yamada <masahiroy@kernel.org >
Cc: Namhyung Kim <namhyung@kernel.org >
Cc: Nicolas Schier <nicolas@fjasle.eu >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Song Liu <song@kernel.org >
Cc: Stanislav Fomichev <sdf@google.com >
Cc: Stephane Eranian <eranian@google.com >
Cc: Yonghong Song <yhs@fb.com >
Cc: bpf@vger.kernel.org
Link: https://lore.kernel.org/r/20221117004356.279422-7-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2022-11-20 11:32:23 -03:00
Ian Rogers
77dce6890a
tools lib subcmd: Make install_headers clearer
...
Add libsubcmd to the name so that this install_headers build appears
different to similar targets in different libraries.
Signed-off-by: Ian Rogers <irogers@google.com >
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com >
Cc: Alexei Starovoitov <ast@kernel.org >
Cc: Andrii Nakryiko <andrii@kernel.org >
Cc: Daniel Borkmann <daniel@iogearbox.net >
Cc: Hao Luo <haoluo@google.com >
Cc: Ingo Molnar <mingo@redhat.com >
Cc: Jiri Olsa <jolsa@kernel.org >
Cc: John Fastabend <john.fastabend@gmail.com >
Cc: KP Singh <kpsingh@kernel.org >
Cc: Mark Rutland <mark.rutland@arm.com >
Cc: Martin KaFai Lau <martin.lau@linux.dev >
Cc: Masahiro Yamada <masahiroy@kernel.org >
Cc: Namhyung Kim <namhyung@kernel.org >
Cc: Nicolas Schier <nicolas@fjasle.eu >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Song Liu <song@kernel.org >
Cc: Stanislav Fomichev <sdf@google.com >
Cc: Stephane Eranian <eranian@google.com >
Cc: Yonghong Song <yhs@fb.com >
Cc: bpf@vger.kernel.org
Link: https://lore.kernel.org/r/20221117004356.279422-6-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2022-11-20 11:32:23 -03:00
Ian Rogers
e8951bfb4c
tools lib perf: Make install_headers clearer
...
Add libperf to the name so that this install_headers build appears
different to similar targets in different libraries.
Signed-off-by: Ian Rogers <irogers@google.com >
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com >
Cc: Alexei Starovoitov <ast@kernel.org >
Cc: Andrii Nakryiko <andrii@kernel.org >
Cc: Daniel Borkmann <daniel@iogearbox.net >
Cc: Hao Luo <haoluo@google.com >
Cc: Ingo Molnar <mingo@redhat.com >
Cc: Jiri Olsa <jolsa@kernel.org >
Cc: John Fastabend <john.fastabend@gmail.com >
Cc: KP Singh <kpsingh@kernel.org >
Cc: Mark Rutland <mark.rutland@arm.com >
Cc: Martin KaFai Lau <martin.lau@linux.dev >
Cc: Masahiro Yamada <masahiroy@kernel.org >
Cc: Namhyung Kim <namhyung@kernel.org >
Cc: Nicolas Schier <nicolas@fjasle.eu >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Song Liu <song@kernel.org >
Cc: Stanislav Fomichev <sdf@google.com >
Cc: Stephane Eranian <eranian@google.com >
Cc: Yonghong Song <yhs@fb.com >
Cc: bpf@vger.kernel.org
Link: https://lore.kernel.org/r/20221117004356.279422-5-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2022-11-20 11:32:23 -03:00
Ian Rogers
806dda31b8
tools lib symbol: Clean up build output
...
Missing @ when building libsymbol. Make the install echo specific to
installing the libsymbol headers.
Signed-off-by: Ian Rogers <irogers@google.com >
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com >
Cc: Alexei Starovoitov <ast@kernel.org >
Cc: Andrii Nakryiko <andrii@kernel.org >
Cc: Daniel Borkmann <daniel@iogearbox.net >
Cc: Hao Luo <haoluo@google.com >
Cc: Ingo Molnar <mingo@redhat.com >
Cc: Jiri Olsa <jolsa@kernel.org >
Cc: John Fastabend <john.fastabend@gmail.com >
Cc: KP Singh <kpsingh@kernel.org >
Cc: Mark Rutland <mark.rutland@arm.com >
Cc: Martin KaFai Lau <martin.lau@linux.dev >
Cc: Masahiro Yamada <masahiroy@kernel.org >
Cc: Namhyung Kim <namhyung@kernel.org >
Cc: Nicolas Schier <nicolas@fjasle.eu >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Song Liu <song@kernel.org >
Cc: Stanislav Fomichev <sdf@google.com >
Cc: Stephane Eranian <eranian@google.com >
Cc: Yonghong Song <yhs@fb.com >
Cc: bpf@vger.kernel.org
Link: https://lore.kernel.org/r/20221117004356.279422-4-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2022-11-20 11:32:23 -03:00
Ian Rogers
daa45f3f35
tools lib bpf: Avoid install_headers make warning
...
The perf build makes the install_headers target, however, as there is
no action for this target a warning is always produced of:
make[3]: Nothing to be done for 'install_headers'.
Solve this by adding a display of 'INSTALL libbpf_headers'.
Signed-off-by: Ian Rogers <irogers@google.com >
Acked-by: Andrii Nakryiko <andrii@kernel.org >
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com >
Cc: Alexei Starovoitov <ast@kernel.org >
Cc: Daniel Borkmann <daniel@iogearbox.net >
Cc: Hao Luo <haoluo@google.com >
Cc: Ingo Molnar <mingo@redhat.com >
Cc: Jiri Olsa <jolsa@kernel.org >
Cc: John Fastabend <john.fastabend@gmail.com >
Cc: KP Singh <kpsingh@kernel.org >
Cc: Mark Rutland <mark.rutland@arm.com >
Cc: Martin KaFai Lau <martin.lau@linux.dev >
Cc: Masahiro Yamada <masahiroy@kernel.org >
Cc: Namhyung Kim <namhyung@kernel.org >
Cc: Nicolas Schier <nicolas@fjasle.eu >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Song Liu <song@kernel.org >
Cc: Stanislav Fomichev <sdf@google.com >
Cc: Stephane Eranian <eranian@google.com >
Cc: Yonghong Song <yhs@fb.com >
Cc: bpf@vger.kernel.org
Link: https://lore.kernel.org/r/20221117004356.279422-3-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2022-11-20 11:32:23 -03:00
Ian Rogers
586cb1d65c
tools lib api: Clean up install_headers
...
Add missing backslash that caused an install command to always appear
in build output. Make the install headers more specific.
Signed-off-by: Ian Rogers <irogers@google.com >
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com >
Cc: Alexei Starovoitov <ast@kernel.org >
Cc: Andrii Nakryiko <andrii@kernel.org >
Cc: Daniel Borkmann <daniel@iogearbox.net >
Cc: Hao Luo <haoluo@google.com >
Cc: Ingo Molnar <mingo@redhat.com >
Cc: Jiri Olsa <jolsa@kernel.org >
Cc: John Fastabend <john.fastabend@gmail.com >
Cc: KP Singh <kpsingh@kernel.org >
Cc: Mark Rutland <mark.rutland@arm.com >
Cc: Martin KaFai Lau <martin.lau@linux.dev >
Cc: Masahiro Yamada <masahiroy@kernel.org >
Cc: Namhyung Kim <namhyung@kernel.org >
Cc: Nicolas Schier <nicolas@fjasle.eu >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Song Liu <song@kernel.org >
Cc: Stanislav Fomichev <sdf@google.com >
Cc: Stephane Eranian <eranian@google.com >
Cc: Yonghong Song <yhs@fb.com >
Cc: bpf@vger.kernel.org
Link: https://lore.kernel.org/r/20221117004356.279422-2-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2022-11-20 11:32:23 -03:00
Andrii Nakryiko
f80e16b614
libbpf: Ignore hashmap__find() result explicitly in btf_dump
...
Coverity is reporting that btf_dump_name_dups() doesn't check return
result of hashmap__find() call. This is intentional, so make it explicit
with (void) cast.
Signed-off-by: Andrii Nakryiko <andrii@kernel.org >
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net >
Link: https://lore.kernel.org/bpf/20221117192824.4093553-1-andrii@kernel.org
2022-11-18 23:13:38 +01:00
Hou Tao
05c1558bfc
libbpf: Check the validity of size in user_ring_buffer__reserve()
...
The top two bits of size are used as busy and discard flags, so reject
the reservation that has any of these special bits in the size. With the
addition of validity check, these is also no need to check whether or
not total_size is overflowed.
Signed-off-by: Hou Tao <houtao1@huawei.com >
Signed-off-by: Andrii Nakryiko <andrii@kernel.org >
Link: https://lore.kernel.org/bpf/20221116072351.1168938-5-houtao@huaweicloud.com
2022-11-17 15:49:59 -08:00
Hou Tao
64176bff24
libbpf: Handle size overflow for user ringbuf mmap
...
Similar with the overflow problem on ringbuf mmap, in user_ringbuf_map()
2 * max_entries may overflow u32 when mapping writeable region.
Fixing it by casting the size of writable mmap region into a __u64 and
checking whether or not there will be overflow during mmap.
Fixes: b66ccae01f ("bpf: Add libbpf logic for user-space ring buffer")
Signed-off-by: Hou Tao <houtao1@huawei.com >
Signed-off-by: Andrii Nakryiko <andrii@kernel.org >
Link: https://lore.kernel.org/bpf/20221116072351.1168938-4-houtao@huaweicloud.com
2022-11-17 15:49:39 -08:00
Hou Tao
927cbb478a
libbpf: Handle size overflow for ringbuf mmap
...
The maximum size of ringbuf is 2GB on x86-64 host, so 2 * max_entries
will overflow u32 when mapping producer page and data pages. Only
casting max_entries to size_t is not enough, because for 32-bits
application on 64-bits kernel the size of read-only mmap region
also could overflow size_t.
So fixing it by casting the size of read-only mmap region into a __u64
and checking whether or not there will be overflow during mmap.
Fixes: bf99c936f9 ("libbpf: Add BPF ring buffer support")
Signed-off-by: Hou Tao <houtao1@huawei.com >
Signed-off-by: Andrii Nakryiko <andrii@kernel.org >
Link: https://lore.kernel.org/bpf/20221116072351.1168938-3-houtao@huaweicloud.com
2022-11-17 15:48:50 -08:00
Hou Tao
689eb2f1ba
libbpf: Use page size as max_entries when probing ring buffer map
...
Using page size as max_entries when probing ring buffer map, else the
probe may fail on host with 64KB page size (e.g., an ARM64 host).
After the fix, the output of "bpftool feature" on above host will be
correct.
Before :
eBPF map_type ringbuf is NOT available
eBPF map_type user_ringbuf is NOT available
After :
eBPF map_type ringbuf is available
eBPF map_type user_ringbuf is available
Signed-off-by: Hou Tao <houtao1@huawei.com >
Signed-off-by: Andrii Nakryiko <andrii@kernel.org >
Link: https://lore.kernel.org/bpf/20221116072351.1168938-2-houtao@huaweicloud.com
2022-11-17 15:46:05 -08:00
Arnaldo Carvalho de Melo
63a3bf5e8d
libperf: Add missing 'struct perf_cpu_map' forward declaration to perf/cpumap.h
...
The perf/cpumap.h header is getting the 'struct perf_cpu_map' forward
declaration by luck, add it.
Acked-by: Ian Rogers <irogers@google.com >
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2022-11-16 16:00:49 -03:00
Arnaldo Carvalho de Melo
35fef9b471
libperf: Remove recursive perf/cpumap.h include from perf/cpumap.h
...
It just hits the header guard, becoming a no-op, ditch it.
Acked-by: Ian Rogers <irogers@google.com >
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2022-11-16 16:00:49 -03:00