linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/2] bpftool: improve error handing for missing .BTF section
@ 2022-11-29 13:42 Changbin Du
  2022-11-29 13:42 ` [PATCH v2 1/2] libbpf: show error info about missing ".BTF" section Changbin Du
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Changbin Du @ 2022-11-29 13:42 UTC (permalink / raw)
  To: Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
	Quentin Monnet, Peter Zijlstra, Ingo Molnar,
	Arnaldo Carvalho de Melo, Shuah Khan
  Cc: Martin KaFai Lau, Song Liu, Yonghong Song, John Fastabend,
	KP Singh, Stanislav Fomichev, Hao Luo, Jiri Olsa, bpf,
	linux-kernel, Mark Rutland, Alexander Shishkin, Namhyung Kim,
	Mykola Lysenko, linux-perf-users, linux-kselftest, Changbin Du

v2:
 - remove vmlinux specific error info.
 - use builtin target .DELETE_ON_ERROR: to delete empty vmlinux.h

Changbin Du (2):
  libbpf: show error info about missing ".BTF" section
  bpf: makefiles: do not generate empty vmlinux.h

 tools/bpf/bpftool/Makefile           | 3 +++
 tools/lib/bpf/btf.c                  | 1 +
 tools/perf/Makefile.perf             | 2 ++
 tools/testing/selftests/bpf/Makefile | 3 +++
 4 files changed, 9 insertions(+)

-- 
2.37.2


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH v2 1/2] libbpf: show error info about missing ".BTF" section
  2022-11-29 13:42 [PATCH v2 0/2] bpftool: improve error handing for missing .BTF section Changbin Du
@ 2022-11-29 13:42 ` Changbin Du
  2022-12-01  0:55   ` Andrii Nakryiko
  2022-11-29 13:42 ` [PATCH v2 2/2] bpf: makefiles: do not generate empty vmlinux.h Changbin Du
  2022-12-01  0:55 ` [PATCH v2 0/2] bpftool: improve error handing for missing .BTF section Andrii Nakryiko
  2 siblings, 1 reply; 8+ messages in thread
From: Changbin Du @ 2022-11-29 13:42 UTC (permalink / raw)
  To: Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
	Quentin Monnet, Peter Zijlstra, Ingo Molnar,
	Arnaldo Carvalho de Melo, Shuah Khan
  Cc: Martin KaFai Lau, Song Liu, Yonghong Song, John Fastabend,
	KP Singh, Stanislav Fomichev, Hao Luo, Jiri Olsa, bpf,
	linux-kernel, Mark Rutland, Alexander Shishkin, Namhyung Kim,
	Mykola Lysenko, linux-perf-users, linux-kselftest, Changbin Du

Show the real problem instead of just saying "No such file or directory".

Now will print below info:
libbpf: can not find '.BTF' section
Error: failed to load BTF from /home/changbin/work/linux/vmlinux: No such file or directory

Signed-off-by: Changbin Du <changbin.du@gmail.com>
---
 tools/lib/bpf/btf.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/tools/lib/bpf/btf.c b/tools/lib/bpf/btf.c
index d88647da2c7f..1adc0f6019a0 100644
--- a/tools/lib/bpf/btf.c
+++ b/tools/lib/bpf/btf.c
@@ -990,6 +990,7 @@ static struct btf *btf_parse_elf(const char *path, struct btf *base_btf,
 	err = 0;
 
 	if (!btf_data) {
+		pr_warn("can not find '%s' section\n", BTF_ELF_SEC);
 		err = -ENOENT;
 		goto done;
 	}
-- 
2.37.2


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH v2 2/2] bpf: makefiles: do not generate empty vmlinux.h
  2022-11-29 13:42 [PATCH v2 0/2] bpftool: improve error handing for missing .BTF section Changbin Du
  2022-11-29 13:42 ` [PATCH v2 1/2] libbpf: show error info about missing ".BTF" section Changbin Du
