All of lore.kernel.org
 help / color / mirror / Atom feed
* PowerPC, ftrace: Add PPC raw syscall tracepoints & ftrace fixes (mimimal subset only) v4
@ 2011-02-03  3:27 ` Ian Munsie
  0 siblings, 0 replies; 30+ messages in thread
From: Ian Munsie @ 2011-02-03  3:27 UTC (permalink / raw)
  To: linux-kernel
  Cc: Andreas Dilger, Dave Kleikamp, Andrew Morton, Jiri Kosina,
	Jason Baron, linuxppc-dev, Steven Rostedt, Alexander Graf,
	Ingo Molnar, Paul Mackerras, KOSAKI Motohiro,
	Frederic Weisbecker, Scott Wood, Nathan Lynch, Avantika Mathur,
	David Gibson, Andreas Schwab, Namhyung Kim

Hi All,

This is a partial version of my 'ftrace syscalls, PowerPC: Various fixes,
Compat Syscall support and PowerPC implementation'. This is updated from
yesterday with arch_syscall_addr changed to a static inline function from
Steven's suggestion.

This subset implements the raw syscall tracepoints on PowerPC which has been
requested recently.  It also fixes ftrace syscalls to ensure that events will
only be created for syscalls that successfully map their metadata to a syscall
number, so that non-working phantom events are not created. Patches #2 and #6
in this series are not strictly necessary for this, they just optimise ftrace
syscalls a bit.

What's missing from this series that was in the full 40 patch v2 series is the
conversion of all the syscalls implemented under /arch/powerpc, Jason Baron's
compat syscall support and the conversion of the remaining native and compat
syscalls to this infrastructure.

Cheers,
-Ian


Changelog:
Subset v4:
- Changed arch_syscall_addr to a static inline function from Steven's
  suggestion. Archs implementing their own function must now define
  ARCH_HAS_SYSCALL_MATCH_SYM_NAME in their asm/ftrace.h

Subset v3:
- Rather than removing the redundant syscall_nr checks completely, I have
  turned them into WARN_ON_ONCE to catch possible future regressions, from
  Steven Rostedt's suggestion.
- From Mike Frysinger's suggestion, arch_syscall_addr is now a macro rather
  than a weak function to minimise the overhead at boot. Archs with special
  requirements (such as ppc64) can define their own macro in asm/ftrace.h.
  Steven Rostedt suggested this be made a static inline function, but I don't
  see how this would be possible (at least without #defines and #ifndefs) given
  that it has to be weak to allow archs to override it (Unless I misunderstood
  something?  Steven?).

Subset v2:
- Minimal unchanged subset from 'ftrace syscalls, PowerPC: Various fixes,
  Compat Syscall support and PowerPC implementation' v2 patch series.



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

* PowerPC, ftrace: Add PPC raw syscall tracepoints & ftrace fixes (mimimal subset only) v4
@ 2011-02-03  3:27 ` Ian Munsie
  0 siblings, 0 replies; 30+ messages in thread
From: Ian Munsie @ 2011-02-03  3:27 UTC (permalink / raw)
  To: linux-kernel
  Cc: Andreas Dilger, Andreas Schwab, Dave Kleikamp, Namhyung Kim,
	Jiri Kosina, Jason Baron, Alexander Graf, Steven Rostedt,
	David Gibson, Ingo Molnar, Paul Mackerras, KOSAKI Motohiro,
	Frederic Weisbecker, Scott Wood, Nathan Lynch, Andrew Morton,
	linuxppc-dev, Avantika Mathur

Hi All,

This is a partial version of my 'ftrace syscalls, PowerPC: Various fixes,
Compat Syscall support and PowerPC implementation'. This is updated from
yesterday with arch_syscall_addr changed to a static inline function from
Steven's suggestion.

This subset implements the raw syscall tracepoints on PowerPC which has been
requested recently.  It also fixes ftrace syscalls to ensure that events will
only be created for syscalls that successfully map their metadata to a syscall
number, so that non-working phantom events are not created. Patches #2 and #6
in this series are not strictly necessary for this, they just optimise ftrace
syscalls a bit.

What's missing from this series that was in the full 40 patch v2 series is the
conversion of all the syscalls implemented under /arch/powerpc, Jason Baron's
compat syscall support and the conversion of the remaining native and compat
syscalls to this infrastructure.

Cheers,
-Ian


Changelog:
Subset v4:
- Changed arch_syscall_addr to a static inline function from Steven's
  suggestion. Archs implementing their own function must now define
  ARCH_HAS_SYSCALL_MATCH_SYM_NAME in their asm/ftrace.h

Subset v3:
- Rather than removing the redundant syscall_nr checks completely, I have
  turned them into WARN_ON_ONCE to catch possible future regressions, from
  Steven Rostedt's suggestion.
