diff mbox series

[bpf-next,1/3] selftests/bpf: Use cpu_number only on arches that have it

Message ID 20211012023218.399568-2-iii@linux.ibm.com (mailing list archive)
State Superseded
Delegated to: BPF
Headers show
Series btf_dump fixes for s390 | expand

Checks

Context Check Description
bpf/vmtest-bpf-next success VM_Test
bpf/vmtest-bpf-next-PR success PR summary
netdev/cover_letter success Series has a cover letter
netdev/fixes_present success Fixes tag not required for -next series
netdev/patch_count success Link
netdev/tree_selection success Clearly marked for bpf-next
netdev/subject_prefix success Link
netdev/cc_maintainers warning 11 maintainers not CCed: lmb@cloudflare.com andrii@kernel.org songliubraving@fb.com netdev@vger.kernel.org yhs@fb.com john.fastabend@gmail.com kafai@fb.com alan.maguire@oracle.com shuah@kernel.org linux-kselftest@vger.kernel.org kpsingh@kernel.org
netdev/source_inline success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/module_param success Was 0 now: 0
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/verify_fixes success No Fixes tag
netdev/checkpatch warning CHECK: architecture specific defines should be avoided
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/header_inline success No static functions without inline keyword in header files

Commit Message

Ilya Leoshkevich Oct. 12, 2021, 2:32 a.m. UTC
cpu_number exists only on Intel and aarch64, so skip the test involing
it on other arches. An alternative would be to replace it with an
exported non-ifdefed primitive-typed percpu variable from the common
code, but there appears to be none.

Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
---
 tools/testing/selftests/bpf/prog_tests/btf_dump.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Andrii Nakryiko Oct. 12, 2021, 3:56 a.m. UTC | #1
