Skip to contentSkip to conversation

Add minimal support for software performance counters for ia64

PATCH In review William Cohen 3 participants 9 messages Aug 19, 2009 – Aug 21, 2009 perf events

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Add minimal support for software performance counters for ia64

The following patch adds minimal support for software performance counters for ia64.

For the kernel the patch enables configuration of the perf counter option, adds the perf_counter_open syscall, and includes a minimal machine specific asm/perf.h header file.

For the perf tool the header perf.h includes an ia64 specific section and the options used in the Makefile were adjusted to allow compilation on ia64. The -Wcast-align gives "cast increases required alignment of target type" warning for the list_for_each_entry() macro. The "-fno-strict-aliasing" was used to avoid warnings for "dereferencing type-punned pointer will break strict-aliasing rules" warnings for sscanf() functions in util/trace-event-parse.c

-Will

arch/ia64/Kconfig +1 -0
index 170042b..8471526 100644
@@ -29,6 +29,7 @@ config IA64
 	select HAVE_KVM
 	select HAVE_ARCH_TRACEHOOK
 	select HAVE_DMA_API_DEBUG
+	select HAVE_PERF_COUNTERS
 	default y
 	help
 	  The Itanium Processor Family is Intel's 64-bit successor to
arch/ia64/include/asm/unistd.h +2 -1
index 5a5347f..f69d1c9 100644
@@ -311,11 +311,12 @@
 #define __NR_preadv			1319
 #define __NR_pwritev			1320
 #define __NR_rt_tgsigqueueinfo		1321
+#define __NR_perf_counter_open		1322
 
 #ifdef __KERNEL__
 
 
-#define NR_syscalls			298 /* length of syscall table */
+#define NR_syscalls			299 /* length of syscall table */
 
 /*
  * The following defines stop scripts/checksyscalls.sh from complaining about
arch/ia64/kernel/entry.S +1 -0
index d0e7d37..4cf88b0 100644
@@ -1806,6 +1806,7 @@ sys_call_table:
 	data8 sys_preadv
 	data8 sys_pwritev			// 1320
 	data8 sys_rt_tgsigqueueinfo
+	data8 sys_perf_counter_open
 
 	.org sys_call_table + 8*NR_syscalls	// guard against failures to increase NR_syscalls
 #endif /* __IA64_ASM_PARAVIRTUALIZED_NATIVE */
include/asm-ia64/perf_counter.h new file +9 -0
new file mode 100644
index 0000000..cab4352
@@ -0,0 +1,9 @@
+#ifndef __ASM_IA64_PERF_COUNTER_H
+#define __ASM_IA64_PERF_COUNTER_H
+
+/* IA64 only supports software counters through this interface. */
+static inline void set_perf_counter_pending(void) {}
+
+#define PERF_COUNTER_INDEX_OFFSET	0
+
+#endif /* __ASM_IA64_PERF_COUNTER_H */
tools/perf/Makefile +6 -4
index c481a51..69db3de 100644
@@ -159,8 +159,10 @@ uname_V := $(shell sh -c 'uname -v 2>/dev/null || echo not')
 
 # If we're on a 64-bit kernel, use -m64
 ifndef NO_64BIT
-	ifneq ($(patsubst %64,%,$(uname_M)),$(uname_M))
-	  M64 := -m64
+	ifeq ($(patsubst %ia64,%,$(uname_M)),$(uname_M))
+	  ifneq ($(patsubst %64,%,$(uname_M)),$(uname_M))
+	    M64 := -m64
+	  endif
 	endif
 endif
 
@@ -169,9 +171,9 @@ endif
 #
 # Include saner warnings here, which can catch bugs:
 #
-EXTRA_WARNINGS = -Wcast-align -Wformat -Wformat-security -Wformat-y2k -Wshadow -Winit-self -Wpacked -Wredundant-decls -Wstack-protector -Wstrict-aliasing=3 -Wswitch-default -Wswitch-enum -Wno-system-headers -Wundef -Wvolatile-register-var -Wwrite-strings -Wbad-function-cast -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -Wold-style-definition -Wstrict-prototypes -Wdeclaration-after-statement
+EXTRA_WARNINGS = -Wformat -Wformat-security -Wformat-y2k -Wshadow -Winit-self -Wpacked -Wredundant-decls -Wstack-protector -Wstrict-aliasing=3 -Wswitch-default -Wswitch-enum -Wno-system-headers -Wundef -Wvolatile-register-var -Wwrite-strings -Wbad-function-cast -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -Wold-style-definition -Wstrict-prototypes -Wdeclaration-after-statement
 