- From Mike Frysinger's suggestion, arch_syscall_addr is now a macro rather
  than a weak function to minimise the overhead at boot. Archs with special
  requirements (such as ppc64) can define their own macro in asm/ftrace.h.
  Steven Rostedt suggested this be made a static inline function, but I don't
  see how this would be possible (at least without #defines and #ifndefs) given
  that it has to be weak to allow archs to override it (Unless I misunderstood
  something?  Steven?).

Subset v2:
- Minimal unchanged subset from 'ftrace syscalls, PowerPC: Various fixes,
  Compat Syscall support and PowerPC implementation' v2 patch series.

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

* [PATCH 1/6] ftrace syscalls: don't add events for unmapped syscalls
  2011-02-03  3:27 ` Ian Munsie
@ 2011-02-03  3:27   ` Ian Munsie
  -1 siblings, 0 replies; 30+ messages in thread
From: Ian Munsie @ 2011-02-03  3:27 UTC (permalink / raw)
  To: linux-kernel
  Cc: Andreas Dilger, Dave Kleikamp, Andrew Morton, Jiri Kosina,
	Jason Baron, linuxppc-dev, Steven Rostedt, Alexander Graf,
	Ingo Molnar, Paul Mackerras, KOSAKI Motohiro,
	Frederic Weisbecker, Scott Wood, Nathan Lynch, Avantika Mathur,
	David Gibson, Andreas Schwab, Namhyung Kim, Ian Munsie

From: Ian Munsie <imunsie@au1.ibm.com>

FTRACE_SYSCALLS would create events for each and every system call, even
if it had failed to map the system call's name with it's number. This
resulted in a number of events being created that would not behave as
expected.

This could happen, for example, on architectures who's symbol names are
unusual and will not match the system call name. It could also happen
with system calls which were mapped to sys_ni_syscall.

This patch changes the default system call number in the metadata to -1.
If the system call name from the metadata is not successfully mapped to
a system call number during boot, than the event initialisation routine
will now return an error, preventing the event from being created.

Signed-off-by: Ian Munsie <imunsie@au1.ibm.com>
---
 include/linux/syscalls.h      |    2 ++
 kernel/trace/trace_syscalls.c |    8 ++++++++
 2 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h
index 18cd068..2e5a68d 100644
--- a/include/linux/syscalls.h
+++ b/include/linux/syscalls.h
@@ -160,6 +160,7 @@ extern struct trace_event_functions exit_syscall_print_funcs;
 	  __attribute__((section("__syscalls_metadata")))	\
 	  __syscall_meta_##sname = {				\
 		.name 		= "sys"#sname,			\
+		.syscall_nr	= -1,	/* Filled in at boot */	\
 		.nb_args 	= nb,				\
 		.types		= types_##sname,		\
 		.args		= args_##sname,			\
@@ -176,6 +177,7 @@ extern struct trace_event_functions exit_syscall_print_funcs;
 	  __attribute__((section("__syscalls_metadata")))	\
 	  __syscall_meta__##sname = {				\
 		.name 		= "sys_"#sname,			\
+		.syscall_nr	= -1,	/* Filled in at boot */	\
 		.nb_args 	= 0,				\
 		.enter_event	= &event_enter__##sname,	\
 		.exit_event	= &event_exit__##sname,		\
diff --git a/kernel/trace/trace_syscalls.c b/kernel/trace/trace_syscalls.c
index b706529..a66bc13 100644
--- a/kernel/trace/trace_syscalls.c
+++ b/kernel/trace/trace_syscalls.c
@@ -423,6 +423,14 @@ void unreg_event_syscall_exit(struct ftrace_event_call *call)
 int init_syscall_trace(struct ftrace_event_call *call)
 {
 	int id;
+	int num;
+
+	num = ((struct syscall_metadata *)call->data)->syscall_nr;
+	if (num < 0 || num >= NR_syscalls) {
+		pr_debug("syscall %s metadata not mapped, disabling ftrace event\n",
+				((struct syscall_metadata *)call->data)->name);
+		return -ENOSYS;
+	}
 
 	if (set_syscall_print_fmt(call) < 0)
 		return -ENOMEM;
-- 
1.7.2.3


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

* [PATCH 1/6] ftrace syscalls: don't add events for unmapped syscalls
@ 2011-02-03  3:27   ` Ian Munsie
  0 siblings, 0 replies; 30+ messages in thread
From: Ian Munsie @ 2011-02-03  3:27 UTC (permalink / raw)
  To: linux-kernel
  Cc: Andreas Dilger, Andreas Schwab, Dave Kleikamp, Namhyung Kim,
	Jiri Kosina, Jason Baron, Alexander Graf, Steven Rostedt,
	David Gibson, Ingo Molnar, Paul Mackerras, Ian Munsie,
	KOSAKI Motohiro, Frederic Weisbecker, Scott Wood, Nathan Lynch,
	Andrew Morton, linuxppc-dev, Avantika Mathur

From: Ian Munsie <imunsie@au1.ibm.com>

FTRACE_SYSCALLS would create events for each and every system call, even
if it had failed to map the system call's name with it's number. This
resulted in a number of events being created that would not behave as
expected.

This could happen, for example, on architectures who's symbol names are
unusual and will not match the system call name. It could also happen
with system calls which were mapped to sys_ni_syscall.

This patch changes the default system call number in the metadata to -1.
If the system call name from the metadata is not successfully mapped to
a system call number during boot, than the event initialisation routine
will now return an error, preventing the event from being created.

Signed-off-by: Ian Munsie <imunsie@au1.ibm.com>
---
 include/linux/syscalls.h      |    2 ++
 kernel/trace/trace_syscalls.c |    8 ++++++++
 2 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h
index 18cd068..2e5a68d 100644
--- a/include/linux/syscalls.h
+++ b/include/linux/syscalls.h
@@ -160,6 +160,7 @@ extern struct trace_event_functions exit_syscall_print_funcs;
 	  __attribute__((section("__syscalls_metadata")))	\
 	  __syscall_meta_##sname = {				\
 		.name 		= "sys"#sname,			\
+		.syscall_nr	= -1,	/* Filled in at boot */	\
 		.nb_args 	= nb,				\
 		.types		= types_##sname,		\
 		.args		= args_##sname,			\
@@ -176,6 +177,7 @@ extern struct trace_event_functions exit_syscall_print_funcs;
 	  __attribute__((section("__syscalls_metadata")))	\
 	  __syscall_meta__##sname = {				\
 		.name 		= "sys_"#sname,			\
+		.syscall_nr	= -1,	/* Filled in at boot */	\
 		.nb_args 	= 0,				\
 		.enter_event	= &event_enter__##sname,	\
 		.exit_event	= &event_exit__##sname,		\
diff --git a/kernel/trace/trace_syscalls.c b/kernel/trace/trace_syscalls.c
index b706529..a66bc13 100644
--- a/kernel/trace/trace_syscalls.c
+++ b/kernel/trace/trace_syscalls.c
@@ -423,6 +423,14 @@ void unreg_event_syscall_exit(struct ftrace_event_call *call)
 int init_syscall_trace(struct ftrace_event_call *call)
 {
 	int id;
+	int num;
+
+	num = ((struct syscall_metadata *)call->data)->syscall_nr;
+	if (num < 0 || num >= NR_syscalls) {
+		pr_debug("syscall %s metadata not mapped, disabling ftrace event\n",
+				((struct syscall_metadata *)call->data)->name);
+		return -ENOSYS;
+	}
 
 	if (set_syscall_print_fmt(call) < 0)
 		return -ENOMEM;
-- 
1.7.2.3

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

* [PATCH 2/6] ftrace syscalls: Convert redundant syscall_nr checks into WARN_ON
  2011-02-03  3:27 ` Ian Munsie
@ 2011-02-03  3:27   ` Ian Munsie
  -1 siblings, 0 replies; 30+ messages in thread
From: Ian Munsie @ 2011-02-03  3:27 UTC (permalink / raw)
  To: linux-kernel
  Cc: Andreas Dilger, Dave Kleikamp, Andrew Morton, Jiri Kosina,
	Jason Baron, linuxppc-dev, Steven Rostedt, Alexander Graf,
	Ingo Molnar, Paul Mackerras, KOSAKI Motohiro,
	Frederic Weisbecker, Scott Wood, Nathan Lynch, Avantika Mathur,
	David Gibson, Andreas Schwab, Namhyung Kim, Ian Munsie

From: Ian Munsie <imunsie@au1.ibm.com>

With the ftrace events now checking if the syscall_nr is valid upon
initialisation it should no longer be possible to register or unregister
a syscall event without a valid syscall_nr since they should not be
created. This adds a WARN_ON_ONCE in the register and unregister
functions to locate potential regressions in the future.

Signed-off-by: Ian Munsie <imunsie@au1.ibm.com>
---
 kernel/trace/trace_syscalls.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/kernel/trace/trace_syscalls.c b/kernel/trace/trace_syscalls.c
index a66bc13..1a6e8dd 100644
--- a/kernel/trace/trace_syscalls.c
+++ b/kernel/trace/trace_syscalls.c
@@ -358,7 +358,7 @@ int reg_event_syscall_enter(struct ftrace_event_call *call)
 	int num;
 
 	num = ((struct syscall_metadata *)call->data)->syscall_nr;
-	if (num < 0 || num >= NR_syscalls)
+	if (WARN_ON_ONCE(num < 0 || num >= NR_syscalls))
 		return -ENOSYS;
 	mutex_lock(&syscall_trace_lock);
 	if (!sys_refcount_enter)
@@ -376,7 +376,7 @@ void unreg_event_syscall_enter(struct ftrace_event_call *call)
 	int num;
 
 	num = ((struct syscall_metadata *)call->data)->syscall_nr;
-	if (num < 0 || num >= NR_syscalls)
+	if (WARN_ON_ONCE(num < 0 || num >= NR_syscalls))
 		return;
 	mutex_lock(&syscall_trace_lock);
 	sys_refcount_enter--;
@@ -392,7 +392,7 @@ int reg_event_syscall_exit(struct ftrace_event_call *call)
 	int num;
 
 	num = ((struct syscall_metadata *)call->data)->syscall_nr;
-	if (num < 0 || num >= NR_syscalls)
+	if (WARN_ON_ONCE(num < 0 || num >= NR_syscalls))
 		return -ENOSYS;
 	mutex_lock(&syscall_trace_lock);
 	if (!sys_refcount_exit)
@@ -410,7 +410,7 @@ void unreg_event_syscall_exit(struct ftrace_event_call *call)
 	int num;
 
 	num = ((struct syscall_metadata *)call->data)->syscall_nr;
-	if (num < 0 || num >= NR_syscalls)
+	if (WARN_ON_ONCE(num < 0 || num >= NR_syscalls))
 		return;
 	mutex_lock(&syscall_trace_lock);
 	sys_refcount_exit--;
-- 
1.7.2.3


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

* [PATCH 2/6] ftrace syscalls: Convert redundant syscall_nr checks into WARN_ON
@ 2011-02-03  3:27   ` Ian Munsie
  0 siblings, 0 replies; 30+ messages in thread
From: Ian Munsie @ 2011-02-03  3:27 UTC (permalink / raw)
  To: linux-kernel
  Cc: Andreas Dilger, Andreas Schwab, Dave Kleikamp, Namhyung Kim,
	Jiri Kosina, Jason Baron, Alexander Graf, Steven Rostedt,
	David Gibson, Ingo Molnar, Paul Mackerras, Ian Munsie,
	KOSAKI Motohiro, Frederic Weisbecker, Scott Wood, Nathan Lynch,
	Andrew Morton, linuxppc-dev, Avantika Mathur

From: Ian Munsie <imunsie@au1.ibm.com>

With the ftrace events now checking if the syscall_nr is valid upon
initialisation it should no longer be possible to register or unregister
a syscall event without a valid syscall_nr since they should not be
created. This adds a WARN_ON_ONCE in the register and unregister
functions to locate potential regressions in the future.

Signed-off-by: Ian Munsie <imunsie@au1.ibm.com>
---
 kernel/trace/trace_syscalls.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/kernel/trace/trace_syscalls.c b/kernel/trace/trace_syscalls.c
index a66bc13..1a6e8dd 100644
--- a/kernel/trace/trace_syscalls.c
+++ b/kernel/trace/trace_syscalls.c
@@ -358,7 +358,7 @@ int reg_event_syscall_enter(struct ftrace_event_call *call)
 	int num;
 
 	num = ((struct syscall_metadata *)call->data)->syscall_nr;
-	if (num < 0 || num >= NR_syscalls)
+	if (WARN_ON_ONCE(num < 0 || num >= NR_syscalls))
 		return -ENOSYS;
 	mutex_lock(&syscall_trace_lock);
 	if (!sys_refcount_enter)
@@ -376,7 +376,7 @@ void unreg_event_syscall_enter(struct ftrace_event_call *call)
 	int num;
 
 	num = ((struct syscall_metadata *)call->data)->syscall_nr;
-	if (num < 0 || num >= NR_syscalls)
+	if (WARN_ON_ONCE(num < 0 || num >= NR_syscalls))
 		return;
 	mutex_lock(&syscall_trace_lock);
 	sys_refcount_enter--;
@@ -392,7 +392,7 @@ int reg_event_syscall_exit(struct ftrace_event_call *call)
 	int num;
 
 	num = ((struct syscall_metadata *)call->data)->syscall_nr;
-	if (num < 0 || num >= NR_syscalls)
+	if (WARN_ON_ONCE(num < 0 || num >= NR_syscalls))
 		return -ENOSYS;
 	mutex_lock(&syscall_trace_lock);
 	if (!sys_refcount_exit)
@@ -410,7 +410,7 @@ void unreg_event_syscall_exit(struct ftrace_event_call *call)
 	int num;
 
 	num = ((struct syscall_metadata *)call->data)->syscall_nr;
-	if (num < 0 || num >= NR_syscalls)
+	if (WARN_ON_ONCE(num < 0 || num >= NR_syscalls))
 		return;
 	mutex_lock(&syscall_trace_lock);
 	sys_refcount_exit--;
-- 
1.7.2.3

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

* [PATCH 3/6] ftrace syscalls: Make arch_syscall_addr weak
  2011-02-03  3:27 ` Ian Munsie
@ 2011-02-03  3:27   ` Ian Munsie
  -1 siblings, 0 replies; 30+ messages in thread
From: Ian Munsie @ 2011-02-03  3:27 UTC (permalink / raw)
  To: linux-kernel
  Cc: Andreas Dilger, Dave Kleikamp, Andrew Morton, Jiri Kosina,
	Jason Baron, linuxppc-dev, Steven Rostedt, Alexander Graf,
	Ingo Molnar, Paul Mackerras, KOSAKI Motohiro,
	Frederic Weisbecker, Scott Wood, Nathan Lynch, Avantika Mathur,
	David Gibson, Andreas Schwab, Namhyung Kim, Ian Munsie,
	open list:DOCUMENTATION

From: Ian Munsie <imunsie@au1.ibm.com>

Some architectures use non-trivial system call tables and will not work
with the generic arch_syscall_addr code. For example, PowerPC64 uses a
table of twin long longs.

This patch makes the generic arch_syscall_addr weak to allow
architectures with non-trivial system call tables to override it.

Signed-off-by: Ian Munsie <imunsie@au1.ibm.com>
---
 Documentation/trace/ftrace-design.txt |    3 +++
 kernel/trace/trace_syscalls.c         |    2 +-
 2 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/Documentation/trace/ftrace-design.txt b/Documentation/trace/ftrace-design.txt
index dc52bd4..6fca17b 100644
--- a/Documentation/trace/ftrace-design.txt
+++ b/Documentation/trace/ftrace-design.txt
@@ -247,6 +247,9 @@ You need very few things to get the syscalls tracing in an arch.
 - Support the TIF_SYSCALL_TRACEPOINT thread flags.
 - Put the trace_sys_enter() and trace_sys_exit() tracepoints calls from ptrace
   in the ptrace syscalls tracing path.
+- If the system call table on this arch is more complicated than a simple array
+  of addresses of the system calls, implement an arch_syscall_addr to return
+  the address of a given system call.
 - Tag this arch as HAVE_SYSCALL_TRACEPOINTS.
 
 
diff --git a/kernel/trace/trace_syscalls.c b/kernel/trace/trace_syscalls.c
index 1a6e8dd..33360b9 100644
--- a/kernel/trace/trace_syscalls.c
+++ b/kernel/trace/trace_syscalls.c
@@ -445,7 +445,7 @@ int init_syscall_trace(struct ftrace_event_call *call)
 	return id;
 }
 
-unsigned long __init arch_syscall_addr(int nr)
+unsigned long __init __weak arch_syscall_addr(int nr)
 {
 	return (unsigned long)sys_call_table[nr];
 }
-- 
1.7.2.3


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

* [PATCH 3/6] ftrace syscalls: Make arch_syscall_addr weak
@ 2011-02-03  3:27   ` Ian Munsie
  0 siblings, 0 replies; 30+ messages in thread
From: Ian Munsie @ 2011-02-03  3:27 UTC (permalink / raw)
  To: linux-kernel
  Cc: Andreas Dilger, Andreas Schwab, Dave Kleikamp,
	open list:DOCUMENTATION, Namhyung Kim, Jiri Kosina, Jason Baron,
	Alexander Graf, Steven Rostedt, David Gibson, Ingo Molnar,
	Paul Mackerras, Ian Munsie, KOSAKI Motohiro, Frederic Weisbecker,
	Scott Wood, Nathan Lynch, Andrew Morton, linuxppc-dev,
	Avantika Mathur

From: Ian Munsie <imunsie@au1.ibm.com>

Some architectures use non-trivial system call tables and will not work
with the generic arch_syscall_addr code. For example, PowerPC64 uses a
table of twin long longs.

This patch makes the generic arch_syscall_addr weak to allow
architectures with non-trivial system call tables to override it.

Signed-off-by: Ian Munsie <imunsie@au1.ibm.com>
---
 Documentation/trace/ftrace-design.txt |    3 +++
 kernel/trace/trace_syscalls.c         |    2 +-
 2 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/Documentation/trace/ftrace-design.txt b/Documentation/trace/ftrace-design.txt
index dc52bd4..6fca17b 100644
--- a/Documentation/trace/ftrace-design.txt
+++ b/Documentation/trace/ftrace-design.txt
@@ -247,6 +247,9 @@ You need very few things to get the syscalls tracing in an arch.
 - Support the TIF_SYSCALL_TRACEPOINT thread flags.
 - Put the trace_sys_enter() and trace_sys_exit() tracepoints calls from ptrace
   in the ptrace syscalls tracing path.
+- If the system call table on this arch is more complicated than a simple array
+  of addresses of the system calls, implement an arch_syscall_addr to return
+  the address of a given system call.
 - Tag this arch as HAVE_SYSCALL_TRACEPOINTS.
 
 
diff --git a/kernel/trace/trace_syscalls.c b/kernel/trace/trace_syscalls.c
index 1a6e8dd..33360b9 100644
--- a/kernel/trace/trace_syscalls.c
+++ b/kernel/trace/trace_syscalls.c
@@ -445,7 +445,7 @@ int init_syscall_trace(struct ftrace_event_call *call)
 	return id;
 }
 
-unsigned long __init arch_syscall_addr(int nr)
+unsigned long __init __weak arch_syscall_addr(int nr)
 {
 	return (unsigned long)sys_call_table[nr];
 }
-- 
1.7.2.3

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

* [PATCH 4/6] ftrace syscalls: Allow arch specific syscall symbol matching
  2011-02-03  3:27 ` Ian Munsie
@ 2011-02-03  3:27   ` Ian Munsie
  -1 siblings, 0 replies; 30+ messages in thread
From: Ian Munsie @ 2011-02-03  3:27 UTC (permalink / raw)
  To: linux-kernel
  Cc: Andreas Dilger, Dave Kleikamp, Andrew Morton, Jiri Kosina,
	Jason Baron, linuxppc-dev, Steven Rostedt, Alexander Graf,
	Ingo Molnar, Paul Mackerras, KOSAKI Motohiro,
	Frederic Weisbecker, Scott Wood, Nathan Lynch, Avantika Mathur,
	David Gibson, Andreas Schwab, Namhyung Kim, Ian Munsie,
	open list:DOCUMENTATION

From: Ian Munsie <imunsie@au1.ibm.com>

Some architectures have unusual symbol names and the generic code to
match the symbol name with the function name for the syscall metadata
will fail. For example, symbols on PPC64 start with a period and the
generic code will fail to match them.

This patch moves the match logic out into a separate function which an
arch can override by defining ARCH_HAS_SYSCALL_MATCH_SYM_NAME in
asm/ftrace.h and implementing arch_syscall_match_sym_name.

Signed-off-by: Ian Munsie <imunsie@au1.ibm.com>
---
 Documentation/trace/ftrace-design.txt |    4 ++++
 kernel/trace/trace_syscalls.c         |   21 ++++++++++++++-------
 2 files changed, 18 insertions(+), 7 deletions(-)

diff --git a/Documentation/trace/ftrace-design.txt b/Documentation/trace/ftrace-design.txt
index 6fca17b..79fcafc 100644
--- a/Documentation/trace/ftrace-design.txt
+++ b/Documentation/trace/ftrace-design.txt
@@ -250,6 +250,10 @@ You need very few things to get the syscalls tracing in an arch.
 - If the system call table on this arch is more complicated than a simple array
   of addresses of the system calls, implement an arch_syscall_addr to return
   the address of a given system call.
+- If the symbol names of the system calls do not match the function names on
+  this arch, define ARCH_HAS_SYSCALL_MATCH_SYM_NAME in asm/ftrace.h and
+  implement arch_syscall_match_sym_name with the appropriate logic to return
+  true if the function name corresponds with the symbol name.
 - Tag this arch as HAVE_SYSCALL_TRACEPOINTS.
 
 
diff --git a/kernel/trace/trace_syscalls.c b/kernel/trace/trace_syscalls.c
index 33360b9..7b76a65 100644
--- a/kernel/trace/trace_syscalls.c
+++ b/kernel/trace/trace_syscalls.c
@@ -60,6 +60,19 @@ extern unsigned long __stop_syscalls_metadata[];
 
 static struct syscall_metadata **syscalls_metadata;
 
+#ifndef ARCH_HAS_SYSCALL_MATCH_SYM_NAME
+static inline bool arch_syscall_match_sym_name(const char *sym, const char *name)
+{
+	/*
+	 * Only compare after the "sys" prefix. Archs that use
+	 * syscall wrappers may have syscalls symbols aliases prefixed
+	 * with "SyS" instead of "sys", leading to an unwanted
+	 * mismatch.
+	 */
+	return !strcmp(sym + 3, name + 3);
+}
+#endif
+
 static struct syscall_metadata *find_syscall_meta(unsigned long syscall)
 {
 	struct syscall_metadata *start;
@@ -72,13 +85,7 @@ static struct syscall_metadata *find_syscall_meta(unsigned long syscall)
 	kallsyms_lookup(syscall, NULL, NULL, NULL, str);
 
 	for ( ; start < stop; start++) {
-		/*
-		 * Only compare after the "sys" prefix. Archs that use
-		 * syscall wrappers may have syscalls symbols aliases prefixed
-		 * with "SyS" instead of "sys", leading to an unwanted
-		 * mismatch.
-		 */
-		if (start->name && !strcmp(start->name + 3, str + 3))
+		if (start->name && arch_syscall_match_sym_name(str, start->name))
 			return start;
 	}
 	return NULL;
-- 
1.7.2.3


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

* [PATCH 4/6] ftrace syscalls: Allow arch specific syscall symbol matching
@ 2011-02-03  3:27   ` Ian Munsie
  0 siblings, 0 replies; 30+ messages in thread
From: Ian Munsie @ 2011-02-03  3:27 UTC (permalink / raw)
  To: linux-kernel
  Cc: Andreas Dilger, Andreas Schwab, Dave Kleikamp,
	open list:DOCUMENTATION, Namhyung Kim, Jiri Kosina, Jason Baron,
	Alexander Graf, Steven Rostedt, David Gibson, Ingo Molnar,
	Paul Mackerras, Ian Munsie, KOSAKI Motohiro, Frederic Weisbecker,
	Scott Wood, Nathan Lynch, Andrew Morton, linuxppc-dev,
	Avantika Mathur

From: Ian Munsie <imunsie@au1.ibm.com>

Some architectures have unusual symbol names and the generic code to
match the symbol name with the function name for the syscall metadata
will fail. For example, symbols on PPC64 start with a period and the
generic code will fail to match them.

This patch moves the match logic out into a separate function which an
arch can override by defining ARCH_HAS_SYSCALL_MATCH_SYM_NAME in
asm/ftrace.h and implementing arch_syscall_match_sym_name.

Signed-off-by: Ian Munsie <imunsie@au1.ibm.com>
---
 Documentation/trace/ftrace-design.txt |    4 ++++
 kernel/trace/trace_syscalls.c         |   21 ++++++++++++++-------
 2 files changed, 18 insertions(+), 7 deletions(-)

diff --git a/Documentation/trace/ftrace-design.txt b/Documentation/trace/ftrace-design.txt
index 6fca17b..79fcafc 100644
--- a/Documentation/trace/ftrace-design.txt
+++ b/Documentation/trace/ftrace-design.txt
@@ -250,6 +250,10 @@ You need very few things to get the syscalls tracing in an arch.
 - If the system call table on this arch is more complicated than a simple array
   of addresses of the system calls, implement an arch_syscall_addr to return
   the address of a given system call.
+- If the symbol names of the system calls do not match the function names on
+  this arch, define ARCH_HAS_SYSCALL_MATCH_SYM_NAME in asm/ftrace.h and
+  implement arch_syscall_match_sym_name with the appropriate logic to return
+  true if the function name corresponds with the symbol name.
 - Tag this arch as HAVE_SYSCALL_TRACEPOINTS.
 
 
diff --git a/kernel/trace/trace_syscalls.c b/kernel/trace/trace_syscalls.c
index 33360b9..7b76a65 100644
--- a/kernel/trace/trace_syscalls.c
+++ b/kernel/trace/trace_syscalls.c
@@ -60,6 +60,19 @@ extern unsigned long __stop_syscalls_metadata[];
 
 static struct syscall_metadata **syscalls_metadata;
 
+#ifndef ARCH_HAS_SYSCALL_MATCH_SYM_NAME
+static inline bool arch_syscall_match_sym_name(const char *sym, const char *name)
+{
+	/*
+	 * Only compare after the "sys" prefix. Archs that use
+	 * syscall wrappers may have syscalls symbols aliases prefixed
+	 * with "SyS" instead of "sys", leading to an unwanted
+	 * mismatch.
+	 */
+	return !strcmp(sym + 3, name + 3);
+}
+#endif
+
 static struct syscall_metadata *find_syscall_meta(unsigned long syscall)
 {
 	struct syscall_metadata *start;
@@ -72,13 +85,7 @@ static struct syscall_metadata *find_syscall_meta(unsigned long syscall)
 	kallsyms_lookup(syscall, NULL, NULL, NULL, str);
 
 	for ( ; start < stop; start++) {
-		/*
-		 * Only compare after the "sys" prefix. Archs that use
-		 * syscall wrappers may have syscalls symbols aliases prefixed
-		 * with "SyS" instead of "sys", leading to an unwanted
-		 * mismatch.
-		 */
-		if (start->name && !strcmp(start->name + 3, str + 3))
+		if (start->name && arch_syscall_match_sym_name(str, start->name))
 			return start;
 	}
 	return NULL;
-- 
1.7.2.3

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

* [PATCH 5/6] ftrace, powerpc: Implement raw syscall tracepoints on PowerPC
  2011-02-03  3:27 ` Ian Munsie
@ 2011-02-03  3:27   ` Ian Munsie
  -1 siblings, 0 replies; 30+ messages in thread
From: Ian Munsie @ 2011-02-03  3:27 UTC (permalink / raw)
  To: linux-kernel
  Cc: Andreas Dilger, Dave Kleikamp, Andrew Morton, Jiri Kosina,
	Jason Baron, linuxppc-dev, Steven Rostedt, Alexander Graf,
	Ingo Molnar, Paul Mackerras, KOSAKI Motohiro,
	Frederic Weisbecker, Scott Wood, Nathan Lynch, Avantika Mathur,
	David Gibson, Andreas Schwab, Namhyung Kim, Ian Munsie,
	Ian Munsie

From: Ian Munsie <imunsie@au.ibm.com>

This patch implements the raw syscall tracepoints on PowerPC and exports
them for ftrace syscalls to use.

To minimise reworking existing code, I slightly re-ordered the thread
info flags such that the new TIF_SYSCALL_TRACEPOINT bit would still fit
within the 16 bits of the andi. instruction's UI field. The instructions
in question are in /arch/powerpc/kernel/entry_{32,64}.S to and the
_TIF_SYSCALL_T_OR_A with the thread flags to see if system call tracing
is enabled.

In the case of 64bit PowerPC, arch_syscall_addr and
arch_syscall_match_sym_name are overridden to allow ftrace syscalls to
work given the unusual system call table structure and symbol names that
start with a period.

Signed-off-by: Ian Munsie <imunsie@au1.ibm.com>
---
 arch/powerpc/Kconfig                   |    1 +
 arch/powerpc/include/asm/ftrace.h      |   14 ++++++++++++++
 arch/powerpc/include/asm/syscall.h     |    5 +++++
 arch/powerpc/include/asm/thread_info.h |    7 +++++--
 arch/powerpc/kernel/Makefile           |    1 +
 arch/powerpc/kernel/ftrace.c           |    8 ++++++++
 arch/powerpc/kernel/ptrace.c           |   10 ++++++++++
 7 files changed, 44 insertions(+), 2 deletions(-)

diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index 7d69e9b..a0e8e02 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -134,6 +134,7 @@ config PPC
 	select HAVE_GENERIC_HARDIRQS
 	select HAVE_SPARSE_IRQ
 	select IRQ_PER_CPU
+	select HAVE_SYSCALL_TRACEPOINTS
 
 config EARLY_PRINTK
 	bool
diff --git a/arch/powerpc/include/asm/ftrace.h b/arch/powerpc/include/asm/ftrace.h
index dde1296..169d039 100644
--- a/arch/powerpc/include/asm/ftrace.h
+++ b/arch/powerpc/include/asm/ftrace.h
@@ -60,4 +60,18 @@ struct dyn_arch_ftrace {
 
 #endif
 
+#if defined(CONFIG_FTRACE_SYSCALLS) && defined(CONFIG_PPC64) && !defined(__ASSEMBLY__)
+#define ARCH_HAS_SYSCALL_MATCH_SYM_NAME
+static inline bool arch_syscall_match_sym_name(const char *sym, const char *name)
+{
+	/*
+	 * Compare the symbol name with the system call name. Skip the .sys or .SyS
+	 * prefix from the symbol name and the sys prefix from the system call name and
+	 * just match the rest. This is only needed on ppc64 since symbol names on
+	 * 32bit do not start with a period so the generic function will work.
+	 */
+	return !strcmp(sym + 4, name + 3);
+}
+#endif /* CONFIG_FTRACE_SYSCALLS && CONFIG_PPC64 && !__ASSEMBLY__ */
+
 #endif /* _ASM_POWERPC_FTRACE */
diff --git a/arch/powerpc/include/asm/syscall.h b/arch/powerpc/include/asm/syscall.h
index 23913e9..b54b2ad 100644
--- a/arch/powerpc/include/asm/syscall.h
+++ b/arch/powerpc/include/asm/syscall.h
@@ -15,6 +15,11 @@
 
 #include <linux/sched.h>
 
+/* ftrace syscalls requires exporting the sys_call_table */
+#ifdef CONFIG_FTRACE_SYSCALLS
+extern const unsigned long *sys_call_table;
+#endif /* CONFIG_FTRACE_SYSCALLS */
+
 static inline long syscall_get_nr(struct task_struct *task,
 				  struct pt_regs *regs)
 {
diff --git a/arch/powerpc/include/asm/thread_info.h b/arch/powerpc/include/asm/thread_info.h
index 65eb859..4403f09 100644
--- a/arch/powerpc/include/asm/thread_info.h
+++ b/arch/powerpc/include/asm/thread_info.h
@@ -110,7 +110,8 @@ static inline struct thread_info *current_thread_info(void)
 #define TIF_NOERROR		12	/* Force successful syscall return */
 #define TIF_NOTIFY_RESUME	13	/* callback before returning to user */
 #define TIF_FREEZE		14	/* Freezing for suspend */
-#define TIF_RUNLATCH		15	/* Is the runlatch enabled? */
+#define TIF_SYSCALL_TRACEPOINT	15	/* syscall tracepoint instrumentation */
+#define TIF_RUNLATCH		16	/* Is the runlatch enabled? */
 
 /* as above, but as bit values */
 #define _TIF_SYSCALL_TRACE	(1<<TIF_SYSCALL_TRACE)
@@ -127,8 +128,10 @@ static inline struct thread_info *current_thread_info(void)
 #define _TIF_NOERROR		(1<<TIF_NOERROR)
 #define _TIF_NOTIFY_RESUME	(1<<TIF_NOTIFY_RESUME)
 #define _TIF_FREEZE		(1<<TIF_FREEZE)
+#define _TIF_SYSCALL_TRACEPOINT	(1<<TIF_SYSCALL_TRACEPOINT)
 #define _TIF_RUNLATCH		(1<<TIF_RUNLATCH)
-#define _TIF_SYSCALL_T_OR_A	(_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT|_TIF_SECCOMP)
+#define _TIF_SYSCALL_T_OR_A	(_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | \
+				 _TIF_SECCOMP | _TIF_SYSCALL_TRACEPOINT)
 
 #define _TIF_USER_WORK_MASK	(_TIF_SIGPENDING | _TIF_NEED_RESCHED | \
 				 _TIF_NOTIFY_RESUME)
diff --git a/arch/powerpc/kernel/Makefile b/arch/powerpc/kernel/Makefile
index 3bb2a3e..fe1ac47 100644
--- a/arch/powerpc/kernel/Makefile
+++ b/arch/powerpc/kernel/Makefile
@@ -105,6 +105,7 @@ obj64-$(CONFIG_AUDIT)		+= compat_audit.o
 
 obj-$(CONFIG_DYNAMIC_FTRACE)	+= ftrace.o
 obj-$(CONFIG_FUNCTION_GRAPH_TRACER)	+= ftrace.o
+obj-$(CONFIG_FTRACE_SYSCALLS)	+= ftrace.o
 obj-$(CONFIG_PERF_EVENTS)	+= perf_callchain.o
 
 obj-$(CONFIG_PPC_PERF_CTRS)	+= perf_event.o
diff --git a/arch/powerpc/kernel/ftrace.c b/arch/powerpc/kernel/ftrace.c
index ce1f3e4..bf99cfa 100644
--- a/arch/powerpc/kernel/ftrace.c
+++ b/arch/powerpc/kernel/ftrace.c
@@ -22,6 +22,7 @@
 #include <asm/cacheflush.h>
 #include <asm/code-patching.h>
 #include <asm/ftrace.h>
+#include <asm/syscall.h>
 
 
 #ifdef CONFIG_DYNAMIC_FTRACE
@@ -600,3 +601,10 @@ void prepare_ftrace_return(unsigned long *parent, unsigned long self_addr)
 	}
 }
 #endif /* CONFIG_FUNCTION_GRAPH_TRACER */