On Tue, Oct 12, 2021 at 4:51 AM Ilya Leoshkevich <iii@linux.ibm.com> wrote:
>
> cpu_number exists only on Intel and aarch64, so skip the test involing
> it on other arches. An alternative would be to replace it with an
> exported non-ifdefed primitive-typed percpu variable from the common
> code, but there appears to be none.
>
> Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
> ---
>  tools/testing/selftests/bpf/prog_tests/btf_dump.c | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/tools/testing/selftests/bpf/prog_tests/btf_dump.c b/tools/testing/selftests/bpf/prog_tests/btf_dump.c
> index 87f9df653e4e..12f457b6786d 100644
> --- a/tools/testing/selftests/bpf/prog_tests/btf_dump.c
> +++ b/tools/testing/selftests/bpf/prog_tests/btf_dump.c
> @@ -778,8 +778,10 @@ static void test_btf_dump_struct_data(struct btf *btf, struct btf_dump *d,
>  static void test_btf_dump_var_data(struct btf *btf, struct btf_dump *d,
>                                    char *str)
>  {
> +#if defined(__i386__) || defined(__x86_64__) || defined(__aarch64__)
>         TEST_BTF_DUMP_VAR(btf, d, NULL, str, "cpu_number", int, BTF_F_COMPACT,
>                           "int cpu_number = (int)100", 100);
> +#endif

We are in the talks about supporting cross-compilation of selftests,
and this will be just another breakage that we'll have to undo.

Can we find some other variable that will be available on all
architectures? Maybe "runqueues"?

>         TEST_BTF_DUMP_VAR(btf, d, NULL, str, "cpu_profile_flip", int, BTF_F_COMPACT,
>                           "static int cpu_profile_flip = (int)2", 2);
>  }
> --
> 2.31.1
>
Ilya Leoshkevich Oct. 12, 2021, 11:02 a.m. UTC | #2
On Tue, 2021-10-12 at 05:56 +0200, Andrii Nakryiko wrote:
> On Tue, Oct 12, 2021 at 4:51 AM Ilya Leoshkevich <iii@linux.ibm.com>
> wrote:
> > 
> > cpu_number exists only on Intel and aarch64, so skip the test
> > involing
> > it on other arches. An alternative would be to replace it with an
> > exported non-ifdefed primitive-typed percpu variable from the
> > common
> > code, but there appears to be none.
> > 
> > Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
> > ---
> >  tools/testing/selftests/bpf/prog_tests/btf_dump.c | 2 ++
> >  1 file changed, 2 insertions(+)
> > 
> > diff --git a/tools/testing/selftests/bpf/prog_tests/btf_dump.c
> > b/tools/testing/selftests/bpf/prog_tests/btf_dump.c
> > index 87f9df653e4e..12f457b6786d 100644
> > --- a/tools/testing/selftests/bpf/prog_tests/btf_dump.c
> > +++ b/tools/testing/selftests/bpf/prog_tests/btf_dump.c
> > @@ -778,8 +778,10 @@ static void test_btf_dump_struct_data(struct
> > btf *btf, struct btf_dump *d,
> >  static void test_btf_dump_var_data(struct btf *btf, struct
> > btf_dump *d,
> >                                    char *str)
> >  {
> > +#if defined(__i386__) || defined(__x86_64__) ||
> > defined(__aarch64__)
> >         TEST_BTF_DUMP_VAR(btf, d, NULL, str, "cpu_number", int,
> > BTF_F_COMPACT,
> >                           "int cpu_number = (int)100", 100);
> > +#endif
> 
> We are in the talks about supporting cross-compilation of selftests,
> and this will be just another breakage that we'll have to undo.

Why would this break? Cross-compilation should define these macros
based on target, not build system.

> Can we find some other variable that will be available on all
> architectures? Maybe "runqueues"?

Wouldn't runqueues be pointless? We already have cpu_profile_flip. I
thought the idea here was to have something marked with
EXPORT_PER_CPU_SYMBOL.

> >         TEST_BTF_DUMP_VAR(btf, d, NULL, str, "cpu_profile_flip",
> > int, BTF_F_COMPACT,
> >                           "static int cpu_profile_flip = (int)2",
> > 2);
> >  }
> > --
> > 2.31.1
Andrii Nakryiko Oct. 20, 2021, 6:32 p.m. UTC | #3
On Tue, Oct 12, 2021 at 4:03 AM Ilya Leoshkevich <iii@linux.ibm.com> wrote:
>
> On Tue, 2021-10-12 at 05:56 +0200, Andrii Nakryiko wrote:
> > On Tue, Oct 12, 2021 at 4:51 AM Ilya Leoshkevich <iii@linux.ibm.com>
> > wrote:
> > >
> > > cpu_number exists only on Intel and aarch64, so skip the test
> > > involing
> > > it on other arches. An alternative would be to replace it with an
> > > exported non-ifdefed primitive-typed percpu variable from the
> > > common
> > > code, but there appears to be none.
> > >
> > > Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
> > > ---
> > >  tools/testing/selftests/bpf/prog_tests/btf_dump.c | 2 ++
> > >  1 file changed, 2 insertions(+)
> > >
> > > diff --git a/tools/testing/selftests/bpf/prog_tests/btf_dump.c
> > > b/tools/testing/selftests/bpf/prog_tests/btf_dump.c
> > > index 87f9df653e4e..12f457b6786d 100644
> > > --- a/tools/testing/selftests/bpf/prog_tests/btf_dump.c
> > > +++ b/tools/testing/selftests/bpf/prog_tests/btf_dump.c
> > > @@ -778,8 +778,10 @@ static void test_btf_dump_struct_data(struct
> > > btf *btf, struct btf_dump *d,
> > >  static void test_btf_dump_var_data(struct btf *btf, struct
> > > btf_dump *d,
> > >                                    char *str)
> > >  {
> > > +#if defined(__i386__) || defined(__x86_64__) ||
> > > defined(__aarch64__)
> > >         TEST_BTF_DUMP_VAR(btf, d, NULL, str, "cpu_number", int,
> > > BTF_F_COMPACT,
> > >                           "int cpu_number = (int)100", 100);
> > > +#endif
> >
> > We are in the talks about supporting cross-compilation of selftests,
> > and this will be just another breakage that we'll have to undo.
>
> Why would this break? Cross-compilation should define these macros
> based on target, not build system.

Ok, then it should be good.

>
> > Can we find some other variable that will be available on all
> > architectures? Maybe "runqueues"?
>
> Wouldn't runqueues be pointless? We already have cpu_profile_flip. I
> thought the idea here was to have something marked with
> EXPORT_PER_CPU_SYMBOL.

No idea what the idea was, tbh.

>
> > >         TEST_BTF_DUMP_VAR(btf, d, NULL, str, "cpu_profile_flip",
> > > int, BTF_F_COMPACT,
> > >                           "static int cpu_profile_flip = (int)2",
> > > 2);
> > >  }
> > > --
> > > 2.31.1
>
diff mbox series

Patch

diff --git a/tools/testing/selftests/bpf/prog_tests/btf_dump.c b/tools/testing/selftests/bpf/prog_tests/btf_dump.c
index 87f9df653e4e..12f457b6786d 100644
--- a/tools/testing/selftests/bpf/prog_tests/btf_dump.c
+++ b/tools/testing/selftests/bpf/prog_tests/btf_dump.c
@@ -778,8 +778,10 @@  static void test_btf_dump_struct_data(struct btf *btf, struct btf_dump *d,
 static void test_btf_dump_var_data(struct btf *btf, struct btf_dump *d,
 				   char *str)
 {
+#if defined(__i386__) || defined(__x86_64__) || defined(__aarch64__)
 	TEST_BTF_DUMP_VAR(btf, d, NULL, str, "cpu_number", int, BTF_F_COMPACT,
 			  "int cpu_number = (int)100", 100);
+#endif
 	TEST_BTF_DUMP_VAR(btf, d, NULL, str, "cpu_profile_flip", int, BTF_F_COMPACT,
 			  "static int cpu_profile_flip = (int)2", 2);
 }