-CFLAGS = $(M64) -ggdb3 -Wall -Wextra -std=gnu99 -Werror -O6 -fstack-protector-all -D_FORTIFY_SOURCE=2 $(EXTRA_WARNINGS)
+CFLAGS = $(M64) -ggdb3 -Wall -Wextra -std=gnu99 -Werror -O6 -fstack-protector-all -D_FORTIFY_SOURCE=2 -fno-strict-aliasing $(EXTRA_WARNINGS)
 LDFLAGS = -lpthread -lrt -lelf -lm
 ALL_CFLAGS = $(CFLAGS)
 ALL_LDFLAGS = $(LDFLAGS)
tools/perf/perf.h +6 -0
index e5148e2..90179c9 100644
@@ -41,6 +41,12 @@
 #define cpu_relax()	asm volatile("" ::: "memory");
 #endif
 
+#ifdef __ia64__
+#include "../../arch/ia64/include/asm/unistd.h"
+#define rmb()		asm volatile("" ::: "memory")
+#define cpu_relax()	asm volatile("" ::: "memory");
+#endif
+
 #include <time.h>
 #include <unistd.h>
 #include <sys/types.h>
#1 lore raw

tools/perf/perf.h line 48

Quoted 5 lines · William Cohen
tools/perf/perf.h +5 -0
+#ifdef __ia64__
+#include "../../arch/ia64/include/asm/unistd.h"
+#define rmb()          asm volatile("" ::: "memory")
+#define cpu_relax()    asm volatile("" ::: "memory");
+#endif

Surely the itanic has a real memory barrier? The kernel seems to use something along the lines of mf.

Also, cpu_relax() seems to end up being asm volatile("hint @pause" :::
"memory"), although we don't seem to have an actual user of cpu_relax() in perf atm.

#2 lore raw
Quoted 10 lines · Peter Zijlstra

Review

Quoted 5 lines · William Cohen
(quoted diff) +5 -0
+#ifdef __ia64__
+#include "../../arch/ia64/include/asm/unistd.h"
+#define rmb()          asm volatile("" ::: "memory")
+#define cpu_relax()    asm volatile("" ::: "memory");
+#endif

Surely the itanic has a real memory barrier? The kernel seems to use something along the lines of mf.

Quoted 6 lines

Also, cpu_relax() seems to end up being asm volatile("hint @pause" :::
"memory"), although we don't seem to have an actual user of cpu_relax() in perf atm.

Peter, thanks for the comment. I took a look at the rmb() and cpu_relax() code in the kernel and revised the patch with the appropriate defines

-Will

arch/ia64/Kconfig +1 -0
index 170042b..8471526 100644
@@ -29,6 +29,7 @@ config IA64
 	select HAVE_KVM
 	select HAVE_ARCH_TRACEHOOK
 	select HAVE_DMA_API_DEBUG
+	select HAVE_PERF_COUNTERS
 	default y
 	help
 	  The Itanium Processor Family is Intel's 64-bit successor to
arch/ia64/include/asm/unistd.h +2 -1
index 5a5347f..f69d1c9 100644
@@ -311,11 +311,12 @@
 #define __NR_preadv			1319
 #define __NR_pwritev			1320
 #define __NR_rt_tgsigqueueinfo		1321
+#define __NR_perf_counter_open		1322
 
 #ifdef __KERNEL__
 
 
-#define NR_syscalls			298 /* length of syscall table */
+#define NR_syscalls			299 /* length of syscall table */
 
 /*
  * The following defines stop scripts/checksyscalls.sh from complaining about
arch/ia64/kernel/entry.S +1 -0
index d0e7d37..4cf88b0 100644
@@ -1806,6 +1806,7 @@ sys_call_table:
 	data8 sys_preadv
 	data8 sys_pwritev			// 1320
 	data8 sys_rt_tgsigqueueinfo
+	data8 sys_perf_counter_open
 
 	.org sys_call_table + 8*NR_syscalls	// guard against failures to increase NR_syscalls
 #endif /* __IA64_ASM_PARAVIRTUALIZED_NATIVE */