@ 2022-11-29 13:42 ` Changbin Du
  2022-12-01  0:52   ` Andrii Nakryiko
  2022-12-01  0:55 ` [PATCH v2 0/2] bpftool: improve error handing for missing .BTF section Andrii Nakryiko
  2 siblings, 1 reply; 8+ messages in thread
From: Changbin Du @ 2022-11-29 13:42 UTC (permalink / raw)
  To: Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
	Quentin Monnet, Peter Zijlstra, Ingo Molnar,
	Arnaldo Carvalho de Melo, Shuah Khan
  Cc: Martin KaFai Lau, Song Liu, Yonghong Song, John Fastabend,
	KP Singh, Stanislav Fomichev, Hao Luo, Jiri Olsa, bpf,
	linux-kernel, Mark Rutland, Alexander Shishkin, Namhyung Kim,
	Mykola Lysenko, linux-perf-users, linux-kselftest, Changbin Du

Remove the empty vmlinux.h if bpftool failed to dump btf info.
The emptry vmlinux.h can hide real error when reading output
of make.

This is done by adding .DELETE_ON_ERROR special target in related
makefiles.

Signed-off-by: Changbin Du <changbin.du@gmail.com>
---
 tools/bpf/bpftool/Makefile           | 3 +++
 tools/perf/Makefile.perf             | 2 ++
 tools/testing/selftests/bpf/Makefile | 3 +++
 3 files changed, 8 insertions(+)

diff --git a/tools/bpf/bpftool/Makefile b/tools/bpf/bpftool/Makefile
index 4a95c017ad4c..f6b1e65085db 100644
--- a/tools/bpf/bpftool/Makefile
+++ b/tools/bpf/bpftool/Makefile
@@ -265,3 +265,6 @@ FORCE:
 .PHONY: all FORCE bootstrap clean install-bin install uninstall
 .PHONY: doc doc-clean doc-install doc-uninstall
 .DEFAULT_GOAL := all
+
+# Delete partially updated (corrupted) files on error
+.DELETE_ON_ERROR:
diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf
index a432e59afc42..265254fc641a 100644
--- a/tools/perf/Makefile.perf
+++ b/tools/perf/Makefile.perf
@@ -1149,3 +1149,5 @@ FORCE:
 .PHONY: libtraceevent_plugins archheaders
 
 endif # force_fixdep
+
+.DELETE_ON_ERROR:
diff --git a/tools/testing/selftests/bpf/Makefile b/tools/testing/selftests/bpf/Makefile
index e6cf21fad69f..f41c4b011221 100644
--- a/tools/testing/selftests/bpf/Makefile
+++ b/tools/testing/selftests/bpf/Makefile
@@ -617,3 +617,6 @@ EXTRA_CLEAN := $(TEST_CUSTOM_PROGS) $(SCRATCH_DIR) $(HOST_SCRATCH_DIR)	\
 			       liburandom_read.so)
 
 .PHONY: docs docs-clean
+
+# Delete partially updated (corrupted) files on error
+.DELETE_ON_ERROR:
-- 
2.37.2


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH v2 2/2] bpf: makefiles: do not generate empty vmlinux.h
  2022-11-29 13:42 ` [PATCH v2 2/2] bpf: makefiles: do not generate empty vmlinux.h Changbin Du
@ 2022-12-01  0:52   ` Andrii Nakryiko
  2022-12-17  9:32     ` Changbin Du
  0 siblings, 1 reply; 8+ messages in thread
From: Andrii Nakryiko @ 2022-12-01  0:52 UTC (permalink / raw)
  To: Changbin Du
  Cc: Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
	Quentin Monnet, Peter Zijlstra, Ingo Molnar,
	Arnaldo Carvalho de Melo, Shuah Khan, Martin KaFai Lau, Song Liu,
	Yonghong Song, John Fastabend, KP Singh, Stanislav Fomichev,
	Hao Luo, Jiri Olsa, bpf, linux-kernel, Mark Rutland,
	Alexander Shishkin, Namhyung Kim, Mykola Lysenko,
	linux-perf-users, linux-kselftest

On Tue, Nov 29, 2022 at 5:42 AM Changbin Du <changbin.du@gmail.com> wrote:
>
> Remove the empty vmlinux.h if bpftool failed to dump btf info.
> The emptry vmlinux.h can hide real error when reading output

typo: empty