+
+#if defined(CONFIG_FTRACE_SYSCALLS) && defined(CONFIG_PPC64)
+unsigned long __init arch_syscall_addr(int nr)
+{
+	return sys_call_table[nr*2];
+}
+#endif /* CONFIG_FTRACE_SYSCALLS && CONFIG_PPC64 */
diff --git a/arch/powerpc/kernel/ptrace.c b/arch/powerpc/kernel/ptrace.c
index 9065369..b6ff0cb 100644
--- a/arch/powerpc/kernel/ptrace.c
+++ b/arch/powerpc/kernel/ptrace.c
@@ -29,6 +29,7 @@
 #include <linux/signal.h>
 #include <linux/seccomp.h>
 #include <linux/audit.h>
+#include <trace/syscall.h>
 #ifdef CONFIG_PPC32
 #include <linux/module.h>
 #endif
@@ -40,6 +41,9 @@
 #include <asm/pgtable.h>
 #include <asm/system.h>
 
+#define CREATE_TRACE_POINTS
+#include <trace/events/syscalls.h>
+
 /*
  * The parameter save area on the stack is used to store arguments being passed
  * to callee function and is located at fixed offset from stack pointer.
@@ -1691,6 +1695,9 @@ long do_syscall_trace_enter(struct pt_regs *regs)
 		 */
 		ret = -1L;
 