include/asm-ia64/perf_counter.h new file +9 -0
new file mode 100644
index 0000000..cab4352
@@ -0,0 +1,9 @@
+#ifndef __ASM_IA64_PERF_COUNTER_H
+#define __ASM_IA64_PERF_COUNTER_H
+
+/* IA64 only supports software counters through this interface. */
+static inline void set_perf_counter_pending(void) {}
+
+#define PERF_COUNTER_INDEX_OFFSET	0
+
+#endif /* __ASM_IA64_PERF_COUNTER_H */
tools/perf/Makefile +6 -4
index c481a51..69db3de 100644
@@ -159,8 +159,10 @@ uname_V := $(shell sh -c 'uname -v 2>/dev/null || echo not')
 
 # If we're on a 64-bit kernel, use -m64
 ifndef NO_64BIT
-	ifneq ($(patsubst %64,%,$(uname_M)),$(uname_M))
-	  M64 := -m64
+	ifeq ($(patsubst %ia64,%,$(uname_M)),$(uname_M))
+	  ifneq ($(patsubst %64,%,$(uname_M)),$(uname_M))
+	    M64 := -m64
+	  endif
 	endif
 endif
 
@@ -169,9 +171,9 @@ endif
 #
 # Include saner warnings here, which can catch bugs:
 #
-EXTRA_WARNINGS = -Wcast-align -Wformat -Wformat-security -Wformat-y2k -Wshadow -Winit-self -Wpacked -Wredundant-decls -Wstack-protector -Wstrict-aliasing=3 -Wswitch-default -Wswitch-enum -Wno-system-headers -Wundef -Wvolatile-register-var -Wwrite-strings -Wbad-function-cast -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -Wold-style-definition -Wstrict-prototypes -Wdeclaration-after-statement
+EXTRA_WARNINGS = -Wformat -Wformat-security -Wformat-y2k -Wshadow -Winit-self -Wpacked -Wredundant-decls -Wstack-protector -Wstrict-aliasing=3 -Wswitch-default -Wswitch-enum -Wno-system-headers -Wundef -Wvolatile-register-var -Wwrite-strings -Wbad-function-cast -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -Wold-style-definition -Wstrict-prototypes -Wdeclaration-after-statement
 
-CFLAGS = $(M64) -ggdb3 -Wall -Wextra -std=gnu99 -Werror -O6 -fstack-protector-all -D_FORTIFY_SOURCE=2 $(EXTRA_WARNINGS)
+CFLAGS = $(M64) -ggdb3 -Wall -Wextra -std=gnu99 -Werror -O6 -fstack-protector-all -D_FORTIFY_SOURCE=2 -fno-strict-aliasing $(EXTRA_WARNINGS)
 LDFLAGS = -lpthread -lrt -lelf -lm
 ALL_CFLAGS = $(CFLAGS)
 ALL_LDFLAGS = $(LDFLAGS)
tools/perf/perf.h +6 -0
index e5148e2..c849337 100644
@@ -41,6 +41,12 @@
 #define cpu_relax()	asm volatile("" ::: "memory");
 #endif
 
+#ifdef __ia64__
+#include "../../arch/ia64/include/asm/unistd.h"
+#define rmb()		asm volatile("mf" ::: "memory")
+#define cpu_relax()	asm volatile("hint @pause" ::: "memory")
+#endif
+
 #include <time.h>
 #include <unistd.h>
 #include <sys/types.h>
#3 lore raw
Quoted 18 lines · William Cohen
Quoted 10 lines · Peter Zijlstra

tools/perf/perf.h line 48

Quoted 5 lines · William Cohen
tools/perf/perf.h +5 -0
+#ifdef __ia64__
+#include "../../arch/ia64/include/asm/unistd.h"
+#define rmb()          asm volatile("" ::: "memory")
+#define cpu_relax()    asm volatile("" ::: "memory");
+#endif

Surely the itanic has a real memory barrier? The kernel seems to use something along the lines of mf.

Quoted 6 lines

