* [PATCH] selftests/bpf: clarify build error if no vmlinux
@ 2020-12-14 20:20 Kamal Mostafa
2020-12-15 1:37 ` Andrii Nakryiko
0 siblings, 1 reply; 4+ messages in thread
From: Kamal Mostafa @ 2020-12-14 20:20 UTC (permalink / raw)
To: Shuah Khan, Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
Martin KaFai Lau, Song Liu, Yonghong Song, John Fastabend,
KP Singh, Toke Høiland-Jørgensen, linux-kselftest,
netdev, bpf, linux-kernel
Cc: Kamal Mostafa, stable
If Makefile cannot find any of the vmlinux's in its VMLINUX_BTF_PATHS list,
it tries to run btftool incorrectly, with VMLINUX_BTF unset:
bpftool btf dump file $(VMLINUX_BTF) format c
Such that the keyword 'format' is misinterpreted as the path to vmlinux.
The resulting build error message is fairly cryptic:
GEN vmlinux.h
Error: failed to load BTF from format: No such file or directory
This patch makes the failure reason clearer by yielding this instead:
Makefile:...: *** cannot find a vmlinux for VMLINUX_BTF at any of
"{paths}". Stop.
Fixes: acbd06206bbb ("selftests/bpf: Add vmlinux.h selftest exercising tracing of syscalls")
Cc: stable@vger.kernel.org # 5.7+
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
---
tools/testing/selftests/bpf/Makefile | 3 +++
1 file changed, 3 insertions(+)
diff --git a/tools/testing/selftests/bpf/Makefile b/tools/testing/selftests/bpf/Makefile
index 542768f5195b..93ed34ef6e3f 100644
--- a/tools/testing/selftests/bpf/Makefile
+++ b/tools/testing/selftests/bpf/Makefile
@@ -196,6 +196,9 @@ $(BUILD_DIR)/libbpf $(BUILD_DIR)/bpftool $(BUILD_DIR)/resolve_btfids $(INCLUDE_D
$(INCLUDE_DIR)/vmlinux.h: $(VMLINUX_BTF) | $(BPFTOOL) $(INCLUDE_DIR)
ifeq ($(VMLINUX_H),)
$(call msg,GEN,,$@)
+ifeq ($(VMLINUX_BTF),)
+$(error cannot find a vmlinux for VMLINUX_BTF at any of "$(VMLINUX_BTF_PATHS)")
+endif
$(Q)$(BPFTOOL) btf dump file $(VMLINUX_BTF) format c > $@
else
$(call msg,CP,,$@)
--
2.17.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] selftests/bpf: clarify build error if no vmlinux
2020-12-14 20:20 [PATCH] selftests/bpf: clarify build error if no vmlinux Kamal Mostafa
@ 2020-12-15 1:37 ` Andrii Nakryiko
2020-12-15 18:20 ` [PATCH v2] " Kamal Mostafa
0 siblings, 1 reply; 4+ messages in thread
From: Andrii Nakryiko @ 2020-12-15 1:37 UTC (permalink / raw)
To: Kamal Mostafa
Cc: Shuah Khan, Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
Martin KaFai Lau, Song Liu, Yonghong Song, John Fastabend,
KP Singh, Toke Høiland-Jørgensen,
open list:KERNEL SELFTEST FRAMEWORK, Networking, bpf, open list,
linux- stable
On Mon, Dec 14, 2020 at 12:21 PM Kamal Mostafa <kamal@canonical.com> wrote:
>
> If Makefile cannot find any of the vmlinux's in its VMLINUX_BTF_PATHS list,
> it tries to run btftool incorrectly, with VMLINUX_BTF unset:
>
> bpftool btf dump file $(VMLINUX_BTF) format c
>
> Such that the keyword 'format' is misinterpreted as the path to vmlinux.
> The resulting build error message is fairly cryptic:
>
> GEN vmlinux.h
> Error: failed to load BTF from format: No such file or directory
>
> This patch makes the failure reason clearer by yielding this instead:
>
> Makefile:...: *** cannot find a vmlinux for VMLINUX_BTF at any of
> "{paths}". Stop.
>
> Fixes: acbd06206bbb ("selftests/bpf: Add vmlinux.h selftest exercising tracing of syscalls")
> Cc: stable@vger.kernel.org # 5.7+
> Signed-off-by: Kamal Mostafa <kamal@canonical.com>
> ---
> tools/testing/selftests/bpf/Makefile | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/tools/testing/selftests/bpf/Makefile b/tools/testing/selftests/bpf/Makefile
> index 542768f5195b..93ed34ef6e3f 100644
> --- a/tools/testing/selftests/bpf/Makefile
> +++ b/tools/testing/selftests/bpf/Makefile
> @@ -196,6 +196,9 @@ $(BUILD_DIR)/libbpf $(BUILD_DIR)/bpftool $(BUILD_DIR)/resolve_btfids $(INCLUDE_D
> $(INCLUDE_DIR)/vmlinux.h: $(VMLINUX_BTF) | $(BPFTOOL) $(INCLUDE_DIR)
> ifeq ($(VMLINUX_H),)
> $(call msg,GEN,,$@)
> +ifeq ($(VMLINUX_BTF),)
> +$(error cannot find a vmlinux for VMLINUX_BTF at any of "$(VMLINUX_BTF_PATHS)")
> +endif
> $(Q)$(BPFTOOL) btf dump file $(VMLINUX_BTF) format c > $@
> else
> $(call msg,CP,,$@)
This handles only one possible case where $(VMLINUX_BTF) is expected.
Given $(VMLINUX_BTF) is now almost mandatory to have (bpf_testmod.ko
is dependent on it, for instance), I think it's acceptable to just add
such a check right after VMLINUX_BTF definition, outside of any
specific rule. The downside is that some unrelated targets (e.g.,
non-test_progs tests) will fail if VMLINUX_BTF is not found, even if
they don't need it, but the most common use case us to build
test_progs, as well as bpf_testmod.ko and runqslower, so I think it's
an OK trade off. Worst case, one can work around such with
VMLINUX_BTF=whatever command-line overload.
> --
> 2.17.1
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH v2] selftests/bpf: clarify build error if no vmlinux
2020-12-15 1:37 ` Andrii Nakryiko
@ 2020-12-15 18:20 ` Kamal Mostafa
2020-12-16 18:06 ` Andrii Nakryiko
0 siblings, 1 reply; 4+ messages in thread
From: Kamal Mostafa @ 2020-12-15 18:20 UTC (permalink / raw)
To: andrii.nakryiko
Cc: Kamal Mostafa, stable, Shuah Khan, Alexei Starovoitov,
Daniel Borkmann, Andrii Nakryiko, Martin KaFai Lau, Song Liu,
Yonghong Song, John Fastabend, KP Singh, linux-kselftest, netdev,
bpf, linux-kernel
If Makefile cannot find any of the vmlinux's in its VMLINUX_BTF_PATHS list,
it tries to run btftool incorrectly, with VMLINUX_BTF unset:
bpftool btf dump file $(VMLINUX_BTF) format c
Such that the keyword 'format' is misinterpreted as the path to vmlinux.
The resulting build error message is fairly cryptic:
GEN vmlinux.h
Error: failed to load BTF from format: No such file or directory
This patch makes the failure reason clearer by yielding this instead:
Makefile:...: *** cannot find a vmlinux for VMLINUX_BTF at any of
"{paths}". Stop.
Fixes: acbd06206bbb ("selftests/bpf: Add vmlinux.h selftest exercising tracing of syscalls")
Cc: stable@vger.kernel.org # 5.7+
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
---
[v2] moves the check to right after the VMLINUX_BTF definition.
tools/testing/selftests/bpf/Makefile | 3 +++
1 file changed, 3 insertions(+)
diff --git a/tools/testing/selftests/bpf/Makefile b/tools/testing/selftests/bpf/Makefile
index 542768f5195b..7ba631f495f7 100644
--- a/tools/testing/selftests/bpf/Makefile
+++ b/tools/testing/selftests/bpf/Makefile
@@ -146,6 +146,9 @@ VMLINUX_BTF_PATHS ?= $(if $(O),$(O)/vmlinux) \
/sys/kernel/btf/vmlinux \
/boot/vmlinux-$(shell uname -r)
VMLINUX_BTF ?= $(abspath $(firstword $(wildcard $(VMLINUX_BTF_PATHS))))
+ifeq ($(VMLINUX_BTF),)
+$(error cannot find a vmlinux for VMLINUX_BTF at any of "$(VMLINUX_BTF_PATHS)")
+endif
DEFAULT_BPFTOOL := $(SCRATCH_DIR)/sbin/bpftool
--
2.17.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v2] selftests/bpf: clarify build error if no vmlinux
2020-12-15 18:20 ` [PATCH v2] " Kamal Mostafa
@ 2020-12-16 18:06 ` Andrii Nakryiko
0 siblings, 0 replies; 4+ messages in thread
From: Andrii Nakryiko @ 2020-12-16 18:06 UTC (permalink / raw)
To: Kamal Mostafa
Cc: linux- stable, Shuah Khan, Alexei Starovoitov, Daniel Borkmann,
Andrii Nakryiko, Martin KaFai Lau, Song Liu, Yonghong Song,
John Fastabend, KP Singh, open list:KERNEL SELFTEST FRAMEWORK,
Networking, bpf, open list
On Tue, Dec 15, 2020 at 10:20 AM Kamal Mostafa <kamal@canonical.com> wrote:
>
> If Makefile cannot find any of the vmlinux's in its VMLINUX_BTF_PATHS list,
> it tries to run btftool incorrectly, with VMLINUX_BTF unset:
>
> bpftool btf dump file $(VMLINUX_BTF) format c
>
> Such that the keyword 'format' is misinterpreted as the path to vmlinux.
> The resulting build error message is fairly cryptic:
>
> GEN vmlinux.h
> Error: failed to load BTF from format: No such file or directory
>
> This patch makes the failure reason clearer by yielding this instead:
>
> Makefile:...: *** cannot find a vmlinux for VMLINUX_BTF at any of
> "{paths}". Stop.
>
> Fixes: acbd06206bbb ("selftests/bpf: Add vmlinux.h selftest exercising tracing of syscalls")
> Cc: stable@vger.kernel.org # 5.7+
> Signed-off-by: Kamal Mostafa <kamal@canonical.com>
> ---
Applied to bpf tree, thanks. This conflicted with a67079b03165
("selftests/bpf: fix bpf_testmod.ko recompilation logic"), I resolved
the conflict and capitalized "Cannot" in the error message.
>
> [v2] moves the check to right after the VMLINUX_BTF definition.
>
> tools/testing/selftests/bpf/Makefile | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/tools/testing/selftests/bpf/Makefile b/tools/testing/selftests/bpf/Makefile
> index 542768f5195b..7ba631f495f7 100644
> --- a/tools/testing/selftests/bpf/Makefile
> +++ b/tools/testing/selftests/bpf/Makefile
> @@ -146,6 +146,9 @@ VMLINUX_BTF_PATHS ?= $(if $(O),$(O)/vmlinux) \
> /sys/kernel/btf/vmlinux \
> /boot/vmlinux-$(shell uname -r)
> VMLINUX_BTF ?= $(abspath $(firstword $(wildcard $(VMLINUX_BTF_PATHS))))
> +ifeq ($(VMLINUX_BTF),)
> +$(error cannot find a vmlinux for VMLINUX_BTF at any of "$(VMLINUX_BTF_PATHS)")
> +endif
>
> DEFAULT_BPFTOOL := $(SCRATCH_DIR)/sbin/bpftool
>
> --
> 2.17.1
>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2020-12-16 18:07 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-14 20:20 [PATCH] selftests/bpf: clarify build error if no vmlinux Kamal Mostafa
2020-12-15 1:37 ` Andrii Nakryiko
2020-12-15 18:20 ` [PATCH v2] " Kamal Mostafa
2020-12-16 18:06 ` Andrii Nakryiko
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).