+	if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
+		trace_sys_enter(regs, regs->gpr[0]);
+
 	if (unlikely(current->audit_context)) {
 #ifdef CONFIG_PPC64
 		if (!is_32bit_task())
@@ -1719,6 +1726,9 @@ void do_syscall_trace_leave(struct pt_regs *regs)
 		audit_syscall_exit((regs->ccr&0x10000000)?AUDITSC_FAILURE:AUDITSC_SUCCESS,
 				   regs->result);
 
+	if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
+		trace_sys_exit(regs, regs->result);
+
 	step = test_thread_flag(TIF_SINGLESTEP);
 	if (step || test_thread_flag(TIF_SYSCALL_TRACE))
 		tracehook_report_syscall_exit(regs, step);
-- 
1.7.2.3


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

* [PATCH 5/6] ftrace, powerpc: Implement raw syscall tracepoints on PowerPC
@ 2011-02-03  3:27   ` Ian Munsie
  0 siblings, 0 replies; 30+ messages in thread
From: Ian Munsie @ 2011-02-03  3:27 UTC (permalink / raw)
  To: linux-kernel
  Cc: Andreas Dilger, Andreas Schwab, Dave Kleikamp, Namhyung Kim,
	Jiri Kosina, Jason Baron, Alexander Graf, Steven Rostedt,
	David Gibson, Ingo Molnar, Paul Mackerras, Ian Munsie,
	KOSAKI Motohiro, Frederic Weisbecker, Scott Wood, Nathan Lynch,
	Andrew Morton, linuxppc-dev, Avantika Mathur

From: Ian Munsie <imunsie@au.ibm.com>

This patch implements the raw syscall tracepoints on PowerPC and exports
them for ftrace syscalls to use.

To minimise reworking existing code, I slightly re-ordered the thread
info flags such that the new TIF_SYSCALL_TRACEPOINT bit would still fit
within the 16 bits of the andi. instruction's UI field. The instructions
in question are in /arch/powerpc/kernel/entry_{32,64}.S to and the
_TIF_SYSCALL_T_OR_A with the thread flags to see if system call tracing
is enabled.

In the case of 64bit PowerPC, arch_syscall_addr and
arch_syscall_match_sym_name are overridden to allow ftrace syscalls to
work given the unusual system call table structure and symbol names that
start with a period.

Signed-off-by: Ian Munsie <imunsie@au1.ibm.com>
---
 arch/powerpc/Kconfig                   |    1 +
 arch/powerpc/include/asm/ftrace.h      |   14 ++++++++++++++
 arch/powerpc/include/asm/syscall.h     |    5 +++++
 arch/powerpc/include/asm/thread_info.h |    7 +++++--
 arch/powerpc/kernel/Makefile           |    1 +
 arch/powerpc/kernel/ftrace.c           |    8 ++++++++
 arch/powerpc/kernel/ptrace.c           |   10 ++++++++++
 7 files changed, 44 insertions(+), 2 deletions(-)

diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index 7d69e9b..a0e8e02 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -134,6 +134,7 @@ config PPC
 	select HAVE_GENERIC_HARDIRQS
 	select HAVE_SPARSE_IRQ
 	select IRQ_PER_CPU
+	select HAVE_SYSCALL_TRACEPOINTS
 
 config EARLY_PRINTK
 	bool
diff --git a/arch/powerpc/include/asm/ftrace.h b/arch/powerpc/include/asm/ftrace.h
index dde1296..169d039 100644
--- a/arch/powerpc/include/asm/ftrace.h
+++ b/arch/powerpc/include/asm/ftrace.h
@@ -60,4 +60,18 @@ struct dyn_arch_ftrace {
 
 #endif
 
+#if defined(CONFIG_FTRACE_SYSCALLS) && defined(CONFIG_PPC64) && !defined(__ASSEMBLY__)
+#define ARCH_HAS_SYSCALL_MATCH_SYM_NAME
+static inline bool arch_syscall_match_sym_name(const char *sym, const char *name)
+{
+	/*
+	 * Compare the symbol name with the system call name. Skip the .sys or .SyS
+	 * prefix from the symbol name and the sys prefix from the system call name and
+	 * just match the rest. This is only needed on ppc64 since symbol names on
+	 * 32bit do not start with a period so the generic function will work.
+	 */
+	return !strcmp(sym + 4, name + 3);
+}
+#endif /* CONFIG_FTRACE_SYSCALLS && CONFIG_PPC64 && !__ASSEMBLY__ */
+
 #endif /* _ASM_POWERPC_FTRACE */
diff --git a/arch/powerpc/include/asm/syscall.h b/arch/powerpc/include/asm/syscall.h
index 23913e9..b54b2ad 100644
--- a/arch/powerpc/include/asm/syscall.h
+++ b/arch/powerpc/include/asm/syscall.h
@@ -15,6 +15,11 @@
 
 #include <linux/sched.h>
 
+/* ftrace syscalls requires exporting the sys_call_table */
+#ifdef CONFIG_FTRACE_SYSCALLS
+extern const unsigned long *sys_call_table;
+#endif /* CONFIG_FTRACE_SYSCALLS */
+
 static inline long syscall_get_nr(struct task_struct *task,
 				  struct pt_regs *regs)
 {
diff --git a/arch/powerpc/include/asm/thread_info.h b/arch/powerpc/include/asm/thread_info.h
index 65eb859..4403f09 100644
--- a/arch/powerpc/include/asm/thread_info.h
+++ b/arch/powerpc/include/asm/thread_info.h
@@ -110,7 +110,8 @@ static inline struct thread_info *current_thread_info(void)
 #define TIF_NOERROR		12	/* Force successful syscall return */
 #define TIF_NOTIFY_RESUME	13	/* callback before returning to user */
 #define TIF_FREEZE		14	/* Freezing for suspend */
-#define TIF_RUNLATCH		15	/* Is the runlatch enabled? */
+#define TIF_SYSCALL_TRACEPOINT	15	/* syscall tracepoint instrumentation */
+#define TIF_RUNLATCH		16	/* Is the runlatch enabled? */
 
 /* as above, but as bit values */
 #define _TIF_SYSCALL_TRACE	(1<<TIF_SYSCALL_TRACE)
@@ -127,8 +128,10 @@ static inline struct thread_info *current_thread_info(void)
 #define _TIF_NOERROR		(1<<TIF_NOERROR)
 #define _TIF_NOTIFY_RESUME	(1<<TIF_NOTIFY_RESUME)
 #define _TIF_FREEZE		(1<<TIF_FREEZE)
+#define _TIF_SYSCALL_TRACEPOINT	(1<<TIF_SYSCALL_TRACEPOINT)
 #define _TIF_RUNLATCH		(1<<TIF_RUNLATCH)
-#define _TIF_SYSCALL_T_OR_A	(_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT|_TIF_SECCOMP)
+#define _TIF_SYSCALL_T_OR_A	(_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | \
+				 _TIF_SECCOMP | _TIF_SYSCALL_TRACEPOINT)
 
 #define _TIF_USER_WORK_MASK	(_TIF_SIGPENDING | _TIF_NEED_RESCHED | \
 				 _TIF_NOTIFY_RESUME)
diff --git a/arch/powerpc/kernel/Makefile b/arch/powerpc/kernel/Makefile
index 3bb2a3e..fe1ac47 100644
--- a/arch/powerpc/kernel/Makefile
+++ b/arch/powerpc/kernel/Makefile
@@ -105,6 +105,7 @@ obj64-$(CONFIG_AUDIT)		+= compat_audit.o
 
 obj-$(CONFIG_DYNAMIC_FTRACE)	+= ftrace.o
 obj-$(CONFIG_FUNCTION_GRAPH_TRACER)	+= ftrace.o
+obj-$(CONFIG_FTRACE_SYSCALLS)	+= ftrace.o
 obj-$(CONFIG_PERF_EVENTS)	+= perf_callchain.o
 
 obj-$(CONFIG_PPC_PERF_CTRS)	+= perf_event.o
diff --git a/arch/powerpc/kernel/ftrace.c b/arch/powerpc/kernel/ftrace.c
index ce1f3e4..bf99cfa 100644
--- a/arch/powerpc/kernel/ftrace.c
+++ b/arch/powerpc/kernel/ftrace.c
@@ -22,6 +22,7 @@
 #include <asm/cacheflush.h>
 #include <asm/code-patching.h>
 #include <asm/ftrace.h>
+#include <asm/syscall.h>
 
 
 #ifdef CONFIG_DYNAMIC_FTRACE
@@ -600,3 +601,10 @@ void prepare_ftrace_return(unsigned long *parent, unsigned long self_addr)
 	}
 }
 #endif /* CONFIG_FUNCTION_GRAPH_TRACER */
+
+#if defined(CONFIG_FTRACE_SYSCALLS) && defined(CONFIG_PPC64)
+unsigned long __init arch_syscall_addr(int nr)
+{
+	return sys_call_table[nr*2];
+}
+#endif /* CONFIG_FTRACE_SYSCALLS && CONFIG_PPC64 */
diff --git a/arch/powerpc/kernel/ptrace.c b/arch/powerpc/kernel/ptrace.c
index 9065369..b6ff0cb 100644
--- a/arch/powerpc/kernel/ptrace.c
+++ b/arch/powerpc/kernel/ptrace.c
@@ -29,6 +29,7 @@
 #include <linux/signal.h>
 #include <linux/seccomp.h>
 #include <linux/audit.h>
+#include <trace/syscall.h>
 #ifdef CONFIG_PPC32
 #include <linux/module.h>
 #endif
@@ -40,6 +41,9 @@
 #include <asm/pgtable.h>
 #include <asm/system.h>
 
+#define CREATE_TRACE_POINTS
+#include <trace/events/syscalls.h>
+
 /*
  * The parameter save area on the stack is used to store arguments being passed
  * to callee function and is located at fixed offset from stack pointer.
@@ -1691,6 +1695,9 @@ long do_syscall_trace_enter(struct pt_regs *regs)
 		 */
 		ret = -1L;
 
+	if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
+		trace_sys_enter(regs, regs->gpr[0]);
+
 	if (unlikely(current->audit_context)) {
 #ifdef CONFIG_PPC64
 		if (!is_32bit_task())
@@ -1719,6 +1726,9 @@ void do_syscall_trace_leave(struct pt_regs *regs)
 		audit_syscall_exit((regs->ccr&0x10000000)?AUDITSC_FAILURE:AUDITSC_SUCCESS,
 				   regs->result);
 
+	if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
+		trace_sys_exit(regs, regs->result);
+
 	step = test_thread_flag(TIF_SINGLESTEP);
 	if (step || test_thread_flag(TIF_SYSCALL_TRACE))
 		tracehook_report_syscall_exit(regs, step);
-- 
1.7.2.3

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

* [PATCH 6/6] ftrace syscalls: Early terminate search for sys_ni_syscall
  2011-02-03  3:27 ` Ian Munsie
@ 2011-02-03  3:27   ` Ian Munsie
  -1 siblings, 0 replies; 30+ messages in thread
From: Ian Munsie @ 2011-02-03  3:27 UTC (permalink / raw)
  To: linux-kernel
  Cc: Andreas Dilger, Dave Kleikamp, Andrew Morton, Jiri Kosina,
	Jason Baron, linuxppc-dev, Steven Rostedt, Alexander Graf,
	Ingo Molnar, Paul Mackerras, KOSAKI Motohiro,
	Frederic Weisbecker, Scott Wood, Nathan Lynch, Avantika Mathur,
	David Gibson, Andreas Schwab, Namhyung Kim, Ian Munsie

From: Ian Munsie <imunsie@au1.ibm.com>

Many system calls are unimplemented and mapped to sys_ni_syscall, but at
boot ftrace would still search through every syscall metadata entry for
a match which wouldn't be there.

This patch adds causes the search to terminate early if the system call
is not mapped.

Signed-off-by: Ian Munsie <imunsie@au1.ibm.com>
---
 kernel/trace/trace_syscalls.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/kernel/trace/trace_syscalls.c b/kernel/trace/trace_syscalls.c
index 7b76a65..f498154 100644
--- a/kernel/trace/trace_syscalls.c
+++ b/kernel/trace/trace_syscalls.c
@@ -84,6 +84,9 @@ static struct syscall_metadata *find_syscall_meta(unsigned long syscall)
 	stop = (struct syscall_metadata *)__stop_syscalls_metadata;
 	kallsyms_lookup(syscall, NULL, NULL, NULL, str);
 
+	if (arch_syscall_match_sym_name(str, "sys_ni_syscall"))
+		return NULL;
+
 	for ( ; start < stop; start++) {
 		if (start->name && arch_syscall_match_sym_name(str, start->name))
 			return start;
-- 
1.7.2.3


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

* [PATCH 6/6] ftrace syscalls: Early terminate search for sys_ni_syscall
@ 2011-02-03  3:27   ` Ian Munsie
  0 siblings, 0 replies; 30+ messages in thread
From: Ian Munsie @ 2011-02-03  3:27 UTC (permalink / raw)
  To: linux-kernel
  Cc: Andreas Dilger, Andreas Schwab, Dave Kleikamp, Namhyung Kim,
	Jiri Kosina, Jason Baron, Alexander Graf, Steven Rostedt,
	David Gibson, Ingo Molnar, Paul Mackerras, Ian Munsie,
	KOSAKI Motohiro, Frederic Weisbecker, Scott Wood, Nathan Lynch,
	Andrew Morton, linuxppc-dev, Avantika Mathur

From: Ian Munsie <imunsie@au1.ibm.com>

Many system calls are unimplemented and mapped to sys_ni_syscall, but at
boot ftrace would still search through every syscall metadata entry for
a match which wouldn't be there.

This patch adds causes the search to terminate early if the system call
is not mapped.

Signed-off-by: Ian Munsie <imunsie@au1.ibm.com>
---
 kernel/trace/trace_syscalls.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/kernel/trace/trace_syscalls.c b/kernel/trace/trace_syscalls.c
index 7b76a65..f498154 100644
--- a/kernel/trace/trace_syscalls.c
+++ b/kernel/trace/trace_syscalls.c
@@ -84,6 +84,9 @@ static struct syscall_metadata *find_syscall_meta(unsigned long syscall)
 	stop = (struct syscall_metadata *)__stop_syscalls_metadata;
 	kallsyms_lookup(syscall, NULL, NULL, NULL, str);
 
+	if (arch_syscall_match_sym_name(str, "sys_ni_syscall"))
+		return NULL;
+
 	for ( ; start < stop; start++) {
 		if (start->name && arch_syscall_match_sym_name(str, start->name))
 			return start;
-- 
1.7.2.3

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

* Re: [PATCH 5/6] ftrace, powerpc: Implement raw syscall tracepoints on PowerPC
  2011-02-03  3:27   ` Ian Munsie
@ 2011-02-08  2:10     ` Steven Rostedt
  -1 siblings, 0 replies; 30+ messages in thread
From: Steven Rostedt @ 2011-02-08  2:10 UTC (permalink / raw)
  To: Ian Munsie, Benjamin Herrenschmidt
  Cc: linux-kernel, Andreas Dilger, Dave Kleikamp, Andrew Morton,
	Jiri Kosina, Jason Baron, linuxppc-dev, Alexander Graf,
	Ingo Molnar, Paul Mackerras, KOSAKI Motohiro,
	Frederic Weisbecker, Scott Wood, Nathan Lynch, Avantika Mathur,
	David Gibson, Andreas Schwab, Namhyung Kim

Ben,

How do you want to work this? Do you want to ack it and I take this
patch with the others through the tracing tree, or do you want to wait
till the tracing tree gets updated into mainline and then pull this in
though the ppc tree. As this touches a bit of the ppc side.

-- Steve


On Thu, 2011-02-03 at 14:27 +1100, Ian Munsie wrote:
> From: Ian Munsie <imunsie@au.ibm.com>
> 
> This patch implements the raw syscall tracepoints on PowerPC and exports
> them for ftrace syscalls to use.
> 
> To minimise reworking existing code, I slightly re-ordered the thread
> info flags such that the new TIF_SYSCALL_TRACEPOINT bit would still fit
> within the 16 bits of the andi. instruction's UI field. The instructions
> in question are in /arch/powerpc/kernel/entry_{32,64}.S to and the
> _TIF_SYSCALL_T_OR_A with the thread flags to see if system call tracing
> is enabled.
> 
> In the case of 64bit PowerPC, arch_syscall_addr and
> arch_syscall_match_sym_name are overridden to allow ftrace syscalls to
> work given the unusual system call table structure and symbol names that
> start with a period.
> 
> Signed-off-by: Ian Munsie <imunsie@au1.ibm.com>
> ---
>  arch/powerpc/Kconfig                   |    1 +
>  arch/powerpc/include/asm/ftrace.h      |   14 ++++++++++++++
>  arch/powerpc/include/asm/syscall.h     |    5 +++++
>  arch/powerpc/include/asm/thread_info.h |    7 +++++--
>  arch/powerpc/kernel/Makefile           |    1 +
>  arch/powerpc/kernel/ftrace.c           |    8 ++++++++
>  arch/powerpc/kernel/ptrace.c           |   10 ++++++++++
>  7 files changed, 44 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
> index 7d69e9b..a0e8e02 100644
> --- a/arch/powerpc/Kconfig
> +++ b/arch/powerpc/Kconfig
> @@ -134,6 +134,7 @@ config PPC
>  	select HAVE_GENERIC_HARDIRQS
>  	select HAVE_SPARSE_IRQ
>  	select IRQ_PER_CPU
> +	select HAVE_SYSCALL_TRACEPOINTS
>  
>  config EARLY_PRINTK
>  	bool
> diff --git a/arch/powerpc/include/asm/ftrace.h b/arch/powerpc/include/asm/ftrace.h
> index dde1296..169d039 100644
> --- a/arch/powerpc/include/asm/ftrace.h
> +++ b/arch/powerpc/include/asm/ftrace.h
> @@ -60,4 +60,18 @@ struct dyn_arch_ftrace {
>  
>  #endif
>  
> +#if defined(CONFIG_FTRACE_SYSCALLS) && defined(CONFIG_PPC64) && !defined(__ASSEMBLY__)
> +#define ARCH_HAS_SYSCALL_MATCH_SYM_NAME
> +static inline bool arch_syscall_match_sym_name(const char *sym, const char *name)
> +{
> +	/*
> +	 * Compare the symbol name with the system call name. Skip the .sys or .SyS
> +	 * prefix from the symbol name and the sys prefix from the system call name and
> +	 * just match the rest. This is only needed on ppc64 since symbol names on
> +	 * 32bit do not start with a period so the generic function will work.
> +	 */
> +	return !strcmp(sym + 4, name + 3);
> +}
> +#endif /* CONFIG_FTRACE_SYSCALLS && CONFIG_PPC64 && !__ASSEMBLY__ */
> +
>  #endif /* _ASM_POWERPC_FTRACE */
> diff --git a/arch/powerpc/include/asm/syscall.h b/arch/powerpc/include/asm/syscall.h
> index 23913e9..b54b2ad 100644
> --- a/arch/powerpc/include/asm/syscall.h
> +++ b/arch/powerpc/include/asm/syscall.h
> @@ -15,6 +15,11 @@
>  
>  #include <linux/sched.h>
>  
> +/* ftrace syscalls requires exporting the sys_call_table */
> +#ifdef CONFIG_FTRACE_SYSCALLS
> +extern const unsigned long *sys_call_table;
> +#endif /* CONFIG_FTRACE_SYSCALLS */
> +
>  static inline long syscall_get_nr(struct task_struct *task,
>  				  struct pt_regs *regs)
>  {
> diff --git a/arch/powerpc/include/asm/thread_info.h b/arch/powerpc/include/asm/thread_info.h
> index 65eb859..4403f09 100644
> --- a/arch/powerpc/include/asm/thread_info.h
> +++ b/arch/powerpc/include/asm/thread_info.h
> @@ -110,7 +110,8 @@ static inline struct thread_info *current_thread_info(void)
>  #define TIF_NOERROR		12	/* Force successful syscall return */
>  #define TIF_NOTIFY_RESUME	13	/* callback before returning to user */
>  #define TIF_FREEZE		14	/* Freezing for suspend */
> -#define TIF_RUNLATCH		15	/* Is the runlatch enabled? */
> +#define TIF_SYSCALL_TRACEPOINT	15	/* syscall tracepoint instrumentation */
> +#define TIF_RUNLATCH		16	/* Is the runlatch enabled? */
>  
>  /* as above, but as bit values */
>  #define _TIF_SYSCALL_TRACE	(1<<TIF_SYSCALL_TRACE)
> @@ -127,8 +128,10 @@ static inline struct thread_info *current_thread_info(void)
>  #define _TIF_NOERROR		(1<<TIF_NOERROR)
>  #define _TIF_NOTIFY_RESUME	(1<<TIF_NOTIFY_RESUME)
>  #define _TIF_FREEZE		(1<<TIF_FREEZE)
> +#define _TIF_SYSCALL_TRACEPOINT	(1<<TIF_SYSCALL_TRACEPOINT)
>  #define _TIF_RUNLATCH		(1<<TIF_RUNLATCH)
> -#define _TIF_SYSCALL_T_OR_A	(_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT|_TIF_SECCOMP)
> +#define _TIF_SYSCALL_T_OR_A	(_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | \
> +				 _TIF_SECCOMP | _TIF_SYSCALL_TRACEPOINT)
>  
>  #define _TIF_USER_WORK_MASK	(_TIF_SIGPENDING | _TIF_NEED_RESCHED | \
>  				 _TIF_NOTIFY_RESUME)
> diff --git a/arch/powerpc/kernel/Makefile b/arch/powerpc/kernel/Makefile
> index 3bb2a3e..fe1ac47 100644
> --- a/arch/powerpc/kernel/Makefile
> +++ b/arch/powerpc/kernel/Makefile
> @@ -105,6 +105,7 @@ obj64-$(CONFIG_AUDIT)		+= compat_audit.o
>  
>  obj-$(CONFIG_DYNAMIC_FTRACE)	+= ftrace.o
>  obj-$(CONFIG_FUNCTION_GRAPH_TRACER)	+= ftrace.o
> +obj-$(CONFIG_FTRACE_SYSCALLS)	+= ftrace.o
>  obj-$(CONFIG_PERF_EVENTS)	+= perf_callchain.o
>  
>  obj-$(CONFIG_PPC_PERF_CTRS)	+= perf_event.o
> diff --git a/arch/powerpc/kernel/ftrace.c b/arch/powerpc/kernel/ftrace.c
> index ce1f3e4..bf99cfa 100644
> --- a/arch/powerpc/kernel/ftrace.c
> +++ b/arch/powerpc/kernel/ftrace.c
> @@ -22,6 +22,7 @@
>  #include <asm/cacheflush.h>
>  #include <asm/code-patching.h>
>  #include <asm/ftrace.h>
> +#include <asm/syscall.h>
>  
> 
>  #ifdef CONFIG_DYNAMIC_FTRACE
> @@ -600,3 +601,10 @@ void prepare_ftrace_return(unsigned long *parent, unsigned long self_addr)
>  	}
>  }
>  #endif /* CONFIG_FUNCTION_GRAPH_TRACER */
> +
> +#if defined(CONFIG_FTRACE_SYSCALLS) && defined(CONFIG_PPC64)
> +unsigned long __init arch_syscall_addr(int nr)
> +{
> +	return sys_call_table[nr*2];
> +}
> +#endif /* CONFIG_FTRACE_SYSCALLS && CONFIG_PPC64 */
> diff --git a/arch/powerpc/kernel/ptrace.c b/arch/powerpc/kernel/ptrace.c
> index 9065369..b6ff0cb 100644
> --- a/arch/powerpc/kernel/ptrace.c
> +++ b/arch/powerpc/kernel/ptrace.c
> @@ -29,6 +29,7 @@
>  #include <linux/signal.h>
>  #include <linux/seccomp.h>
>  #include <linux/audit.h>
> +#include <trace/syscall.h>
>  #ifdef CONFIG_PPC32
>  #include <linux/module.h>
>  #endif
> @@ -40,6 +41,9 @@
>  #include <asm/pgtable.h>
>  #include <asm/system.h>
>  
> +#define CREATE_TRACE_POINTS
> +#include <trace/events/syscalls.h>
> +
>  /*
>   * The parameter save area on the stack is used to store arguments being passed
>   * to callee function and is located at fixed offset from stack pointer.
> @@ -1691,6 +1695,9 @@ long do_syscall_trace_enter(struct pt_regs *regs)
>  		 */
>  		ret = -1L;
>  
> +	if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
> +		trace_sys_enter(regs, regs->gpr[0]);
> +
>  	if (unlikely(current->audit_context)) {
>  #ifdef CONFIG_PPC64
>  		if (!is_32bit_task())
> @@ -1719,6 +1726,9 @@ void do_syscall_trace_leave(struct pt_regs *regs)
>  		audit_syscall_exit((regs->ccr&0x10000000)?AUDITSC_FAILURE:AUDITSC_SUCCESS,
>  				   regs->result);
>  
> +	if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
> +		trace_sys_exit(regs, regs->result);
> +
>  	step = test_thread_flag(TIF_SINGLESTEP);
>  	if (step || test_thread_flag(TIF_SYSCALL_TRACE))
>  		tracehook_report_syscall_exit(regs, step);



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

* Re: [PATCH 5/6] ftrace, powerpc: Implement raw syscall tracepoints on PowerPC
@ 2011-02-08  2:10     ` Steven Rostedt
  0 siblings, 0 replies; 30+ messages in thread
From: Steven Rostedt @ 2011-02-08  2:10 UTC (permalink / raw)
  To: Ian Munsie, Benjamin Herrenschmidt
  Cc: Andreas Dilger, Andreas Schwab, Dave Kleikamp, Namhyung Kim,
	Jiri Kosina, Jason Baron, linux-kernel, Alexander Graf,
	Ingo Molnar, Paul Mackerras, KOSAKI Motohiro,
	Frederic Weisbecker, Scott Wood, Nathan Lynch, Andrew Morton,
	David Gibson, linuxppc-dev, Avantika Mathur

Ben,

How do you want to work this? Do you want to ack it and I take this
patch with the others through the tracing tree, or do you want to wait
till the tracing tree gets updated into mainline and then pull this in
though the ppc tree. As this touches a bit of the ppc side.

-- Steve


On Thu, 2011-02-03 at 14:27 +1100, Ian Munsie wrote:
> From: Ian Munsie <imunsie@au.ibm.com>
> 
> This patch implements the raw syscall tracepoints on PowerPC and exports
> them for ftrace syscalls to use.
> 
> To minimise reworking existing code, I slightly re-ordered the thread
> info flags such that the new TIF_SYSCALL_TRACEPOINT bit would still fit
> within the 16 bits of the andi. instruction's UI field. The instructions
> in question are in /arch/powerpc/kernel/entry_{32,64}.S to and the
> _TIF_SYSCALL_T_OR_A with the thread flags to see if system call tracing
> is enabled.
> 
> In the case of 64bit PowerPC, arch_syscall_addr and
> arch_syscall_match_sym_name are overridden to allow ftrace syscalls to
> work given the unusual system call table structure and symbol names that
> start with a period.
> 
> Signed-off-by: Ian Munsie <imunsie@au1.ibm.com>
> ---
>  arch/powerpc/Kconfig                   |    1 +
>  arch/powerpc/include/asm/ftrace.h      |   14 ++++++++++++++
>  arch/powerpc/include/asm/syscall.h     |    5 +++++
>  arch/powerpc/include/asm/thread_info.h |    7 +++++--
>  arch/powerpc/kernel/Makefile           |    1 +
>  arch/powerpc/kernel/ftrace.c           |    8 ++++++++
>  arch/powerpc/kernel/ptrace.c           |   10 ++++++++++
>  7 files changed, 44 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
> index 7d69e9b..a0e8e02 100644
> --- a/arch/powerpc/Kconfig
> +++ b/arch/powerpc/Kconfig
> @@ -134,6 +134,7 @@ config PPC
>  	select HAVE_GENERIC_HARDIRQS
>  	select HAVE_SPARSE_IRQ
>  	select IRQ_PER_CPU
> +	select HAVE_SYSCALL_TRACEPOINTS
>  
>  config EARLY_PRINTK
>  	bool
> diff --git a/arch/powerpc/include/asm/ftrace.h b/arch/powerpc/include/asm/ftrace.h
> index dde1296..169d039 100644
> --- a/arch/powerpc/include/asm/ftrace.h
> +++ b/arch/powerpc/include/asm/ftrace.h
> @@ -60,4 +60,18 @@ struct dyn_arch_ftrace {
>  
>  #endif
>  
> +#if defined(CONFIG_FTRACE_SYSCALLS) && defined(CONFIG_PPC64) && !defined(__ASSEMBLY__)
> +#define ARCH_HAS_SYSCALL_MATCH_SYM_NAME
> +static inline bool arch_syscall_match_sym_name(const char *sym, const char *name)
> +{
> +	/*
> +	 * Compare the symbol name with the system call name. Skip the .sys or .SyS
> +	 * prefix from the symbol name and the sys prefix from the system call name and
> +	 * just match the rest. This is only needed on ppc64 since symbol names on
> +	 * 32bit do not start with a period so the generic function will work.
> +	 */
> +	return !strcmp(sym + 4, name + 3);
> +}
> +#endif /* CONFIG_FTRACE_SYSCALLS && CONFIG_PPC64 && !__ASSEMBLY__ */
> +
>  #endif /* _ASM_POWERPC_FTRACE */
> diff --git a/arch/powerpc/include/asm/syscall.h b/arch/powerpc/include/asm/syscall.h
> index 23913e9..b54b2ad 100644
> --- a/arch/powerpc/include/asm/syscall.h
> +++ b/arch/powerpc/include/asm/syscall.h
> @@ -15,6 +15,11 @@
>  
>  #include <linux/sched.h>
>  
> +/* ftrace syscalls requires exporting the sys_call_table */
> +#ifdef CONFIG_FTRACE_SYSCALLS
> +extern const unsigned long *sys_call_table;
> +#endif /* CONFIG_FTRACE_SYSCALLS */
> +
>  static inline long syscall_get_nr(struct task_struct *task,
>  				  struct pt_regs *regs)
>  {
> diff --git a/arch/powerpc/include/asm/thread_info.h b/arch/powerpc/include/asm/thread_info.h
> index 65eb859..4403f09 100644
> --- a/arch/powerpc/include/asm/thread_info.h
> +++ b/arch/powerpc/include/asm/thread_info.h
> @@ -110,7 +110,8 @@ static inline struct thread_info *current_thread_info(void)
>  #define TIF_NOERROR		12	/* Force successful syscall return */
>  #define TIF_NOTIFY_RESUME	13	/* callback before returning to user */
>  #define TIF_FREEZE		14	/* Freezing for suspend */
> -#define TIF_RUNLATCH		15	/* Is the runlatch enabled? */
> +#define TIF_SYSCALL_TRACEPOINT	15	/* syscall tracepoint instrumentation */
> +#define TIF_RUNLATCH		16	/* Is the runlatch enabled? */
>  
>  /* as above, but as bit values */
>  #define _TIF_SYSCALL_TRACE	(1<<TIF_SYSCALL_TRACE)
> @@ -127,8 +128,10 @@ static inline struct thread_info *current_thread_info(void)
>  #define _TIF_NOERROR		(1<<TIF_NOERROR)
>  #define _TIF_NOTIFY_RESUME	(1<<TIF_NOTIFY_RESUME)
>  #define _TIF_FREEZE		(1<<TIF_FREEZE)
> +#define _TIF_SYSCALL_TRACEPOINT	(1<<TIF_SYSCALL_TRACEPOINT)
>  #define _TIF_RUNLATCH		(1<<TIF_RUNLATCH)
> -#define _TIF_SYSCALL_T_OR_A	(_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT|_TIF_SECCOMP)
> +#define _TIF_SYSCALL_T_OR_A	(_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | \
> +				 _TIF_SECCOMP | _TIF_SYSCALL_TRACEPOINT)
>  
>  #define _TIF_USER_WORK_MASK	(_TIF_SIGPENDING | _TIF_NEED_RESCHED | \
>  				 _TIF_NOTIFY_RESUME)
> diff --git a/arch/powerpc/kernel/Makefile b/arch/powerpc/kernel/Makefile
> index 3bb2a3e..fe1ac47 100644
> --- a/arch/powerpc/kernel/Makefile
> +++ b/arch/powerpc/kernel/Makefile
> @@ -105,6 +105,7 @@ obj64-$(CONFIG_AUDIT)		+= compat_audit.o
>  
>  obj-$(CONFIG_DYNAMIC_FTRACE)	+= ftrace.o
>  obj-$(CONFIG_FUNCTION_GRAPH_TRACER)	+= ftrace.o
> +obj-$(CONFIG_FTRACE_SYSCALLS)	+= ftrace.o
>  obj-$(CONFIG_PERF_EVENTS)	+= perf_callchain.o
>  
>  obj-$(CONFIG_PPC_PERF_CTRS)	+= perf_event.o
> diff --git a/arch/powerpc/kernel/ftrace.c b/arch/powerpc/kernel/ftrace.c
> index ce1f3e4..bf99cfa 100644
> --- a/arch/powerpc/kernel/ftrace.c
> +++ b/arch/powerpc/kernel/ftrace.c
> @@ -22,6 +22,7 @@
>  #include <asm/cacheflush.h>
>  #include <asm/code-patching.h>
>  #include <asm/ftrace.h>
> +#include <asm/syscall.h>
>  
> 
>  #ifdef CONFIG_DYNAMIC_FTRACE
> @@ -600,3 +601,10 @@ void prepare_ftrace_return(unsigned long *parent, unsigned long self_addr)
>  	}
>  }
>  #endif /* CONFIG_FUNCTION_GRAPH_TRACER */
> +
> +#if defined(CONFIG_FTRACE_SYSCALLS) && defined(CONFIG_PPC64)
> +unsigned long __init arch_syscall_addr(int nr)
> +{
> +	return sys_call_table[nr*2];
> +}
> +#endif /* CONFIG_FTRACE_SYSCALLS && CONFIG_PPC64 */
> diff --git a/arch/powerpc/kernel/ptrace.c b/arch/powerpc/kernel/ptrace.c
> index 9065369..b6ff0cb 100644
> --- a/arch/powerpc/kernel/ptrace.c
> +++ b/arch/powerpc/kernel/ptrace.c
> @@ -29,6 +29,7 @@
>  #include <linux/signal.h>
>  #include <linux/seccomp.h>
>  #include <linux/audit.h>
> +#include <trace/syscall.h>
>  #ifdef CONFIG_PPC32
>  #include <linux/module.h>
>  #endif
> @@ -40,6 +41,9 @@
>  #include <asm/pgtable.h>
>  #include <asm/system.h>
>  
> +#define CREATE_TRACE_POINTS
> +#include <trace/events/syscalls.h>
> +
>  /*
>   * The parameter save area on the stack is used to store arguments being passed
>   * to callee function and is located at fixed offset from stack pointer.
> @@ -1691,6 +1695,9 @@ long do_syscall_trace_enter(struct pt_regs *regs)
>  		 */
>  		ret = -1L;
>  
> +	if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
> +		trace_sys_enter(regs, regs->gpr[0]);
> +
>  	if (unlikely(current->audit_context)) {
>  #ifdef CONFIG_PPC64
>  		if (!is_32bit_task())
> @@ -1719,6 +1726,9 @@ void do_syscall_trace_leave(struct pt_regs *regs)
>  		audit_syscall_exit((regs->ccr&0x10000000)?AUDITSC_FAILURE:AUDITSC_SUCCESS,
>  				   regs->result);
>  
> +	if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
> +		trace_sys_exit(regs, regs->result);
> +
>  	step = test_thread_flag(TIF_SINGLESTEP);
>  	if (step || test_thread_flag(TIF_SYSCALL_TRACE))
>  		tracehook_report_syscall_exit(regs, step);

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

* Re: PowerPC, ftrace: Add PPC raw syscall tracepoints & ftrace fixes (mimimal subset only) v4
  2011-02-03  3:27 ` Ian Munsie
@ 2011-02-08  2:10   ` Steven Rostedt
  -1 siblings, 0 replies; 30+ messages in thread
From: Steven Rostedt @ 2011-02-08  2:10 UTC (permalink / raw)
  To: Ian Munsie
  Cc: linux-kernel, Andreas Dilger, Dave Kleikamp, Andrew Morton,
	Jiri Kosina, Jason Baron, linuxppc-dev, Alexander Graf,
	Ingo Molnar, Paul Mackerras, KOSAKI Motohiro,
	Frederic Weisbecker, Scott Wood, Nathan Lynch, Avantika Mathur,
	David Gibson, Andreas Schwab, Namhyung Kim

On Thu, 2011-02-03 at 14:27 +1100, Ian Munsie wrote:
> Hi All,
> 
> This is a partial version of my 'ftrace syscalls, PowerPC: Various fixes,
> Compat Syscall support and PowerPC implementation'. This is updated from
> yesterday with arch_syscall_addr changed to a static inline function from
> Steven's suggestion.
> 
> This subset implements the raw syscall tracepoints on PowerPC which has been
> requested recently.  It also fixes ftrace syscalls to ensure that events will
> only be created for syscalls that successfully map their metadata to a syscall
> number, so that non-working phantom events are not created. Patches #2 and #6
> in this series are not strictly necessary for this, they just optimise ftrace
> syscalls a bit.
> 
> What's missing from this series that was in the full 40 patch v2 series is the
> conversion of all the syscalls implemented under /arch/powerpc, Jason Baron's
> compat syscall support and the conversion of the remaining native and compat
> syscalls to this infrastructure.

Thanks Ian,

I'll pull this into my local repo and start running my tests on it.

-- Steve



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

* Re: PowerPC, ftrace: Add PPC raw syscall tracepoints & ftrace fixes (mimimal subset only) v4
@ 2011-02-08  2:10   ` Steven Rostedt
  0 siblings, 0 replies; 30+ messages in thread
From: Steven Rostedt @ 2011-02-08  2:10 UTC (permalink / raw)
  To: Ian Munsie
  Cc: Andreas Dilger, Andreas Schwab, Dave Kleikamp, Namhyung Kim,
	Jiri Kosina, Jason Baron, linux-kernel, Alexander Graf,
	Ingo Molnar, Paul Mackerras, KOSAKI Motohiro,
	Frederic Weisbecker, Scott Wood, Nathan Lynch, Andrew Morton,
	David Gibson, linuxppc-dev, Avantika Mathur

On Thu, 2011-02-03 at 14:27 +1100, Ian Munsie wrote:
> Hi All,
> 
> This is a partial version of my 'ftrace syscalls, PowerPC: Various fixes,
> Compat Syscall support and PowerPC implementation'. This is updated from
> yesterday with arch_syscall_addr changed to a static inline function from
> Steven's suggestion.
> 
> This subset implements the raw syscall tracepoints on PowerPC which has been
> requested recently.  It also fixes ftrace syscalls to ensure that events will
> only be created for syscalls that successfully map their metadata to a syscall
> number, so that non-working phantom events are not created. Patches #2 and #6
> in this series are not strictly necessary for this, they just optimise ftrace
> syscalls a bit.
> 
> What's missing from this series that was in the full 40 patch v2 series is the
> conversion of all the syscalls implemented under /arch/powerpc, Jason Baron's
> compat syscall support and the conversion of the remaining native and compat
> syscalls to this infrastructure.

Thanks Ian,

I'll pull this into my local repo and start running my tests on it.

-- Steve

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

* Re: [PATCH 5/6] ftrace, powerpc: Implement raw syscall tracepoints on PowerPC
  2011-02-08  2:10     ` Steven Rostedt
@ 2011-02-08 10:07       ` Benjamin Herrenschmidt
  -1 siblings, 0 replies; 30+ messages in thread
From: Benjamin Herrenschmidt @ 2011-02-08 10:07 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: Ian Munsie, linux-kernel, Andreas Dilger, Dave Kleikamp,
	Andrew Morton, Jiri Kosina, Jason Baron, linuxppc-dev,
	Alexander Graf, Ingo Molnar, Paul Mackerras, KOSAKI Motohiro,
	Frederic Weisbecker, Scott Wood, Nathan Lynch, Avantika Mathur,
	David Gibson, Andreas Schwab, Namhyung Kim

On Mon, 2011-02-07 at 21:10 -0500, Steven Rostedt wrote:
> Ben,
> 
> How do you want to work this? Do you want to ack it and I take this
> patch with the others through the tracing tree, or do you want to wait
> till the tracing tree gets updated into mainline and then pull this in
> though the ppc tree. As this touches a bit of the ppc side.

I was waiting to see what you were up to vs. the rest of the series :-)