Also, cpu_relax() seems to end up being asm volatile("hint @pause" :::
"memory"), although we don't seem to have an actual user of cpu_relax() in perf atm.

Quoted 2 lines

Peter, thanks for the comment. I took a look at the rmb() and cpu_relax() code in the kernel and revised the patch with the appropriate defines

Looks good now, thanks!

#4 lore raw
Quoted 17 lines · Peter Zijlstra
Quoted 16 lines · William Cohen
Quoted 15 lines · Peter Zijlstra

tools/perf/perf.h line 48

Quoted 5 lines · William Cohen
tools/perf/perf.h +5 -0
+#ifdef __ia64__
+#include "../../arch/ia64/include/asm/unistd.h"
+#define rmb()          asm volatile("" ::: "memory")
+#define cpu_relax()    asm volatile("" ::: "memory");
+#endif

Surely the itanic has a real memory barrier? The kernel seems to use something along the lines of mf.

Also, cpu_relax() seems to end up being asm volatile("hint @pause" :::
"memory"), although we don't seem to have an actual user of cpu_relax() in perf atm.

Quoted 5 lines
Quoted 2 lines

Peter, thanks for the comment. I took a look at the rmb() and cpu_relax() code in the kernel and revised the patch with the appropriate defines

Looks good now, thanks!

When looking through the patch today I realized the new perf_counter.h was placed in include/asm-ia64. It should be placed in arch/ia64/include/asm/perf_counter.h.

-Will

#5 lore raw
Quoted 21 lines · William Cohen
Quoted 20 lines · Peter Zijlstra
Quoted 18 lines · William Cohen
Quoted 9 lines · Peter Zijlstra

tools/perf/perf.h line 48

Quoted 5 lines · William Cohen
tools/perf/perf.h +5 -0
+#ifdef __ia64__
+#include "../../arch/ia64/include/asm/unistd.h"
+#define rmb()          asm volatile("" ::: "memory")
+#define cpu_relax()    asm volatile("" ::: "memory");
+#endif

Surely the itanic has a real memory barrier? The kernel seems to use something along the lines of mf.

Quoted 6 lines

Also, cpu_relax() seems to end up being asm volatile("hint @pause" :::
"memory"), although we don't seem to have an actual user of cpu_relax() in perf atm.

Peter, thanks for the comment. I took a look at the rmb() and cpu_relax() code in the kernel and revised the patch with the appropriate defines

Quoted 6 lines
Quoted 2 lines

Looks good now, thanks!

When looking through the patch today I realized the new perf_counter.h was placed in include/asm-ia64. It should be placed in arch/ia64/include/asm/perf_counter.h.

mind sending out a v2 patch with all review feedback folded in, for IA64 maintainers to ack if they like it?

Thanks,

Ingo

#6 lore raw
Quoted 28 lines · Ingo Molnar
Quoted 18 lines · William Cohen
Quoted 17 lines · Peter Zijlstra
Quoted 16 lines · William Cohen
Quoted 15 lines · Peter Zijlstra

Review

Quoted 5 lines · William Cohen
(quoted diff) +5 -0
+#ifdef __ia64__
+#include "../../arch/ia64/include/asm/unistd.h"
+#define rmb()          asm volatile("" ::: "memory")
+#define cpu_relax()    asm volatile("" ::: "memory");
+#endif

Surely the itanic has a real memory barrier? The kernel seems to use something along the lines of mf.

Also, cpu_relax() seems to end up being asm volatile("hint @pause" :::
"memory"), although we don't seem to have an actual user of cpu_relax() in perf atm.

Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

Peter, thanks for the comment. I took a look at the rmb() and cpu_relax() code in the kernel and revised the patch with the appropriate defines

Looks good now, thanks!

When looking through the patch today I realized the new perf_counter.h was placed in include/asm-ia64. It should be placed in arch/ia64/include/asm/perf_counter.h.

Quoted 6 lines

mind sending out a v2 patch with all review feedback folded in, for IA64 maintainers to ack if they like it?

Thanks,

Ingo

Hi Ingo,

The following is the revised patch with the corrected macros and the include file in the correct place.

-Will

arch/ia64/Kconfig +1 -0
index 170042b..8471526 100644
@@ -29,6 +29,7 @@ config IA64
 	select HAVE_KVM
 	select HAVE_ARCH_TRACEHOOK
 	select HAVE_DMA_API_DEBUG