> of make.
>
> This is done by adding .DELETE_ON_ERROR special target in related
> makefiles.
>
> Signed-off-by: Changbin Du <changbin.du@gmail.com>
> ---
>  tools/bpf/bpftool/Makefile           | 3 +++
>  tools/perf/Makefile.perf             | 2 ++
>  tools/testing/selftests/bpf/Makefile | 3 +++
>  3 files changed, 8 insertions(+)
>
> diff --git a/tools/bpf/bpftool/Makefile b/tools/bpf/bpftool/Makefile
> index 4a95c017ad4c..f6b1e65085db 100644
> --- a/tools/bpf/bpftool/Makefile
> +++ b/tools/bpf/bpftool/Makefile
> @@ -265,3 +265,6 @@ FORCE:
>  .PHONY: all FORCE bootstrap clean install-bin install uninstall
>  .PHONY: doc doc-clean doc-install doc-uninstall
>  .DEFAULT_GOAL := all
> +
> +# Delete partially updated (corrupted) files on error
> +.DELETE_ON_ERROR:
> diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf
> index a432e59afc42..265254fc641a 100644
> --- a/tools/perf/Makefile.perf
> +++ b/tools/perf/Makefile.perf
> @@ -1149,3 +1149,5 @@ FORCE:
>  .PHONY: libtraceevent_plugins archheaders
>
>  endif # force_fixdep
> +
> +.DELETE_ON_ERROR:

please split out perf changes, they should go through perf tree

> diff --git a/tools/testing/selftests/bpf/Makefile b/tools/testing/selftests/bpf/Makefile
> index e6cf21fad69f..f41c4b011221 100644
> --- a/tools/testing/selftests/bpf/Makefile
> +++ b/tools/testing/selftests/bpf/Makefile
> @@ -617,3 +617,6 @@ EXTRA_CLEAN := $(TEST_CUSTOM_PROGS) $(SCRATCH_DIR) $(HOST_SCRATCH_DIR)      \
>                                liburandom_read.so)
>
>  .PHONY: docs docs-clean
> +
> +# Delete partially updated (corrupted) files on error
> +.DELETE_ON_ERROR:
> --
> 2.37.2
>

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v2 1/2] libbpf: show error info about missing ".BTF" section
  2022-11-29 13:42 ` [PATCH v2 1/2] libbpf: show error info about missing ".BTF" section Changbin Du
@ 2022-12-01  0:55   ` Andrii Nakryiko
  2022-12-17  9:43     ` Changbin Du
  0 siblings, 1 reply; 8+ messages in thread
From: Andrii Nakryiko @ 2022-12-01  0:55 UTC (permalink / raw)
  To: Changbin Du
  Cc: Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
	Quentin Monnet, Peter Zijlstra, Ingo Molnar,
	Arnaldo Carvalho de Melo, Shuah Khan, Martin KaFai Lau, Song Liu,
	Yonghong Song, John Fastabend, KP Singh, Stanislav Fomichev,
	Hao Luo, Jiri Olsa, bpf, linux-kernel, Mark Rutland,
	Alexander Shishkin, Namhyung Kim, Mykola Lysenko,
	linux-perf-users, linux-kselftest

On Tue, Nov 29, 2022 at 5:42 AM Changbin Du <changbin.du@gmail.com> wrote:
>
> Show the real problem instead of just saying "No such file or directory".
>
> Now will print below info:
> libbpf: can not find '.BTF' section
> Error: failed to load BTF from /home/changbin/work/linux/vmlinux: No such file or directory
>
> Signed-off-by: Changbin Du <changbin.du@gmail.com>
> ---
>  tools/lib/bpf/btf.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/tools/lib/bpf/btf.c b/tools/lib/bpf/btf.c
> index d88647da2c7f..1adc0f6019a0 100644
> --- a/tools/lib/bpf/btf.c
> +++ b/tools/lib/bpf/btf.c
> @@ -990,6 +990,7 @@ static struct btf *btf_parse_elf(const char *path, struct btf *base_btf,
>         err = 0;
>
>         if (!btf_data) {
> +               pr_warn("can not find '%s' section\n", BTF_ELF_SEC);

let's use consistent form of error messages:

pr_warn("failed to find '%s' ELF section in %s\n", BTF_ELF_SEC, path);

>                 err = -ENOENT;
>                 goto done;
>         }
> --
> 2.37.2
>

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v2 0/2] bpftool: improve error handing for missing .BTF section
  2022-11-29 13:42 [PATCH v2 0/2] bpftool: improve error handing for missing .BTF section Changbin Du
  2022-11-29 13:42 ` [PATCH v2 1/2] libbpf: show error info about missing ".BTF" section Changbin Du
  2022-11-29 13:42 ` [PATCH v2 2/2] bpf: makefiles: do not generate empty vmlinux.h Changbin Du
@ 2022-12-01  0:55 ` Andrii Nakryiko
  2 siblings, 0 replies; 8+ messages in thread
