linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [RESEND PATCH v4 0/3] perf build: PowerPC: Fix build breakage due to libbpf
@ 2015-12-17  1:43 Wang Nan
  2015-12-17  1:43 ` [RESEND PATCH v4 1/3] perf tools: Fix PowerPC native building Wang Nan
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Wang Nan @ 2015-12-17  1:43 UTC (permalink / raw)
  To: acme, naveen.n.rao, jolsa; +Cc: linux-kernel, linuxppc-dev, wangnan0, sukadev

Fix PowerPC build breakage found by Naveen.

Perf building should not be blocked if BPF syscall is broken in some
platform.

In v3 a problem in 3/3 is found and fixed, but I only sent v4 of 3/3.
Send all 3 patches together again.

Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
Cc: Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>

Naveen N. Rao (1):
  perf: bpf: Fix build breakage due to libbpf

Wang Nan (2):
  perf tools: Fix PowerPC native building
  tools: Move Makefile.arch from perf/config to tools/scripts

 tools/build/feature/test-bpf.c  | 20 +++++++++++++++++++-
 tools/lib/bpf/Makefile          |  9 ++++++++-
 tools/lib/bpf/bpf.c             |  4 ++--
 tools/perf/config/Makefile      |  2 +-
 tools/perf/config/Makefile.arch | 18 ------------------
 tools/perf/tests/make           |  2 +-
 tools/scripts/Makefile.arch     | 18 ++++++++++++++++++
 7 files changed, 49 insertions(+), 24 deletions(-)
 delete mode 100644 tools/perf/config/Makefile.arch
 create mode 100644 tools/scripts/Makefile.arch

-- 
1.8.3.4

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

* [RESEND PATCH v4 1/3] perf tools: Fix PowerPC native building
  2015-12-17  1:43 [RESEND PATCH v4 0/3] perf build: PowerPC: Fix build breakage due to libbpf Wang Nan
@ 2015-12-17  1:43 ` Wang Nan
  2015-12-17  1:43 ` [RESEND PATCH v4 2/3] tools: Move Makefile.arch from perf/config to tools/scripts Wang Nan
  2015-12-17  1:43 ` [RESEND PATCH v4 3/3] perf: bpf: Fix build breakage due to libbpf Wang Nan
  2 siblings, 0 replies; 6+ messages in thread
From: Wang Nan @ 2015-12-17  1:43 UTC (permalink / raw)
  To: acme, naveen.n.rao, jolsa; +Cc: linux-kernel, linuxppc-dev, wangnan0, sukadev

Checks BPF syscall number, turn off libbpf building on platform doesn't
correctly support sys_bpf instead of blocking compiling.

Reported-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Tested-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
Signed-off-by: Wang Nan <wangnan0@huawei.com>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
---
 tools/build/feature/test-bpf.c | 20 +++++++++++++++++++-
 tools/lib/bpf/bpf.c            |  4 ++--
 2 files changed, 21 insertions(+), 3 deletions(-)

diff --git a/tools/build/feature/test-bpf.c b/tools/build/feature/test-bpf.c
index 062bac8..b389026 100644
--- a/tools/build/feature/test-bpf.c
+++ b/tools/build/feature/test-bpf.c
@@ -1,9 +1,23 @@
+#include <asm/unistd.h>
 #include <linux/bpf.h>
+#include <unistd.h>
+
+#ifndef __NR_bpf
+# if defined(__i386__)
+#  define __NR_bpf 357
+# elif defined(__x86_64__)
+#  define __NR_bpf 321
+# elif defined(__aarch64__)
+#  define __NR_bpf 280
+#  error __NR_bpf not defined. libbpf does not support your arch.
+# endif
+#endif
 
 int main(void)
 {
 	union bpf_attr attr;
 
+	/* Check fields in attr */
 	attr.prog_type = BPF_PROG_TYPE_KPROBE;
 	attr.insn_cnt = 0;
 	attr.insns = 0;
@@ -14,5 +28,9 @@ int main(void)
 	attr.kern_version = 0;
 
 	attr = attr;
-	return 0;
+	/*
+	 * Test existence of __NR_bpf and BPF_PROG_LOAD.
+	 * This call should fail if we run the testcase.
+	 */
+	return syscall(__NR_bpf, BPF_PROG_LOAD, attr, sizeof(attr));
 }
