LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH] tools/bpf: fix perf build error with uClibc (seen on ARC)
@ 2019-05-01 22:53 Vineet Gupta
  2019-05-02  6:31 ` Y Song
  0 siblings, 1 reply; 5+ messages in thread
From: Vineet Gupta @ 2019-05-01 22:53 UTC (permalink / raw)
  To: Alexei Starovoitov, Daniel Borkmann
  Cc: netdev, Wang Nan, Song Liu, Yonghong Song, Martin KaFai Lau, bpf,
	linux-kernel, linux-snps-arc, linux-perf-users, arnaldo.melo,
	Vineet Gupta

When build perf for ARC recently, there was a build failure due to lack
of __NR_bpf.

| Auto-detecting system features:
|
| ...                     get_cpuid: [ OFF ]
| ...                           bpf: [ on  ]
|
| #  error __NR_bpf not defined. libbpf does not support your arch.
    ^~~~~
| bpf.c: In function 'sys_bpf':
| bpf.c:66:17: error: '__NR_bpf' undeclared (first use in this function)
|  return syscall(__NR_bpf, cmd, attr, size);
|                 ^~~~~~~~
|                 sys_bpf

The fix is to define a fallbak __NR_bpf.

The obvious fix with be __arc__ specific value, but i think a better fix
is to use the asm-generic uapi value applicable to ARC as well as any new
arch (hopefully we don't add an old existing arch here). Otherwise I can
just add __arc__

Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
---
 tools/lib/bpf/bpf.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/tools/lib/bpf/bpf.c b/tools/lib/bpf/bpf.c
index 9cd015574e83..2c5eb7928400 100644
--- a/tools/lib/bpf/bpf.c
+++ b/tools/lib/bpf/bpf.c
@@ -47,7 +47,10 @@
 # elif defined(__s390__)
 #  define __NR_bpf 351
 # else
-#  error __NR_bpf not defined. libbpf does not support your arch.
+/*
+ * Any non listed arch (new) will have to asm-generic uapi complient
+ */
+#  define __NR_bpf 280
 # endif
 #endif
 
-- 
2.7.4


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

* Re: [PATCH] tools/bpf: fix perf build error with uClibc (seen on ARC)
  2019-05-01 22:53 [PATCH] tools/bpf: fix perf build error with uClibc (seen on ARC) Vineet Gupta
@ 2019-05-02  6:31 ` Y Song
  2019-05-02 15:56   ` [PATCH v2] " Vineet Gupta
  0 siblings, 1 reply; 5+ messages in thread
From: Y Song @ 2019-05-02  6:31 UTC (permalink / raw)
  To: Vineet Gupta
  Cc: Alexei Starovoitov, Daniel Borkmann, netdev, Wang Nan, Song Liu,
	Yonghong Song, Martin KaFai Lau, bpf, LKML, linux-snps-arc,
	linux-perf-users, arnaldo.melo

On Wed, May 1, 2019 at 3:55 PM Vineet Gupta <Vineet.Gupta1@synopsys.com> wrote:
>
> When build perf for ARC recently, there was a build failure due to lack
> of __NR_bpf.
>
> | Auto-detecting system features:
> |
> | ...                     get_cpuid: [ OFF ]
> | ...                           bpf: [ on  ]
> |
> | #  error __NR_bpf not defined. libbpf does not support your arch.
>     ^~~~~
> | bpf.c: In function 'sys_bpf':
> | bpf.c:66:17: error: '__NR_bpf' undeclared (first use in this function)
> |  return syscall(__NR_bpf, cmd, attr, size);
> |                 ^~~~~~~~
> |                 sys_bpf
>
> The fix is to define a fallbak __NR_bpf.
>
> The obvious fix with be __arc__ specific value, but i think a better fix
> is to use the asm-generic uapi value applicable to ARC as well as any new
> arch (hopefully we don't add an old existing arch here). Otherwise I can
> just add __arc__

I prefer explicitly guard with __arc__. We still have arm/sh with different
__NR_bpf values. This patch will give wrong bpf syscall values for these
two architectures.

Alternatively, you could add support for arm/sh together
with your current patch. Hopefully I did not miss other architectures.

>
> Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
> ---
>  tools/lib/bpf/bpf.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/tools/lib/bpf/bpf.c b/tools/lib/bpf/bpf.c
> index 9cd015574e83..2c5eb7928400 100644
> --- a/tools/lib/bpf/bpf.c
> +++ b/tools/lib/bpf/bpf.c
> @@ -47,7 +47,10 @@
>  # elif defined(__s390__)
>  #  define __NR_bpf 351
>  # else
> -#  error __NR_bpf not defined. libbpf does not support your arch.
> +/*
> + * Any non listed arch (new) will have to asm-generic uapi complient
> + */
> +#  define __NR_bpf 280
>  # endif
>  #endif
>
> --
> 2.7.4
>

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

* [PATCH v2] tools/bpf: fix perf build error with uClibc (seen on ARC)
  2019-05-02  6:31 ` Y Song
@ 2019-05-02 15:56   ` Vineet Gupta
  2019-05-02 20:19     ` Y Song
  0 siblings, 1 reply; 5+ messages in thread
From: Vineet Gupta @ 2019-05-02 15:56 UTC (permalink / raw)
  To: Alexei Starovoitov, Daniel Borkmann
  Cc: netdev, Wang Nan, Song Liu, Yonghong Song, Martin KaFai Lau, bpf,
	linux-kernel, linux-snps-arc, linux-perf-users, arnaldo.melo,
	Y Song, Vineet Gupta

When build perf for ARC recently, there was a build failure due to lack
of __NR_bpf.