From: Andrii Nakryiko @ 2022-12-01  0:55 UTC (permalink / raw)
  To: Changbin Du
  Cc: Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
	Quentin Monnet, Peter Zijlstra, Ingo Molnar,
	Arnaldo Carvalho de Melo, Shuah Khan, Martin KaFai Lau, Song Liu,
	Yonghong Song, John Fastabend, KP Singh, Stanislav Fomichev,
	Hao Luo, Jiri Olsa, bpf, linux-kernel, Mark Rutland,
	Alexander Shishkin, Namhyung Kim, Mykola Lysenko,
	linux-perf-users, linux-kselftest

On Tue, Nov 29, 2022 at 5:42 AM Changbin Du <changbin.du@gmail.com> wrote:
>

please fill out cover letter


> v2:
>  - remove vmlinux specific error info.
>  - use builtin target .DELETE_ON_ERROR: to delete empty vmlinux.h
>
> Changbin Du (2):
>   libbpf: show error info about missing ".BTF" section
>   bpf: makefiles: do not generate empty vmlinux.h
>
>  tools/bpf/bpftool/Makefile           | 3 +++
>  tools/lib/bpf/btf.c                  | 1 +
>  tools/perf/Makefile.perf             | 2 ++
>  tools/testing/selftests/bpf/Makefile | 3 +++
>  4 files changed, 9 insertions(+)
>
> --
> 2.37.2
>

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v2 2/2] bpf: makefiles: do not generate empty vmlinux.h
  2022-12-01  0:52   ` Andrii Nakryiko
@ 2022-12-17  9:32     ` Changbin Du
  0 siblings, 0 replies; 8+ messages in thread
From: Changbin Du @ 2022-12-17  9:32 UTC (permalink / raw)
  To: Andrii Nakryiko
  Cc: Changbin Du, Alexei Starovoitov, Daniel Borkmann,
	Andrii Nakryiko, Quentin Monnet, Peter Zijlstra, Ingo Molnar,
	Arnaldo Carvalho de Melo, Shuah Khan, Martin KaFai Lau, Song Liu,
	Yonghong Song, John Fastabend, KP Singh, Stanislav Fomichev,
	Hao Luo, Jiri Olsa, bpf, linux-kernel, Mark Rutland,
	Alexander Shishkin, Namhyung Kim, Mykola Lysenko,
	linux-perf-users, linux-kselftest

On Wed, Nov 30, 2022 at 04:52:11PM -0800, Andrii Nakryiko wrote:
> On Tue, Nov 29, 2022 at 5:42 AM Changbin Du <changbin.du@gmail.com> wrote:
> >
> > Remove the empty vmlinux.h if bpftool failed to dump btf info.
> > The emptry vmlinux.h can hide real error when reading output
> 
> typo: empty
>
Will be fixed, thanks.

> > of make.
> >
> > This is done by adding .DELETE_ON_ERROR special target in related
> > makefiles.
> >
> > Signed-off-by: Changbin Du <changbin.du@gmail.com>
> > ---
> >  tools/bpf/bpftool/Makefile           | 3 +++
> >  tools/perf/Makefile.perf             | 2 ++
> >  tools/testing/selftests/bpf/Makefile | 3 +++
> >  3 files changed, 8 insertions(+)
> >
> > diff --git a/tools/bpf/bpftool/Makefile b/tools/bpf/bpftool/Makefile
> > index 4a95c017ad4c..f6b1e65085db 100644
> > --- a/tools/bpf/bpftool/Makefile
> > +++ b/tools/bpf/bpftool/Makefile
> > @@ -265,3 +265,6 @@ FORCE:
> >  .PHONY: all FORCE bootstrap clean install-bin install uninstall
> >  .PHONY: doc doc-clean doc-install doc-uninstall
> >  .DEFAULT_GOAL := all
> > +
> > +# Delete partially updated (corrupted) files on error
> > +.DELETE_ON_ERROR:
> > diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf
> > index a432e59afc42..265254fc641a 100644
> > --- a/tools/perf/Makefile.perf
> > +++ b/tools/perf/Makefile.perf
> > @@ -1149,3 +1149,5 @@ FORCE:
> >  .PHONY: libtraceevent_plugins archheaders
> >
> >  endif # force_fixdep
> > +
> > +.DELETE_ON_ERROR:
> 
> please split out perf changes, they should go through perf tree
> 
sure, I'll send a standalone patch to perf tree.