I still need to review that one closely, at which point I'm happy for
you to take it.

Cheers,
Ben.

> -- Steve
> 
> 
> On Thu, 2011-02-03 at 14:27 +1100, Ian Munsie wrote:
> > From: Ian Munsie <imunsie@au.ibm.com>
> > 
> > This patch implements the raw syscall tracepoints on PowerPC and exports
> > them for ftrace syscalls to use.
> > 
> > To minimise reworking existing code, I slightly re-ordered the thread
> > info flags such that the new TIF_SYSCALL_TRACEPOINT bit would still fit
> > within the 16 bits of the andi. instruction's UI field. The instructions
> > in question are in /arch/powerpc/kernel/entry_{32,64}.S to and the
> > _TIF_SYSCALL_T_OR_A with the thread flags to see if system call tracing
> > is enabled.
> > 
> > In the case of 64bit PowerPC, arch_syscall_addr and
> > arch_syscall_match_sym_name are overridden to allow ftrace syscalls to
> > work given the unusual system call table structure and symbol names that
> > start with a period.
> > 
> > Signed-off-by: Ian Munsie <imunsie@au1.ibm.com>
> > ---
> >  arch/powerpc/Kconfig                   |    1 +
> >  arch/powerpc/include/asm/ftrace.h      |   14 ++++++++++++++
> >  arch/powerpc/include/asm/syscall.h     |    5 +++++
> >  arch/powerpc/include/asm/thread_info.h |    7 +++++--
> >  arch/powerpc/kernel/Makefile           |    1 +
> >  arch/powerpc/kernel/ftrace.c           |    8 ++++++++
> >  arch/powerpc/kernel/ptrace.c           |   10 ++++++++++
> >  7 files changed, 44 insertions(+), 2 deletions(-)
> > 
> > diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
> > index 7d69e9b..a0e8e02 100644
> > --- a/arch/powerpc/Kconfig
> > +++ b/arch/powerpc/Kconfig
> > @@ -134,6 +134,7 @@ config PPC
> >  	select HAVE_GENERIC_HARDIRQS
> >  	select HAVE_SPARSE_IRQ
> >  	select IRQ_PER_CPU
> > +	select HAVE_SYSCALL_TRACEPOINTS
> >  
> >  config EARLY_PRINTK
> >  	bool
> > diff --git a/arch/powerpc/include/asm/ftrace.h b/arch/powerpc/include/asm/ftrace.h
> > index dde1296..169d039 100644
> > --- a/arch/powerpc/include/asm/ftrace.h
> > +++ b/arch/powerpc/include/asm/ftrace.h
> > @@ -60,4 +60,18 @@ struct dyn_arch_ftrace {
> >  
> >  #endif
> >  
> > +#if defined(CONFIG_FTRACE_SYSCALLS) && defined(CONFIG_PPC64) && !defined(__ASSEMBLY__)
> > +#define ARCH_HAS_SYSCALL_MATCH_SYM_NAME
> > +static inline bool arch_syscall_match_sym_name(const char *sym, const char *name)
> > +{
> > +	/*
> > +	 * Compare the symbol name with the system call name. Skip the .sys or .SyS
> > +	 * prefix from the symbol name and the sys prefix from the system call name and
> > +	 * just match the rest. This is only needed on ppc64 since symbol names on
> > +	 * 32bit do not start with a period so the generic function will work.
> > +	 */
> > +	return !strcmp(sym + 4, name + 3);
> > +}
> > +#endif /* CONFIG_FTRACE_SYSCALLS && CONFIG_PPC64 && !__ASSEMBLY__ */
> > +
> >  #endif /* _ASM_POWERPC_FTRACE */
> > diff --git a/arch/powerpc/include/asm/syscall.h b/arch/powerpc/include/asm/syscall.h
> > index 23913e9..b54b2ad 100644
> > --- a/arch/powerpc/include/asm/syscall.h
> > +++ b/arch/powerpc/include/asm/syscall.h
> > @@ -15,6 +15,11 @@
> >  
> >  #include <linux/sched.h>
> >  
> > +/* ftrace syscalls requires exporting the sys_call_table */
> > +#ifdef CONFIG_FTRACE_SYSCALLS
> > +extern const unsigned long *sys_call_table;
> > +#endif /* CONFIG_FTRACE_SYSCALLS */
> > +
> >  static inline long syscall_get_nr(struct task_struct *task,
> >  				  struct pt_regs *regs)
> >  {
> > diff --git a/arch/powerpc/include/asm/thread_info.h b/arch/powerpc/include/asm/thread_info.h
> > index 65eb859..4403f09 100644
> > --- a/arch/powerpc/include/asm/thread_info.h
> > +++ b/arch/powerpc/include/asm/thread_info.h
> > @@ -110,7 +110,8 @@ static inline struct thread_info *current_thread_info(void)
> >  #define TIF_NOERROR		12	/* Force successful syscall return */
> >  #define TIF_NOTIFY_RESUME	13	/* callback before returning to user */
> >  #define TIF_FREEZE		14	/* Freezing for suspend */
> > -#define TIF_RUNLATCH		15	/* Is the runlatch enabled? */
> > +#define TIF_SYSCALL_TRACEPOINT	15	/* syscall tracepoint instrumentation */
> > +#define TIF_RUNLATCH		16	/* Is the runlatch enabled? */
> >  
> >  /* as above, but as bit values */
> >  #define _TIF_SYSCALL_TRACE	(1<<TIF_SYSCALL_TRACE)
> > @@ -127,8 +128,10 @@ static inline struct thread_info *current_thread_info(void)
> >  #define _TIF_NOERROR		(1<<TIF_NOERROR)
> >  #define _TIF_NOTIFY_RESUME	(1<<TIF_NOTIFY_RESUME)
> >  #define _TIF_FREEZE		(1<<TIF_FREEZE)
> > +#define _TIF_SYSCALL_TRACEPOINT	(1<<TIF_SYSCALL_TRACEPOINT)
> >  #define _TIF_RUNLATCH		(1<<TIF_RUNLATCH)
> > -#define _TIF_SYSCALL_T_OR_A	(_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT|_TIF_SECCOMP)
> > +#define _TIF_SYSCALL_T_OR_A	(_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | \
> > +				 _TIF_SECCOMP | _TIF_SYSCALL_TRACEPOINT)
> >  
> >  #define _TIF_USER_WORK_MASK	(_TIF_SIGPENDING | _TIF_NEED_RESCHED | \
> >  				 _TIF_NOTIFY_RESUME)
> > diff --git a/arch/powerpc/kernel/Makefile b/arch/powerpc/kernel/Makefile
> > index 3bb2a3e..fe1ac47 100644
> > --- a/arch/powerpc/kernel/Makefile
> > +++ b/arch/powerpc/kernel/Makefile
> > @@ -105,6 +105,7 @@ obj64-$(CONFIG_AUDIT)		+= compat_audit.o
> >  
> >  obj-$(CONFIG_DYNAMIC_FTRACE)	+= ftrace.o
> >  obj-$(CONFIG_FUNCTION_GRAPH_TRACER)	+= ftrace.o
> > +obj-$(CONFIG_FTRACE_SYSCALLS)	+= ftrace.o
> >  obj-$(CONFIG_PERF_EVENTS)	+= perf_callchain.o
> >  
> >  obj-$(CONFIG_PPC_PERF_CTRS)	+= perf_event.o
> > diff --git a/arch/powerpc/kernel/ftrace.c b/arch/powerpc/kernel/ftrace.c
> > index ce1f3e4..bf99cfa 100644
> > --- a/arch/powerpc/kernel/ftrace.c
> > +++ b/arch/powerpc/kernel/ftrace.c
> > @@ -22,6 +22,7 @@
> >  #include <asm/cacheflush.h>
> >  #include <asm/code-patching.h>
> >  #include <asm/ftrace.h>
> > +#include <asm/syscall.h>
> >  
> > 
> >  #ifdef CONFIG_DYNAMIC_FTRACE
> > @@ -600,3 +601,10 @@ void prepare_ftrace_return(unsigned long *parent, unsigned long self_addr)
> >  	}
> >  }
> >  #endif /* CONFIG_FUNCTION_GRAPH_TRACER */
> > +
> > +#if defined(CONFIG_FTRACE_SYSCALLS) && defined(CONFIG_PPC64)
> > +unsigned long __init arch_syscall_addr(int nr)
> > +{
> > +	return sys_call_table[nr*2];
> > +}
> > +#endif /* CONFIG_FTRACE_SYSCALLS && CONFIG_PPC64 */
> > diff --git a/arch/powerpc/kernel/ptrace.c b/arch/powerpc/kernel/ptrace.c
> > index 9065369..b6ff0cb 100644
> > --- a/arch/powerpc/kernel/ptrace.c
> > +++ b/arch/powerpc/kernel/ptrace.c
> > @@ -29,6 +29,7 @@
> >  #include <linux/signal.h>
> >  #include <linux/seccomp.h>
> >  #include <linux/audit.h>
> > +#include <trace/syscall.h>
> >  #ifdef CONFIG_PPC32
> >  #include <linux/module.h>
> >  #endif
> > @@ -40,6 +41,9 @@
> >  #include <asm/pgtable.h>
> >  #include <asm/system.h>
> >  
> > +#define CREATE_TRACE_POINTS
> > +#include <trace/events/syscalls.h>
> > +
> >  /*
> >   * The parameter save area on the stack is used to store arguments being passed
> >   * to callee function and is located at fixed offset from stack pointer.
> > @@ -1691,6 +1695,9 @@ long do_syscall_trace_enter(struct pt_regs *regs)
> >  		 */
> >  		ret = -1L;
> >  
> > +	if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
> > +		trace_sys_enter(regs, regs->gpr[0]);
> > +
> >  	if (unlikely(current->audit_context)) {
> >  #ifdef CONFIG_PPC64
> >  		if (!is_32bit_task())
> > @@ -1719,6 +1726,9 @@ void do_syscall_trace_leave(struct pt_regs *regs)
> >  		audit_syscall_exit((regs->ccr&0x10000000)?AUDITSC_FAILURE:AUDITSC_SUCCESS,
> >  				   regs->result);
> >  
> > +	if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
> > +		trace_sys_exit(regs, regs->result);
> > +
> >  	step = test_thread_flag(TIF_SINGLESTEP);
> >  	if (step || test_thread_flag(TIF_SYSCALL_TRACE))
> >  		tracehook_report_syscall_exit(regs, step);
> 



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

* Re: [PATCH 5/6] ftrace, powerpc: Implement raw syscall tracepoints on PowerPC
@ 2011-02-08 10:07       ` Benjamin Herrenschmidt
  0 siblings, 0 replies; 30+ messages in thread
From: Benjamin Herrenschmidt @ 2011-02-08 10:07 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: Andreas Dilger, Andreas Schwab, Dave Kleikamp, Namhyung Kim,
	Jiri Kosina, Jason Baron, linux-kernel, Alexander Graf,
	Ingo Molnar, Paul Mackerras, Ian Munsie, KOSAKI Motohiro,
	Frederic Weisbecker, Scott Wood, Nathan Lynch, Andrew Morton,
	David Gibson, linuxppc-dev, Avantika Mathur

On Mon, 2011-02-07 at 21:10 -0500, Steven Rostedt wrote:
> Ben,
> 
> How do you want to work this? Do you want to ack it and I take this
> patch with the others through the tracing tree, or do you want to wait
> till the tracing tree gets updated into mainline and then pull this in
> though the ppc tree. As this touches a bit of the ppc side.

I was waiting to see what you were up to vs. the rest of the series :-)

I still need to review that one closely, at which point I'm happy for
you to take it.

Cheers,
Ben.

> -- Steve
> 
> 
> On Thu, 2011-02-03 at 14:27 +1100, Ian Munsie wrote:
> > From: Ian Munsie <imunsie@au.ibm.com>
> > 
> > This patch implements the raw syscall tracepoints on PowerPC and exports
> > them for ftrace syscalls to use.
> > 
> > To minimise reworking existing code, I slightly re-ordered the thread
> > info flags such that the new TIF_SYSCALL_TRACEPOINT bit would still fit
> > within the 16 bits of the andi. instruction's UI field. The instructions
> > in question are in /arch/powerpc/kernel/entry_{32,64}.S to and the
> > _TIF_SYSCALL_T_OR_A with the thread flags to see if system call tracing
> > is enabled.
> > 
> > In the case of 64bit PowerPC, arch_syscall_addr and
> > arch_syscall_match_sym_name are overridden to allow ftrace syscalls to
> > work given the unusual system call table structure and symbol names that
> > start with a period.
> > 
> > Signed-off-by: Ian Munsie <imunsie@au1.ibm.com>
> > ---
> >  arch/powerpc/Kconfig                   |    1 +
> >  arch/powerpc/include/asm/ftrace.h      |   14 ++++++++++++++
> >  arch/powerpc/include/asm/syscall.h     |    5 +++++
> >  arch/powerpc/include/asm/thread_info.h |    7 +++++--
> >  arch/powerpc/kernel/Makefile           |    1 +
> >  arch/powerpc/kernel/ftrace.c           |    8 ++++++++
> >  arch/powerpc/kernel/ptrace.c           |   10 ++++++++++
> >  7 files changed, 44 insertions(+), 2 deletions(-)
> > 
> > diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
> > index 7d69e9b..a0e8e02 100644
> > --- a/arch/powerpc/Kconfig
> > +++ b/arch/powerpc/Kconfig
> > @@ -134,6 +134,7 @@ config PPC
> >  	select HAVE_GENERIC_HARDIRQS
> >  	select HAVE_SPARSE_IRQ
> >  	select IRQ_PER_CPU
> > +	select HAVE_SYSCALL_TRACEPOINTS
> >  
> >  config EARLY_PRINTK
> >  	bool
> > diff --git a/arch/powerpc/include/asm/ftrace.h b/arch/powerpc/include/asm/ftrace.h
> > index dde1296..169d039 100644
> > --- a/arch/powerpc/include/asm/ftrace.h
> > +++ b/arch/powerpc/include/asm/ftrace.h
> > @@ -60,4 +60,18 @@ struct dyn_arch_ftrace {
> >  
> >  #endif
> >  
> > +#if defined(CONFIG_FTRACE_SYSCALLS) && defined(CONFIG_PPC64) && !defined(__ASSEMBLY__)
> > +#define ARCH_HAS_SYSCALL_MATCH_SYM_NAME
> > +static inline bool arch_syscall_match_sym_name(const char *sym, const char *name)
> > +{
> > +	/*
> > +	 * Compare the symbol name with the system call name. Skip the .sys or .SyS
> > +	 * prefix from the symbol name and the sys prefix from the system call name and
> > +	 * just match the rest. This is only needed on ppc64 since symbol names on
> > +	 * 32bit do not start with a period so the generic function will work.
> > +	 */
> > +	return !strcmp(sym + 4, name + 3);
> > +}
> > +#endif /* CONFIG_FTRACE_SYSCALLS && CONFIG_PPC64 && !__ASSEMBLY__ */
> > +
> >  #endif /* _ASM_POWERPC_FTRACE */
> > diff --git a/arch/powerpc/include/asm/syscall.h b/arch/powerpc/include/asm/syscall.h
> > index 23913e9..b54b2ad 100644
> > --- a/arch/powerpc/include/asm/syscall.h
> > +++ b/arch/powerpc/include/asm/syscall.h
> > @@ -15,6 +15,11 @@
> >  
> >  #include <linux/sched.h>
> >  
> > +/* ftrace syscalls requires exporting the sys_call_table */
> > +#ifdef CONFIG_FTRACE_SYSCALLS
> > +extern const unsigned long *sys_call_table;
> > +#endif /* CONFIG_FTRACE_SYSCALLS */
> > +
> >  static inline long syscall_get_nr(struct task_struct *task,
> >  				  struct pt_regs *regs)
> >  {
> > diff --git a/arch/powerpc/include/asm/thread_info.h b/arch/powerpc/include/asm/thread_info.h
> > index 65eb859..4403f09 100644
> > --- a/arch/powerpc/include/asm/thread_info.h
> > +++ b/arch/powerpc/include/asm/thread_info.h
> > @@ -110,7 +110,8 @@ static inline struct thread_info *current_thread_info(void)
> >  #define TIF_NOERROR		12	/* Force successful syscall return */
> >  #define TIF_NOTIFY_RESUME	13	/* callback before returning to user */
> >  #define TIF_FREEZE		14	/* Freezing for suspend */
> > -#define TIF_RUNLATCH		15	/* Is the runlatch enabled? */
> > +#define TIF_SYSCALL_TRACEPOINT	15	/* syscall tracepoint instrumentation */
> > +#define TIF_RUNLATCH		16	/* Is the runlatch enabled? */
> >  
> >  /* as above, but as bit values */
> >  #define _TIF_SYSCALL_TRACE	(1<<TIF_SYSCALL_TRACE)
> > @@ -127,8 +128,10 @@ static inline struct thread_info *current_thread_info(void)
> >  #define _TIF_NOERROR		(1<<TIF_NOERROR)
> >  #define _TIF_NOTIFY_RESUME	(1<<TIF_NOTIFY_RESUME)
> >  #define _TIF_FREEZE		(1<<TIF_FREEZE)
> > +#define _TIF_SYSCALL_TRACEPOINT	(1<<TIF_SYSCALL_TRACEPOINT)
> >  #define _TIF_RUNLATCH		(1<<TIF_RUNLATCH)
> > -#define _TIF_SYSCALL_T_OR_A	(_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT|_TIF_SECCOMP)
> > +#define _TIF_SYSCALL_T_OR_A	(_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | \
> > +				 _TIF_SECCOMP | _TIF_SYSCALL_TRACEPOINT)
> >  
> >  #define _TIF_USER_WORK_MASK	(_TIF_SIGPENDING | _TIF_NEED_RESCHED | \
> >  				 _TIF_NOTIFY_RESUME)
> > diff --git a/arch/powerpc/kernel/Makefile b/arch/powerpc/kernel/Makefile
> > index 3bb2a3e..fe1ac47 100644
> > --- a/arch/powerpc/kernel/Makefile
> > +++ b/arch/powerpc/kernel/Makefile
> > @@ -105,6 +105,7 @@ obj64-$(CONFIG_AUDIT)		+= compat_audit.o
> >  
> >  obj-$(CONFIG_DYNAMIC_FTRACE)	+= ftrace.o
> >  obj-$(CONFIG_FUNCTION_GRAPH_TRACER)	+= ftrace.o
> > +obj-$(CONFIG_FTRACE_SYSCALLS)	+= ftrace.o
> >  obj-$(CONFIG_PERF_EVENTS)	+= perf_callchain.o
> >  
> >  obj-$(CONFIG_PPC_PERF_CTRS)	+= perf_event.o
> > diff --git a/arch/powerpc/kernel/ftrace.c b/arch/powerpc/kernel/ftrace.c
> > index ce1f3e4..bf99cfa 100644
> > --- a/arch/powerpc/kernel/ftrace.c
> > +++ b/arch/powerpc/kernel/ftrace.c
> > @@ -22,6 +22,7 @@
> >  #include <asm/cacheflush.h>
> >  #include <asm/code-patching.h>
> >  #include <asm/ftrace.h>
> > +#include <asm/syscall.h>
> >  
> > 
> >  #ifdef CONFIG_DYNAMIC_FTRACE
> > @@ -600,3 +601,10 @@ void prepare_ftrace_return(unsigned long *parent, unsigned long self_addr)
> >  	}
> >  }
> >  #endif /* CONFIG_FUNCTION_GRAPH_TRACER */
> > +
> > +#if defined(CONFIG_FTRACE_SYSCALLS) && defined(CONFIG_PPC64)
> > +unsigned long __init arch_syscall_addr(int nr)
> > +{
> > +	return sys_call_table[nr*2];
> > +}
> > +#endif /* CONFIG_FTRACE_SYSCALLS && CONFIG_PPC64 */
> > diff --git a/arch/powerpc/kernel/ptrace.c b/arch/powerpc/kernel/ptrace.c
> > index 9065369..b6ff0cb 100644
> > --- a/arch/powerpc/kernel/ptrace.c
> > +++ b/arch/powerpc/kernel/ptrace.c
> > @@ -29,6 +29,7 @@
> >  #include <linux/signal.h>
> >  #include <linux/seccomp.h>
> >  #include <linux/audit.h>
> > +#include <trace/syscall.h>
> >  #ifdef CONFIG_PPC32
> >  #include <linux/module.h>
> >  #endif
> > @@ -40,6 +41,9 @@
> >  #include <asm/pgtable.h>
> >  #include <asm/system.h>
> >  
> > +#define CREATE_TRACE_POINTS
> > +#include <trace/events/syscalls.h>
> > +
> >  /*
> >   * The parameter save area on the stack is used to store arguments being passed
> >   * to callee function and is located at fixed offset from stack pointer.
> > @@ -1691,6 +1695,9 @@ long do_syscall_trace_enter(struct pt_regs *regs)
> >  		 */
> >  		ret = -1L;
> >  
> > +	if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
> > +		trace_sys_enter(regs, regs->gpr[0]);
> > +
> >  	if (unlikely(current->audit_context)) {
> >  #ifdef CONFIG_PPC64
> >  		if (!is_32bit_task())
> > @@ -1719,6 +1726,9 @@ void do_syscall_trace_leave(struct pt_regs *regs)
> >  		audit_syscall_exit((regs->ccr&0x10000000)?AUDITSC_FAILURE:AUDITSC_SUCCESS,
> >  				   regs->result);
> >  
> > +	if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
> > +		trace_sys_exit(regs, regs->result);
> > +
> >  	step = test_thread_flag(TIF_SINGLESTEP);
> >  	if (step || test_thread_flag(TIF_SYSCALL_TRACE))
> >  		tracehook_report_syscall_exit(regs, step);
> 

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

* Re: [PATCH 5/6] ftrace, powerpc: Implement raw syscall tracepoints on PowerPC
  2011-02-08 10:07       ` Benjamin Herrenschmidt
@ 2011-02-08 16:54         ` Steven Rostedt
  -1 siblings, 0 replies; 30+ messages in thread
From: Steven Rostedt @ 2011-02-08 16:54 UTC (permalink / raw)
  To: Benjamin Herrenschmidt
  Cc: Ian Munsie, linux-kernel, Andreas Dilger, Dave Kleikamp,
	Andrew Morton, Jiri Kosina, Jason Baron, linuxppc-dev,
	Alexander Graf, Ingo Molnar, Paul Mackerras, KOSAKI Motohiro,
	Frederic Weisbecker, Scott Wood, Nathan Lynch, Avantika Mathur,
	David Gibson, Andreas Schwab, Namhyung Kim

On Tue, 2011-02-08 at 21:07 +1100, Benjamin Herrenschmidt wrote:
> On Mon, 2011-02-07 at 21:10 -0500, Steven Rostedt wrote:
> > Ben,
> > 
> > How do you want to work this? Do you want to ack it and I take this
> > patch with the others through the tracing tree, or do you want to wait
> > till the tracing tree gets updated into mainline and then pull this in
> > though the ppc tree. As this touches a bit of the ppc side.
> 
> I was waiting to see what you were up to vs. the rest of the series :-)
> 
> I still need to review that one closely, at which point I'm happy for
> you to take it.

It survived my tests, I'm continuing with other patches for 39 and I
have no problem with Ian's patches.

-- Steve



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

* Re: [PATCH 5/6] ftrace, powerpc: Implement raw syscall tracepoints on PowerPC
@ 2011-02-08 16:54         ` Steven Rostedt
  0 siblings, 0 replies; 30+ messages in thread
From: Steven Rostedt @ 2011-02-08 16:54 UTC (permalink / raw)
  To: Benjamin Herrenschmidt
  Cc: Andreas Dilger, Andreas Schwab, Dave Kleikamp, Namhyung Kim,
	Jiri Kosina, Jason Baron, linux-kernel, Alexander Graf,
	Ingo Molnar, Paul Mackerras, Ian Munsie, KOSAKI Motohiro,
	Frederic Weisbecker, Scott Wood, Nathan Lynch, Andrew Morton,
	David Gibson, linuxppc-dev, Avantika Mathur

On Tue, 2011-02-08 at 21:07 +1100, Benjamin Herrenschmidt wrote:
> On Mon, 2011-02-07 at 21:10 -0500, Steven Rostedt wrote:
> > Ben,
> > 
> > How do you want to work this? Do you want to ack it and I take this
> > patch with the others through the tracing tree, or do you want to wait
> > till the tracing tree gets updated into mainline and then pull this in
> > though the ppc tree. As this touches a bit of the ppc side.
> 
> I was waiting to see what you were up to vs. the rest of the series :-)
> 
> I still need to review that one closely, at which point I'm happy for
> you to take it.

