All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH bpf-next] selftests/bpf: Fix test_ksyms on non-SMP kernels
@ 2020-09-10 17:13 Ilya Leoshkevich
  2020-09-10 20:00 ` Andrii Nakryiko
  0 siblings, 1 reply; 3+ messages in thread
From: Ilya Leoshkevich @ 2020-09-10 17:13 UTC (permalink / raw)
  To: Alexei Starovoitov, Daniel Borkmann
  Cc: bpf, Heiko Carstens, Vasily Gorbik, Andrii Nakryiko, Ilya Leoshkevich

On non-SMP kernels __per_cpu_start is not 0, so look it up in kallsyms.

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

diff --git a/tools/testing/selftests/bpf/prog_tests/ksyms.c b/tools/testing/selftests/bpf/prog_tests/ksyms.c
index e3d6777226a8..b771804b2342 100644
--- a/tools/testing/selftests/bpf/prog_tests/ksyms.c
+++ b/tools/testing/selftests/bpf/prog_tests/ksyms.c
@@ -32,6 +32,7 @@ static __u64 kallsyms_find(const char *sym)
 
 void test_ksyms(void)
 {
+	__u64 per_cpu_start_addr = kallsyms_find("__per_cpu_start");
 	__u64 link_fops_addr = kallsyms_find("bpf_link_fops");
 	const char *btf_path = "/sys/kernel/btf/vmlinux";
 	struct test_ksyms *skel;
@@ -63,8 +64,9 @@ void test_ksyms(void)
 	      "got %llu, exp %llu\n", data->out__bpf_link_fops1, (__u64)0);
 	CHECK(data->out__btf_size != btf_size, "btf_size",
 	      "got %llu, exp %llu\n", data->out__btf_size, btf_size);
-	CHECK(data->out__per_cpu_start != 0, "__per_cpu_start",
-	      "got %llu, exp %llu\n", data->out__per_cpu_start, (__u64)0);
+	CHECK(data->out__per_cpu_start != per_cpu_start_addr, "__per_cpu_start",
+	      "got %llu, exp %llu\n", data->out__per_cpu_start,
+	      per_cpu_start_addr);
 
 cleanup:
 	test_ksyms__destroy(skel);
-- 
2.25.4


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

* Re: [PATCH bpf-next] selftests/bpf: Fix test_ksyms on non-SMP kernels
  2020-09-10 17:13 [PATCH bpf-next] selftests/bpf: Fix test_ksyms on non-SMP kernels Ilya Leoshkevich
@ 2020-09-10 20:00 ` Andrii Nakryiko
  2020-09-11  2:57   ` Alexei Starovoitov
  0 siblings, 1 reply; 3+ messages in thread
From: Andrii Nakryiko @ 2020-09-10 20:00 UTC (permalink / raw)
  To: Ilya Leoshkevich
  Cc: Alexei Starovoitov, Daniel Borkmann, bpf, Heiko Carstens, Vasily Gorbik

On Thu, Sep 10, 2020 at 10:13 AM Ilya Leoshkevich <iii@linux.ibm.com> wrote:
>
> On non-SMP kernels __per_cpu_start is not 0, so look it up in kallsyms.
>
> Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
> ---

Acked-by: Andrii Nakryiko <andriin@fb.com>

>  tools/testing/selftests/bpf/prog_tests/ksyms.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/tools/testing/selftests/bpf/prog_tests/ksyms.c b/tools/testing/selftests/bpf/prog_tests/ksyms.c
> index e3d6777226a8..b771804b2342 100644
> --- a/tools/testing/selftests/bpf/prog_tests/ksyms.c
> +++ b/tools/testing/selftests/bpf/prog_tests/ksyms.c
> @@ -32,6 +32,7 @@ static __u64 kallsyms_find(const char *sym)
>
>  void test_ksyms(void)
>  {
> +       __u64 per_cpu_start_addr = kallsyms_find("__per_cpu_start");
>         __u64 link_fops_addr = kallsyms_find("bpf_link_fops");
>         const char *btf_path = "/sys/kernel/btf/vmlinux";
>         struct test_ksyms *skel;
> @@ -63,8 +64,9 @@ void test_ksyms(void)
>               "got %llu, exp %llu\n", data->out__bpf_link_fops1, (__u64)0);
>         CHECK(data->out__btf_size != btf_size, "btf_size",
>               "got %llu, exp %llu\n", data->out__btf_size, btf_size);
> -       CHECK(data->out__per_cpu_start != 0, "__per_cpu_start",
> -             "got %llu, exp %llu\n", data->out__per_cpu_start, (__u64)0);
> +       CHECK(data->out__per_cpu_start != per_cpu_start_addr, "__per_cpu_start",
> +             "got %llu, exp %llu\n", data->out__per_cpu_start,
> +             per_cpu_start_addr);
>
>  cleanup:
>         test_ksyms__destroy(skel);
> --
> 2.25.4
>

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

* Re: [PATCH bpf-next] selftests/bpf: Fix test_ksyms on non-SMP kernels
  2020-09-10 20:00 ` Andrii Nakryiko
@ 2020-09-11  2:57   ` Alexei Starovoitov
  0 siblings, 0 replies; 3+ messages in thread
From: Alexei Starovoitov @ 2020-09-11  2:57 UTC (permalink / raw)
  To: Andrii Nakryiko
  Cc: Ilya Leoshkevich, Alexei Starovoitov, Daniel Borkmann, bpf,
	Heiko Carstens, Vasily Gorbik

On Thu, Sep 10, 2020 at 1:01 PM Andrii Nakryiko
<andrii.nakryiko@gmail.com> wrote:
>
> On Thu, Sep 10, 2020 at 10:13 AM Ilya Leoshkevich <iii@linux.ibm.com> wrote:
> >
> > On non-SMP kernels __per_cpu_start is not 0, so look it up in kallsyms.
> >
> > Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
> > ---
>
> Acked-by: Andrii Nakryiko <andriin@fb.com>

Applied. Thanks

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

end of thread, other threads:[~2020-09-11  2:57 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-10 17:13 [PATCH bpf-next] selftests/bpf: Fix test_ksyms on non-SMP kernels Ilya Leoshkevich
2020-09-10 20:00 ` Andrii Nakryiko
2020-09-11  2:57   ` Alexei Starovoitov

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.