diff --git a/tools/lib/bpf/bpf.c b/tools/lib/bpf/bpf.c
index 5bdc6ea..1f91cc9 100644
--- a/tools/lib/bpf/bpf.c
+++ b/tools/lib/bpf/bpf.c
@@ -14,8 +14,8 @@
 #include "bpf.h"
 
 /*
- * When building perf, unistd.h is override. Define __NR_bpf is
- * required to be defined.
+ * When building perf, unistd.h is overrided. __NR_bpf is
+ * required to be defined explicitly.
  */
 #ifndef __NR_bpf
 # if defined(__i386__)
-- 
1.8.3.4

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

* [RESEND PATCH v4 2/3] tools: Move Makefile.arch from perf/config to tools/scripts
  2015-12-17  1:43 [RESEND PATCH v4 0/3] perf build: PowerPC: Fix build breakage due to libbpf Wang Nan
  2015-12-17  1:43 ` [RESEND PATCH v4 1/3] perf tools: Fix PowerPC native building Wang Nan
@ 2015-12-17  1:43 ` Wang Nan
  2015-12-17  5:10   ` Naveen N. Rao
  2015-12-17  1:43 ` [RESEND PATCH v4 3/3] perf: bpf: Fix build breakage due to libbpf Wang Nan
  2 siblings, 1 reply; 6+ messages in thread
From: Wang Nan @ 2015-12-17  1:43 UTC (permalink / raw)
  To: acme, naveen.n.rao, jolsa; +Cc: linux-kernel, linuxppc-dev, wangnan0, sukadev

After this patch other directories can use this architecture detector
without directly including it from perf's directory. Libbpf would
utilize it to get proper $(ARCH) so it can receive correct uapi include
directory.

Signed-off-by: Wang Nan <wangnan0@huawei.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Tested-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
Cc: Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
---
 tools/perf/config/Makefile      |  2 +-
 tools/perf/config/Makefile.arch | 18 ------------------
 tools/perf/tests/make           |  2 +-
 tools/scripts/Makefile.arch     | 18 ++++++++++++++++++
 4 files changed, 20 insertions(+), 20 deletions(-)
 delete mode 100644 tools/perf/config/Makefile.arch
 create mode 100644 tools/scripts/Makefile.arch

diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile
index a552417..34717e4 100644
--- a/tools/perf/config/Makefile
+++ b/tools/perf/config/Makefile
@@ -17,7 +17,7 @@ detected_var = $(shell echo "$(1)=$($(1))" >> $(OUTPUT).config-detected)
 
 CFLAGS := $(EXTRA_CFLAGS) $(EXTRA_WARNINGS)
 
-include $(src-perf)/config/Makefile.arch
+include $(srctree)/tools/scripts/Makefile.arch
 
 $(call detected_var,ARCH)
 
diff --git a/tools/perf/config/Makefile.arch b/tools/perf/config/Makefile.arch
deleted file mode 100644
index e11fbd6..0000000
--- a/tools/perf/config/Makefile.arch
+++ /dev/null
@@ -1,18 +0,0 @@
-ifndef ARCH
-ARCH := $(shell uname -m 2>/dev/null || echo not)
-endif
-
-ARCH := $(shell echo $(ARCH) | sed -e s/i.86/x86/ -e s/x86_64/x86/ \
-                                  -e s/sun4u/sparc/ -e s/sparc64/sparc/ \
-                                  -e /arm64/!s/arm.*/arm/ -e s/sa110/arm/ \
-                                  -e s/s390x/s390/ -e s/parisc64/parisc/ \
-                                  -e s/ppc.*/powerpc/ -e s/mips.*/mips/ \
-                                  -e s/sh[234].*/sh/ -e s/aarch64.*/arm64/ \
-                                  -e s/tile.*/tile/ )
-
-LP64 := $(shell echo __LP64__ | ${CC} ${CFLAGS} -E -x c - | tail -n 1)
-ifeq ($(LP64), 1)
-  IS_64_BIT := 1
-else
-  IS_64_BIT := 0
-endif
diff --git a/tools/perf/tests/make b/tools/perf/tests/make
index c1fbb8e..a8ede37 100644
--- a/tools/perf/tests/make
+++ b/tools/perf/tests/make
@@ -12,7 +12,7 @@ endif
 else
 PERF := .
 