| Auto-detecting system features:
|
| ...                     get_cpuid: [ OFF ]
| ...                           bpf: [ on  ]
|
| #  error __NR_bpf not defined. libbpf does not support your arch.
    ^~~~~
| bpf.c: In function 'sys_bpf':
| bpf.c:66:17: error: '__NR_bpf' undeclared (first use in this function)
|  return syscall(__NR_bpf, cmd, attr, size);
|                 ^~~~~~~~
|                 sys_bpf

Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
---
v1 -> v2
  - Only add syscall nr for ARC, as asm-generic won't work with arm/sh [Y Song]
---
 tools/lib/bpf/bpf.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/tools/lib/bpf/bpf.c b/tools/lib/bpf/bpf.c
index 9cd015574e83..d82edadf7589 100644
--- a/tools/lib/bpf/bpf.c
+++ b/tools/lib/bpf/bpf.c
@@ -46,6 +46,8 @@
 #  define __NR_bpf 349
 # elif defined(__s390__)
 #  define __NR_bpf 351
+# elif defined(__arc__)
+#  define __NR_bpf 280
 # else
 #  error __NR_bpf not defined. libbpf does not support your arch.
 # endif
-- 
2.7.4


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

* Re: [PATCH v2] tools/bpf: fix perf build error with uClibc (seen on ARC)
  2019-05-02 15:56   ` [PATCH v2] " Vineet Gupta
@ 2019-05-02 20:19     ` Y Song
  2019-05-05  7:05       ` Alexei Starovoitov
  0 siblings, 1 reply; 5+ messages in thread
From: Y Song @ 2019-05-02 20:19 UTC (permalink / raw)
  To: Vineet Gupta
  Cc: Alexei Starovoitov, Daniel Borkmann, netdev, Wang Nan, Song Liu,
	Yonghong Song, Martin KaFai Lau, bpf, LKML, linux-snps-arc,
	linux-perf-users, arnaldo.melo

On Thu, May 2, 2019 at 8:57 AM Vineet Gupta <Vineet.Gupta1@synopsys.com> wrote:
>
> When build perf for ARC recently, there was a build failure due to lack
> of __NR_bpf.
>
> | Auto-detecting system features:
> |
> | ...                     get_cpuid: [ OFF ]
> | ...                           bpf: [ on  ]
> |
> | #  error __NR_bpf not defined. libbpf does not support your arch.
>     ^~~~~
> | bpf.c: In function 'sys_bpf':
> | bpf.c:66:17: error: '__NR_bpf' undeclared (first use in this function)
> |  return syscall(__NR_bpf, cmd, attr, size);
> |                 ^~~~~~~~
> |                 sys_bpf
>
> Signed-off-by: Vineet Gupta <vgupta@synopsys.com>

Acked-by: Yonghong Song <yhs@fb.com>

> ---
> v1 -> v2
>   - Only add syscall nr for ARC, as asm-generic won't work with arm/sh [Y Song]
> ---
>  tools/lib/bpf/bpf.c | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/tools/lib/bpf/bpf.c b/tools/lib/bpf/bpf.c
> index 9cd015574e83..d82edadf7589 100644
> --- a/tools/lib/bpf/bpf.c
> +++ b/tools/lib/bpf/bpf.c
> @@ -46,6 +46,8 @@
>  #  define __NR_bpf 349
>  # elif defined(__s390__)
>  #  define __NR_bpf 351
> +# elif defined(__arc__)
> +#  define __NR_bpf 280
>  # else
>  #  error __NR_bpf not defined. libbpf does not support your arch.
>  # endif
> --
> 2.7.4
>

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

* Re: [PATCH v2] tools/bpf: fix perf build error with uClibc (seen on ARC)
  2019-05-02 20:19     ` Y Song
@ 2019-05-05  7:05       ` Alexei Starovoitov
  0 siblings, 0 replies; 5+ messages in thread
From: Alexei Starovoitov @ 2019-05-05  7:05 UTC (permalink / raw)
  To: Y Song
  Cc: Vineet Gupta, Alexei Starovoitov, Daniel Borkmann, netdev,
	Wang Nan, Song Liu, Yonghong Song, Martin KaFai Lau, bpf, LKML,
	linux-snps-arc, linux-perf-users, Arnaldo Carvalho de Melo

On Thu, May 2, 2019 at 1:20 PM Y Song <ys114321@gmail.com> wrote:
>
> On Thu, May 2, 2019 at 8:57 AM Vineet Gupta <Vineet.Gupta1@synopsys.com> wrote:
> >
> > When build perf for ARC recently, there was a build failure due to lack
> > of __NR_bpf.
> >
> > | Auto-detecting system features:
> > |
> > | ...                     get_cpuid: [ OFF ]
> > | ...                           bpf: [ on  ]
> > |
> > | #  error __NR_bpf not defined. libbpf does not support your arch.
> >     ^~~~~
> > | bpf.c: In function 'sys_bpf':
> > | bpf.c:66:17: error: '__NR_bpf' undeclared (first use in this function)
> > |  return syscall(__NR_bpf, cmd, attr, size);
> > |                 ^~~~~~~~
> > |                 sys_bpf
> >
> > Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
>
> Acked-by: Yonghong Song <yhs@fb.com>

Applied. Thanks

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

end of thread, other threads:[~2019-05-05  7:05 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-01 22:53 [PATCH] tools/bpf: fix perf build error with uClibc (seen on ARC) Vineet Gupta
2019-05-02  6:31 ` Y Song
2019-05-02 15:56   ` [PATCH v2] " Vineet Gupta
2019-05-02 20:19     ` Y Song
2019-05-05  7:05       ` Alexei Starovoitov

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).