Add minimal support for software performance events.
Subsystems (2)
PATCH 1/1 Add minimal support for software performance events.
In the kernel the patch enables configuration of the perf event option, adds the perf_event_open syscall, and includes a minimal architecture specific asm/perf_event.h header file.
For the perf tool the patch implements an Alpha specific section in the perf.h header file and adjusts options used in the Makefile to allow compilation on Alpha. The -Wcast-align gives a "cast increases required alignment of target type" warning for the list_for_each_entry() macro. The -fstack-protector-all option generates a "not supported for this target" warning which with -Werror causes the compiler to abort.
--- arch/alpha/Kconfig | 1 + arch/alpha/include/asm/perf_event.h | 9 +++++++++ arch/alpha/include/asm/unistd.h | 3 ++- arch/alpha/kernel/systbls.S | 1 + tools/perf/Makefile | 5 ++--- tools/perf/perf.h | 6 ++++++ 6 files changed, 21 insertions(+), 4 deletions(-) create mode 100644 arch/alpha/include/asm/perf_event.h
arch/alpha/Kconfig +1 -0
@@ -9,6 +9,7 @@ config ALPHA select HAVE_IDE select HAVE_OPROFILE select HAVE_SYSCALL_WRAPPERS + select HAVE_PERF_EVENTS help The Alpha is a 64-bit general-purpose processor designed and marketed by the Digital Equipment Corporation of blessed memory,
arch/alpha/include/asm/perf_event.h new file +9 -0
@@ -0,0 +1,9 @@ +#ifndef __ASM_ALPHA_PERF_EVENT_H +#define __ASM_ALPHA_PERF_EVENT_H + +/* Alpha only supports software events through this interface. */ +static inline void set_perf_event_pending (void ) { } + +#define PERF_EVENT_INDEX_OFFSET 0 + +#endif /* __ASM_ALPHA_PERF_EVENT_H */
arch/alpha/include/asm/unistd.h +2 -1
@@ -447,10 +447,11 @@#define __NR_preadv 489#define __NR_pwritev 490#define __NR_rt_tgsigqueueinfo 491 +#define __NR_perf_event_open 492#ifdef __KERNEL__ -#define NR_SYSCALLS 492 +#define NR_SYSCALLS 493#define __ARCH_WANT_IPC_PARSE_VERSION#define __ARCH_WANT_OLD_READDIR
arch/alpha/kernel/systbls.S +1 -0
@@ -510,6 +510,7 @@ sys_call_table: .quad sys_preadv .quad sys_pwritev /* 490 */ .quad sys_rt_tgsigqueueinfo + .quad sys_perf_event_open .size sys_call_table, . - sys_call_table .type sys_call_table, @object
tools/perf/Makefile +2 -3
@@ -177,8 +177,7 @@ endif # Include saner warnings here, which can catch bugs: # -EXTRA_WARNINGS := -Wcast-align -EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wformat +EXTRA_WARNINGS := -Wformat EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wformat-security EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wformat-y2k EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wshadow
@@ -201,7 +200,7 @@ EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wold-style-definition EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wstrict-prototypes EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wdeclaration-after-statement -CFLAGS = $(MBITS) -ggdb3 -Wall -Wextra -std=gnu99 -Werror -O6 -fstack-protector-all -D_FORTIFY_SOURCE=2 $(EXTRA_WARNINGS) +CFLAGS = $(MBITS) -ggdb3 -Wall -Wextra -std=gnu99 -Werror -O6 -D_FORTIFY_SOURCE=2 $(EXTRA_WARNINGS) LDFLAGS = -lpthread -lrt -lelf -lm ALL_CFLAGS = $(CFLAGS) ALL_LDFLAGS = $(LDFLAGS)
tools/perf/perf.h +6 -0
@@ -47,6 +47,12 @@#define cpu_relax () asm volatile("":::"memory")#endif +#ifdef __alpha__ +#include "../../arch/alpha/include/asm/unistd.h" +#define rmb () asm volatile("mb" ::: "memory") +#define cpu_relax () asm volatile("" ::: "memory") +#endif +#include <time.h> #include <unistd.h> #include <sys/types.h>
Signature · 1 line
1.6.3.3
Quoted 13 lines · Michael Cree
In the kernel the patch enables configuration of the perf event option, adds the
perf_event_opensyscall, and includes a minimal architecture specificasm/perf_event.hheader file.For the perf tool the patch implements an Alpha specific section in the
perf.hheader file and adjusts options used in theMakefileto allow compilation on Alpha. The -Wcast-align gives a "cast increases required alignment of target type" warning for thelist_for_each_entry()macro. The -fstack-protector-all option generates a "not supported for this target" warning which with -Werror causes the compiler to abort.Signed-off-by Michael Cree <[email protected]>
Quoted 9 lines
--- arch/alpha/Kconfig | 1 + arch/alpha/include/asm/perf_event.h | 9 +++++++++ arch/alpha/include/asm/unistd.h | 3 ++- arch/alpha/kernel/systbls.S | 1 + tools/perf/Makefile | 5 ++--- tools/perf/perf.h | 6 ++++++ 6 files changed, 21 insertions(+), 4 deletions(-) create mode 100644 arch/alpha/include/asm/perf_event.h
Nice!
I've picked up the perf.h bit in an independent commit. Is there a tree for Alpha bits?
This portion:
tools/perf/Makefile EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wold-style-definition · line 206
Quoted 11 lines
tools/perf/Makefile +1
-1@@ -201,7 +200,7 @@ EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wold-style-definition EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wstrict-prototypes EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wdeclaration-after-statement -CFLAGS = $(MBITS) -ggdb3 -Wall -Wextra -std=gnu99 -Werror -O6 -fstack-protector-all -D_FORTIFY_SOURCE=2 $(EXTRA_WARNINGS) +CFLAGS = $(MBITS) -ggdb3 -Wall -Wextra -std=gnu99 -Werror -O6 -D_FORTIFY_SOURCE=2 $(EXTRA_WARNINGS) LDFLAGS = -lpthread -lrt -lelf -lm ALL_CFLAGS = $(CFLAGS) ALL_LDFLAGS = $(LDFLAGS)
Should be done not by removing the stack-protector build unconditionally
- but by auto-testing whether stackprotector is supported by GCC and using it if yes.
Examples can be found n arch/x86/Makefile's use of scripts/gcc-*-has-stack-protector.sh.
Thanks,
Ingo
Quoted 24 lines · Ingo Molnar
Quoted 11 lines · Michael Cree
In the kernel the patch enables configuration of the perf event option, adds the
perf_event_opensyscall, and includes a minimal architecture specificasm/perf_event.hheader file.For the perf tool the patch implements an Alpha specific section in the
perf.hheader file and adjusts options used in theMakefileto allow compilation on Alpha. The -Wcast-align gives a "cast increases required alignment of target type" warning for thelist_for_each_entry()macro. The -fstack-protector-all option generates a "not supported for this target" warning which with -Werror causes the compiler to abort.Signed-off-by Michael Cree <[email protected]>Quoted 10 lines
--- arch/alpha/Kconfig | 1 + arch/alpha/include/asm/perf_event.h | 9 +++++++++ arch/alpha/include/asm/unistd.h | 3 ++- arch/alpha/kernel/systbls.S | 1 + tools/perf/Makefile | 5 ++--- tools/perf/perf.h | 6 ++++++ 6 files changed, 21 insertions(+), 4 deletions(-) create mode 100644 arch/alpha/include/asm/perf_event.h
Quoted 4 lines
Nice!
I've picked up the
perf.hbit in an independent commit. Is there a tree for Alpha bits?
Not that I know of. Note also that this patch is on top of the patch "alpha: Wire up missing/new syscalls" recently posted by Daniele Calore (http://lkml.org/lkml/2009/10/21/99). Hopefully this and prior patches get picked up by the Alpha maintainers.
Quoted 8 lines
This portion:
Quoted 6 lines
tools/perf/Makefile +0
-0@@ -201,7 +200,7 @@ EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wold-style-definition EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wstrict-prototypes EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wdeclaration-after-statement
Quoted 11 lines
tools/perf/Makefile EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wold-style-definition · line 206
Quoted 6 lines
tools/perf/Makefile +1
-1-CFLAGS = $(MBITS) -ggdb3 -Wall -Wextra -std=gnu99 -Werror -O6 -fstack-protector-all -D_FORTIFY_SOURCE=2 $(EXTRA_WARNINGS) +CFLAGS = $(MBITS) -ggdb3 -Wall -Wextra -std=gnu99 -Werror -O6 -D_FORTIFY_SOURCE=2 $(EXTRA_WARNINGS) LDFLAGS = -lpthread -lrt -lelf -lm ALL_CFLAGS = $(CFLAGS) ALL_LDFLAGS = $(LDFLAGS)Should be done not by removing the stack-protector build unconditionally
- but by auto-testing whether stackprotector is supported by GCC and using it if yes.
Revised patch attached. It includes a test that the compiler doesn't bomb out with -fstack-protector-all and only adds the option to CFLAGS if ok. But I have had to put the test below the definition of the macro CC. This has the side effect of separating the addition of -fstack-protector-all from the main definitions of CFLAGS and ALL_CFLAGS, and is not ideal in my opinion. The patch also removes -Wcast-align (I forgot to say that in the commit message of the patch).
Michael.
From 92feeaec19635a10145fa32a2f0077c4ddda5c7d Mon Sep 17 00:00:00 2001
From: Michael Cree <[email protected]>
Date: Tue, 27 Oct 2009 20:56:27 +1300
Subject: [PATCH] Test -fstack-protector-all compiler option for inclusion in CFLAGS.
Some architectures (e.g. Alpha) do not support the -fstack-protector-all compiler option and the use of the option with -Werror causes the compiler to abort. Test that the compiler supports -fstack-protector-all before inclusion in CFLAGS.
--- tools/perf/Makefile | 8 +++++--- 1 files changed, 5 insertions(+), 3 deletions(-)
tools/perf/Makefile +5 -3
@@ -177,8 +177,7 @@ endif # Include saner warnings here, which can catch bugs: # -EXTRA_WARNINGS := -Wcast-align -EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wformat +EXTRA_WARNINGS := -Wformat EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wformat-security EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wformat-y2k EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wshadow
@@ -201,7 +200,7 @@ EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wold-style-definition EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wstrict-prototypes EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wdeclaration-after-statement -CFLAGS = $(MBITS) -ggdb3 -Wall -Wextra -std=gnu99 -Werror -O6 -fstack-protector-all -D_FORTIFY_SOURCE=2 $(EXTRA_WARNINGS) +CFLAGS = $(MBITS) -ggdb3 -Wall -Wextra -std=gnu99 -Werror -O6 -D_FORTIFY_SOURCE=2 $(EXTRA_WARNINGS) LDFLAGS = -lpthread -lrt -lelf -lm ALL_CFLAGS = $(CFLAGS) ALL_LDFLAGS = $(LDFLAGS)
@@ -253,6 +252,9 @@ PTHREAD_LIBS = -lpthread # explicitly what architecture to check for. Fix this up for yours.. SPARSE_FLAGS = -D__BIG_ENDIAN__ -D__powerpc__ +ifeq ($(shell sh -c "echo 'int foo(void) {char X[2]; return 3;}' | $(CC) -x c -c -Werror -fstack-protector-all - -o /dev/null >/dev/null 2>&1 && echo y"), y) + CFLAGS := $(CFLAGS) -fstack-protector-all +endif ### --- END CONFIGURATION SECTION ---
Signature · 1 line
1.6.3.3
Quoted 4 lines · Michael Cree
Quoted 3 lines
Should be done not by removing the stack-protector build unconditionally - but by auto-testing whether stackprotector is supported by GCC and using it if yes.
Quoted 8 lines
Revised patch attached. It includes a test that the compiler doesn't bomb out with -fstack-protector-all and only adds the option to CFLAGS if ok. But I have had to put the test below the definition of the macro CC. This has the side effect of separating the addition of -fstack-protector-all from the main definitions of CFLAGS and
ALL_CFLAGS, and is not ideal in my opinion. The patch also removes -Wcast-align (I forgot to say that in the commit message of the patch).
Nice, i'll queue this up for Linus.
Your S-O-B line was missing from this second patch - i presume you intended it to be included, right?
Thanks,
Ingo
Quoted 18 lines · Ingo Molnar
Quoted 4 lines · Michael Cree
Quoted 3 lines
Should be done not by removing the stack-protector build unconditionally - but by auto-testing whether stackprotector is supported by GCC and using it if yes.
Quoted 8 lines
Revised patch attached. It includes a test that the compiler doesn't bomb out with -fstack-protector-all and only adds the option to CFLAGS if ok. But I have had to put the test below the definition of the macro CC. This has the side effect of separating the addition of -fstack-protector-all from the main definitions of CFLAGS and
ALL_CFLAGS, and is not ideal in my opinion. The patch also removes -Wcast-align (I forgot to say that in the commit message of the patch).Nice, i'll queue this up for Linus.
Quoted 2 lines
Your S-O-B line was missing from this second patch - i presume you intended it to be included, right?
Mind resending the patch against latest -tip?
http://people.redhat.com/mingo/tip.git/README
There's been other changes in this area so your patch does not apply anymore.
Ingo
Quoted 1 line · Ingo Molnar
Mind resending the patch against latest -tip?
Not a problem. Attached.
Cheers
Michael.
From df1a596909b30c9792e55acc731c2578b71d2670 Mon Sep 17 00:00:00 2001
From: Michael Cree <[email protected]>
Date: Tue, 10 Nov 2009 22:20:37 +1300
Subject: [PATCH] Test -fstack-protector-all compiler option for inclusion in CFLAGS
Some architectures (e.g. Alpha) do not support the -fstack-protector-all compiler option and the use of the option with -Werror causes the compiler to abort. Test that the compiler supports -fstack-protector-all before inclusion in CFLAGS.
--- tools/perf/Makefile | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-)
tools/perf/Makefile +4 -1
@@ -207,7 +207,7 @@ ifndef PERF_DEBUG CFLAGS_OPTIMIZE = -O6 endif -CFLAGS = $(MBITS) -ggdb3 -Wall -Wextra -std=gnu99 -Werror $(CFLAGS_OPTIMIZE) -fstack-protector-all -D_FORTIFY_SOURCE=2 $(EXTRA_WARNINGS) +CFLAGS = $(MBITS) -ggdb3 -Wall -Wextra -std=gnu99 -Werror $(CFLAGS_OPTIMIZE) -D_FORTIFY_SOURCE=2 $(EXTRA_WARNINGS) LDFLAGS = -lpthread -lrt -lelf -lm ALL_CFLAGS = $(CFLAGS) ALL_LDFLAGS = $(LDFLAGS)
@@ -259,6 +259,9 @@ PTHREAD_LIBS = -lpthread # explicitly what architecture to check for. Fix this up for yours.. SPARSE_FLAGS = -D__BIG_ENDIAN__ -D__powerpc__ +ifeq ($(shell sh -c "echo 'int foo(void) {char X[2]; return 3;}' | $(CC) -x c -c -Werror -fstack-protector-all - -o /dev/null >/dev/null 2>&1 && echo y"), y) + CFLAGS := $(CFLAGS) -fstack-protector-all +endif ### --- END CONFIGURATION SECTION ---
Signature · 1 line
1.6.3.3
[tip:perf/core] perf tools: Test -fstack-protector-all compiler option for inclusion in CFLAGS
Commit-ID: 5d7bdab75cd56d2bdc0986ae5546be3b09fea70a Gitweb: http://git.kernel.org/tip/5d7bdab75cd56d2bdc0986ae5546be3b09fea70a Author: Michael Cree <[email protected]> AuthorDate: Wed, 11 Nov 2009 20:43:03 +1300 Committer: Ingo Molnar <[email protected]> CommitDate: Wed, 11 Nov 2009 08:46:45 +0100
perf tools: Test -fstack-protector-all compiler option for inclusion in CFLAGS
Some architectures (e.g. Alpha) do not support the -fstack-protector-all compiler option and the use of the option with -Werror causes the compiler to abort and the build fails.
Test that the compiler supports -fstack-protector-all before inclusion in CFLAGS.
LKML-Reference: <20091111074302.GA3728@omega>
--- tools/perf/Makefile | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-)
tools/perf/Makefile +4 -1
@@ -207,7 +207,7 @@ ifndef PERF_DEBUG CFLAGS_OPTIMIZE = -O6 endif -CFLAGS = $(MBITS) -ggdb3 -Wall -Wextra -std=gnu99 -Werror $(CFLAGS_OPTIMIZE) -fstack-protector-all -D_FORTIFY_SOURCE=2 $(EXTRA_WARNINGS) +CFLAGS = $(MBITS) -ggdb3 -Wall -Wextra -std=gnu99 -Werror $(CFLAGS_OPTIMIZE) -D_FORTIFY_SOURCE=2 $(EXTRA_WARNINGS) LDFLAGS = -lpthread -lrt -lelf -lm ALL_CFLAGS = $(CFLAGS) ALL_LDFLAGS = $(LDFLAGS)
@@ -259,6 +259,9 @@ PTHREAD_LIBS = -lpthread # explicitly what architecture to check for. Fix this up for yours.. SPARSE_FLAGS = -D__BIG_ENDIAN__ -D__powerpc__ +ifeq ($(shell sh -c "echo 'int foo(void) {char X[2]; return 3;}' | $(CC) -x c -c -Werror -fstack-protector-all - -o /dev/null >/dev/null 2>&1 && echo y"), y) + CFLAGS := $(CFLAGS) -fstack-protector-all +endif ### --- END CONFIGURATION SECTION ---
Matt Turner
maintainerQuoted 1 line · Ingo Molnar
Is there a tree for Alpha bits?
No, but really other than a very few scattered patches we don't have much activity.
Maybe it's worth creating one at git.kernel.org? I don't think Richard or Ivan are interested in doing it. Could Michael or I do it without being maintainers?
Matt
Quoted 9 lines · Matt Turner
Quoted 1 line · Ingo Molnar
Is there a tree for Alpha bits?
No, but really other than a very few scattered patches we don't have much activity.
Maybe it's worth creating one at git.kernel.org? I don't think Richard or Ivan are interested in doing it. Could Michael or I do it without being maintainers?
If you start handling alpha related stuff then you are automatically becoming maintainers.
Officially in MAINTAINERS would preferably be with OK from rth and Ivan.
So do not be shy and create such a tree.
Sam
[tip:perf/core] perf tools, Alpha: Add Alpha support to perf.h
In reply to Michael CreeCommit-ID: fcd14b3203b538dca04a2b065c774c0b57863eec Gitweb: http://git.kernel.org/tip/fcd14b3203b538dca04a2b065c774c0b57863eec Author: Michael Cree <[email protected]> AuthorDate: Mon, 26 Oct 2009 21:32:06 +1300 Committer: Ingo Molnar <[email protected]> CommitDate: Mon, 26 Oct 2009 09:45:41 +0100
perf tools, Alpha: Add Alpha support to perf.h
For the perf tool the patch implements an Alpha specific section in the perf.h header file.
LKML-Reference: <[email protected]>
--- tools/perf/perf.h | 6 ++++++ 1 files changed, 6 insertions(+), 0 deletions(-)
tools/perf/perf.h +6 -0
@@ -47,6 +47,12 @@#define cpu_relax () asm volatile("":::"memory")#endif +#ifdef __alpha__ +#include "../../arch/alpha/include/asm/unistd.h" +#define rmb () asm volatile("mb" ::: "memory") +#define cpu_relax () asm volatile("" ::: "memory") +#endif +#include <time.h> #include <unistd.h> #include <sys/types.h>
Re: [tip:perf/core] perf tools, Alpha: Add Alpha support to perf.h
Hi Ingo,
Quoted 28 lines · tip-bot for Michael Cree
Commit-ID: fcd14b3203b538dca04a2b065c774c0b57863eec
Gitweb: http://git.kernel.org/tip/fcd14b3203b538dca04a2b065c774c0b57863eec
Author: Michael Cree <[email protected]>
AuthorDate: Mon, 26 Oct 2009 21:32:06 +1300
Committer: Ingo Molnar <[email protected]>
CommitDate: Mon, 26 Oct 2009 09:45:41 +0100perf tools, Alpha: Add Alpha support to
perf.hFor the perf tool the patch implements an Alpha specific section in the
perf.hheader file.Signed-off-by Michael Cree <[email protected]>Cc Richard Henderson <[email protected]>Cc Ivan Kokshaysky <[email protected]>Cc Peter Zijlstra <[email protected]>Cc Paul Mackerras <[email protected]>LKML-Reference: <[email protected]>
Signed-off-by Ingo Molnar <[email protected]>---
tools/perf/perf.h | 6 ++++++1 files changed, 6 insertions(+), 0 deletions(-)tools/perf/perf.h +0
-0
tools/perf/perf.h line 54
Quoted 8 lines
tools/perf/perf.h +5
-0@@ -47,6 +47,12 @@ #define cpu_relax() asm volatile("":::"memory") #endif +#ifdef __alpha__ +#include "../../arch/alpha/include/asm/unistd.h" +#define rmb () asm volatile("mb" ::: "memory") +#define cpu_relax () asm volatile("" ::: "memory") +#endif
OK, I'll bite. We tell userspace developers not to include kernel headers. Why is it okay for perf to do it (especially for something that's in asm)?
Pekka
Re: [tip:perf/core] perf tools, Alpha: Add Alpha support to perf.h
Quoted 35 lines · Pekka Enberg
Hi Ingo,
Quoted 31 lines · tip-bot for Michael Cree
Commit-ID: fcd14b3203b538dca04a2b065c774c0b57863eec
Gitweb: http://git.kernel.org/tip/fcd14b3203b538dca04a2b065c774c0b57863eec
Author: Michael Cree <[email protected]>
AuthorDate: Mon, 26 Oct 2009 21:32:06 +1300
Committer: Ingo Molnar <[email protected]>
CommitDate: Mon, 26 Oct 2009 09:45:41 +0100perf tools, Alpha: Add Alpha support to
perf.hFor the perf tool the patch implements an Alpha specific section in the
perf.hheader file.Signed-off-by Michael Cree <[email protected]>Cc Richard Henderson <[email protected]>Cc Ivan Kokshaysky <[email protected]>Cc Peter Zijlstra <[email protected]>Cc Paul Mackerras <[email protected]>LKML-Reference: <[email protected]>
Signed-off-by Ingo Molnar <[email protected]>---
tools/perf/perf.h | 6 ++++++1 files changed, 6 insertions(+), 0 deletions(-)tools/perf/perf.h +0
-0@@ -47,6 +47,12 @@ #define cpu_relax() asm volatile("":::"memory") #endif
Quoted 9 lines
tools/perf/perf.h line 54
Quoted 5 lines
tools/perf/perf.h +5
-0+#ifdef __alpha__ +#include "../../arch/alpha/include/asm/unistd.h" +#define rmb () asm volatile("mb" ::: "memory") +#define cpu_relax () asm volatile("" ::: "memory") +#endif OK, I'll bite. We tell userspace developers not to include kernel headers. Why is it okay for perf to do it (especially for something that's in asm)?
The main counter-argument against inclusion was always "what if we break them accidentally". I.e. it can become a semi-ABI - stuff we cannot change because we cannot change the outside projects. With perf this cannot occur - it's all in one Git tree and can always be fixed/changed.
Note that we reuse a couple of other facilities in tools/perf as well - linux/list.h, rbtree.c, etc. - and this is good - you can code perf as if you were hacking on the kernel! ;-)
Ingo
Re: [tip:perf/core] perf tools, Alpha: Add Alpha support to perf.h
Quoted 5 lines
Quoted 4 lines
OK, I'll bite. We tell userspace developers not to include kernel headers. Why is it okay for perf to do it (especially for something that's in asm)?
Quoted 8 lines
The main counter-argument against inclusion was always "what if we break them accidentally". I.e. it can become a semi-ABI - stuff we cannot change because we cannot change the outside projects. With perf this cannot occur - it's all in one Git tree and can always be fixed/changed.
Note that we reuse a couple of other facilities in
tools/perfas well -linux/list.h,rbtree.c, etc. - and this is good - you can code perf as if you were hacking on the kernel! ;-)
I see no reasons why perf should not use the exported headers in the default case. unistd.h from alpha is indeed exported.
If perf then on top of that uses some kernel internal stuff - then pick it up there.
But having perf in the kernel is not an excuse for avoinding the exported headers.
Sam
Peter Zijlstra
maintainerRe: [tip:perf/core] perf tools, Alpha: Add Alpha support to perf.h
In reply to Pekka EnbergQuoted 9 lines · Pekka Enberg
tools/perf/perf.h line 54
Quoted 5 lines
tools/perf/perf.h +5
-0+#ifdef __alpha__ +#include "../../arch/alpha/include/asm/unistd.h" +#define rmb () asm volatile("mb" ::: "memory") +#define cpu_relax () asm volatile("" ::: "memory") +#endif OK, I'll bite. We tell userspace developers not to include kernel headers. Why is it okay for perf to do it (especially for something that's in asm)?
The reason we take the explicit arch header is because we need the perf syscall thingy, which isn't yet in the installed system unistd.h because that's probably some ancient version.
Once distro's have had perf enabled kernels for long enough that all of userspace has the syscall bits we can remove it.
Matt Turner
maintainerQuoted 122 lines · Michael Cree
In the kernel the patch enables configuration of the perf event option, adds the
perf_event_opensyscall, and includes a minimal architecture specificasm/perf_event.hheader file.For the perf tool the patch implements an Alpha specific section in the
perf.hheader file and adjusts options used in theMakefileto allow compilation on Alpha. The -Wcast-align gives a "cast increases required alignment of target type" warning for thelist_for_each_entry()macro. The -fstack-protector-all option generates a "not supported for this target" warning which with -Werror causes the compiler to abort.Signed-off-by Michael Cree <[email protected]>---
arch/alpha/Kconfig | 1 +arch/alpha/include/asm/perf_event.h| 9 +++++++++arch/alpha/include/asm/unistd.h| 3 ++-arch/alpha/kernel/systbls.S| 1 +tools/perf/Makefile| 5 ++---tools/perf/perf.h| 6 ++++++6 files changed, 21 insertions(+), 4 deletions(-)create mode 100644
arch/alpha/include/asm/perf_event.harch/alpha/Kconfig +0
-0@@ -9,6 +9,7 @@ config ALPHAselect
HAVE_IDE
selectHAVE_OPROFILE
selectHAVE_SYSCALL_WRAPPERS
+ selectHAVE_PERF_EVENTS
help
The Alpha is a 64-bit general-purpose processor designed and marketed by the Digital Equipment Corporation of blessed memory,arch/alpha/include/asm/perf_event.h new file +9
-0@@ -0,0 +1,9 @@ +#ifndef __ASM_ALPHA_PERF_EVENT_H +#define __ASM_ALPHA_PERF_EVENT_H + +/* Alpha only supports software events through this interface. */ +static inline void set_perf_event_pending (void ) { } + +#define PERF_EVENT_INDEX_OFFSET 0 + +#endif /* __ASM_ALPHA_PERF_EVENT_H */ arch/alpha/include/asm/unistd.h +2
-1@@ -447,10 +447,11 @@ #define __NR_preadv 489 #define __NR_pwritev 490 #define __NR_rt_tgsigqueueinfo 491 +#define __NR_perf_event_open 492 #ifdef __KERNEL__ -#define NR_SYSCALLS 492 +#define NR_SYSCALLS 493 #define __ARCH_WANT_IPC_PARSE_VERSION #define __ARCH_WANT_OLD_READDIRarch/alpha/kernel/systbls.S +0
-0@@ -510,6 +510,7 @@ sys_call_table:.quad
sys_preadv
.quadsys_pwritev/* 490 */ .quadsys_rt_tgsigqueueinfo
+ .quadsys_perf_event_open.size
sys_call_table, . -sys_call_table
.typesys_call_table, @objecttools/perf/Makefile +1
-2@@ -177,8 +177,7 @@ endif # Include saner warnings here, which can catch bugs: # -EXTRA_WARNINGS := -Wcast-align -EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wformat +EXTRA_WARNINGS := -WformatEXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wformat-security
EXTRA_WARNINGS:= $(EXTRA_WARNINGS) -Wformat-y2kEXTRA_WARNINGS:= $(EXTRA_WARNINGS) -Wshadowtools/perf/Makefile +0
-0@@ -201,7 +200,7 @@ EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wold-style-definitionEXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wstrict-prototypes
EXTRA_WARNINGS:= $(EXTRA_WARNINGS) -Wdeclaration-after-statementtools/perf/Makefile +1
-1-CFLAGS = $(MBITS) -ggdb3 -Wall -Wextra -std=gnu99 -Werror -O6 -fstack-protector-all -D_FORTIFY_SOURCE=2 $(EXTRA_WARNINGS) +CFLAGS = $(MBITS) -ggdb3 -Wall -Wextra -std=gnu99 -Werror -O6 -D_FORTIFY_SOURCE=2 $(EXTRA_WARNINGS)LDFLAGS = -lpthread -lrt -lelf -lm
ALL_CFLAGS = $(CFLAGS)
ALL_LDFLAGS = $(LDFLAGS)tools/perf/perf.h +6
-1@@ -47,6 +47,12 @@ #define cpu_relax() asm volatile("":::"memory") #endif +#ifdef __alpha__ +#include "../../arch/alpha/include/asm/unistd.h" +#define rmb () asm volatile("mb" ::: "memory") +#define cpu_relax () asm volatile("" ::: "memory") +#endif + #include <time.h> #include <unistd.h> #include <sys/types.h> --1.6.3.3
Quoted 1 line
--
Please take a look at the attached patch and let me know if it's what you want pushed. I wasn't sure if the last hunk (the memory barriers) needed to be included or had already been picked up.
Thanks,
Matt
From cb58e6d37b406cdb154b34d700c9478546b1e84f Mon Sep 17 00:00:00 2001
From: Michael Cree <[email protected]>
Date: Mon, 30 Nov 2009 23:27:36 -0500
Subject: [PATCH] alpha: Add minimal support for software performance events.
In the kernel the patch enables configuration of the perf event option, adds the perf_event_open syscall, and includes a minimal architecture specific asm/perf_event.h header file.
For the perf tool the patch implements an Alpha specific section in the perf.h header file and adjusts options used in the Makefile to allow compilation on Alpha. The -Wcast-align gives a "cast increases required alignment of target type" warning for the list_for_each_entry() macro. The -fstack-protector-all option generates a "not supported for this target" warning which with -Werror causes the compiler to abort.
--- arch/alpha/Kconfig | 1 + arch/alpha/include/asm/perf_event.h | 9 +++++++++ arch/alpha/include/asm/unistd.h | 3 ++- arch/alpha/kernel/systbls.S | 1 + tools/perf/perf.h | 6 ++++++ 5 files changed, 19 insertions(+), 1 deletions(-) create mode 100644 arch/alpha/include/asm/perf_event.h
arch/alpha/Kconfig +1 -0
@@ -9,6 +9,7 @@ config ALPHA select HAVE_IDE select HAVE_OPROFILE select HAVE_SYSCALL_WRAPPERS + select HAVE_PERF_EVENTS help The Alpha is a 64-bit general-purpose processor designed and marketed by the Digital Equipment Corporation of blessed memory,
arch/alpha/include/asm/perf_event.h new file +9 -0
@@ -0,0 +1,9 @@ +#ifndef __ASM_ALPHA_PERF_EVENT_H +#define __ASM_ALPHA_PERF_EVENT_H + +/* Alpha only supports software events through this interface. */ +static inline void set_perf_event_pending (void ) { } + +#define PERF_EVENT_INDEX_OFFSET 0 + +#endif /* __ASM_ALPHA_PERF_EVENT_H */
arch/alpha/include/asm/unistd.h +2 -1
@@ -447,10 +447,11 @@#define __NR_preadv 489#define __NR_pwritev 490#define __NR_rt_tgsigqueueinfo 491 +#define __NR_perf_event_open 492#ifdef __KERNEL__ -#define NR_SYSCALLS 492 +#define NR_SYSCALLS 493#define __ARCH_WANT_IPC_PARSE_VERSION#define __ARCH_WANT_OLD_READDIR
arch/alpha/kernel/systbls.S +1 -0
@@ -510,6 +510,7 @@ sys_call_table: .quad sys_preadv .quad sys_pwritev /* 490 */ .quad sys_rt_tgsigqueueinfo + .quad sys_perf_event_open .size sys_call_table, . - sys_call_table .type sys_call_table, @object
tools/perf/perf.h +6 -0
@@ -47,6 +47,12 @@#define cpu_relax () asm volatile("":::"memory")#endif +#ifdef __alpha__ +#include "../../arch/alpha/include/asm/unistd.h" +#define rmb () asm volatile("mb" ::: "memory") +#define cpu_relax () asm volatile("" ::: "memory") +#endif +#include <time.h> #include <unistd.h> #include <sys/types.h>
Signature · 1 line
1.6.4.4
Quoted 3 lines · Matt Turner
Please take a look at the attached patch and let me know if it's what you want pushed. I wasn't sure if the last hunk (the memory barriers) needed to be included or had already been picked up.
All the tools/perf stuff, including the memory barriers, have been picked up by linux-tip. Updated patch with the arch/alpha bits only attached.
The patch should apply cleanly on top of the "alpha: Wire up missing/new syscalls" patch which I see you have already applied.
Cheers
Michael.
Quoted 1 line
From
2c22c2a528d5c89f52d77b0d7a49c12865f82eccMon Sep 17 00:00:00 2001
From: Michael Cree <[email protected]>
Date: Tue, 1 Dec 2009 22:15:17 +1300
Subject: [PATCH] alpha: Add minimal support for software performance events.
Enable configuration of the perf event option, add the perf_event_open syscall, and include a minimal architecture specific asm/perf_event.h header file.
--- arch/alpha/Kconfig | 1 + arch/alpha/include/asm/perf_event.h | 9 +++++++++ arch/alpha/include/asm/unistd.h | 3 ++- arch/alpha/kernel/systbls.S | 1 + 4 files changed, 13 insertions(+), 1 deletions(-) create mode 100644 arch/alpha/include/asm/perf_event.h
arch/alpha/Kconfig +1 -0
@@ -9,6 +9,7 @@ config ALPHA select HAVE_IDE select HAVE_OPROFILE select HAVE_SYSCALL_WRAPPERS + select HAVE_PERF_EVENTS help The Alpha is a 64-bit general-purpose processor designed and marketed by the Digital Equipment Corporation of blessed memory,
arch/alpha/include/asm/perf_event.h new file +9 -0
@@ -0,0 +1,9 @@ +#ifndef __ASM_ALPHA_PERF_EVENT_H +#define __ASM_ALPHA_PERF_EVENT_H + +/* Alpha only supports software events through this interface. */ +static inline void set_perf_event_pending (void ) { } + +#define PERF_EVENT_INDEX_OFFSET 0 + +#endif /* __ASM_ALPHA_PERF_EVENT_H */
arch/alpha/include/asm/unistd.h +2 -1
@@ -447,10 +447,11 @@#define __NR_preadv 489#define __NR_pwritev 490#define __NR_rt_tgsigqueueinfo 491 +#define __NR_perf_event_open 492#ifdef __KERNEL__ -#define NR_SYSCALLS 492 +#define NR_SYSCALLS 493#define __ARCH_WANT_IPC_PARSE_VERSION#define __ARCH_WANT_OLD_READDIR
arch/alpha/kernel/systbls.S +1 -0
@@ -510,6 +510,7 @@ sys_call_table: .quad sys_preadv .quad sys_pwritev /* 490 */ .quad sys_rt_tgsigqueueinfo + .quad sys_perf_event_open .size sys_call_table, . - sys_call_table .type sys_call_table, @object
Signature · 1 line
1.5.6.5