-include config/Makefile.arch
+include $(srctree)/scripts/Makefile.arch
 
 # FIXME looks like x86 is the only arch running tests ;-)
 # we need some IS_(32/64) flag to make this generic
diff --git a/tools/scripts/Makefile.arch b/tools/scripts/Makefile.arch
new file mode 100644
index 0000000..e11fbd6
--- /dev/null
+++ b/tools/scripts/Makefile.arch
@@ -0,0 +1,18 @@
+ifndef ARCH
+ARCH := $(shell uname -m 2>/dev/null || echo not)
+endif
+
+ARCH := $(shell echo $(ARCH) | sed -e s/i.86/x86/ -e s/x86_64/x86/ \
+                                  -e s/sun4u/sparc/ -e s/sparc64/sparc/ \
+                                  -e /arm64/!s/arm.*/arm/ -e s/sa110/arm/ \
+                                  -e s/s390x/s390/ -e s/parisc64/parisc/ \
+                                  -e s/ppc.*/powerpc/ -e s/mips.*/mips/ \
+                                  -e s/sh[234].*/sh/ -e s/aarch64.*/arm64/ \
+                                  -e s/tile.*/tile/ )
+
+LP64 := $(shell echo __LP64__ | ${CC} ${CFLAGS} -E -x c - | tail -n 1)
+ifeq ($(LP64), 1)
+  IS_64_BIT := 1
+else
+  IS_64_BIT := 0
+endif
-- 
1.8.3.4

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

* [RESEND PATCH v4 3/3] perf: bpf: Fix build breakage due to libbpf
  2015-12-17  1:43 [RESEND PATCH v4 0/3] perf build: PowerPC: Fix build breakage due to libbpf Wang Nan
  2015-12-17  1:43 ` [RESEND PATCH v4 1/3] perf tools: Fix PowerPC native building Wang Nan
  2015-12-17  1:43 ` [RESEND PATCH v4 2/3] tools: Move Makefile.arch from perf/config to tools/scripts Wang Nan
@ 2015-12-17  1:43 ` Wang Nan
  2 siblings, 0 replies; 6+ messages in thread
From: Wang Nan @ 2015-12-17  1:43 UTC (permalink / raw)
  To: acme, naveen.n.rao, jolsa; +Cc: linux-kernel, linuxppc-dev, wangnan0, sukadev

From: "Naveen N. Rao" <naveen.n.rao@linux.vnet.ibm.com>

perf build is currently (v4.4-rc5) broken on powerpc:

bpf.c:28:4: error: #error __NR_bpf not defined. libbpf does not support
your arch.
 #  error __NR_bpf not defined. libbpf does not support your arch.
    ^

Fix this by including tools/scripts/Makefile.arch for the proper
$ARCH macro. While at it, remove redundant LP64 macro definition.

Also, since libbpf require $(srctree) now, detect the path of
srctree like perf.

Signed-off-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
Signed-off-by: Wang Nan <wangnan0@huawei.com>
[Use tools/scripts/Makefile.arch]
Acked-by: Jiri Olsa <jolsa@kernel.org>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
---
 tools/lib/bpf/Makefile | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/tools/lib/bpf/Makefile b/tools/lib/bpf/Makefile
index 636e3dd..0b6e013 100644
--- a/tools/lib/bpf/Makefile
+++ b/tools/lib/bpf/Makefile
@@ -6,6 +6,12 @@ BPF_EXTRAVERSION = 1
 
 MAKEFLAGS += --no-print-directory
 
+ifeq ($(srctree),)
+srctree := $(patsubst %/,%,$(dir $(shell pwd)))
+srctree := $(patsubst %/,%,$(dir $(srctree)))
+srctree := $(patsubst %/,%,$(dir $(srctree)))
+#$(info Determined 'srctree' to be $(srctree))
+endif
 
 # Makefiles suck: This macro sets a default value of $(2) for the
 # variable named by $(1), unless the variable has been set by
@@ -31,7 +37,8 @@ INSTALL = install
 DESTDIR ?=
 DESTDIR_SQ = '$(subst ','\'',$(DESTDIR))'
 
-LP64 := $(shell echo __LP64__ | ${CC} ${CFLAGS} -E -x c - | tail -n 1)
+include $(srctree)/tools/scripts/Makefile.arch
+
 ifeq ($(LP64), 1)
   libdir_relative = lib64
 else
-- 
1.8.3.4

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

* Re: [RESEND PATCH v4 2/3] tools: Move Makefile.arch from perf/config to tools/scripts
  2015-12-17  1:43 ` [RESEND PATCH v4 2/3] tools: Move Makefile.arch from perf/config to tools/scripts Wang Nan