+	select HAVE_PERF_COUNTERS
 	default y
 	help
 	  The Itanium Processor Family is Intel's 64-bit successor to
arch/ia64/include/asm/unistd.h +2 -1
index 5a5347f..f69d1c9 100644
@@ -311,11 +311,12 @@
 #define __NR_preadv			1319
 #define __NR_pwritev			1320
 #define __NR_rt_tgsigqueueinfo		1321
+#define __NR_perf_counter_open		1322
 
 #ifdef __KERNEL__
 
 
-#define NR_syscalls			298 /* length of syscall table */
+#define NR_syscalls			299 /* length of syscall table */
 
 /*
  * The following defines stop scripts/checksyscalls.sh from complaining about
arch/ia64/kernel/entry.S +1 -0
index d0e7d37..4cf88b0 100644
@@ -1806,6 +1806,7 @@ sys_call_table:
 	data8 sys_preadv
 	data8 sys_pwritev			// 1320
 	data8 sys_rt_tgsigqueueinfo
+	data8 sys_perf_counter_open
 
 	.org sys_call_table + 8*NR_syscalls	// guard against failures to increase NR_syscalls
 #endif /* __IA64_ASM_PARAVIRTUALIZED_NATIVE */
arch/ia64/include/asm/perf_counter.h new file +9 -0
new file mode 100644
index 0000000..cab4352
@@ -0,0 +1,9 @@
+#ifndef __ASM_IA64_PERF_COUNTER_H
+#define __ASM_IA64_PERF_COUNTER_H
+
+/* IA64 only supports software counters through this interface. */
+static inline void set_perf_counter_pending(void) {}
+
+#define PERF_COUNTER_INDEX_OFFSET	0
+
+#endif /* __ASM_IA64_PERF_COUNTER_H */
tools/perf/Makefile +6 -4
index c481a51..69db3de 100644
@@ -159,8 +159,10 @@ uname_V := $(shell sh -c 'uname -v 2>/dev/null || echo not')
 
 # If we're on a 64-bit kernel, use -m64
 ifndef NO_64BIT
-	ifneq ($(patsubst %64,%,$(uname_M)),$(uname_M))
-	  M64 := -m64
+	ifeq ($(patsubst %ia64,%,$(uname_M)),$(uname_M))
+	  ifneq ($(patsubst %64,%,$(uname_M)),$(uname_M))
+	    M64 := -m64
+	  endif
 	endif
 endif
 
@@ -169,9 +171,9 @@ endif
 #
 # Include saner warnings here, which can catch bugs:
 #
-EXTRA_WARNINGS = -Wcast-align -Wformat -Wformat-security -Wformat-y2k -Wshadow -Winit-self -Wpacked -Wredundant-decls -Wstack-protector -Wstrict-aliasing=3 -Wswitch-default -Wswitch-enum -Wno-system-headers -Wundef -Wvolatile-register-var -Wwrite-strings -Wbad-function-cast -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -Wold-style-definition -Wstrict-prototypes -Wdeclaration-after-statement
+EXTRA_WARNINGS = -Wformat -Wformat-security -Wformat-y2k -Wshadow -Winit-self -Wpacked -Wredundant-decls -Wstack-protector -Wstrict-aliasing=3 -Wswitch-default -Wswitch-enum -Wno-system-headers -Wundef -Wvolatile-register-var -Wwrite-strings -Wbad-function-cast -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -Wold-style-definition -Wstrict-prototypes -Wdeclaration-after-statement
 
-CFLAGS = $(M64) -ggdb3 -Wall -Wextra -std=gnu99 -Werror -O6 -fstack-protector-all -D_FORTIFY_SOURCE=2 $(EXTRA_WARNINGS)
+CFLAGS = $(M64) -ggdb3 -Wall -Wextra -std=gnu99 -Werror -O6 -fstack-protector-all -D_FORTIFY_SOURCE=2 -fno-strict-aliasing $(EXTRA_WARNINGS)
 LDFLAGS = -lpthread -lrt -lelf -lm
 ALL_CFLAGS = $(CFLAGS)
 ALL_LDFLAGS = $(LDFLAGS)