It survived my tests, I'm continuing with other patches for 39 and I
have no problem with Ian's patches.

-- Steve

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

* [tip:perf/core] tracing/syscalls: Don't add events for unmapped syscalls
  2011-02-03  3:27   ` Ian Munsie
  (?)
@ 2011-02-17 14:58   ` tip-bot for Ian Munsie
  -1 siblings, 0 replies; 30+ messages in thread
From: tip-bot for Ian Munsie @ 2011-02-17 14:58 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: linux-kernel, hpa, mingo, rostedt, tglx, imunsie

Commit-ID:  ba976970c79fd2fbfe1a4b3b6766a318f4eb9d4c
Gitweb:     http://git.kernel.org/tip/ba976970c79fd2fbfe1a4b3b6766a318f4eb9d4c
Author:     Ian Munsie <imunsie@au1.ibm.com>
AuthorDate: Thu, 3 Feb 2011 14:27:20 +1100
Committer:  Steven Rostedt <rostedt@goodmis.org>
CommitDate: Mon, 7 Feb 2011 21:24:44 -0500

tracing/syscalls: Don't add events for unmapped syscalls

FTRACE_SYSCALLS would create events for each and every system call, even
if it had failed to map the system call's name with it's number. This
resulted in a number of events being created that would not behave as
expected.

