diff mbox series

[bpf-next,v3,8/8] bpftool: Add llvm feature to "bpftool version"

Message ID 20221020123704.91203-9-quentin@isovalent.com (mailing list archive)
State Superseded
Delegated to: BPF
Headers show
Series bpftool: Add LLVM as default library for disassembling JIT-ed programs | expand

Checks

Context Check Description
netdev/tree_selection success Clearly marked for bpf-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix success Link
netdev/cover_letter success Series has a cover letter
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers warning 6 maintainers not CCed: trix@redhat.com song@kernel.org ndesaulniers@google.com llvm@lists.linux.dev martin.lau@linux.dev nathan@kernel.org
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 42 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
bpf/vmtest-bpf-next-PR success PR summary
bpf/vmtest-bpf-next-VM_Test-1 success Logs for build for s390x with gcc
bpf/vmtest-bpf-next-VM_Test-2 success Logs for build for x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-3 success Logs for build for x86_64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-4 success Logs for llvm-toolchain
bpf/vmtest-bpf-next-VM_Test-5 success Logs for set-matrix
bpf/vmtest-bpf-next-VM_Test-6 success Logs for test_maps on s390x with gcc
bpf/vmtest-bpf-next-VM_Test-7 success Logs for test_maps on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-8 success Logs for test_maps on x86_64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-9 success Logs for test_progs on s390x with gcc
bpf/vmtest-bpf-next-VM_Test-10 success Logs for test_progs on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-11 success Logs for test_progs on x86_64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-12 success Logs for test_progs_no_alu32 on s390x with gcc
bpf/vmtest-bpf-next-VM_Test-13 success Logs for test_progs_no_alu32 on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-14 success Logs for test_progs_no_alu32 on x86_64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-15 success Logs for test_verifier on s390x with gcc
bpf/vmtest-bpf-next-VM_Test-16 success Logs for test_verifier on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-17 success Logs for test_verifier on x86_64 with llvm-16

Commit Message

Quentin Monnet Oct. 20, 2022, 12:37 p.m. UTC
Similarly to "libbfd", add a "llvm" feature to the output of command
"bpftool version" to indicate that LLVM is used for disassembling JIT-ed
programs. This feature is mutually exclusive with "libbfd".

Signed-off-by: Quentin Monnet <quentin@isovalent.com>
Tested-by: Niklas Söderlund <niklas.soderlund@corigine.com>
Acked-by: Yonghong Song <yhs@fb.com>
---
Note: There's a conflict on this change with the patch at
https://lore.kernel.org/bpf/20221020100332.69563-1-quentin@isovalent.com/
Supposiing both are accepted, I will of course rebase one or the other,
accordingly.
---
 tools/bpf/bpftool/Documentation/common_options.rst |  8 ++++----
 tools/bpf/bpftool/main.c                           | 10 ++++++++++
 2 files changed, 14 insertions(+), 4 deletions(-)

Comments