tools/perf/perf.h +6 -0
index e5148e2..c849337 100644
@@ -41,6 +41,12 @@
 #define cpu_relax()	asm volatile("" ::: "memory");
 #endif
 
+#ifdef __ia64__
+#include "../../arch/ia64/include/asm/unistd.h"
+#define rmb()		asm volatile("mf" ::: "memory")
+#define cpu_relax()	asm volatile("hint @pause" ::: "memory")
+#endif
+
 #include <time.h>
 #include <unistd.h>
 #include <sys/types.h>
#7 lore raw

PATCH v2 1/1 perf_counter, IA64: Add support for software performance counters

Quoted 2 lines · William Cohen

The following is the revised patch with the corrected macros and the include file in the correct place.

Note, this is not how v2 patches are generally expected to be submitted upstream - all info is supposed to be re-submitted with a new v2 email title to make it easy and context-less for maintainers.

I've done that here: i've tidied up the changelog (to match IA64 and perf_counter patch title standards), added a diffstat, added the acks/signoffs the patch got in the discussion and included the whole thing below, for IA64 folks to comment on.

Thanks,

Ingo

---------------------->
Subject: perf_counter, IA64: Add support for software performance counters
From: William Cohen <[email protected]>
Date: Fri, 21 Aug 2009 11:09:29 -0400

The patch enables configuration of the perf counter option on IA64, adds the perf_counter_open syscall, and includes a minimal machine specific asm/perf.h header file.

For the perf tool the header perf.h includes an ia64 specific section and the options used in the Makefile were adjusted to allow compilation on ia64.

