linux-alpha.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] [alpha] Add minimal support for software performance events.
@ 2009-10-26  8:32 Michael Cree
  2009-10-26  8:48 ` Ingo Molnar
  2009-12-01  4:30 ` Matt Turner
  0 siblings, 2 replies; 10+ messages in thread
From: Michael Cree @ 2009-10-26  8:32 UTC (permalink / raw)
  To: linux-kernel, linux-alpha
  Cc: Michael Cree, Richard Henderson, Ivan Kokshaysky, Peter Zijlstra,
	Paul Mackerras, Ingo Molnar

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.

Signed-off-by: Michael Cree <mcree@orcon.net.nz>
---
 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

diff --git a/arch/alpha/Kconfig b/arch/alpha/Kconfig
index 4434481..bd7261e 100644
--- a/arch/alpha/Kconfig
+++ b/arch/alpha/Kconfig
@@ -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,
diff --git a/arch/alpha/include/asm/perf_event.h b/arch/alpha/include/asm/perf_event.h
new file mode 100644
index 0000000..3bef852
--- /dev/null
+++ b/arch/alpha/include/asm/perf_event.h
@@ -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 */
diff --git a/arch/alpha/include/asm/unistd.h b/arch/alpha/include/asm/unistd.h
index 17f72b7..414de17 100644
--- a/arch/alpha/include/asm/unistd.h
+++ b/arch/alpha/include/asm/unistd.h
@@ -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
diff --git a/arch/alpha/kernel/systbls.S b/arch/alpha/kernel/systbls.S
index 78199b9..63c78e4 100644
--- a/arch/alpha/kernel/systbls.S
+++ b/arch/alpha/kernel/systbls.S
@@ -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
diff --git a/tools/perf/Makefile b/tools/perf/Makefile
index 742a32e..7940d66 100644
--- a/tools/perf/Makefile
+++ b/tools/perf/Makefile
@@ -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)
diff --git a/tools/perf/perf.h b/tools/perf/perf.h
index 8cc4623..216bdb2 100644
--- a/tools/perf/perf.h
+++ b/tools/perf/perf.h
@@ -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


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

* Re: [PATCH] [alpha] Add minimal support for software performance events.
  2009-10-26  8:32 [PATCH] [alpha] Add minimal support for software performance events Michael Cree
@ 2009-10-26  8:48 ` Ingo Molnar
  2009-10-27  8:09   ` Michael Cree
  2009-10-27 18:29   ` Matt Turner
  2009-12-01  4:30 ` Matt Turner
  1 sibling, 2 replies; 10+ messages in thread
From: Ingo Molnar @ 2009-10-26  8:48 UTC (permalink / raw)
  To: Michael Cree
  Cc: linux-kernel, linux-alpha, Richard Henderson, Ivan Kokshaysky,
	Peter Zijlstra, Paul Mackerras, Andrew Morton


* Michael Cree <mcree@orcon.net.nz> wrote:

> 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.
> 
> Signed-off-by: Michael Cree <mcree@orcon.net.nz>
> ---
>  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:

> --- a/tools/perf/Makefile
> +++ b/tools/perf/Makefile
> @@ -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

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

* Re: [PATCH] [alpha] Add minimal support for software performance events.
  2009-10-26  8:48 ` Ingo Molnar
@ 2009-10-27  8:09   ` Michael Cree
  2009-11-08 12:22     ` Ingo Molnar
  2009-10-27 18:29   ` Matt Turner
  1 sibling, 1 reply; 10+ messages in thread
From: Michael Cree @ 2009-10-27  8:09 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: linux-kernel, linux-alpha, Richard Henderson, Ivan Kokshaysky,
	Peter Zijlstra, Paul Mackerras, Andrew Morton