Andrii Nakryiko Oct. 21, 2022, 10:38 p.m. UTC | #1
On Thu, Oct 20, 2022 at 5:37 AM Quentin Monnet <quentin@isovalent.com> wrote:
>
> Similarly to "libbfd", add a "llvm" feature to the output of command
> "bpftool version" to indicate that LLVM is used for disassembling JIT-ed
> programs. This feature is mutually exclusive with "libbfd".
>
> Signed-off-by: Quentin Monnet <quentin@isovalent.com>
> Tested-by: Niklas Söderlund <niklas.soderlund@corigine.com>
> Acked-by: Yonghong Song <yhs@fb.com>
> ---
> Note: There's a conflict on this change with the patch at
> https://lore.kernel.org/bpf/20221020100332.69563-1-quentin@isovalent.com/
> Supposiing both are accepted, I will of course rebase one or the other,
> accordingly.
> ---
>  tools/bpf/bpftool/Documentation/common_options.rst |  8 ++++----
>  tools/bpf/bpftool/main.c                           | 10 ++++++++++
>  2 files changed, 14 insertions(+), 4 deletions(-)
>
> diff --git a/tools/bpf/bpftool/Documentation/common_options.rst b/tools/bpf/bpftool/Documentation/common_options.rst
> index 4107a586b68b..05350a1aadf9 100644
> --- a/tools/bpf/bpftool/Documentation/common_options.rst
> +++ b/tools/bpf/bpftool/Documentation/common_options.rst
> @@ -7,10 +7,10 @@
>           Print bpftool's version number (similar to **bpftool version**), the
>           number of the libbpf version in use, and optional features that were
>           included when bpftool was compiled. Optional features include linking
> -         against libbfd to provide the disassembler for JIT-ted programs
> -         (**bpftool prog dump jited**) and usage of BPF skeletons (some
> -         features like **bpftool prog profile** or showing pids associated to
> -         BPF objects may rely on it).
> +         against LLVM or libbfd to provide the disassembler for JIT-ted
> +         programs (**bpftool prog dump jited**) and usage of BPF skeletons
> +         (some features like **bpftool prog profile** or showing pids
> +         associated to BPF objects may rely on it).
>
>  -j, --json
>           Generate JSON output. For commands that cannot produce JSON, this
> diff --git a/tools/bpf/bpftool/main.c b/tools/bpf/bpftool/main.c
> index ccd7457f92bf..7e06ca2c5d42 100644
> --- a/tools/bpf/bpftool/main.c
> +++ b/tools/bpf/bpftool/main.c
> @@ -89,6 +89,11 @@ static int do_version(int argc, char **argv)
>  #else
>         const bool has_libbfd = false;
>  #endif
> +#ifdef HAVE_LLVM_SUPPORT
> +       const bool has_llvm = true;
> +#else
> +       const bool has_llvm = false;
> +#endif
>  #ifdef BPFTOOL_WITHOUT_SKELETONS
>         const bool has_skeletons = false;
>  #else
> @@ -112,6 +117,7 @@ static int do_version(int argc, char **argv)
>                 jsonw_name(json_wtr, "features");
>                 jsonw_start_object(json_wtr);   /* features */
>                 jsonw_bool_field(json_wtr, "libbfd", has_libbfd);
> +               jsonw_bool_field(json_wtr, "llvm", has_llvm);
>                 jsonw_bool_field(json_wtr, "libbpf_strict", !legacy_libbpf);
>                 jsonw_bool_field(json_wtr, "skeletons", has_skeletons);
>                 jsonw_end_object(json_wtr);     /* features */
> @@ -132,6 +138,10 @@ static int do_version(int argc, char **argv)
>                         printf(" libbfd");
>                         nb_features++;
>                 }
> +               if (has_llvm) {
> +                       printf(" llvm");
> +                       nb_features++;
> +               }
>                 if (!legacy_libbpf) {

completely unrelated to your patch set, but we don't have legacy
libbpf anymore, right? let's clean this part up (separately from this
patch set, of course)?


>                         printf("%s libbpf_strict", nb_features++ ? "," : "");
>                         nb_features++;
> --
> 2.34.1
>
Quentin Monnet Oct. 24, 2022, 11:09 a.m. UTC | #2
2022-10-21 15:38 UTC-0700 ~ Andrii Nakryiko <andrii.nakryiko@gmail.com>
> On Thu, Oct 20, 2022 at 5:37 AM Quentin Monnet <quentin@isovalent.com> wrote:
>>
>> Similarly to "libbfd", add a "llvm" feature to the output of command
>> "bpftool version" to indicate that LLVM is used for disassembling JIT-ed
>> programs. This feature is mutually exclusive with "libbfd".
>>
>> Signed-off-by: Quentin Monnet <quentin@isovalent.com>
>> Tested-by: Niklas Söderlund <niklas.soderlund@corigine.com>
>> Acked-by: Yonghong Song <yhs@fb.com>
>> ---
>> Note: There's a conflict on this change with the patch at
>> https://lore.kernel.org/bpf/20221020100332.69563-1-quentin@isovalent.com/
>> Supposiing both are accepted, I will of course rebase one or the other,
>> accordingly.
>> ---
>>  tools/bpf/bpftool/Documentation/common_options.rst |  8 ++++----
>>  tools/bpf/bpftool/main.c                           | 10 ++++++++++
>>  2 files changed, 14 insertions(+), 4 deletions(-)
>>
>> diff --git a/tools/bpf/bpftool/Documentation/common_options.rst b/tools/bpf/bpftool/Documentation/common_options.rst
>> index 4107a586b68b..05350a1aadf9 100644
>> --- a/tools/bpf/bpftool/Documentation/common_options.rst
>> +++ b/tools/bpf/bpftool/Documentation/common_options.rst
>> @@ -7,10 +7,10 @@
>>           Print bpftool's version number (similar to **bpftool version**), the
>>           number of the libbpf version in use, and optional features that were
>>           included when bpftool was compiled. Optional features include linking
>> -         against libbfd to provide the disassembler for JIT-ted programs
>> -         (**bpftool prog dump jited**) and usage of BPF skeletons (some
>> -         features like **bpftool prog profile** or showing pids associated to
>> -         BPF objects may rely on it).
>> +         against LLVM or libbfd to provide the disassembler for JIT-ted
>> +         programs (**bpftool prog dump jited**) and usage of BPF skeletons
>> +         (some features like **bpftool prog profile** or showing pids
>> +         associated to BPF objects may rely on it).
>>
>>  -j, --json
>>           Generate JSON output. For commands that cannot produce JSON, this
>> diff --git a/tools/bpf/bpftool/main.c b/tools/bpf/bpftool/main.c
>> index ccd7457f92bf..7e06ca2c5d42 100644
>> --- a/tools/bpf/bpftool/main.c
>> +++ b/tools/bpf/bpftool/main.c
>> @@ -89,6 +89,11 @@ static int do_version(int argc, char **argv)
>>  #else
>>         const bool has_libbfd = false;
>>  #endif
>> +#ifdef HAVE_LLVM_SUPPORT
>> +       const bool has_llvm = true;
>> +#else
>> +       const bool has_llvm = false;
>> +#endif
>>  #ifdef BPFTOOL_WITHOUT_SKELETONS
>>         const bool has_skeletons = false;
>>  #else
>> @@ -112,6 +117,7 @@ static int do_version(int argc, char **argv)
>>                 jsonw_name(json_wtr, "features");
>>                 jsonw_start_object(json_wtr);   /* features */
>>                 jsonw_bool_field(json_wtr, "libbfd", has_libbfd);
>> +               jsonw_bool_field(json_wtr, "llvm", has_llvm);
>>                 jsonw_bool_field(json_wtr, "libbpf_strict", !legacy_libbpf);
>>                 jsonw_bool_field(json_wtr, "skeletons", has_skeletons);
>>                 jsonw_end_object(json_wtr);     /* features */
>> @@ -132,6 +138,10 @@ static int do_version(int argc, char **argv)
>>                         printf(" libbfd");
>>                         nb_features++;
>>                 }
>> +               if (has_llvm) {
>> +                       printf(" llvm");
>> +                       nb_features++;
>> +               }
>>                 if (!legacy_libbpf) {
> 
> completely unrelated to your patch set, but we don't have legacy
> libbpf anymore, right? let's clean this part up (separately from this
> patch set, of course)?