This could happen, for example, on architectures who's symbol names are
unusual and will not match the system call name. It could also happen
with system calls which were mapped to sys_ni_syscall.

This patch changes the default system call number in the metadata to -1.
If the system call name from the metadata is not successfully mapped to
a system call number during boot, than the event initialisation routine
will now return an error, preventing the event from being created.

Signed-off-by: Ian Munsie <imunsie@au1.ibm.com>
LKML-Reference: <1296703645-18718-2-git-send-email-imunsie@au1.ibm.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
 include/linux/syscalls.h      |    2 ++
 kernel/trace/trace_syscalls.c |    8 ++++++++
 2 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h
index 98664db..8e8968e 100644
--- a/include/linux/syscalls.h
+++ b/include/linux/syscalls.h
@@ -158,6 +158,7 @@ extern struct trace_event_functions exit_syscall_print_funcs;
 	static struct syscall_metadata __used			\
 	  __syscall_meta_##sname = {				\
 		.name 		= "sys"#sname,			\
+		.syscall_nr	= -1,	/* Filled in at boot */	\
 		.nb_args 	= nb,				\
 		.types		= types_##sname,		\
 		.args		= args_##sname,			\
@@ -175,6 +176,7 @@ extern struct trace_event_functions exit_syscall_print_funcs;
 	static struct syscall_metadata __used			\
 	  __syscall_meta__##sname = {				\
 		.name 		= "sys_"#sname,			\
+		.syscall_nr	= -1,	/* Filled in at boot */	\
 		.nb_args 	= 0,				\
 		.enter_event	= &event_enter__##sname,	\
 		.exit_event	= &event_exit__##sname,		\
diff --git a/kernel/trace/trace_syscalls.c b/kernel/trace/trace_syscalls.c
index 5c9fe08..a9ceabd 100644
--- a/kernel/trace/trace_syscalls.c
+++ b/kernel/trace/trace_syscalls.c
@@ -424,6 +424,14 @@ void unreg_event_syscall_exit(struct ftrace_event_call *call)
 int init_syscall_trace(struct ftrace_event_call *call)
 {
 	int id;
+	int num;
+
+	num = ((struct syscall_metadata *)call->data)->syscall_nr;
+	if (num < 0 || num >= NR_syscalls) {
+		pr_debug("syscall %s metadata not mapped, disabling ftrace event\n",
+				((struct syscall_metadata *)call->data)->name);
+		return -ENOSYS;
+	}
 
 	if (set_syscall_print_fmt(call) < 0)
 		return -ENOMEM;

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

* [tip:perf/core] tracing/syscalls: Convert redundant syscall_nr checks into WARN_ON
  2011-02-03  3:27   ` Ian Munsie
  (?)
@ 2011-02-17 14:59   ` tip-bot for Ian Munsie
  -1 siblings, 0 replies; 30+ messages in thread
From: tip-bot for Ian Munsie @ 2011-02-17 14:59 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: linux-kernel, hpa, mingo, rostedt, tglx, imunsie

Commit-ID:  3773b389b6927595512558594d040c1edba46f36
Gitweb:     http://git.kernel.org/tip/3773b389b6927595512558594d040c1edba46f36
Author:     Ian Munsie <imunsie@au1.ibm.com>
AuthorDate: Thu, 3 Feb 2011 14:27:21 +1100
Committer:  Steven Rostedt <rostedt@goodmis.org>
CommitDate: Mon, 7 Feb 2011 21:25:52 -0500

tracing/syscalls: Convert redundant syscall_nr checks into WARN_ON

With the ftrace events now checking if the syscall_nr is valid upon
initialisation it should no longer be possible to register or unregister
a syscall event without a valid syscall_nr since they should not be
created. This adds a WARN_ON_ONCE in the register and unregister
functions to locate potential regressions in the future.

Signed-off-by: Ian Munsie <imunsie@au1.ibm.com>
LKML-Reference: <1296703645-18718-3-git-send-email-imunsie@au1.ibm.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
 kernel/trace/trace_syscalls.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/kernel/trace/trace_syscalls.c b/kernel/trace/trace_syscalls.c
index a9ceabd..4230942 100644
--- a/kernel/trace/trace_syscalls.c
+++ b/kernel/trace/trace_syscalls.c
@@ -359,7 +359,7 @@ int reg_event_syscall_enter(struct ftrace_event_call *call)
 	int num;
 
 	num = ((struct syscall_metadata *)call->data)->syscall_nr;
-	if (num < 0 || num >= NR_syscalls)
+	if (WARN_ON_ONCE(num < 0 || num >= NR_syscalls))
 		return -ENOSYS;
 	mutex_lock(&syscall_trace_lock);
 	if (!sys_refcount_enter)
@@ -377,7 +377,7 @@ void unreg_event_syscall_enter(struct ftrace_event_call *call)
 	int num;
 
 	num = ((struct syscall_metadata *)call->data)->syscall_nr;
-	if (num < 0 || num >= NR_syscalls)
+	if (WARN_ON_ONCE(num < 0 || num >= NR_syscalls))
 		return;
 	mutex_lock(&syscall_trace_lock);
 	sys_refcount_enter--;
@@ -393,7 +393,7 @@ int reg_event_syscall_exit(struct ftrace_event_call *call)
 	int num;
 
 	num = ((struct syscall_metadata *)call->data)->syscall_nr;
-	if (num < 0 || num >= NR_syscalls)
+	if (WARN_ON_ONCE(num < 0 || num >= NR_syscalls))
 		return -ENOSYS;
 	mutex_lock(&syscall_trace_lock);
 	if (!sys_refcount_exit)
@@ -411,7 +411,7 @@ void unreg_event_syscall_exit(struct ftrace_event_call *call)
 	int num;
 
 	num = ((struct syscall_metadata *)call->data)->syscall_nr;
-	if (num < 0 || num >= NR_syscalls)
+	if (WARN_ON_ONCE(num < 0 || num >= NR_syscalls))
 		return;
 	mutex_lock(&syscall_trace_lock);
 	sys_refcount_exit--;

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

* [tip:perf/core] tracing/syscalls: Make arch_syscall_addr weak
  2011-02-03  3:27   ` Ian Munsie
  (?)
@ 2011-02-17 14:59   ` tip-bot for Ian Munsie
  -1 siblings, 0 replies; 30+ messages in thread
From: tip-bot for Ian Munsie @ 2011-02-17 14:59 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: linux-kernel, hpa, mingo, rostedt, tglx, imunsie

Commit-ID:  c763ba06bd9b5db2c46c36276c89103d92d2c604
Gitweb:     http://git.kernel.org/tip/c763ba06bd9b5db2c46c36276c89103d92d2c604
Author:     Ian Munsie <imunsie@au1.ibm.com>
AuthorDate: Thu, 3 Feb 2011 14:27:22 +1100
Committer:  Steven Rostedt <rostedt@goodmis.org>
CommitDate: Mon, 7 Feb 2011 21:26:22 -0500

tracing/syscalls: Make arch_syscall_addr weak

Some architectures use non-trivial system call tables and will not work
with the generic arch_syscall_addr code. For example, PowerPC64 uses a
table of twin long longs.

This patch makes the generic arch_syscall_addr weak to allow
architectures with non-trivial system call tables to override it.

Signed-off-by: Ian Munsie <imunsie@au1.ibm.com>
LKML-Reference: <1296703645-18718-4-git-send-email-imunsie@au1.ibm.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
 Documentation/trace/ftrace-design.txt |    3 +++
 kernel/trace/trace_syscalls.c         |    2 +-
 2 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/Documentation/trace/ftrace-design.txt b/Documentation/trace/ftrace-design.txt
index dc52bd4..6fca17b 100644
--- a/Documentation/trace/ftrace-design.txt
+++ b/Documentation/trace/ftrace-design.txt
@@ -247,6 +247,9 @@ You need very few things to get the syscalls tracing in an arch.
 - Support the TIF_SYSCALL_TRACEPOINT thread flags.
 - Put the trace_sys_enter() and trace_sys_exit() tracepoints calls from ptrace
   in the ptrace syscalls tracing path.
+- If the system call table on this arch is more complicated than a simple array
+  of addresses of the system calls, implement an arch_syscall_addr to return
+  the address of a given system call.
 - Tag this arch as HAVE_SYSCALL_TRACEPOINTS.
 
 
diff --git a/kernel/trace/trace_syscalls.c b/kernel/trace/trace_syscalls.c
index 4230942..af83154 100644
--- a/kernel/trace/trace_syscalls.c
+++ b/kernel/trace/trace_syscalls.c
@@ -446,7 +446,7 @@ int init_syscall_trace(struct ftrace_event_call *call)
 	return id;
 }
 
-unsigned long __init arch_syscall_addr(int nr)
+unsigned long __init __weak arch_syscall_addr(int nr)
 {
 	return (unsigned long)sys_call_table[nr];
 }

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

* [tip:perf/core] tracing/syscalls: Allow arch specific syscall symbol matching
  2011-02-03  3:27   ` Ian Munsie
  (?)
@ 2011-02-17 14:59   ` tip-bot for Ian Munsie
  -1 siblings, 0 replies; 30+ messages in thread
From: tip-bot for Ian Munsie @ 2011-02-17 14:59 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: linux-kernel, hpa, mingo, rostedt, tglx, imunsie

Commit-ID:  b2d55496818d64310b9f5486d4eea76ea614d7f8
Gitweb:     http://git.kernel.org/tip/b2d55496818d64310b9f5486d4eea76ea614d7f8
Author:     Ian Munsie <imunsie@au1.ibm.com>
AuthorDate: Thu, 3 Feb 2011 14:27:23 +1100
Committer:  Steven Rostedt <rostedt@goodmis.org>
CommitDate: Mon, 7 Feb 2011 21:29:03 -0500

tracing/syscalls: Allow arch specific syscall symbol matching

Some architectures have unusual symbol names and the generic code to
match the symbol name with the function name for the syscall metadata
will fail. For example, symbols on PPC64 start with a period and the
generic code will fail to match them.

This patch moves the match logic out into a separate function which an
arch can override by defining ARCH_HAS_SYSCALL_MATCH_SYM_NAME in
asm/ftrace.h and implementing arch_syscall_match_sym_name.

Signed-off-by: Ian Munsie <imunsie@au1.ibm.com>
LKML-Reference: <1296703645-18718-5-git-send-email-imunsie@au1.ibm.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
 Documentation/trace/ftrace-design.txt |    4 ++++
 kernel/trace/trace_syscalls.c         |   21 ++++++++++++++-------
 2 files changed, 18 insertions(+), 7 deletions(-)

diff --git a/Documentation/trace/ftrace-design.txt b/Documentation/trace/ftrace-design.txt
index 6fca17b..79fcafc 100644
--- a/Documentation/trace/ftrace-design.txt
+++ b/Documentation/trace/ftrace-design.txt
@@ -250,6 +250,10 @@ You need very few things to get the syscalls tracing in an arch.
 - If the system call table on this arch is more complicated than a simple array
   of addresses of the system calls, implement an arch_syscall_addr to return
   the address of a given system call.
+- If the symbol names of the system calls do not match the function names on
+  this arch, define ARCH_HAS_SYSCALL_MATCH_SYM_NAME in asm/ftrace.h and
+  implement arch_syscall_match_sym_name with the appropriate logic to return
+  true if the function name corresponds with the symbol name.
 - Tag this arch as HAVE_SYSCALL_TRACEPOINTS.
 
 