[ The -Wcast-align gives "cast increases required alignment of
target type" warning for the list_for_each_entry() macro. The "-fno-strict-aliasing" was used to avoid warnings for "dereferencing type-punned pointer will break strict-aliasing rules" warnings for sscanf() functions in util/trace-event-parse.c ]

LKML-Reference: <[email protected]>

---
 arch/ia64/Kconfig                    |    1 +
 arch/ia64/include/asm/perf_counter.h |    9 +++++++++
 arch/ia64/include/asm/unistd.h       |    3 ++-
 arch/ia64/kernel/entry.S             |    1 +
 tools/perf/Makefile                  |   10 ++++++----
 tools/perf/perf.h                    |    6 ++++++
 6 files changed, 25 insertions(+), 5 deletions(-)
arch/ia64/Kconfig +1 -0
Index: tip/arch/ia64/Kconfig
===================================================================
@@ -29,6 +29,7 @@ config IA64
 	select HAVE_KVM
 	select HAVE_ARCH_TRACEHOOK
 	select HAVE_DMA_API_DEBUG
+	select HAVE_PERF_COUNTERS
 	default y
 	help
 	  The Itanium Processor Family is Intel's 64-bit successor to
arch/ia64/include/asm/perf_counter.h new file +9 -0
Index: tip/arch/ia64/include/asm/perf_counter.h
===================================================================
@@ -0,0 +1,9 @@
+#ifndef __ASM_IA64_PERF_COUNTER_H
+#define __ASM_IA64_PERF_COUNTER_H
+
+/* IA64 only supports software counters through this interface. */
+static inline void set_perf_counter_pending(void) {}
+
+#define PERF_COUNTER_INDEX_OFFSET	0
+
+#endif /* __ASM_IA64_PERF_COUNTER_H */
arch/ia64/include/asm/unistd.h +2 -1
Index: tip/arch/ia64/include/asm/unistd.h
===================================================================
@@ -311,11 +311,12 @@
 #define __NR_preadv			1319
 #define __NR_pwritev			1320
 #define __NR_rt_tgsigqueueinfo		1321
+#define __NR_perf_counter_open		1322
 
 #ifdef __KERNEL__
 
 
-#define NR_syscalls			298 /* length of syscall table */
+#define NR_syscalls			299 /* length of syscall table */
 
 /*
  * The following defines stop scripts/checksyscalls.sh from complaining about
arch/ia64/kernel/entry.S +1 -0
Index: tip/arch/ia64/kernel/entry.S
===================================================================
@@ -1806,6 +1806,7 @@ sys_call_table:
 	data8 sys_preadv
 	data8 sys_pwritev			// 1320
 	data8 sys_rt_tgsigqueueinfo
+	data8 sys_perf_counter_open
 
 	.org sys_call_table + 8*NR_syscalls	// guard against failures to increase NR_syscalls
 #endif /* __IA64_ASM_PARAVIRTUALIZED_NATIVE */
tools/perf/Makefile +6 -4
Index: tip/tools/perf/Makefile
===================================================================
@@ -159,8 +159,10 @@ uname_V := $(shell sh -c 'uname -v 2>/de
 
 # If we're on a 64-bit kernel, use -m64
 ifndef NO_64BIT
-	ifneq ($(patsubst %64,%,$(uname_M)),$(uname_M))
-	  M64 := -m64
+	ifeq ($(patsubst %ia64,%,$(uname_M)),$(uname_M))
+	  ifneq ($(patsubst %64,%,$(uname_M)),$(uname_M))
+	    M64 := -m64
+	  endif
 	endif
 endif
 
@@ -169,9 +171,9 @@ endif
 #
 # Include saner warnings here, which can catch bugs:
 #
-EXTRA_WARNINGS = -Wcast-align -Wformat -Wformat-security -Wformat-y2k -Wshadow -Winit-self -Wpacked -Wredundant-decls -Wstack-protector -Wstrict-aliasing=3 -Wswitch-default -Wswitch-enum -Wno-system-headers -Wundef -Wvolatile-register-var -Wwrite-strings -Wbad-function-cast -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -Wold-style-definition -Wstrict-prototypes -Wdeclaration-after-statement
+EXTRA_WARNINGS = -Wformat -Wformat-security -Wformat-y2k -Wshadow -Winit-self -Wpacked -Wredundant-decls -Wstack-protector -Wstrict-aliasing=3 -Wswitch-default -Wswitch-enum -Wno-system-headers -Wundef -Wvolatile-register-var -Wwrite-strings -Wbad-function-cast -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -Wold-style-definition -Wstrict-prototypes -Wdeclaration-after-statement
 
-CFLAGS = $(M64) -ggdb3 -Wall -Wextra -std=gnu99 -Werror -O6 -fstack-protector-all -D_FORTIFY_SOURCE=2 $(EXTRA_WARNINGS)
+CFLAGS = $(M64) -ggdb3 -Wall -Wextra -std=gnu99 -Werror -O6 -fstack-protector-all -D_FORTIFY_SOURCE=2 -fno-strict-aliasing $(EXTRA_WARNINGS)
 LDFLAGS = -lpthread -lrt -lelf -lm
 ALL_CFLAGS = $(CFLAGS)
 ALL_LDFLAGS = $(LDFLAGS)
tools/perf/perf.h +6 -0
Index: tip/tools/perf/perf.h
===================================================================
@@ -41,6 +41,12 @@
 #define cpu_relax()	asm volatile("" ::: "memory");
 #endif
 
+#ifdef __ia64__
+#include "../../arch/ia64/include/asm/unistd.h"
+#define rmb()		asm volatile("mf" ::: "memory")
+#define cpu_relax()	asm volatile("hint @pause" ::: "memory")
+#endif
+
 #include <time.h>
 #include <unistd.h>
 #include <sys/types.h>
#8 lore raw
In reply to William Cohen
Quoted 2 lines · William Cohen

The following patch adds minimal support for software performance counters for ia64.

Nice!

Quoted 5 lines

For the kernel the patch enables configuration of the perf counter option, adds the perf_counter_open syscall, and includes a minimal machine specific asm/perf.h header file.

Quoted 9 lines

For the perf tool the header perf.h includes an ia64 specific section and the options used in the Makefile were adjusted to allow compilation on ia64. The -Wcast-align gives "cast increases required alignment of target type" warning for the list_for_each_entry() macro. The "-fno-strict-aliasing" was used to avoid warnings for "dereferencing type-punned pointer will break strict-aliasing rules" warnings for sscanf() functions in util/trace-event-parse.c

Tony, Fenghua Yu, this patch already depends on .32 changes in the perfcounters tree - would be OK to you if we merged this patch into the perfcounters tree? Plus perhaps merge a syscall placeholder patch into the ia64 tree?

Thanks,

Ingo