Yes agreed, this and the related warning in prog.c. And cleaning up all
the libbpf_get_error() too. I'll work on this when I find some time.

Thanks,
Quentin
diff mbox series

Patch

diff --git a/tools/bpf/bpftool/Documentation/common_options.rst b/tools/bpf/bpftool/Documentation/common_options.rst
index 4107a586b68b..05350a1aadf9 100644
--- a/tools/bpf/bpftool/Documentation/common_options.rst
+++ b/tools/bpf/bpftool/Documentation/common_options.rst
@@ -7,10 +7,10 @@ 
 	  Print bpftool's version number (similar to **bpftool version**), the
 	  number of the libbpf version in use, and optional features that were
 	  included when bpftool was compiled. Optional features include linking
-	  against libbfd to provide the disassembler for JIT-ted programs
-	  (**bpftool prog dump jited**) and usage of BPF skeletons (some
-	  features like **bpftool prog profile** or showing pids associated to
-	  BPF objects may rely on it).
+	  against LLVM or libbfd to provide the disassembler for JIT-ted
+	  programs (**bpftool prog dump jited**) and usage of BPF skeletons
+	  (some features like **bpftool prog profile** or showing pids
+	  associated to BPF objects may rely on it).
 
 -j, --json
 	  Generate JSON output. For commands that cannot produce JSON, this
diff --git a/tools/bpf/bpftool/main.c b/tools/bpf/bpftool/main.c
index ccd7457f92bf..7e06ca2c5d42 100644
--- a/tools/bpf/bpftool/main.c
+++ b/tools/bpf/bpftool/main.c
@@ -89,6 +89,11 @@  static int do_version(int argc, char **argv)
 #else
 	const bool has_libbfd = false;
 #endif
+#ifdef HAVE_LLVM_SUPPORT
+	const bool has_llvm = true;
+#else
+	const bool has_llvm = false;
+#endif
 #ifdef BPFTOOL_WITHOUT_SKELETONS
 	const bool has_skeletons = false;
 #else
@@ -112,6 +117,7 @@  static int do_version(int argc, char **argv)
 		jsonw_name(json_wtr, "features");
 		jsonw_start_object(json_wtr);	/* features */
 		jsonw_bool_field(json_wtr, "libbfd", has_libbfd);
+		jsonw_bool_field(json_wtr, "llvm", has_llvm);
 		jsonw_bool_field(json_wtr, "libbpf_strict", !legacy_libbpf);
 		jsonw_bool_field(json_wtr, "skeletons", has_skeletons);
 		jsonw_end_object(json_wtr);	/* features */
@@ -132,6 +138,10 @@  static int do_version(int argc, char **argv)
 			printf(" libbfd");
 			nb_features++;
 		}
+		if (has_llvm) {
+			printf(" llvm");
+			nb_features++;
+		}
 		if (!legacy_libbpf) {
 			printf("%s libbpf_strict", nb_features++ ? "," : "");
 			nb_features++;