[-- Attachment #1: Type: text/plain, Size: 2867 bytes --]

Ingo Molnar wrote:
> * Michael Cree <mcree@orcon.net.nz> wrote:
>   
>> 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.
>>
>> Signed-off-by: Michael Cree <mcree@orcon.net.nz>
>> ---
>>  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?
>   

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.

> This portion:
>   
>> --- a/tools/perf/Makefile
>> +++ b/tools/perf/Makefile
>> @@ -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.
>   

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.



[-- Attachment #2: 0001-Test-fstack-protector-all-compiler-option-for-inclus.patch --]
[-- Type: text/x-patch, Size: 1993 bytes --]

From 92feeaec19635a10145fa32a2f0077c4ddda5c7d Mon Sep 17 00:00:00 2001
From: Michael Cree <mcree@orcon.net.nz>
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(-)

diff --git a/tools/perf/Makefile b/tools/perf/Makefile
index 742a32e..e7dc01d 100644
--- a/tools/perf/Makefile
+++ b/tools/perf/Makefile
@@ -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 ---
-- 
1.6.3.3


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

* Re: [PATCH] [alpha] Add minimal support for software performance  events.
  2009-10-26  8:48 ` Ingo Molnar
  2009-10-27  8:09   ` Michael Cree
@ 2009-10-27 18:29   ` Matt Turner
  2009-10-28 20:56     ` Sam Ravnborg
  1 sibling, 1 reply; 10+ messages in thread
From: Matt Turner @ 2009-10-27 18:29 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: Michael Cree, linux-kernel, linux-alpha, Richard Henderson,
	Ivan Kokshaysky, Peter Zijlstra, Paul Mackerras, Andrew Morton

On Mon, Oct 26, 2009 at 4:48 AM, Ingo Molnar <mingo@elte.hu> wrote:
> 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

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

* Re: [PATCH] [alpha] Add minimal support for software performance events.
  2009-10-27 18:29   ` Matt Turner
@ 2009-10-28 20:56     ` Sam Ravnborg
  0 siblings, 0 replies; 10+ messages in thread
From: Sam Ravnborg @ 2009-10-28 20:56 UTC (permalink / raw)
  To: Matt Turner
  Cc: Ingo Molnar, Michael Cree, linux-kernel, linux-alpha,
	Richard Henderson, Ivan Kokshaysky, Peter Zijlstra,
	Paul Mackerras, Andrew Morton

On Tue, Oct 27, 2009 at 02:29:52PM -0400, Matt Turner wrote:
> On Mon, Oct 26, 2009 at 4:48 AM, Ingo Molnar <mingo@elte.hu> wrote:
> > 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

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

* Re: [PATCH] [alpha] Add minimal support for software performance events.
  2009-10-27  8:09   ` Michael Cree
@ 2009-11-08 12:22     ` Ingo Molnar
  2009-11-08 12:27       ` Ingo Molnar
  0 siblings, 1 reply; 10+ messages in thread
From: Ingo Molnar @ 2009-11-08 12:22 UTC (permalink / raw)
  To: Michael Cree
  Cc: linux-kernel, linux-alpha, Richard Henderson, Ivan Kokshaysky,
	Peter Zijlstra, Paul Mackerras, Andrew Morton


* Michael Cree <mcree@orcon.net.nz> wrote:

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

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

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

* Re: [PATCH] [alpha] Add minimal support for software performance events.
  2009-11-08 12:22     ` Ingo Molnar
@ 2009-11-08 12:27       ` Ingo Molnar
  2009-11-11  7:43         ` Michael Cree
  0 siblings, 1 reply; 10+ messages in thread
From: Ingo Molnar @ 2009-11-08 12:27 UTC (permalink / raw)
  To: Michael Cree
  Cc: linux-kernel, linux-alpha, Richard Henderson, Ivan Kokshaysky,
	Peter Zijlstra, Paul Mackerras, Andrew Morton


* Ingo Molnar <mingo@elte.hu> wrote:

> 
> * Michael Cree <mcree@orcon.net.nz> wrote:
> 
> > > 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).
> 
> 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?

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

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

* Re: [PATCH] [alpha] Add minimal support for software performance events.
  2009-11-08 12:27       ` Ingo Molnar
@ 2009-11-11  7:43         ` Michael Cree
  0 siblings, 0 replies; 10+ messages in thread
From: Michael Cree @ 2009-11-11  7:43 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: linux-kernel, linux-alpha, Richard Henderson, Ivan Kokshaysky,
	Peter Zijlstra, Paul Mackerras, Andrew Morton

[-- Attachment #1: Type: text/plain, Size: 154 bytes --]

On Sun, Nov 08, 2009 at 01:27:39PM +0100, Ingo Molnar wrote:
> Mind resending the patch against latest -tip?

Not a problem.  Attached.

Cheers
Michael.


[-- Attachment #2: 0001-Test-fstack-protector-all-compiler-option-for-inclus.patch --]
[-- Type: text/x-diff, Size: 1594 bytes --]

From df1a596909b30c9792e55acc731c2578b71d2670 Mon Sep 17 00:00:00 2001
From: Michael Cree <mcree@orcon.net.nz>
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.

Signed-off-by: Michael Cree <mcree@orcon.net.nz>
---
 tools/perf/Makefile |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/tools/perf/Makefile b/tools/perf/Makefile
index 64e5107..cd42c97 100644
--- a/tools/perf/Makefile
+++ b/tools/perf/Makefile
@@ -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 ---
-- 
1.6.3.3


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

* Re: [PATCH] [alpha] Add minimal support for software performance  events.
  2009-10-26  8:32 [PATCH] [alpha] Add minimal support for software performance events Michael Cree
  2009-10-26  8:48 ` Ingo Molnar
@ 2009-12-01  4:30 ` Matt Turner
  2009-12-01  9:31   ` Michael Cree
  1 sibling, 1 reply; 10+ messages in thread
From: Matt Turner @ 2009-12-01  4:30 UTC (permalink / raw)
  To: Michael Cree
  Cc: linux-kernel, linux-alpha, Richard Henderson, Ivan Kokshaysky,
	Peter Zijlstra, Paul Mackerras, Ingo Molnar

[-- Attachment #1: Type: text/plain, Size: 5088 bytes --]

On Mon, Oct 26, 2009 at 3:32 AM, Michael Cree <mcree@orcon.net.nz> wrote:
> 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.
>
> Signed-off-by: Michael Cree <mcree@orcon.net.nz>
> ---
>  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
>
> diff --git a/arch/alpha/Kconfig b/arch/alpha/Kconfig
> index 4434481..bd7261e 100644
> --- a/arch/alpha/Kconfig
> +++ b/arch/alpha/Kconfig
> @@ -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,
> diff --git a/arch/alpha/include/asm/perf_event.h b/arch/alpha/include/asm/perf_event.h
> new file mode 100644
> index 0000000..3bef852
> --- /dev/null
> +++ b/arch/alpha/include/asm/perf_event.h
> @@ -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 */
> diff --git a/arch/alpha/include/asm/unistd.h b/arch/alpha/include/asm/unistd.h
> index 17f72b7..414de17 100644
> --- a/arch/alpha/include/asm/unistd.h
> +++ b/arch/alpha/include/asm/unistd.h
> @@ -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
> diff --git a/arch/alpha/kernel/systbls.S b/arch/alpha/kernel/systbls.S
> index 78199b9..63c78e4 100644
> --- a/arch/alpha/kernel/systbls.S
> +++ b/arch/alpha/kernel/systbls.S
> @@ -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
> diff --git a/tools/perf/Makefile b/tools/perf/Makefile
> index 742a32e..7940d66 100644
> --- a/tools/perf/Makefile
> +++ b/tools/perf/Makefile
> @@ -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)
> diff --git a/tools/perf/perf.h b/tools/perf/perf.h
> index 8cc4623..216bdb2 100644
> --- a/tools/perf/perf.h
> +++ b/tools/perf/perf.h
> @@ -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
>
> --

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

[-- Attachment #2: 0001-alpha-Add-minimal-support-for-software-performance-e.patch --]
[-- Type: application/octet-stream, Size: 3693 bytes --]

From cb58e6d37b406cdb154b34d700c9478546b1e84f Mon Sep 17 00:00:00 2001
From: Michael Cree <mcree@orcon.net.nz>
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.

Signed-off-by: Michael Cree <mcree@orcon.net.nz>
Cc: Richard Henderson <rth@twiddle.net>
Cc: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Matt Turner <mattst88@gmail.com>
---
 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

diff --git a/arch/alpha/Kconfig b/arch/alpha/Kconfig
index 4434481..bd7261e 100644
--- a/arch/alpha/Kconfig
+++ b/arch/alpha/Kconfig
@@ -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,
diff --git a/arch/alpha/include/asm/perf_event.h b/arch/alpha/include/asm/perf_event.h
new file mode 100644
index 0000000..3bef852
--- /dev/null
+++ b/arch/alpha/include/asm/perf_event.h
@@ -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 */
diff --git a/arch/alpha/include/asm/unistd.h b/arch/alpha/include/asm/unistd.h
index 17f72b7..414de17 100644
--- a/arch/alpha/include/asm/unistd.h
+++ b/arch/alpha/include/asm/unistd.h
@@ -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
diff --git a/arch/alpha/kernel/systbls.S b/arch/alpha/kernel/systbls.S
index 78199b9..63c78e4 100644
--- a/arch/alpha/kernel/systbls.S
+++ b/arch/alpha/kernel/systbls.S
@@ -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
diff --git a/tools/perf/perf.h b/tools/perf/perf.h
index 8cc4623..216bdb2 100644
--- a/tools/perf/perf.h
+++ b/tools/perf/perf.h
@@ -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.4.4


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

* Re: [PATCH] [alpha] Add minimal support for software performance events.
  2009-12-01  4:30 ` Matt Turner
@ 2009-12-01  9:31   ` Michael Cree
  0 siblings, 0 replies; 10+ messages in thread
From: Michael Cree @ 2009-12-01  9:31 UTC (permalink / raw)
  To: Matt Turner
  Cc: linux-kernel, linux-alpha, Richard Henderson, Ivan Kokshaysky,
	Peter Zijlstra, Paul Mackerras, Ingo Molnar

[-- Attachment #1: Type: text/plain, Size: 532 bytes --]

On 01/12/09 17:30, Matt Turner wrote:
> 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.

[-- Attachment #2: 0001-alpha-Add-minimal-support-for-software-performance.patch --]
[-- Type: text/x-diff, Size: 2498 bytes --]

From 2c22c2a528d5c89f52d77b0d7a49c12865f82ecc Mon Sep 17 00:00:00 2001
From: Michael Cree <mcree@orcon.net.nz>
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.

Signed-off-by: Michael Cree <mcree@orcon.net.nz>
---
 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

diff --git a/arch/alpha/Kconfig b/arch/alpha/Kconfig
index 4434481..bd7261e 100644
--- a/arch/alpha/Kconfig
+++ b/arch/alpha/Kconfig
@@ -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,
diff --git a/arch/alpha/include/asm/perf_event.h b/arch/alpha/include/asm/perf_event.h
new file mode 100644
index 0000000..3bef852
--- /dev/null
+++ b/arch/alpha/include/asm/perf_event.h
@@ -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 */
diff --git a/arch/alpha/include/asm/unistd.h b/arch/alpha/include/asm/unistd.h
index 17f72b7..414de17 100644
--- a/arch/alpha/include/asm/unistd.h
+++ b/arch/alpha/include/asm/unistd.h
@@ -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
diff --git a/arch/alpha/kernel/systbls.S b/arch/alpha/kernel/systbls.S
index 78199b9..63c78e4 100644
--- a/arch/alpha/kernel/systbls.S
+++ b/arch/alpha/kernel/systbls.S
@@ -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
-- 
1.5.6.5


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

end of thread, other threads:[~2009-12-01  9:31 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-10-26  8:32 [PATCH] [alpha] Add minimal support for software performance events Michael Cree
2009-10-26  8:48 ` Ingo Molnar
2009-10-27  8:09   ` Michael Cree
2009-11-08 12:22     ` Ingo Molnar
2009-11-08 12:27       ` Ingo Molnar
2009-11-11  7:43         ` Michael Cree
2009-10-27 18:29   ` Matt Turner
2009-10-28 20:56     ` Sam Ravnborg
2009-12-01  4:30 ` Matt Turner
2009-12-01  9:31   ` Michael Cree

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