diff --git a/kernel/trace/trace_syscalls.c b/kernel/trace/trace_syscalls.c
index af83154..86a23e7 100644
--- a/kernel/trace/trace_syscalls.c
+++ b/kernel/trace/trace_syscalls.c
@@ -60,6 +60,19 @@ extern struct syscall_metadata *__stop_syscalls_metadata[];
 
 static struct syscall_metadata **syscalls_metadata;
 
+#ifndef ARCH_HAS_SYSCALL_MATCH_SYM_NAME
+static inline bool arch_syscall_match_sym_name(const char *sym, const char *name)
+{
+	/*
+	 * Only compare after the "sys" prefix. Archs that use
+	 * syscall wrappers may have syscalls symbols aliases prefixed
+	 * with "SyS" instead of "sys", leading to an unwanted
+	 * mismatch.
+	 */
+	return !strcmp(sym + 3, name + 3);
+}
+#endif
+
 static __init struct syscall_metadata *
 find_syscall_meta(unsigned long syscall)
 {
@@ -73,13 +86,7 @@ find_syscall_meta(unsigned long syscall)
 	kallsyms_lookup(syscall, NULL, NULL, NULL, str);
 
 	for ( ; start < stop; start++) {
-		/*
-		 * Only compare after the "sys" prefix. Archs that use
-		 * syscall wrappers may have syscalls symbols aliases prefixed
-		 * with "SyS" instead of "sys", leading to an unwanted
-		 * mismatch.
-		 */
-		if ((*start)->name && !strcmp((*start)->name + 3, str + 3))
+		if ((*start)->name && arch_syscall_match_sym_name(str, (*start)->name))
 			return *start;
 	}
 	return NULL;

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

* [tip:perf/core] tracing/syscalls: Early terminate search for sys_ni_syscall
  2011-02-03  3:27   ` Ian Munsie
  (?)
@ 2011-02-17 15:00   ` tip-bot for Ian Munsie
  -1 siblings, 0 replies; 30+ messages in thread
From: tip-bot for Ian Munsie @ 2011-02-17 15:00 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: linux-kernel, hpa, mingo, rostedt, tglx, imunsie

Commit-ID:  ae07f551c42d6e4162436ca452a199deac9dab4d
Gitweb:     http://git.kernel.org/tip/ae07f551c42d6e4162436ca452a199deac9dab4d
Author:     Ian Munsie <imunsie@au1.ibm.com>
AuthorDate: Thu, 3 Feb 2011 14:27:25 +1100
Committer:  Steven Rostedt <rostedt@goodmis.org>
CommitDate: Mon, 7 Feb 2011 21:30:14 -0500

tracing/syscalls: Early terminate search for sys_ni_syscall

Many system calls are unimplemented and mapped to sys_ni_syscall, but at
boot ftrace would still search through every syscall metadata entry for
a match which wouldn't be there.

This patch adds causes the search to terminate early if the system call
is not mapped.

Signed-off-by: Ian Munsie <imunsie@au1.ibm.com>
LKML-Reference: <1296703645-18718-7-git-send-email-imunsie@au1.ibm.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
 kernel/trace/trace_syscalls.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/kernel/trace/trace_syscalls.c b/kernel/trace/trace_syscalls.c
index 86a23e7..ee7b5a0 100644
--- a/kernel/trace/trace_syscalls.c
+++ b/kernel/trace/trace_syscalls.c
@@ -85,6 +85,9 @@ find_syscall_meta(unsigned long syscall)
 	stop = __stop_syscalls_metadata;
 	kallsyms_lookup(syscall, NULL, NULL, NULL, str);
 
+	if (arch_syscall_match_sym_name(str, "sys_ni_syscall"))
+		return NULL;
+
 	for ( ; start < stop; start++) {
 		if ((*start)->name && arch_syscall_match_sym_name(str, (*start)->name))
 			return *start;

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

* [PATCH 1/6] ftrace syscalls: don't add events for unmapped syscalls
  2011-02-02  7:11 PowerPC, ftrace: Add PPC raw syscall tracepoints & ftrace fixes (mimimal subset only) v3 Ian Munsie
@ 2011-02-02  7:11   ` Ian Munsie
  0 siblings, 0 replies; 30+ messages in thread
From: Ian Munsie @ 2011-02-02  7:11 UTC (permalink / raw)
  To: linux-kernel
  Cc: Andreas Dilger, Dave Kleikamp, Andrew Morton, Jiri Kosina,
	Jason Baron, linuxppc-dev, Steven Rostedt, Alexander Graf,
	Ingo Molnar, Paul Mackerras, KOSAKI Motohiro,
	Frederic Weisbecker, Scott Wood, Nathan Lynch, Avantika Mathur,
	David Gibson, Andreas Schwab, Namhyung Kim, Ian Munsie

From: Ian Munsie <imunsie@au1.ibm.com>

FTRACE_SYSCALLS would create events for each and every system call, even
if it had failed to map the system call's name with it's number. This
resulted in a number of events being created that would not behave as
expected.

This could happen, for example, on architectures who's symbol names are
unusual and will not match the system call name. It could also happen
with system calls which were mapped to sys_ni_syscall.

This patch changes the default system call number in the metadata to -1.
If the system call name from the metadata is not successfully mapped to
a system call number during boot, than the event initialisation routine
will now return an error, preventing the event from being created.

Signed-off-by: Ian Munsie <imunsie@au1.ibm.com>
---
 include/linux/syscalls.h      |    2 ++
 kernel/trace/trace_syscalls.c |    8 ++++++++
 2 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h
index 18cd068..2e5a68d 100644
--- a/include/linux/syscalls.h
+++ b/include/linux/syscalls.h
@@ -160,6 +160,7 @@ extern struct trace_event_functions exit_syscall_print_funcs;
 	  __attribute__((section("__syscalls_metadata")))	\
 	  __syscall_meta_##sname = {				\
 		.name 		= "sys"#sname,			\
+		.syscall_nr	= -1,	/* Filled in at boot */	\
 		.nb_args 	= nb,				\
 		.types		= types_##sname,		\
 		.args		= args_##sname,			\
@@ -176,6 +177,7 @@ extern struct trace_event_functions exit_syscall_print_funcs;
 	  __attribute__((section("__syscalls_metadata")))	\
 	  __syscall_meta__##sname = {				\
 		.name 		= "sys_"#sname,			\
+		.syscall_nr	= -1,	/* Filled in at boot */	\
 		.nb_args 	= 0,				\
 		.enter_event	= &event_enter__##sname,	\
 		.exit_event	= &event_exit__##sname,		\
diff --git a/kernel/trace/trace_syscalls.c b/kernel/trace/trace_syscalls.c
index b706529..a66bc13 100644
--- a/kernel/trace/trace_syscalls.c
+++ b/kernel/trace/trace_syscalls.c
@@ -423,6 +423,14 @@ void unreg_event_syscall_exit(struct ftrace_event_call *call)
 int init_syscall_trace(struct ftrace_event_call *call)
 {
 	int id;
+	int num;
+
+	num = ((struct syscall_metadata *)call->data)->syscall_nr;
+	if (num < 0 || num >= NR_syscalls) {
+		pr_debug("syscall %s metadata not mapped, disabling ftrace event\n",
+				((struct syscall_metadata *)call->data)->name);
+		return -ENOSYS;
+	}
 
 	if (set_syscall_print_fmt(call) < 0)
 		return -ENOMEM;
-- 
1.7.2.3


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

* [PATCH 1/6] ftrace syscalls: don't add events for unmapped syscalls
@ 2011-02-02  7:11   ` Ian Munsie
  0 siblings, 0 replies; 30+ messages in thread
From: Ian Munsie @ 2011-02-02  7:11 UTC (permalink / raw)
  To: linux-kernel
  Cc: Andreas Dilger, Andreas Schwab, Dave Kleikamp, Namhyung Kim,
	Jiri Kosina, Jason Baron, Alexander Graf, Steven Rostedt,
	David Gibson, Ingo Molnar, Paul Mackerras, Ian Munsie,
	KOSAKI Motohiro, Frederic Weisbecker, Scott Wood, Nathan Lynch,
	Andrew Morton, linuxppc-dev, Avantika Mathur

From: Ian Munsie <imunsie@au1.ibm.com>

FTRACE_SYSCALLS would create events for each and every system call, even
if it had failed to map the system call's name with it's number. This
resulted in a number of events being created that would not behave as
expected.

This could happen, for example, on architectures who's symbol names are
unusual and will not match the system call name. It could also happen
with system calls which were mapped to sys_ni_syscall.

This patch changes the default system call number in the metadata to -1.
If the system call name from the metadata is not successfully mapped to
a system call number during boot, than the event initialisation routine
will now return an error, preventing the event from being created.

Signed-off-by: Ian Munsie <imunsie@au1.ibm.com>
---
 include/linux/syscalls.h      |    2 ++
 kernel/trace/trace_syscalls.c |    8 ++++++++
 2 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h
index 18cd068..2e5a68d 100644
--- a/include/linux/syscalls.h
+++ b/include/linux/syscalls.h
@@ -160,6 +160,7 @@ extern struct trace_event_functions exit_syscall_print_funcs;
 	  __attribute__((section("__syscalls_metadata")))	\
 	  __syscall_meta_##sname = {				\
 		.name 		= "sys"#sname,			\
+		.syscall_nr	= -1,	/* Filled in at boot */	\
 		.nb_args 	= nb,				\
 		.types		= types_##sname,		\
 		.args		= args_##sname,			\
@@ -176,6 +177,7 @@ extern struct trace_event_functions exit_syscall_print_funcs;
 	  __attribute__((section("__syscalls_metadata")))	\
 	  __syscall_meta__##sname = {				\
 		.name 		= "sys_"#sname,			\
+		.syscall_nr	= -1,	/* Filled in at boot */	\
 		.nb_args 	= 0,				\
 		.enter_event	= &event_enter__##sname,	\
 		.exit_event	= &event_exit__##sname,		\
diff --git a/kernel/trace/trace_syscalls.c b/kernel/trace/trace_syscalls.c
index b706529..a66bc13 100644
--- a/kernel/trace/trace_syscalls.c
+++ b/kernel/trace/trace_syscalls.c
@@ -423,6 +423,14 @@ void unreg_event_syscall_exit(struct ftrace_event_call *call)
 int init_syscall_trace(struct ftrace_event_call *call)
 {
 	int id;
+	int num;
+
+	num = ((struct syscall_metadata *)call->data)->syscall_nr;
+	if (num < 0 || num >= NR_syscalls) {
+		pr_debug("syscall %s metadata not mapped, disabling ftrace event\n",
+				((struct syscall_metadata *)call->data)->name);
+		return -ENOSYS;
+	}
 
 	if (set_syscall_print_fmt(call) < 0)
 		return -ENOMEM;
-- 
1.7.2.3

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

* [PATCH 1/6] ftrace syscalls: don't add events for unmapped syscalls
       [not found] <1291696151-4336-1-git-send-email-imunsie@au1.ibm.com>
@ 2010-12-07  4:29 ` Ian Munsie
  0 siblings, 0 replies; 30+ messages in thread
From: Ian Munsie @ 2010-12-07  4:29 UTC (permalink / raw)
  To: Avantika Mathur
  Cc: Jason Baron, Ian Munsie, Steven Rostedt, Frederic Weisbecker,
	Ingo Molnar, Masami Hiramatsu, Andrew Morton, Mathieu Desnoyers,
	linux-kernel

From: Ian Munsie <imunsie@au1.ibm.com>

FTRACE_SYSCALLS would create events for each and every system call, even
if it had failed to map the system call's name with it's number. This
resulted in a number of events being created that would not behave as
expected.

This could happen, for example, on architectures who's symbol names are
unusual and will not match the system call name. It could also happen
with system calls which were mapped to sys_ni_syscall.

This patch changes the default system call number in the metadata to -1.
If the system call name from the metadata is not successfully mapped to
a system call number during boot, than the event initialisation routine
will now return an error, preventing the event from being created.

Signed-off-by: Ian Munsie <imunsie@au1.ibm.com>
---
 include/linux/syscalls.h      |    2 ++
 kernel/trace/trace_syscalls.c |    8 ++++++++
 2 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h
index 18cd068..2e5a68d 100644
--- a/include/linux/syscalls.h
+++ b/include/linux/syscalls.h
@@ -160,6 +160,7 @@ extern struct trace_event_functions exit_syscall_print_funcs;
 	  __attribute__((section("__syscalls_metadata")))	\
 	  __syscall_meta_##sname = {				\
 		.name 		= "sys"#sname,			\
+		.syscall_nr	= -1,	/* Filled in at boot */	\
 		.nb_args 	= nb,				\
 		.types		= types_##sname,		\
 		.args		= args_##sname,			\
@@ -176,6 +177,7 @@ extern struct trace_event_functions exit_syscall_print_funcs;
 	  __attribute__((section("__syscalls_metadata")))	\
 	  __syscall_meta__##sname = {				\
 		.name 		= "sys_"#sname,			\
+		.syscall_nr	= -1,	/* Filled in at boot */	\
 		.nb_args 	= 0,				\
 		.enter_event	= &event_enter__##sname,	\
 		.exit_event	= &event_exit__##sname,		\
diff --git a/kernel/trace/trace_syscalls.c b/kernel/trace/trace_syscalls.c
index bac752f..14f4c02 100644
--- a/kernel/trace/trace_syscalls.c
+++ b/kernel/trace/trace_syscalls.c
@@ -432,6 +432,14 @@ void unreg_event_syscall_exit(struct ftrace_event_call *call)
 int init_syscall_trace(struct ftrace_event_call *call)
 {
 	int id;
+	int num;
+
+	num = ((struct syscall_metadata *)call->data)->syscall_nr;
+	if (num < 0 || num >= NR_syscalls) {
+		pr_debug("syscall %s metadata not mapped, disabling ftrace event\n",
+				((struct syscall_metadata *)call->data)->name);
+		return -ENOSYS;
+	}
 
 	if (set_syscall_print_fmt(call) < 0)
 		return -ENOMEM;
-- 
1.7.2.3


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

end of thread, other threads:[~2011-02-17 15:00 UTC | newest]

Thread overview: 30+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-02-03  3:27 PowerPC, ftrace: Add PPC raw syscall tracepoints & ftrace fixes (mimimal subset only) v4 Ian Munsie
2011-02-03  3:27 ` Ian Munsie
2011-02-03  3:27 ` [PATCH 1/6] ftrace syscalls: don't add events for unmapped syscalls Ian Munsie
2011-02-03  3:27   ` Ian Munsie
2011-02-17 14:58   ` [tip:perf/core] tracing/syscalls: Don't " tip-bot for Ian Munsie
2011-02-03  3:27 ` [PATCH 2/6] ftrace syscalls: Convert redundant syscall_nr checks into WARN_ON Ian Munsie
2011-02-03  3:27   ` Ian Munsie
2011-02-17 14:59   ` [tip:perf/core] tracing/syscalls: " tip-bot for Ian Munsie
2011-02-03  3:27 ` [PATCH 3/6] ftrace syscalls: Make arch_syscall_addr weak Ian Munsie
2011-02-03  3:27   ` Ian Munsie
2011-02-17 14:59   ` [tip:perf/core] tracing/syscalls: " tip-bot for Ian Munsie
2011-02-03  3:27 ` [PATCH 4/6] ftrace syscalls: Allow arch specific syscall symbol matching Ian Munsie
2011-02-03  3:27   ` Ian Munsie
2011-02-17 14:59   ` [tip:perf/core] tracing/syscalls: " tip-bot for Ian Munsie
2011-02-03  3:27 ` [PATCH 5/6] ftrace, powerpc: Implement raw syscall tracepoints on PowerPC Ian Munsie
2011-02-03  3:27   ` Ian Munsie
2011-02-08  2:10   ` Steven Rostedt
2011-02-08  2:10     ` Steven Rostedt
2011-02-08 10:07     ` Benjamin Herrenschmidt
2011-02-08 10:07       ` Benjamin Herrenschmidt
2011-02-08 16:54       ` Steven Rostedt
2011-02-08 16:54         ` Steven Rostedt
2011-02-03  3:27 ` [PATCH 6/6] ftrace syscalls: Early terminate search for sys_ni_syscall Ian Munsie
2011-02-03  3:27   ` Ian Munsie
2011-02-17 15:00   ` [tip:perf/core] tracing/syscalls: " tip-bot for Ian Munsie
2011-02-08  2:10 ` PowerPC, ftrace: Add PPC raw syscall tracepoints & ftrace fixes (mimimal subset only) v4 Steven Rostedt
2011-02-08  2:10   ` Steven Rostedt
  -- strict thread matches above, loose matches on Subject: below --
2011-02-02  7:11 PowerPC, ftrace: Add PPC raw syscall tracepoints & ftrace fixes (mimimal subset only) v3 Ian Munsie
2011-02-02  7:11 ` [PATCH 1/6] ftrace syscalls: don't add events for unmapped syscalls Ian Munsie
2011-02-02  7:11   ` Ian Munsie
     [not found] <1291696151-4336-1-git-send-email-imunsie@au1.ibm.com>
2010-12-07  4:29 ` Ian Munsie

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.