@ 2015-12-17  5:10   ` Naveen N. Rao
  2015-12-17  6:01     ` Wangnan (F)
  0 siblings, 1 reply; 6+ messages in thread
From: Naveen N. Rao @ 2015-12-17  5:10 UTC (permalink / raw)
  To: Wang Nan; +Cc: acme, jolsa, linux-kernel, linuxppc-dev, sukadev

On 2015/12/17 01:43AM, Wang Nan wrote:
> After this patch other directories can use this architecture detector
> without directly including it from perf's directory. Libbpf would
> utilize it to get proper $(ARCH) so it can receive correct uapi include
> directory.
> 
> Signed-off-by: Wang Nan <wangnan0@huawei.com>
> Acked-by: Jiri Olsa <jolsa@kernel.org>
> Tested-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
> Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
> Cc: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
> Cc: Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
> ---
>  tools/perf/config/Makefile      |  2 +-
>  tools/perf/config/Makefile.arch | 18 ------------------
>  tools/perf/tests/make           |  2 +-
>  tools/scripts/Makefile.arch     | 18 ++++++++++++++++++
>  4 files changed, 20 insertions(+), 20 deletions(-)
>  delete mode 100644 tools/perf/config/Makefile.arch
>  create mode 100644 tools/scripts/Makefile.arch
   ^^^^^^
This is different from your previous version. This should be a file 
rename.

- Naveen

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

* Re: [RESEND PATCH v4 2/3] tools: Move Makefile.arch from perf/config to tools/scripts
  2015-12-17  5:10   ` Naveen N. Rao
@ 2015-12-17  6:01     ` Wangnan (F)
  0 siblings, 0 replies; 6+ messages in thread
From: Wangnan (F) @ 2015-12-17  6:01 UTC (permalink / raw)
  To: Naveen N. Rao; +Cc: acme, jolsa, linux-kernel, linuxppc-dev, sukadev



On 2015/12/17 13:10, Naveen N. Rao wrote:
> On 2015/12/17 01:43AM, Wang Nan wrote:
>> After this patch other directories can use this architecture detector
>> without directly including it from perf's directory. Libbpf would
>> utilize it to get proper $(ARCH) so it can receive correct uapi include
>> directory.
>>
>> Signed-off-by: Wang Nan <wangnan0@huawei.com>
>> Acked-by: Jiri Olsa <jolsa@kernel.org>
>> Tested-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
>> Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
>> Cc: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
>> Cc: Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
>> ---
>>   tools/perf/config/Makefile      |  2 +-
>>   tools/perf/config/Makefile.arch | 18 ------------------
>>   tools/perf/tests/make           |  2 +-
>>   tools/scripts/Makefile.arch     | 18 ++++++++++++++++++
>>   4 files changed, 20 insertions(+), 20 deletions(-)
>>   delete mode 100644 tools/perf/config/Makefile.arch
>>   create mode 100644 tools/scripts/Makefile.arch
>     ^^^^^^
> This is different from your previous version. This should be a file
> rename.

Forget to use git format -M. The content is identical. Should I send it 
again?

Thank you.

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

end of thread, other threads:[~2015-12-17  6:02 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-12-17  1:43 [RESEND PATCH v4 0/3] perf build: PowerPC: Fix build breakage due to libbpf Wang Nan
2015-12-17  1:43 ` [RESEND PATCH v4 1/3] perf tools: Fix PowerPC native building Wang Nan
2015-12-17  1:43 ` [RESEND PATCH v4 2/3] tools: Move Makefile.arch from perf/config to tools/scripts Wang Nan
2015-12-17  5:10   ` Naveen N. Rao
2015-12-17  6:01     ` Wangnan (F)
2015-12-17  1:43 ` [RESEND PATCH v4 3/3] perf: bpf: Fix build breakage due to libbpf Wang Nan

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