> > diff --git a/tools/testing/selftests/bpf/Makefile b/tools/testing/selftests/bpf/Makefile
> > index e6cf21fad69f..f41c4b011221 100644
> > --- a/tools/testing/selftests/bpf/Makefile
> > +++ b/tools/testing/selftests/bpf/Makefile
> > @@ -617,3 +617,6 @@ EXTRA_CLEAN := $(TEST_CUSTOM_PROGS) $(SCRATCH_DIR) $(HOST_SCRATCH_DIR)      \
> >                                liburandom_read.so)
> >
> >  .PHONY: docs docs-clean
> > +
> > +# Delete partially updated (corrupted) files on error
> > +.DELETE_ON_ERROR:
> > --
> > 2.37.2
> >

-- 
Cheers,
Changbin Du

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v2 1/2] libbpf: show error info about missing ".BTF" section
  2022-12-01  0:55   ` Andrii Nakryiko
@ 2022-12-17  9:43     ` Changbin Du
  0 siblings, 0 replies; 8+ messages in thread
From: Changbin Du @ 2022-12-17  9:43 UTC (permalink / raw)
  To: Andrii Nakryiko
  Cc: Changbin Du, Alexei Starovoitov, Daniel Borkmann,
	Andrii Nakryiko, Quentin Monnet, Peter Zijlstra, Ingo Molnar,
	Arnaldo Carvalho de Melo, Shuah Khan, Martin KaFai Lau, Song Liu,
	Yonghong Song, John Fastabend, KP Singh, Stanislav Fomichev,
	Hao Luo, Jiri Olsa, bpf, linux-kernel, Mark Rutland,
	Alexander Shishkin, Namhyung Kim, Mykola Lysenko,
	linux-perf-users, linux-kselftest

On Wed, Nov 30, 2022 at 04:55:13PM -0800, Andrii Nakryiko wrote:
> On Tue, Nov 29, 2022 at 5:42 AM Changbin Du <changbin.du@gmail.com> wrote:
> >
> > Show the real problem instead of just saying "No such file or directory".
> >
> > Now will print below info:
> > libbpf: can not find '.BTF' section
> > Error: failed to load BTF from /home/changbin/work/linux/vmlinux: No such file or directory
> >
> > Signed-off-by: Changbin Du <changbin.du@gmail.com>
> > ---
> >  tools/lib/bpf/btf.c | 1 +
> >  1 file changed, 1 insertion(+)
> >
> > diff --git a/tools/lib/bpf/btf.c b/tools/lib/bpf/btf.c
> > index d88647da2c7f..1adc0f6019a0 100644
> > --- a/tools/lib/bpf/btf.c
> > +++ b/tools/lib/bpf/btf.c
> > @@ -990,6 +990,7 @@ static struct btf *btf_parse_elf(const char *path, struct btf *base_btf,
> >         err = 0;
> >
> >         if (!btf_data) {
> > +               pr_warn("can not find '%s' section\n", BTF_ELF_SEC);
> 
> let's use consistent form of error messages:
> 
> pr_warn("failed to find '%s' ELF section in %s\n", BTF_ELF_SEC, path);
>
okay.

> >                 err = -ENOENT;
> >                 goto done;
> >         }
> > --
> > 2.37.2
> >

-- 
Cheers,
Changbin Du

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2022-12-17  9:44 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-29 13:42 [PATCH v2 0/2] bpftool: improve error handing for missing .BTF section Changbin Du
2022-11-29 13:42 ` [PATCH v2 1/2] libbpf: show error info about missing ".BTF" section Changbin Du
2022-12-01  0:55   ` Andrii Nakryiko
2022-12-17  9:43     ` Changbin Du
2022-11-29 13:42 ` [PATCH v2 2/2] bpf: makefiles: do not generate empty vmlinux.h Changbin Du
2022-12-01  0:52   ` Andrii Nakryiko
2022-12-17  9:32     ` Changbin Du
2022-12-01  0:55 ` [PATCH v2 0/2] bpftool: improve error handing for missing .BTF section 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).