All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] tracing: Move tracepoint callbacks into DEFINE
@ 2009-08-18  7:23 Josh Stone
  2009-08-18 14:19 ` Jason Baron
                   ` (3 more replies)
  0 siblings, 4 replies; 70+ messages in thread
From: Josh Stone @ 2009-08-18  7:23 UTC (permalink / raw)
  To: linux-kernel
  Cc: fweisbec, mingo, laijs, rostedt, peterz, mathieu.desnoyers,
	jiayingz, mbligh, lizf, Josh Stone, Jason Baron

It's not strictly correct for the tracepoint reg/unreg callbacks to
occur when a client is hooking up, because the actual tracepoint may no
be present yet.  This happens to be fine for syscall, since that's in
the core kernel, but it would cause problems for tracepoints defined in
a module that hasn't been loaded yet.  It also means the reg/unreg has
to be EXPORTed for any modules to use the tracepoint (as in SystemTap).

This patch removes DECLARE_TRACE_WITH_CALLBACK, and instead introduces
DEFINE_TRACE_WITH_CALLBACK which stores the callbacks in struct
tracepoint.  The callbacks are used now when the active state of the
tracepoint changes in set_tracepoint & disable_tracepoint.

This also introduces TRACE_EVENT_WITH_CALLBACK, so those events can also
provide callbacks if needed.

Signed-off-by: Josh Stone <jistone@redhat.com>
Cc: Jason Baron <jbaron@redhat.com>
---
 arch/x86/kernel/ptrace.c     |    4 ++--
 include/linux/tracepoint.h   |   41 +++++++++++++++--------------------------
 include/trace/define_trace.h |    5 +++++
 include/trace/ftrace.h       |    9 +++++++++
 include/trace/syscall.h      |   12 ++++--------
 kernel/tracepoint.c          |   15 +++++++++------
 6 files changed, 44 insertions(+), 42 deletions(-)

diff --git a/arch/x86/kernel/ptrace.c b/arch/x86/kernel/ptrace.c
index 34dd6f1..692fc14 100644
--- a/arch/x86/kernel/ptrace.c
+++ b/arch/x86/kernel/ptrace.c
@@ -37,8 +37,8 @@
 
 #include <trace/syscall.h>
 
-DEFINE_TRACE(syscall_enter);
-DEFINE_TRACE(syscall_exit);
+DEFINE_TRACE_WITH_CALLBACK(syscall_enter, syscall_regfunc, syscall_unregfunc);
+DEFINE_TRACE_WITH_CALLBACK(syscall_exit, syscall_regfunc, syscall_unregfunc);
 
 #include "tls.h"
 
diff --git a/include/linux/tracepoint.h b/include/linux/tracepoint.h
index 5984ed0..7ffc7b6 100644
--- a/include/linux/tracepoint.h
+++ b/include/linux/tracepoint.h
@@ -23,6 +23,8 @@ struct tracepoint;
 struct tracepoint {
 	const char *name;		/* Tracepoint name */
 	int state;			/* State. */
+	void (*regfunc)(void);
+	void (*unregfunc)(void);
 	void **funcs;
 } __attribute__((aligned(32)));		/*
 					 * Aligned on 32 bytes because it is
@@ -63,7 +65,7 @@ struct tracepoint {
  * An optional set of (un)registration functions can be passed to perform any
  * additional (un)registration work.
  */
-#define DECLARE_TRACE_WITH_CALLBACK(name, proto, args, reg, unreg)	\
+#define DECLARE_TRACE(name, proto, args)				\
 	extern struct tracepoint __tracepoint_##name;			\
 	static inline void trace_##name(proto)				\
 	{								\
@@ -73,36 +75,23 @@ struct tracepoint {
 	}								\
 	static inline int register_trace_##name(void (*probe)(proto))	\
 	{								\
-		int ret;						\
-		void (*func)(void) = reg;				\
-									\
-		ret = tracepoint_probe_register(#name, (void *)probe);	\
-		if (func && !ret)					\
-			func();						\
-		return ret;						\
+		return tracepoint_probe_register(#name, (void *)probe);	\
 	}								\
 	static inline int unregister_trace_##name(void (*probe)(proto))	\
 	{								\
-		int ret;						\
-		void (*func)(void) = unreg;				\
-									\
-		ret = tracepoint_probe_unregister(#name, (void *)probe);\
-		if (func && !ret)					\
-			func();						\
-		return ret;						\
+		return tracepoint_probe_unregister(#name, (void *)probe);\
 	}
 
 
-#define DECLARE_TRACE(name, proto, args)				 \
-	DECLARE_TRACE_WITH_CALLBACK(name, TP_PROTO(proto), TP_ARGS(args),\
-					NULL, NULL);
-
-#define DEFINE_TRACE(name)						\
+#define DEFINE_TRACE_WITH_CALLBACK(name, reg, unreg)			\
 	static const char __tpstrtab_##name[]				\
 	__attribute__((section("__tracepoints_strings"))) = #name;	\
 	struct tracepoint __tracepoint_##name				\
 	__attribute__((section("__tracepoints"), aligned(32))) =	\
-		{ __tpstrtab_##name, 0, NULL }
+		{ __tpstrtab_##name, 0, reg, unreg, NULL }
+
+#define DEFINE_TRACE(name)						\
+	DEFINE_TRACE_WITH_CALLBACK(name, NULL, NULL);
 
 #define EXPORT_TRACEPOINT_SYMBOL_GPL(name)				\
 	EXPORT_SYMBOL_GPL(__tracepoint_##name)
@@ -113,7 +102,7 @@ extern void tracepoint_update_probe_range(struct tracepoint *begin,
 	struct tracepoint *end);
 
 #else /* !CONFIG_TRACEPOINTS */
-#define DECLARE_TRACE_WITH_CALLBACK(name, proto, args, reg, unreg)	\
+#define DECLARE_TRACE(name, proto, args)				\
 	static inline void _do_trace_##name(struct tracepoint *tp, proto) \
 	{ }								\
 	static inline void trace_##name(proto)				\
@@ -127,10 +116,7 @@ extern void tracepoint_update_probe_range(struct tracepoint *begin,
 		return -ENOSYS;						\
 	}
 
-#define DECLARE_TRACE(name, proto, args)				 \
-	DECLARE_TRACE_WITH_CALLBACK(name, TP_PROTO(proto), TP_ARGS(args),\
-					NULL, NULL);
-
+#define DEFINE_TRACE_WITH_CALLBACK(name, reg, unreg)
 #define DEFINE_TRACE(name)
 #define EXPORT_TRACEPOINT_SYMBOL_GPL(name)
 #define EXPORT_TRACEPOINT_SYMBOL(name)
@@ -286,6 +272,9 @@ static inline void tracepoint_synchronize_unregister(void)
 
 #define TRACE_EVENT(name, proto, args, struct, assign, print)	\
 	DECLARE_TRACE(name, PARAMS(proto), PARAMS(args))
+#define TRACE_EVENT_WITH_CALLBACK(name, proto, args, struct,	\
+		assign, print, reg, unreg)			\
+	DECLARE_TRACE(name, PARAMS(proto), PARAMS(args))
 #endif
 
 #endif
diff --git a/include/trace/define_trace.h b/include/trace/define_trace.h
index f7a7ae1..82c623a 100644
--- a/include/trace/define_trace.h
+++ b/include/trace/define_trace.h
@@ -26,6 +26,11 @@
 #define TRACE_EVENT(name, proto, args, tstruct, assign, print)	\
 	DEFINE_TRACE(name)
 
+#undef TRACE_EVENT_WITH_CALLBACK
+#define TRACE_EVENT_WITH_CALLBACK(name, proto, args, tstruct,	\
+		assign, print, reg, unreg)			\
+	DEFINE_TRACE_WITH_CALLBACK(name, reg, unreg)
+
 #undef DECLARE_TRACE
 #define DECLARE_TRACE(name, proto, args)	\
 	DEFINE_TRACE(name)
diff --git a/include/trace/ftrace.h b/include/trace/ftrace.h
index b250b06..61ed0ab 100644
--- a/include/trace/ftrace.h
+++ b/include/trace/ftrace.h
@@ -42,6 +42,15 @@
 	};							\
 	static struct ftrace_event_call event_##name
 
+/* Callbacks are meaningless to ftrace. */
+#undef TRACE_EVENT_WITH_CALLBACK
+#define TRACE_EVENT_WITH_CALLBACK(name, proto, args, tstruct,	\
+		assign, print, reg, unreg)			\
+	TRACE_EVENT(name, TP_PROTO(proto), TP_ARGS(args),	\
+		TP_STRUCT__entry(tstruct),			\
+		TP_fast_assign(assign),				\
+		TP_printk(print))
+
 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
 
 
diff --git a/include/trace/syscall.h b/include/trace/syscall.h
index 0cb0362..49e7ec2 100644
--- a/include/trace/syscall.h
+++ b/include/trace/syscall.h
@@ -11,18 +11,14 @@
 extern void syscall_regfunc(void);
 extern void syscall_unregfunc(void);
 
-DECLARE_TRACE_WITH_CALLBACK(syscall_enter,
+DECLARE_TRACE(syscall_enter,
 	TP_PROTO(struct pt_regs *regs, long id),
-	TP_ARGS(regs, id),
-	syscall_regfunc,
-	syscall_unregfunc
+	TP_ARGS(regs, id)
 );
 
-DECLARE_TRACE_WITH_CALLBACK(syscall_exit,
+DECLARE_TRACE(syscall_exit,
 	TP_PROTO(struct pt_regs *regs, long ret),
-	TP_ARGS(regs, ret),
-	syscall_regfunc,
-	syscall_unregfunc
+	TP_ARGS(regs, ret)
 );
 
 /*
diff --git a/kernel/tracepoint.c b/kernel/tracepoint.c
index 35dd27a..1865c09 100644
--- a/kernel/tracepoint.c
+++ b/kernel/tracepoint.c
@@ -243,6 +243,11 @@ static void set_tracepoint(struct tracepoint_entry **entry,
 {
 	WARN_ON(strcmp((*entry)->name, elem->name) != 0);
 
+	if (elem->regfunc && !elem->state && active)
+		elem->regfunc();
+	else if (elem->unregfunc && elem->state && !active)
+		elem->unregfunc();
+
 	/*
 	 * rcu_assign_pointer has a smp_wmb() which makes sure that the new
 	 * probe callbacks array is consistent before setting a pointer to it.
@@ -262,6 +267,9 @@ static void set_tracepoint(struct tracepoint_entry **entry,
  */
 static void disable_tracepoint(struct tracepoint *elem)
 {
+	if (elem->unregfunc && elem->state)
+		elem->unregfunc();
+
 	elem->state = 0;
 	rcu_assign_pointer(elem->funcs, NULL);
 }
@@ -581,15 +589,13 @@ __initcall(init_tracepoints);
 
 #ifdef CONFIG_FTRACE_SYSCALLS
 
-static DEFINE_MUTEX(regfunc_mutex);
-static int sys_tracepoint_refcount;
+static int sys_tracepoint_refcount; /* guarded by tracepoints_mutex */
 
 void syscall_regfunc(void)
 {
 	unsigned long flags;
 	struct task_struct *g, *t;
 
-	mutex_lock(&regfunc_mutex);
 	if (!sys_tracepoint_refcount) {
 		read_lock_irqsave(&tasklist_lock, flags);
 		do_each_thread(g, t) {
@@ -598,7 +604,6 @@ void syscall_regfunc(void)
 		read_unlock_irqrestore(&tasklist_lock, flags);
 	}
 	sys_tracepoint_refcount++;
-	mutex_unlock(&regfunc_mutex);
 }
 
 void syscall_unregfunc(void)
@@ -606,7 +611,6 @@ void syscall_unregfunc(void)
 	unsigned long flags;
 	struct task_struct *g, *t;
 
-	mutex_lock(&regfunc_mutex);
 	sys_tracepoint_refcount--;
 	if (!sys_tracepoint_refcount) {
 		read_lock_irqsave(&tasklist_lock, flags);
@@ -615,6 +619,5 @@ void syscall_unregfunc(void)
 		} while_each_thread(g, t);
 		read_unlock_irqrestore(&tasklist_lock, flags);
 	}
-	mutex_unlock(&regfunc_mutex);
 }
 #endif
-- 
1.6.2.5


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

* Re: [PATCH] tracing: Move tracepoint callbacks into DEFINE
  2009-08-18  7:23 [PATCH] tracing: Move tracepoint callbacks into DEFINE Josh Stone
@ 2009-08-18 14:19 ` Jason Baron
  2009-08-18 22:11   ` Josh Stone
  2009-08-18 22:25 ` [PATCH] tracing: Create generic syscall TRACE_EVENTs Josh Stone
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 70+ messages in thread
From: Jason Baron @ 2009-08-18 14:19 UTC (permalink / raw)
  To: Josh Stone
  Cc: linux-kernel, fweisbec, mingo, laijs, rostedt, peterz,
	mathieu.desnoyers, jiayingz, mbligh, lizf

On Tue, Aug 18, 2009 at 12:23:47AM -0700, Josh Stone wrote:
> It's not strictly correct for the tracepoint reg/unreg callbacks to
> occur when a client is hooking up, because the actual tracepoint may no
> be present yet.  This happens to be fine for syscall, since that's in
> the core kernel, but it would cause problems for tracepoints defined in
> a module that hasn't been loaded yet.  It also means the reg/unreg has
> to be EXPORTed for any modules to use the tracepoint (as in SystemTap).
> 
> This patch removes DECLARE_TRACE_WITH_CALLBACK, and instead introduces
> DEFINE_TRACE_WITH_CALLBACK which stores the callbacks in struct
> tracepoint.  The callbacks are used now when the active state of the
> tracepoint changes in set_tracepoint & disable_tracepoint.
> 
> This also introduces TRACE_EVENT_WITH_CALLBACK, so those events can also
> provide callbacks if needed.
> 

this makes sense...Ingo also suggested having the two high level
tracepoints be 'TRACE_EVENT' style. That is we should be able to
register with the syscall entry and get the *all* the syscall numbers
and arguments, and likewise on exit we should be able to get *all*
syscall exit return values. see:

http://marc.info/?l=linux-kernel&m=125008740803571&w=2 

does this patch allow/do that?

thanks,

-Jason

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

* Re: [PATCH] tracing: Move tracepoint callbacks into DEFINE
  2009-08-18 14:19 ` Jason Baron
@ 2009-08-18 22:11   ` Josh Stone
  0 siblings, 0 replies; 70+ messages in thread
From: Josh Stone @ 2009-08-18 22:11 UTC (permalink / raw)
  To: Jason Baron
  Cc: linux-kernel, fweisbec, mingo, laijs, rostedt, peterz,
	mathieu.desnoyers, jiayingz, mbligh, lizf

On 08/18/2009 07:19 AM, Jason Baron wrote:
> this makes sense...Ingo also suggested having the two high level
> tracepoints be 'TRACE_EVENT' style. That is we should be able to
> register with the syscall entry and get the *all* the syscall numbers
> and arguments, and likewise on exit we should be able to get *all*
> syscall exit return values. see:
> 
> http://marc.info/?l=linux-kernel&m=125008740803571&w=2 
> 
> does this patch allow/do that?

It does allow this, and I am working on a patch to do it.  There are a
few naming conflicts between trace_syscalls.c and the stuff that ftrace
generates for "TRACE_EVENT(syscall_enter, ...)", but I will post soon
with a patch to resolve this.

Thanks,

Josh

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

* [PATCH] tracing: Create generic syscall TRACE_EVENTs
  2009-08-18  7:23 [PATCH] tracing: Move tracepoint callbacks into DEFINE Josh Stone
  2009-08-18 14:19 ` Jason Baron
@ 2009-08-18 22:25 ` Josh Stone
  2009-08-19  1:32   ` Li Zefan
  2009-08-19 16:16   ` Jason Baron
  2009-08-19 16:13 ` [PATCH] tracing: Move tracepoint callbacks into DEFINE Jason Baron
  2009-08-20 19:09 ` [PATCH v2 1/2] " Josh Stone
  3 siblings, 2 replies; 70+ messages in thread
From: Josh Stone @ 2009-08-18 22:25 UTC (permalink / raw)
  To: linux-kernel
  Cc: fweisbec, mingo, laijs, rostedt, peterz, mathieu.desnoyers,
	jiayingz, mbligh, lizf, Josh Stone, Jason Baron

This converts the syscall_enter/exit tracepoints into TRACE_EVENTs, so
you can have generic ftrace events that capture all system calls with
arguments and return values.

The existing event_syscall_enter/exit trace_event structs are renamed to
event_sys_enter/exit, so they don't conflict with the names generated
automatically by ftrace.

Signed-off-by: Josh Stone <jistone@redhat.com>
Cc: Jason Baron <jbaron@redhat.com>
---
 arch/s390/kernel/ptrace.c       |    3 ++
 arch/x86/kernel/ptrace.c        |    8 ++---
 include/linux/syscalls.h        |    4 +-
 include/trace/events/syscalls.h |   66 +++++++++++++++++++++++++++++++++++++++
 include/trace/syscall.h         |   17 +---------
 kernel/trace/trace_syscalls.c   |    5 ++-
 6 files changed, 79 insertions(+), 24 deletions(-)
 create mode 100644 include/trace/events/syscalls.h

diff --git a/arch/s390/kernel/ptrace.c b/arch/s390/kernel/ptrace.c
index 05f57cd..8730fa7 100644
--- a/arch/s390/kernel/ptrace.c
+++ b/arch/s390/kernel/ptrace.c
@@ -51,6 +51,9 @@
 #include "compat_ptrace.h"
 #endif
 
+#define CREATE_TRACE_POINTS
+#include <trace/events/syscalls.h>
+
 enum s390_regset {
 	REGSET_GENERAL,
 	REGSET_FP,
diff --git a/arch/x86/kernel/ptrace.c b/arch/x86/kernel/ptrace.c
index 692fc14..530ff6f 100644
--- a/arch/x86/kernel/ptrace.c
+++ b/arch/x86/kernel/ptrace.c
@@ -35,13 +35,11 @@
 #include <asm/proto.h>
 #include <asm/ds.h>
 
-#include <trace/syscall.h>
-
-DEFINE_TRACE_WITH_CALLBACK(syscall_enter, syscall_regfunc, syscall_unregfunc);
-DEFINE_TRACE_WITH_CALLBACK(syscall_exit, syscall_regfunc, syscall_unregfunc);
-
 #include "tls.h"
 
+#define CREATE_TRACE_POINTS
+#include <trace/events/syscalls.h>
+
 enum x86_regset {
 	REGSET_GENERAL,
 	REGSET_FP,
diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h
index 87d06c1..19b49fd 100644
--- a/include/linux/syscalls.h
+++ b/include/linux/syscalls.h
@@ -187,7 +187,7 @@ static void prof_sysexit_disable_##sname(struct ftrace_event_call *event_call) \
 	  event_enter_##sname = {					\
 		.name                   = "sys_enter"#sname,		\
 		.system                 = "syscalls",			\
-		.event                  = &event_syscall_enter,		\
+		.event                  = &event_sys_enter,		\
 		.raw_init		= init_enter_##sname,		\
 		.show_format		= ftrace_format_syscall,	\
 		.regfunc		= reg_event_syscall_enter,	\
@@ -223,7 +223,7 @@ static void prof_sysexit_disable_##sname(struct ftrace_event_call *event_call) \
 	  event_exit_##sname = {					\
 		.name                   = "sys_exit"#sname,		\
 		.system                 = "syscalls",			\
-		.event                  = &event_syscall_exit,		\
+		.event                  = &event_sys_exit,		\
 		.raw_init		= init_exit_##sname,		\
 		.regfunc		= reg_event_syscall_exit,	\
 		.unregfunc		= unreg_event_syscall_exit,	\
diff --git a/include/trace/events/syscalls.h b/include/trace/events/syscalls.h
new file mode 100644
index 0000000..75ccc61
--- /dev/null
+++ b/include/trace/events/syscalls.h
@@ -0,0 +1,66 @@
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM syscalls
+
+#if !defined(_TRACE_EVENTS_SYSCALL_H) || defined(TRACE_HEADER_MULTI_READ)
+#define _TRACE_EVENTS_SYSCALL_H
+
+#include <linux/tracepoint.h>
+
+#include <asm/ptrace.h>
+#include <asm/syscall.h>
+
+extern void syscall_regfunc(void);
+extern void syscall_unregfunc(void);
+
+
+TRACE_EVENT_WITH_CALLBACK(syscall_enter,
+
+	TP_PROTO(struct pt_regs *regs, long id),
+
+	TP_ARGS(regs, id),
+
+	TP_STRUCT__entry(
+		__field(	long,	id		)
+		__array(	long,	args,	6	)
+	),
+
+	TP_fast_assign(
+		__entry->id	= id;
+		syscall_get_arguments(current, regs, 0, 6, __entry->args);
+	),
+
+	TP_printk("NR %ld (%ld, %ld, %ld, %ld, %ld, %ld)",
+		  __entry->id,
+		  __entry->args[0], __entry->args[1], __entry->args[2],
+		  __entry->args[3], __entry->args[4], __entry->args[5]),
+
+	syscall_regfunc, syscall_unregfunc
+);
+
+TRACE_EVENT_WITH_CALLBACK(syscall_exit,
+
+	TP_PROTO(struct pt_regs *regs, long ret),
+
+	TP_ARGS(regs, ret),
+
+	TP_STRUCT__entry(
+		__field(	long,	id		)
+		__field(	long,	ret		)
+	),
+
+	TP_fast_assign(
+		__entry->id	= syscall_get_nr(current, regs);
+		__entry->ret	= ret;
+	),
+
+	TP_printk("NR %ld = %ld",
+		  __entry->id, __entry->ret),
+
+	syscall_regfunc, syscall_unregfunc
+);
+
+#endif /* _TRACE_EVENTS_SYSCALL_H */
+
+/* This part must be outside protection */
+#include <trace/define_trace.h>
+
diff --git a/include/trace/syscall.h b/include/trace/syscall.h
index 49e7ec2..5181893 100644
--- a/include/trace/syscall.h
+++ b/include/trace/syscall.h
@@ -8,19 +8,6 @@
 #include <asm/ptrace.h>
 
 
-extern void syscall_regfunc(void);
-extern void syscall_unregfunc(void);
-
-DECLARE_TRACE(syscall_enter,
-	TP_PROTO(struct pt_regs *regs, long id),
-	TP_ARGS(regs, id)
-);
-
-DECLARE_TRACE(syscall_exit,
-	TP_PROTO(struct pt_regs *regs, long ret),
-	TP_ARGS(regs, ret)
-);
-
 /*
  * A syscall entry in the ftrace syscalls array.
  *
@@ -45,8 +32,8 @@ extern struct syscall_metadata *syscall_nr_to_meta(int nr);
 extern int syscall_name_to_nr(char *name);
 void set_syscall_enter_id(int num, int id);
 void set_syscall_exit_id(int num, int id);
-extern struct trace_event event_syscall_enter;
-extern struct trace_event event_syscall_exit;
+extern struct trace_event event_sys_enter;
+extern struct trace_event event_sys_exit;
 extern int reg_event_syscall_enter(void *ptr);
 extern void unreg_event_syscall_enter(void *ptr);
 extern int reg_event_syscall_exit(void *ptr);
diff --git a/kernel/trace/trace_syscalls.c b/kernel/trace/trace_syscalls.c
index f130dac..b174169 100644
--- a/kernel/trace/trace_syscalls.c
+++ b/kernel/trace/trace_syscalls.c
@@ -1,4 +1,5 @@
 #include <trace/syscall.h>
+#include <trace/events/syscalls.h>
 #include <linux/kernel.h>
 #include <linux/ftrace.h>
 #include <linux/perf_counter.h>
@@ -277,11 +278,11 @@ void unreg_event_syscall_exit(void *ptr)
 	mutex_unlock(&syscall_trace_lock);
 }
 
-struct trace_event event_syscall_enter = {
+struct trace_event event_sys_enter = {
 	.trace			= print_syscall_enter,
 };
 
-struct trace_event event_syscall_exit = {
+struct trace_event event_sys_exit = {
 	.trace			= print_syscall_exit,
 };
 
-- 
1.6.2.5


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

* Re: [PATCH] tracing: Create generic syscall TRACE_EVENTs
  2009-08-18 22:25 ` [PATCH] tracing: Create generic syscall TRACE_EVENTs Josh Stone
@ 2009-08-19  1:32   ` Li Zefan
  2009-08-19  3:05     ` Josh Stone
  2009-08-19 16:16   ` Jason Baron
  1 sibling, 1 reply; 70+ messages in thread
From: Li Zefan @ 2009-08-19  1:32 UTC (permalink / raw)
  To: Josh Stone
  Cc: linux-kernel, fweisbec, mingo, laijs, rostedt, peterz,
	mathieu.desnoyers, jiayingz, mbligh, Jason Baron

Josh Stone wrote:
> This converts the syscall_enter/exit tracepoints into TRACE_EVENTs, so
> you can have generic ftrace events that capture all system calls with
> arguments and return values.
> 
> The existing event_syscall_enter/exit trace_event structs are renamed to
> event_sys_enter/exit, so they don't conflict with the names generated
> automatically by ftrace.
> 

It would be much better to see a sample output of these TRACE_EVENTs,

...

> +TRACE_EVENT_WITH_CALLBACK(syscall_enter,
> +
> +	TP_PROTO(struct pt_regs *regs, long id),
> +
> +	TP_ARGS(regs, id),
> +
> +	TP_STRUCT__entry(
> +		__field(	long,	id		)
> +		__array(	long,	args,	6	)
> +	),
> +
> +	TP_fast_assign(
> +		__entry->id	= id;
> +		syscall_get_arguments(current, regs, 0, 6, __entry->args);
> +	),
> +
> +	TP_printk("NR %ld (%ld, %ld, %ld, %ld, %ld, %ld)",
> +		  __entry->id,
> +		  __entry->args[0], __entry->args[1], __entry->args[2],
> +		  __entry->args[3], __entry->args[4], __entry->args[5]),
> +

so we'll see the what's the output if a syscall has less than 6 args.

And I guess it should be "(%lx, %lx, ..., %lx)"? Otherwise I think we'll
see some negative values.

> +	syscall_regfunc, syscall_unregfunc
> +);



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

* Re: [PATCH] tracing: Create generic syscall TRACE_EVENTs
  2009-08-19  1:32   ` Li Zefan
@ 2009-08-19  3:05     ` Josh Stone
  2009-08-19 13:05       ` Ingo Molnar
  0 siblings, 1 reply; 70+ messages in thread
From: Josh Stone @ 2009-08-19  3:05 UTC (permalink / raw)
  To: Li Zefan
  Cc: linux-kernel, fweisbec, mingo, laijs, rostedt, peterz,
	mathieu.desnoyers, jiayingz, mbligh, Jason Baron

On 08/18/2009 06:32 PM, Li Zefan wrote:
> It would be much better to see a sample output of these TRACE_EVENTs,
> so we'll see the what's the output if a syscall has less than 6 args.
> 
> And I guess it should be "(%lx, %lx, ..., %lx)"? Otherwise I think we'll
> see some negative values.

Thanks, you're right -- the args should be unsigned long.  Whether they
are hex or decimal doesn't matter to me, but I guess that does make
pointers easier to spot.

Here's some output that I get on x86_64:

> # tail trace
>             tail-1106  [000] 113218.474657: syscall_enter: NR 2 (7f2d34dd38f0, 0, 7f2d35009010, 5, 4, ffffffffffffffb0)
> 
>             tail-1106  [000] 113218.474809: syscall_enter: NR 5 (3, 7f2d35009040, 7f2d35009040, 5, 4, ffffffffffffffb0)
> 
>             tail-1106  [000] 113218.474855: syscall_enter: NR 9 (0, 50d3ad0, 1, 2, 3, 0)
> 
>             tail-1106  [000] 113218.474946: syscall_enter: NR 3 (3, 7f2d2f9a0000, 5e22, 2, 3, 0)
> 
>             tail-1106  [000] 113218.475673: syscall_enter: NR 2 (7fff5e42a654, 0, 0, 7fff5e429600, 80, 3)

It's very raw indeed, but that's what Ingo asked for. :)  The extra args
show up as whatever happened to be in those registers.

Josh

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

* Re: [PATCH] tracing: Create generic syscall TRACE_EVENTs
  2009-08-19  3:05     ` Josh Stone
@ 2009-08-19 13:05       ` Ingo Molnar
  2009-08-19 13:50         ` Mathieu Desnoyers
  0 siblings, 1 reply; 70+ messages in thread
From: Ingo Molnar @ 2009-08-19 13:05 UTC (permalink / raw)
  To: Josh Stone
  Cc: Li Zefan, linux-kernel, fweisbec, laijs, rostedt, peterz,
	mathieu.desnoyers, jiayingz, mbligh, Jason Baron


* Josh Stone <jistone@redhat.com> wrote:

> On 08/18/2009 06:32 PM, Li Zefan wrote:
> > It would be much better to see a sample output of these TRACE_EVENTs,
> > so we'll see the what's the output if a syscall has less than 6 args.
> > 
> > And I guess it should be "(%lx, %lx, ..., %lx)"? Otherwise I think we'll
> > see some negative values.
> 
> Thanks, you're right -- the args should be unsigned long.  Whether they
> are hex or decimal doesn't matter to me, but I guess that does make
> pointers easier to spot.
> 
> Here's some output that I get on x86_64:
> 
> > # tail trace
> >             tail-1106  [000] 113218.474657: syscall_enter: NR 2 (7f2d34dd38f0, 0, 7f2d35009010, 5, 4, ffffffffffffffb0)
> > 
> >             tail-1106  [000] 113218.474809: syscall_enter: NR 5 (3, 7f2d35009040, 7f2d35009040, 5, 4, ffffffffffffffb0)
> > 
> >             tail-1106  [000] 113218.474855: syscall_enter: NR 9 (0, 50d3ad0, 1, 2, 3, 0)
> > 
> >             tail-1106  [000] 113218.474946: syscall_enter: NR 3 (3, 7f2d2f9a0000, 5e22, 2, 3, 0)
> > 
> >             tail-1106  [000] 113218.475673: syscall_enter: NR 2 (7fff5e42a654, 0, 0, 7fff5e429600, 80, 3)
> 
> It's very raw indeed, but that's what Ingo asked for. :) The 
> extra args show up as whatever happened to be in those registers.

If the syscalls are handled as a single tracepoint, then they 
cannot really have per syscall properties.

The per syscall tracepoints on the other hand give very finegrained 
information.

Note that via the use of filters one can limit the generic 
tracepoint to only output certain syscall NRs, and only with 
certain parameters.

	Ingo

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

* Re: [PATCH] tracing: Create generic syscall TRACE_EVENTs
  2009-08-19 13:05       ` Ingo Molnar
@ 2009-08-19 13:50         ` Mathieu Desnoyers
  0 siblings, 0 replies; 70+ messages in thread
From: Mathieu Desnoyers @ 2009-08-19 13:50 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: Josh Stone, Li Zefan, linux-kernel, fweisbec, laijs, rostedt,
	peterz, jiayingz, mbligh, Jason Baron

* Ingo Molnar (mingo@elte.hu) wrote:
> 
> * Josh Stone <jistone@redhat.com> wrote:
> 
> > On 08/18/2009 06:32 PM, Li Zefan wrote:
> > > It would be much better to see a sample output of these TRACE_EVENTs,
> > > so we'll see the what's the output if a syscall has less than 6 args.
> > > 
> > > And I guess it should be "(%lx, %lx, ..., %lx)"? Otherwise I think we'll
> > > see some negative values.
> > 
> > Thanks, you're right -- the args should be unsigned long.  Whether they
> > are hex or decimal doesn't matter to me, but I guess that does make
> > pointers easier to spot.
> > 
> > Here's some output that I get on x86_64:
> > 
> > > # tail trace
> > >             tail-1106  [000] 113218.474657: syscall_enter: NR 2 (7f2d34dd38f0, 0, 7f2d35009010, 5, 4, ffffffffffffffb0)
> > > 
> > >             tail-1106  [000] 113218.474809: syscall_enter: NR 5 (3, 7f2d35009040, 7f2d35009040, 5, 4, ffffffffffffffb0)
> > > 
> > >             tail-1106  [000] 113218.474855: syscall_enter: NR 9 (0, 50d3ad0, 1, 2, 3, 0)
> > > 
> > >             tail-1106  [000] 113218.474946: syscall_enter: NR 3 (3, 7f2d2f9a0000, 5e22, 2, 3, 0)
> > > 
> > >             tail-1106  [000] 113218.475673: syscall_enter: NR 2 (7fff5e42a654, 0, 0, 7fff5e429600, 80, 3)
> > 
> > It's very raw indeed, but that's what Ingo asked for. :) The 
> > extra args show up as whatever happened to be in those registers.
> 
> If the syscalls are handled as a single tracepoint, then they 
> cannot really have per syscall properties.
> 
> The per syscall tracepoints on the other hand give very finegrained 
> information.
> 

Hi Ingo,

Aiming to identify the event payload type with the event ID alone, I
would recommend either:

- one tracepoint per syscall argument set types (e.g. same syscall
  prototype)
or
- one tracepoint per syscall (seems to be more straightforward)

Otherwise getting to fit a struct sockaddr into an integer might be
cumbersome.

Thanks,

Mathieu

> Note that via the use of filters one can limit the generic 
> tracepoint to only output certain syscall NRs, and only with 
> certain parameters.
> 
> 	Ingo

-- 
Mathieu Desnoyers
OpenPGP key fingerprint: 8CD5 52C3 8E3C 4140 715F  BA06 3F25 A8FE 3BAE 9A68

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

* Re: [PATCH] tracing: Move tracepoint callbacks into DEFINE
  2009-08-18  7:23 [PATCH] tracing: Move tracepoint callbacks into DEFINE Josh Stone
  2009-08-18 14:19 ` Jason Baron
  2009-08-18 22:25 ` [PATCH] tracing: Create generic syscall TRACE_EVENTs Josh Stone
@ 2009-08-19 16:13 ` Jason Baron
  2009-08-20 17:25   ` Josh Stone
  2009-08-20 19:09 ` [PATCH v2 1/2] " Josh Stone
  3 siblings, 1 reply; 70+ messages in thread
From: Jason Baron @ 2009-08-19 16:13 UTC (permalink / raw)
  To: Josh Stone
  Cc: linux-kernel, fweisbec, mingo, laijs, rostedt, peterz,
	mathieu.desnoyers, jiayingz, mbligh, lizf

On Tue, Aug 18, 2009 at 12:23:47AM -0700, Josh Stone wrote:
> --- a/kernel/tracepoint.c
> +++ b/kernel/tracepoint.c
> @@ -243,6 +243,11 @@ static void set_tracepoint(struct tracepoint_entry **entry,
>  {
>  	WARN_ON(strcmp((*entry)->name, elem->name) != 0);
>  
> +	if (elem->regfunc && !elem->state && active)
> +		elem->regfunc();
> +	else if (elem->unregfunc && elem->state && !active)
> +		elem->unregfunc();
> +
>  	/*
>  	 * rcu_assign_pointer has a smp_wmb() which makes sure that the new
>  	 * probe callbacks array is consistent before setting a pointer to it.
> @@ -262,6 +267,9 @@ static void set_tracepoint(struct tracepoint_entry **entry,
>   */
>  static void disable_tracepoint(struct tracepoint *elem)
>  {
> +	if (elem->unregfunc && elem->state)
> +		elem->unregfunc();
> +
>  	elem->state = 0;
>  	rcu_assign_pointer(elem->funcs, NULL);
>  }
> @@ -581,15 +589,13 @@ __initcall(init_tracepoints);
>  
>  #ifdef CONFIG_FTRACE_SYSCALLS
>  
> -static DEFINE_MUTEX(regfunc_mutex);
> -static int sys_tracepoint_refcount;
> +static int sys_tracepoint_refcount; /* guarded by tracepoints_mutex */
>  
>  void syscall_regfunc(void)
>  {
>  	unsigned long flags;
>  	struct task_struct *g, *t;
>  
> -	mutex_lock(&regfunc_mutex);
>  	if (!sys_tracepoint_refcount) {
>  		read_lock_irqsave(&tasklist_lock, flags);
>  		do_each_thread(g, t) {
> @@ -598,7 +604,6 @@ void syscall_regfunc(void)
>  		read_unlock_irqrestore(&tasklist_lock, flags);
>  	}
>  	sys_tracepoint_refcount++;
> -	mutex_unlock(&regfunc_mutex);
>  }
>  
>  void syscall_unregfunc(void)
> @@ -606,7 +611,6 @@ void syscall_unregfunc(void)
>  	unsigned long flags;
>  	struct task_struct *g, *t;
>  
> -	mutex_lock(&regfunc_mutex);
>  	sys_tracepoint_refcount--;
>  	if (!sys_tracepoint_refcount) {
>  		read_lock_irqsave(&tasklist_lock, flags);
> @@ -615,6 +619,5 @@ void syscall_unregfunc(void)
>  		} while_each_thread(g, t);
>  		read_unlock_irqrestore(&tasklist_lock, flags);
>  	}
> -	mutex_unlock(&regfunc_mutex);
>  }
>  #endif

if we disable,  CONFIG_FTRACE_SYSCALLS, then we get undefined references
to syscall_regfunc, and syscall_unregfunc. So, i think we just need to
remove the 'CONFIG_FTRACE_SYSCALLS' ifdef here.

thanks,

-Jason

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

* Re: [PATCH] tracing: Create generic syscall TRACE_EVENTs
  2009-08-18 22:25 ` [PATCH] tracing: Create generic syscall TRACE_EVENTs Josh Stone
  2009-08-19  1:32   ` Li Zefan
@ 2009-08-19 16:16   ` Jason Baron
  2009-08-19 17:43     ` Frederic Weisbecker
  1 sibling, 1 reply; 70+ messages in thread
From: Jason Baron @ 2009-08-19 16:16 UTC (permalink / raw)
  To: Josh Stone
  Cc: linux-kernel, fweisbec, mingo, laijs, rostedt, peterz,
	mathieu.desnoyers, jiayingz, mbligh, lizf

On Tue, Aug 18, 2009 at 03:25:59PM -0700, Josh Stone wrote:
> This converts the syscall_enter/exit tracepoints into TRACE_EVENTs, so
> you can have generic ftrace events that capture all system calls with
> arguments and return values.
> 
> The existing event_syscall_enter/exit trace_event structs are renamed to
> event_sys_enter/exit, so they don't conflict with the names generated
> automatically by ftrace.
> 
> Signed-off-by: Josh Stone <jistone@redhat.com>
> Cc: Jason Baron <jbaron@redhat.com>
> ---
>  arch/s390/kernel/ptrace.c       |    3 ++
>  arch/x86/kernel/ptrace.c        |    8 ++---
>  include/linux/syscalls.h        |    4 +-
>  include/trace/events/syscalls.h |   66 +++++++++++++++++++++++++++++++++++++++
>  include/trace/syscall.h         |   17 +---------
>  kernel/trace/trace_syscalls.c   |    5 ++-
>  6 files changed, 79 insertions(+), 24 deletions(-)
>  create mode 100644 include/trace/events/syscalls.h
> 
> diff --git a/arch/s390/kernel/ptrace.c b/arch/s390/kernel/ptrace.c
> index 05f57cd..8730fa7 100644
> --- a/arch/s390/kernel/ptrace.c
> +++ b/arch/s390/kernel/ptrace.c
> @@ -51,6 +51,9 @@
>  #include "compat_ptrace.h"
>  #endif
>  
> +#define CREATE_TRACE_POINTS
> +#include <trace/events/syscalls.h>
> +
>  enum s390_regset {
>  	REGSET_GENERAL,
>  	REGSET_FP,

this will have to be rebased to remove the new s390 DECLARE_TRACE()
calls here like x86.

> diff --git a/arch/x86/kernel/ptrace.c b/arch/x86/kernel/ptrace.c
> index 692fc14..530ff6f 100644
> --- a/arch/x86/kernel/ptrace.c
> +++ b/arch/x86/kernel/ptrace.c
> @@ -35,13 +35,11 @@
>  #include <asm/proto.h>
>  #include <asm/ds.h>
>  
> -#include <trace/syscall.h>
> -
> -DEFINE_TRACE_WITH_CALLBACK(syscall_enter, syscall_regfunc, syscall_unregfunc);
> -DEFINE_TRACE_WITH_CALLBACK(syscall_exit, syscall_regfunc, syscall_unregfunc);
> -
>  #include "tls.h"
>  
> +#define CREATE_TRACE_POINTS
> +#include <trace/events/syscalls.h>
> +
>  enum x86_regset {
>  	REGSET_GENERAL,
>  	REGSET_FP,
> diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h
> index 87d06c1..19b49fd 100644
> --- a/include/linux/syscalls.h
> +++ b/include/linux/syscalls.h
> @@ -187,7 +187,7 @@ static void prof_sysexit_disable_##sname(struct ftrace_event_call *event_call) \
>  	  event_enter_##sname = {					\
>  		.name                   = "sys_enter"#sname,		\
>  		.system                 = "syscalls",			\
> -		.event                  = &event_syscall_enter,		\
> +		.event                  = &event_sys_enter,		\
>  		.raw_init		= init_enter_##sname,		\
>  		.show_format		= ftrace_format_syscall,	\
>  		.regfunc		= reg_event_syscall_enter,	\
> @@ -223,7 +223,7 @@ static void prof_sysexit_disable_##sname(struct ftrace_event_call *event_call) \
>  	  event_exit_##sname = {					\
>  		.name                   = "sys_exit"#sname,		\
>  		.system                 = "syscalls",			\
> -		.event                  = &event_syscall_exit,		\
> +		.event                  = &event_sys_exit,		\
>  		.raw_init		= init_exit_##sname,		\
>  		.regfunc		= reg_event_syscall_exit,	\
>  		.unregfunc		= unreg_event_syscall_exit,	\
> diff --git a/include/trace/events/syscalls.h b/include/trace/events/syscalls.h
> new file mode 100644
> index 0000000..75ccc61
> --- /dev/null
> +++ b/include/trace/events/syscalls.h
> @@ -0,0 +1,66 @@
> +#undef TRACE_SYSTEM
> +#define TRACE_SYSTEM syscalls
> +
> +#if !defined(_TRACE_EVENTS_SYSCALL_H) || defined(TRACE_HEADER_MULTI_READ)
> +#define _TRACE_EVENTS_SYSCALL_H
> +
> +#include <linux/tracepoint.h>
> +
> +#include <asm/ptrace.h>
> +#include <asm/syscall.h>
> +
> +extern void syscall_regfunc(void);
> +extern void syscall_unregfunc(void);
> +
> +
> +TRACE_EVENT_WITH_CALLBACK(syscall_enter,
> +

do we want to call this something like, 'syscall_enter_generic'? to make
it more clear this is the high level syscall tracepoint. similar for
exit.

> +	TP_PROTO(struct pt_regs *regs, long id),
> +
> +	TP_ARGS(regs, id),
> +
> +	TP_STRUCT__entry(
> +		__field(	long,	id		)
> +		__array(	long,	args,	6	)
> +	),
> +
> +	TP_fast_assign(
> +		__entry->id	= id;
> +		syscall_get_arguments(current, regs, 0, 6, __entry->args);
> +	),
> +
> +	TP_printk("NR %ld (%ld, %ld, %ld, %ld, %ld, %ld)",
> +		  __entry->id,
> +		  __entry->args[0], __entry->args[1], __entry->args[2],
> +		  __entry->args[3], __entry->args[4], __entry->args[5]),
> +
> +	syscall_regfunc, syscall_unregfunc
> +);
> +
> +TRACE_EVENT_WITH_CALLBACK(syscall_exit,
> +
> +	TP_PROTO(struct pt_regs *regs, long ret),
> +
> +	TP_ARGS(regs, ret),
> +
> +	TP_STRUCT__entry(
> +		__field(	long,	id		)
> +		__field(	long,	ret		)
> +	),
> +
> +	TP_fast_assign(
> +		__entry->id	= syscall_get_nr(current, regs);
> +		__entry->ret	= ret;
> +	),
> +
> +	TP_printk("NR %ld = %ld",
> +		  __entry->id, __entry->ret),
> +
> +	syscall_regfunc, syscall_unregfunc
> +);
> +
> +#endif /* _TRACE_EVENTS_SYSCALL_H */
> +
> +/* This part must be outside protection */
> +#include <trace/define_trace.h>
> +
> diff --git a/include/trace/syscall.h b/include/trace/syscall.h
> index 49e7ec2..5181893 100644
> --- a/include/trace/syscall.h
> +++ b/include/trace/syscall.h
> @@ -8,19 +8,6 @@
>  #include <asm/ptrace.h>
>  
>  
> -extern void syscall_regfunc(void);
> -extern void syscall_unregfunc(void);
> -
> -DECLARE_TRACE(syscall_enter,
> -	TP_PROTO(struct pt_regs *regs, long id),
> -	TP_ARGS(regs, id)
> -);
> -
> -DECLARE_TRACE(syscall_exit,
> -	TP_PROTO(struct pt_regs *regs, long ret),
> -	TP_ARGS(regs, ret)
> -);
> -
>  /*
>   * A syscall entry in the ftrace syscalls array.
>   *
> @@ -45,8 +32,8 @@ extern struct syscall_metadata *syscall_nr_to_meta(int nr);
>  extern int syscall_name_to_nr(char *name);
>  void set_syscall_enter_id(int num, int id);
>  void set_syscall_exit_id(int num, int id);
> -extern struct trace_event event_syscall_enter;
> -extern struct trace_event event_syscall_exit;
> +extern struct trace_event event_sys_enter;
> +extern struct trace_event event_sys_exit;
>  extern int reg_event_syscall_enter(void *ptr);
>  extern void unreg_event_syscall_enter(void *ptr);
>  extern int reg_event_syscall_exit(void *ptr);
> diff --git a/kernel/trace/trace_syscalls.c b/kernel/trace/trace_syscalls.c
> index f130dac..b174169 100644
> --- a/kernel/trace/trace_syscalls.c
> +++ b/kernel/trace/trace_syscalls.c
> @@ -1,4 +1,5 @@
>  #include <trace/syscall.h>
> +#include <trace/events/syscalls.h>
>  #include <linux/kernel.h>
>  #include <linux/ftrace.h>
>  #include <linux/perf_counter.h>
> @@ -277,11 +278,11 @@ void unreg_event_syscall_exit(void *ptr)
>  	mutex_unlock(&syscall_trace_lock);
>  }
>  
> -struct trace_event event_syscall_enter = {
> +struct trace_event event_sys_enter = {
>  	.trace			= print_syscall_enter,
>  };
>  
> -struct trace_event event_syscall_exit = {
> +struct trace_event event_sys_exit = {
>  	.trace			= print_syscall_exit,
>  };
>  
> -- 
> 1.6.2.5
> 


looks good.

Acked-by: Jason Baron <jbaron@redhat.com>

thanks,

-Jason

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

* Re: [PATCH] tracing: Create generic syscall TRACE_EVENTs
  2009-08-19 16:16   ` Jason Baron
@ 2009-08-19 17:43     ` Frederic Weisbecker
  0 siblings, 0 replies; 70+ messages in thread
From: Frederic Weisbecker @ 2009-08-19 17:43 UTC (permalink / raw)
  To: Jason Baron
  Cc: Josh Stone, linux-kernel, mingo, laijs, rostedt, peterz,
	mathieu.desnoyers, jiayingz, mbligh, lizf

On Wed, Aug 19, 2009 at 12:16:52PM -0400, Jason Baron wrote:
> On Tue, Aug 18, 2009 at 03:25:59PM -0700, Josh Stone wrote:
> > This converts the syscall_enter/exit tracepoints into TRACE_EVENTs, so
> > you can have generic ftrace events that capture all system calls with
> > arguments and return values.
> > 
> > The existing event_syscall_enter/exit trace_event structs are renamed to
> > event_sys_enter/exit, so they don't conflict with the names generated
> > automatically by ftrace.
> > 
> > Signed-off-by: Josh Stone <jistone@redhat.com>
> > Cc: Jason Baron <jbaron@redhat.com>
> > ---
> >  arch/s390/kernel/ptrace.c       |    3 ++
> >  arch/x86/kernel/ptrace.c        |    8 ++---
> >  include/linux/syscalls.h        |    4 +-
> >  include/trace/events/syscalls.h |   66 +++++++++++++++++++++++++++++++++++++++
> >  include/trace/syscall.h         |   17 +---------
> >  kernel/trace/trace_syscalls.c   |    5 ++-
> >  6 files changed, 79 insertions(+), 24 deletions(-)
> >  create mode 100644 include/trace/events/syscalls.h
> > 
> > diff --git a/arch/s390/kernel/ptrace.c b/arch/s390/kernel/ptrace.c
> > index 05f57cd..8730fa7 100644
> > --- a/arch/s390/kernel/ptrace.c
> > +++ b/arch/s390/kernel/ptrace.c
> > @@ -51,6 +51,9 @@
> >  #include "compat_ptrace.h"
> >  #endif
> >  
> > +#define CREATE_TRACE_POINTS
> > +#include <trace/events/syscalls.h>
> > +
> >  enum s390_regset {
> >  	REGSET_GENERAL,
> >  	REGSET_FP,
> 
> this will have to be rebased to remove the new s390 DECLARE_TRACE()
> calls here like x86.
> 
> > diff --git a/arch/x86/kernel/ptrace.c b/arch/x86/kernel/ptrace.c
> > index 692fc14..530ff6f 100644
> > --- a/arch/x86/kernel/ptrace.c
> > +++ b/arch/x86/kernel/ptrace.c
> > @@ -35,13 +35,11 @@
> >  #include <asm/proto.h>
> >  #include <asm/ds.h>
> >  
> > -#include <trace/syscall.h>
> > -
> > -DEFINE_TRACE_WITH_CALLBACK(syscall_enter, syscall_regfunc, syscall_unregfunc);
> > -DEFINE_TRACE_WITH_CALLBACK(syscall_exit, syscall_regfunc, syscall_unregfunc);
> > -
> >  #include "tls.h"
> >  
> > +#define CREATE_TRACE_POINTS
> > +#include <trace/events/syscalls.h>
> > +
> >  enum x86_regset {
> >  	REGSET_GENERAL,
> >  	REGSET_FP,
> > diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h
> > index 87d06c1..19b49fd 100644
> > --- a/include/linux/syscalls.h
> > +++ b/include/linux/syscalls.h
> > @@ -187,7 +187,7 @@ static void prof_sysexit_disable_##sname(struct ftrace_event_call *event_call) \
> >  	  event_enter_##sname = {					\
> >  		.name                   = "sys_enter"#sname,		\
> >  		.system                 = "syscalls",			\
> > -		.event                  = &event_syscall_enter,		\
> > +		.event                  = &event_sys_enter,		\
> >  		.raw_init		= init_enter_##sname,		\
> >  		.show_format		= ftrace_format_syscall,	\
> >  		.regfunc		= reg_event_syscall_enter,	\
> > @@ -223,7 +223,7 @@ static void prof_sysexit_disable_##sname(struct ftrace_event_call *event_call) \
> >  	  event_exit_##sname = {					\
> >  		.name                   = "sys_exit"#sname,		\
> >  		.system                 = "syscalls",			\
> > -		.event                  = &event_syscall_exit,		\
> > +		.event                  = &event_sys_exit,		\
> >  		.raw_init		= init_exit_##sname,		\
> >  		.regfunc		= reg_event_syscall_exit,	\
> >  		.unregfunc		= unreg_event_syscall_exit,	\
> > diff --git a/include/trace/events/syscalls.h b/include/trace/events/syscalls.h
> > new file mode 100644
> > index 0000000..75ccc61
> > --- /dev/null
> > +++ b/include/trace/events/syscalls.h
> > @@ -0,0 +1,66 @@
> > +#undef TRACE_SYSTEM
> > +#define TRACE_SYSTEM syscalls
> > +
> > +#if !defined(_TRACE_EVENTS_SYSCALL_H) || defined(TRACE_HEADER_MULTI_READ)
> > +#define _TRACE_EVENTS_SYSCALL_H
> > +
> > +#include <linux/tracepoint.h>
> > +
> > +#include <asm/ptrace.h>
> > +#include <asm/syscall.h>
> > +
> > +extern void syscall_regfunc(void);
> > +extern void syscall_unregfunc(void);
> > +
> > +
> > +TRACE_EVENT_WITH_CALLBACK(syscall_enter,
> > +
> 
> do we want to call this something like, 'syscall_enter_generic'? to make
> it more clear this is the high level syscall tracepoint. similar for
> exit.


Yeah, that would be indeed less confusing.


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

* Re: [PATCH] tracing: Move tracepoint callbacks into DEFINE
  2009-08-19 16:13 ` [PATCH] tracing: Move tracepoint callbacks into DEFINE Jason Baron
@ 2009-08-20 17:25   ` Josh Stone
  0 siblings, 0 replies; 70+ messages in thread
From: Josh Stone @ 2009-08-20 17:25 UTC (permalink / raw)
  To: Jason Baron
  Cc: linux-kernel, fweisbec, mingo, laijs, rostedt, peterz,
	mathieu.desnoyers, jiayingz, mbligh, lizf

On 08/19/2009 09:13 AM, Jason Baron wrote:
> On Tue, Aug 18, 2009 at 12:23:47AM -0700, Josh Stone wrote:
>> --- a/kernel/tracepoint.c
>> +++ b/kernel/tracepoint.c
>> @@ -243,6 +243,11 @@ static void set_tracepoint(struct tracepoint_entry **entry,
>>  {
>>  	WARN_ON(strcmp((*entry)->name, elem->name) != 0);
>>  
>> +	if (elem->regfunc && !elem->state && active)
>> +		elem->regfunc();
>> +	else if (elem->unregfunc && elem->state && !active)
>> +		elem->unregfunc();
>> +
>>  	/*
>>  	 * rcu_assign_pointer has a smp_wmb() which makes sure that the new
>>  	 * probe callbacks array is consistent before setting a pointer to it.
>> @@ -262,6 +267,9 @@ static void set_tracepoint(struct tracepoint_entry **entry,
>>   */
>>  static void disable_tracepoint(struct tracepoint *elem)
>>  {
>> +	if (elem->unregfunc && elem->state)
>> +		elem->unregfunc();
>> +
>>  	elem->state = 0;
>>  	rcu_assign_pointer(elem->funcs, NULL);
>>  }
>> @@ -581,15 +589,13 @@ __initcall(init_tracepoints);
>>  
>>  #ifdef CONFIG_FTRACE_SYSCALLS
>>  
>> -static DEFINE_MUTEX(regfunc_mutex);
>> -static int sys_tracepoint_refcount;
>> +static int sys_tracepoint_refcount; /* guarded by tracepoints_mutex */
>>  
>>  void syscall_regfunc(void)
>>  {
>>  	unsigned long flags;
>>  	struct task_struct *g, *t;
>>  
>> -	mutex_lock(&regfunc_mutex);
>>  	if (!sys_tracepoint_refcount) {
>>  		read_lock_irqsave(&tasklist_lock, flags);
>>  		do_each_thread(g, t) {
>> @@ -598,7 +604,6 @@ void syscall_regfunc(void)
>>  		read_unlock_irqrestore(&tasklist_lock, flags);
>>  	}
>>  	sys_tracepoint_refcount++;
>> -	mutex_unlock(&regfunc_mutex);
>>  }
>>  
>>  void syscall_unregfunc(void)
>> @@ -606,7 +611,6 @@ void syscall_unregfunc(void)
>>  	unsigned long flags;
>>  	struct task_struct *g, *t;
>>  
>> -	mutex_lock(&regfunc_mutex);
>>  	sys_tracepoint_refcount--;
>>  	if (!sys_tracepoint_refcount) {
>>  		read_lock_irqsave(&tasklist_lock, flags);
>> @@ -615,6 +619,5 @@ void syscall_unregfunc(void)
>>  		} while_each_thread(g, t);
>>  		read_unlock_irqrestore(&tasklist_lock, flags);
>>  	}
>> -	mutex_unlock(&regfunc_mutex);
>>  }
>>  #endif
> 
> if we disable,  CONFIG_FTRACE_SYSCALLS, then we get undefined references
> to syscall_regfunc, and syscall_unregfunc. So, i think we just need to
> remove the 'CONFIG_FTRACE_SYSCALLS' ifdef here.

This CONFIG check was added by commit 60d970c2 to deal with missing
TIF_SYSCALL_FTRACE.  Perhaps the functions should just have their bodies
#ifdef'ed?

Josh

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

* [PATCH v2 1/2] tracing: Move tracepoint callbacks into DEFINE
  2009-08-18  7:23 [PATCH] tracing: Move tracepoint callbacks into DEFINE Josh Stone
                   ` (2 preceding siblings ...)
  2009-08-19 16:13 ` [PATCH] tracing: Move tracepoint callbacks into DEFINE Jason Baron
@ 2009-08-20 19:09 ` Josh Stone
  2009-08-20 19:09   ` [PATCH v2 2/2] tracing: Create generic syscall TRACE_EVENTs Josh Stone
                     ` (3 more replies)
  3 siblings, 4 replies; 70+ messages in thread
From: Josh Stone @ 2009-08-20 19:09 UTC (permalink / raw)
  To: linux-kernel
  Cc: fweisbec, mingo, laijs, rostedt, peterz, mathieu.desnoyers,
	jiayingz, mbligh, lizf, Josh Stone, Jason Baron

It's not strictly correct for the tracepoint reg/unreg callbacks to
occur when a client is hooking up, because the actual tracepoint may no
be present yet.  This happens to be fine for syscall, since that's in
the core kernel, but it would cause problems for tracepoints defined in
a module that hasn't been loaded yet.  It also means the reg/unreg has
to be EXPORTed for any modules to use the tracepoint (as in SystemTap).

This patch removes DECLARE_TRACE_WITH_CALLBACK, and instead introduces
DEFINE_TRACE_WITH_CALLBACK which stores the callbacks in struct
tracepoint.  The callbacks are used now when the active state of the
tracepoint changes in set_tracepoint & disable_tracepoint.

This also introduces TRACE_EVENT_WITH_CALLBACK, so those events can also
provide callbacks if needed.

Signed-off-by: Josh Stone <jistone@redhat.com>
Cc: Jason Baron <jbaron@redhat.com>
---
 arch/s390/kernel/ptrace.c    |    4 +-
 arch/x86/kernel/ptrace.c     |    4 +-
 include/linux/tracepoint.h   |   46 ++++++++++++++++-------------------------
 include/trace/define_trace.h |    5 ++++
 include/trace/ftrace.h       |    9 ++++++++
 include/trace/syscall.h      |   12 +++-------
 kernel/tracepoint.c          |   18 +++++++++++-----
 7 files changed, 52 insertions(+), 46 deletions(-)

diff --git a/arch/s390/kernel/ptrace.c b/arch/s390/kernel/ptrace.c
index c5e87d8..26194b0 100644
--- a/arch/s390/kernel/ptrace.c
+++ b/arch/s390/kernel/ptrace.c
@@ -51,8 +51,8 @@
 #include "compat_ptrace.h"
 #endif
 
-DEFINE_TRACE(syscall_enter);
-DEFINE_TRACE(syscall_exit);
+DEFINE_TRACE_WITH_CALLBACK(syscall_enter, syscall_regfunc, syscall_unregfunc);
+DEFINE_TRACE_WITH_CALLBACK(syscall_exit, syscall_regfunc, syscall_unregfunc);
 
 enum s390_regset {
 	REGSET_GENERAL,
diff --git a/arch/x86/kernel/ptrace.c b/arch/x86/kernel/ptrace.c
index 34dd6f1..692fc14 100644
--- a/arch/x86/kernel/ptrace.c
+++ b/arch/x86/kernel/ptrace.c
@@ -37,8 +37,8 @@
 
 #include <trace/syscall.h>
 
-DEFINE_TRACE(syscall_enter);
-DEFINE_TRACE(syscall_exit);
+DEFINE_TRACE_WITH_CALLBACK(syscall_enter, syscall_regfunc, syscall_unregfunc);
+DEFINE_TRACE_WITH_CALLBACK(syscall_exit, syscall_regfunc, syscall_unregfunc);
 
 #include "tls.h"
 
diff --git a/include/linux/tracepoint.h b/include/linux/tracepoint.h
index 5984ed0..3604b44 100644
--- a/include/linux/tracepoint.h
+++ b/include/linux/tracepoint.h
@@ -23,6 +23,8 @@ struct tracepoint;
 struct tracepoint {
 	const char *name;		/* Tracepoint name */
 	int state;			/* State. */
+	void (*regfunc)(void);
+	void (*unregfunc)(void);
 	void **funcs;
 } __attribute__((aligned(32)));		/*
 					 * Aligned on 32 bytes because it is
@@ -60,10 +62,8 @@ struct tracepoint {
  * Make sure the alignment of the structure in the __tracepoints section will
  * not add unwanted padding between the beginning of the section and the
  * structure. Force alignment to the same alignment as the section start.
- * An optional set of (un)registration functions can be passed to perform any
- * additional (un)registration work.
  */
-#define DECLARE_TRACE_WITH_CALLBACK(name, proto, args, reg, unreg)	\
+#define DECLARE_TRACE(name, proto, args)				\
 	extern struct tracepoint __tracepoint_##name;			\
 	static inline void trace_##name(proto)				\
 	{								\
@@ -73,36 +73,23 @@ struct tracepoint {
 	}								\
 	static inline int register_trace_##name(void (*probe)(proto))	\
 	{								\
-		int ret;						\
-		void (*func)(void) = reg;				\
-									\
-		ret = tracepoint_probe_register(#name, (void *)probe);	\
-		if (func && !ret)					\
-			func();						\
-		return ret;						\
+		return tracepoint_probe_register(#name, (void *)probe);	\
 	}								\
 	static inline int unregister_trace_##name(void (*probe)(proto))	\
 	{								\
-		int ret;						\
-		void (*func)(void) = unreg;				\
-									\
-		ret = tracepoint_probe_unregister(#name, (void *)probe);\
-		if (func && !ret)					\
-			func();						\
-		return ret;						\
+		return tracepoint_probe_unregister(#name, (void *)probe);\
 	}
 
 
-#define DECLARE_TRACE(name, proto, args)				 \
-	DECLARE_TRACE_WITH_CALLBACK(name, TP_PROTO(proto), TP_ARGS(args),\
-					NULL, NULL);
-
-#define DEFINE_TRACE(name)						\
+#define DEFINE_TRACE_WITH_CALLBACK(name, reg, unreg)			\
 	static const char __tpstrtab_##name[]				\
 	__attribute__((section("__tracepoints_strings"))) = #name;	\
 	struct tracepoint __tracepoint_##name				\
 	__attribute__((section("__tracepoints"), aligned(32))) =	\
-		{ __tpstrtab_##name, 0, NULL }
+		{ __tpstrtab_##name, 0, reg, unreg, NULL }
+
+#define DEFINE_TRACE(name)						\
+	DEFINE_TRACE_WITH_CALLBACK(name, NULL, NULL);
 
 #define EXPORT_TRACEPOINT_SYMBOL_GPL(name)				\
 	EXPORT_SYMBOL_GPL(__tracepoint_##name)
@@ -113,7 +100,7 @@ extern void tracepoint_update_probe_range(struct tracepoint *begin,
 	struct tracepoint *end);
 
 #else /* !CONFIG_TRACEPOINTS */
-#define DECLARE_TRACE_WITH_CALLBACK(name, proto, args, reg, unreg)	\
+#define DECLARE_TRACE(name, proto, args)				\
 	static inline void _do_trace_##name(struct tracepoint *tp, proto) \
 	{ }								\
 	static inline void trace_##name(proto)				\
@@ -127,10 +114,7 @@ extern void tracepoint_update_probe_range(struct tracepoint *begin,
 		return -ENOSYS;						\
 	}
 
-#define DECLARE_TRACE(name, proto, args)				 \
-	DECLARE_TRACE_WITH_CALLBACK(name, TP_PROTO(proto), TP_ARGS(args),\
-					NULL, NULL);
-
+#define DEFINE_TRACE_WITH_CALLBACK(name, reg, unreg)
 #define DEFINE_TRACE(name)
 #define EXPORT_TRACEPOINT_SYMBOL_GPL(name)
 #define EXPORT_TRACEPOINT_SYMBOL(name)
@@ -282,10 +266,16 @@ static inline void tracepoint_synchronize_unregister(void)
  * can also by used by generic instrumentation like SystemTap), and
  * it is also used to expose a structured trace record in
  * /sys/kernel/debug/tracing/events/.
+ *
+ * A set of (un)registration functions can be passed to the variant
+ * TRACE_EVENT_WITH_CALLBACK to perform any (un)registration work.
  */
 
 #define TRACE_EVENT(name, proto, args, struct, assign, print)	\
 	DECLARE_TRACE(name, PARAMS(proto), PARAMS(args))
+#define TRACE_EVENT_WITH_CALLBACK(name, proto, args, struct,	\
+		assign, print, reg, unreg)			\
+	DECLARE_TRACE(name, PARAMS(proto), PARAMS(args))
 #endif
 
 #endif
diff --git a/include/trace/define_trace.h b/include/trace/define_trace.h
index f7a7ae1..82c623a 100644
--- a/include/trace/define_trace.h
+++ b/include/trace/define_trace.h
@@ -26,6 +26,11 @@
 #define TRACE_EVENT(name, proto, args, tstruct, assign, print)	\
 	DEFINE_TRACE(name)
 
+#undef TRACE_EVENT_WITH_CALLBACK
+#define TRACE_EVENT_WITH_CALLBACK(name, proto, args, tstruct,	\
+		assign, print, reg, unreg)			\
+	DEFINE_TRACE_WITH_CALLBACK(name, reg, unreg)
+
 #undef DECLARE_TRACE
 #define DECLARE_TRACE(name, proto, args)	\
 	DEFINE_TRACE(name)
diff --git a/include/trace/ftrace.h b/include/trace/ftrace.h
index 1274002..7b9738c 100644
--- a/include/trace/ftrace.h
+++ b/include/trace/ftrace.h
@@ -42,6 +42,15 @@
 	};							\
 	static struct ftrace_event_call event_##name
 
+/* Callbacks are meaningless to ftrace. */
+#undef TRACE_EVENT_WITH_CALLBACK
+#define TRACE_EVENT_WITH_CALLBACK(name, proto, args, tstruct,	\
+		assign, print, reg, unreg)			\
+	TRACE_EVENT(name, TP_PROTO(proto), TP_ARGS(args),	\
+		TP_STRUCT__entry(tstruct),			\
+		TP_fast_assign(assign),				\
+		TP_printk(print))
+
 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
 
 
diff --git a/include/trace/syscall.h b/include/trace/syscall.h
index 9661dd4..c10e1f5 100644
--- a/include/trace/syscall.h
+++ b/include/trace/syscall.h
@@ -11,18 +11,14 @@
 extern void syscall_regfunc(void);
 extern void syscall_unregfunc(void);
 
-DECLARE_TRACE_WITH_CALLBACK(syscall_enter,
+DECLARE_TRACE(syscall_enter,
 	TP_PROTO(struct pt_regs *regs, long id),
-	TP_ARGS(regs, id),
-	syscall_regfunc,
-	syscall_unregfunc
+	TP_ARGS(regs, id)
 );
 
-DECLARE_TRACE_WITH_CALLBACK(syscall_exit,
+DECLARE_TRACE(syscall_exit,
 	TP_PROTO(struct pt_regs *regs, long ret),
-	TP_ARGS(regs, ret),
-	syscall_regfunc,
-	syscall_unregfunc
+	TP_ARGS(regs, ret)
 );
 
 /*
diff --git a/kernel/tracepoint.c b/kernel/tracepoint.c
index 35dd27a..98fc3ac 100644
--- a/kernel/tracepoint.c
+++ b/kernel/tracepoint.c
@@ -243,6 +243,11 @@ static void set_tracepoint(struct tracepoint_entry **entry,
 {
 	WARN_ON(strcmp((*entry)->name, elem->name) != 0);
 
+	if (elem->regfunc && !elem->state && active)
+		elem->regfunc();
+	else if (elem->unregfunc && elem->state && !active)
+		elem->unregfunc();
+
 	/*
 	 * rcu_assign_pointer has a smp_wmb() which makes sure that the new
 	 * probe callbacks array is consistent before setting a pointer to it.
@@ -262,6 +267,9 @@ static void set_tracepoint(struct tracepoint_entry **entry,
  */
 static void disable_tracepoint(struct tracepoint *elem)
 {
+	if (elem->unregfunc && elem->state)
+		elem->unregfunc();
+
 	elem->state = 0;
 	rcu_assign_pointer(elem->funcs, NULL);
 }
@@ -581,15 +589,13 @@ __initcall(init_tracepoints);
 
 #ifdef CONFIG_FTRACE_SYSCALLS
 
-static DEFINE_MUTEX(regfunc_mutex);
-static int sys_tracepoint_refcount;
+static int sys_tracepoint_refcount; /* guarded by tracepoints_mutex */
 
 void syscall_regfunc(void)
 {
 	unsigned long flags;
 	struct task_struct *g, *t;
 
-	mutex_lock(&regfunc_mutex);
 	if (!sys_tracepoint_refcount) {
 		read_lock_irqsave(&tasklist_lock, flags);
 		do_each_thread(g, t) {
@@ -598,7 +604,6 @@ void syscall_regfunc(void)
 		read_unlock_irqrestore(&tasklist_lock, flags);
 	}
 	sys_tracepoint_refcount++;
-	mutex_unlock(&regfunc_mutex);
 }
 
 void syscall_unregfunc(void)
@@ -606,7 +611,6 @@ void syscall_unregfunc(void)
 	unsigned long flags;
 	struct task_struct *g, *t;
 
-	mutex_lock(&regfunc_mutex);
 	sys_tracepoint_refcount--;
 	if (!sys_tracepoint_refcount) {
 		read_lock_irqsave(&tasklist_lock, flags);
@@ -615,6 +619,8 @@ void syscall_unregfunc(void)
 		} while_each_thread(g, t);
 		read_unlock_irqrestore(&tasklist_lock, flags);
 	}
-	mutex_unlock(&regfunc_mutex);
 }
+#else
+void syscall_regfunc(void) {}
+void syscall_unregfunc(void) {}
 #endif
-- 
1.6.2.5


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

* [PATCH v2 2/2] tracing: Create generic syscall TRACE_EVENTs
  2009-08-20 19:09 ` [PATCH v2 1/2] " Josh Stone
@ 2009-08-20 19:09   ` Josh Stone
  2009-08-21 17:57     ` Jason Baron
  2009-08-21 14:47   ` [PATCH v2 1/2] tracing: Move tracepoint callbacks into DEFINE Ingo Molnar
                     ` (2 subsequent siblings)
  3 siblings, 1 reply; 70+ messages in thread
From: Josh Stone @ 2009-08-20 19:09 UTC (permalink / raw)
  To: linux-kernel
  Cc: fweisbec, mingo, laijs, rostedt, peterz, mathieu.desnoyers,
	jiayingz, mbligh, lizf, Josh Stone, Jason Baron

This converts the syscall_enter/exit tracepoints into TRACE_EVENTs, so
you can have generic ftrace events that capture all system calls with
arguments and return values.  These generic events are also renamed to
sys_enter/exit, so they're more closely aligned to the specific
sys_enter_foo events.

Signed-off-by: Josh Stone <jistone@redhat.com>
Cc: Jason Baron <jbaron@redhat.com>
---
 arch/s390/kernel/ptrace.c       |    8 ++--
 arch/x86/kernel/ptrace.c        |   12 +++----
 include/trace/events/syscalls.h |   66 +++++++++++++++++++++++++++++++++++++++
 include/trace/syscall.h         |   13 --------
 kernel/trace/trace_syscalls.c   |   17 +++++-----
 5 files changed, 84 insertions(+), 32 deletions(-)
 create mode 100644 include/trace/events/syscalls.h

diff --git a/arch/s390/kernel/ptrace.c b/arch/s390/kernel/ptrace.c
index 26194b0..8e578a9 100644
--- a/arch/s390/kernel/ptrace.c
+++ b/arch/s390/kernel/ptrace.c
@@ -51,8 +51,8 @@
 #include "compat_ptrace.h"
 #endif
 
-DEFINE_TRACE_WITH_CALLBACK(syscall_enter, syscall_regfunc, syscall_unregfunc);
-DEFINE_TRACE_WITH_CALLBACK(syscall_exit, syscall_regfunc, syscall_unregfunc);
+#define CREATE_TRACE_POINTS
+#include <trace/events/syscalls.h>
 
 enum s390_regset {
 	REGSET_GENERAL,
@@ -665,7 +665,7 @@ asmlinkage long do_syscall_trace_enter(struct pt_regs *regs)
 	}
 
 	if (unlikely(test_thread_flag(TIF_SYSCALL_FTRACE)))
-		trace_syscall_enter(regs, regs->gprs[2]);
+		trace_sys_enter(regs, regs->gprs[2]);
 
 	if (unlikely(current->audit_context))
 		audit_syscall_entry(is_compat_task() ?
@@ -683,7 +683,7 @@ asmlinkage void do_syscall_trace_exit(struct pt_regs *regs)
 				   regs->gprs[2]);
 
 	if (unlikely(test_thread_flag(TIF_SYSCALL_FTRACE)))
-		trace_syscall_exit(regs, regs->gprs[2]);
+		trace_sys_exit(regs, regs->gprs[2]);
 
 	if (test_thread_flag(TIF_SYSCALL_TRACE))
 		tracehook_report_syscall_exit(regs, 0);
diff --git a/arch/x86/kernel/ptrace.c b/arch/x86/kernel/ptrace.c
index 692fc14..dc87a04 100644
--- a/arch/x86/kernel/ptrace.c
+++ b/arch/x86/kernel/ptrace.c
@@ -35,13 +35,11 @@
 #include <asm/proto.h>
 #include <asm/ds.h>
 
-#include <trace/syscall.h>
-
-DEFINE_TRACE_WITH_CALLBACK(syscall_enter, syscall_regfunc, syscall_unregfunc);
-DEFINE_TRACE_WITH_CALLBACK(syscall_exit, syscall_regfunc, syscall_unregfunc);
-
 #include "tls.h"
 
+#define CREATE_TRACE_POINTS
+#include <trace/events/syscalls.h>
+
 enum x86_regset {
 	REGSET_GENERAL,
 	REGSET_FP,
@@ -1501,7 +1499,7 @@ asmregparm long syscall_trace_enter(struct pt_regs *regs)
 		ret = -1L;
 
 	if (unlikely(test_thread_flag(TIF_SYSCALL_FTRACE)))
-		trace_syscall_enter(regs, regs->orig_ax);
+		trace_sys_enter(regs, regs->orig_ax);
 
 	if (unlikely(current->audit_context)) {
 		if (IS_IA32)
@@ -1527,7 +1525,7 @@ asmregparm void syscall_trace_leave(struct pt_regs *regs)
 		audit_syscall_exit(AUDITSC_RESULT(regs->ax), regs->ax);
 
 	if (unlikely(test_thread_flag(TIF_SYSCALL_FTRACE)))
-		trace_syscall_exit(regs, regs->ax);
+		trace_sys_exit(regs, regs->ax);
 
 	if (test_thread_flag(TIF_SYSCALL_TRACE))
 		tracehook_report_syscall_exit(regs, 0);
diff --git a/include/trace/events/syscalls.h b/include/trace/events/syscalls.h
new file mode 100644
index 0000000..9cd78fc
--- /dev/null
+++ b/include/trace/events/syscalls.h
@@ -0,0 +1,66 @@
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM syscalls
+
+#if !defined(_TRACE_EVENTS_SYSCALLS_H) || defined(TRACE_HEADER_MULTI_READ)
+#define _TRACE_EVENTS_SYSCALLS_H
+
+#include <linux/tracepoint.h>
+
+#include <asm/ptrace.h>
+#include <asm/syscall.h>
+
+extern void syscall_regfunc(void);
+extern void syscall_unregfunc(void);
+
+
+TRACE_EVENT_WITH_CALLBACK(sys_enter,
+
+	TP_PROTO(struct pt_regs *regs, long id),
+
+	TP_ARGS(regs, id),
+
+	TP_STRUCT__entry(
+		__field(	long,		id		)
+		__array(	unsigned long,	args,	6	)
+	),
+
+	TP_fast_assign(
+		__entry->id	= id;
+		syscall_get_arguments(current, regs, 0, 6, __entry->args);
+	),
+
+	TP_printk("NR %ld (%lx, %lx, %lx, %lx, %lx, %lx)",
+		  __entry->id,
+		  __entry->args[0], __entry->args[1], __entry->args[2],
+		  __entry->args[3], __entry->args[4], __entry->args[5]),
+
+	syscall_regfunc, syscall_unregfunc
+);
+
+TRACE_EVENT_WITH_CALLBACK(sys_exit,
+
+	TP_PROTO(struct pt_regs *regs, long ret),
+
+	TP_ARGS(regs, ret),
+
+	TP_STRUCT__entry(
+		__field(	long,	id	)
+		__field(	long,	ret	)
+	),
+
+	TP_fast_assign(
+		__entry->id	= syscall_get_nr(current, regs);
+		__entry->ret	= ret;
+	),
+
+	TP_printk("NR %ld = %ld",
+		  __entry->id, __entry->ret),
+
+	syscall_regfunc, syscall_unregfunc
+);
+
+#endif /* _TRACE_EVENTS_SYSCALLS_H */
+
+/* This part must be outside protection */
+#include <trace/define_trace.h>
+
diff --git a/include/trace/syscall.h b/include/trace/syscall.h
index c10e1f5..5dc283b 100644
--- a/include/trace/syscall.h
+++ b/include/trace/syscall.h
@@ -8,19 +8,6 @@
 #include <asm/ptrace.h>
 
 
-extern void syscall_regfunc(void);
-extern void syscall_unregfunc(void);
-
-DECLARE_TRACE(syscall_enter,
-	TP_PROTO(struct pt_regs *regs, long id),
-	TP_ARGS(regs, id)
-);
-
-DECLARE_TRACE(syscall_exit,
-	TP_PROTO(struct pt_regs *regs, long ret),
-	TP_ARGS(regs, ret)
-);
-
 /*
  * A syscall entry in the ftrace syscalls array.
  *
diff --git a/kernel/trace/trace_syscalls.c b/kernel/trace/trace_syscalls.c
index 46c1b97..2698fe4 100644
--- a/kernel/trace/trace_syscalls.c
+++ b/kernel/trace/trace_syscalls.c
@@ -1,4 +1,5 @@
 #include <trace/syscall.h>
+#include <trace/events/syscalls.h>
 #include <linux/kernel.h>
 #include <linux/ftrace.h>
 #include <linux/perf_counter.h>
@@ -286,7 +287,7 @@ int reg_event_syscall_enter(void *ptr)
 		return -ENOSYS;
 	mutex_lock(&syscall_trace_lock);
 	if (!sys_refcount_enter)
-		ret = register_trace_syscall_enter(ftrace_syscall_enter);
+		ret = register_trace_sys_enter(ftrace_syscall_enter);
 	if (ret) {
 		pr_info("event trace: Could not activate"
 				"syscall entry trace point");
@@ -311,7 +312,7 @@ void unreg_event_syscall_enter(void *ptr)
 	sys_refcount_enter--;
 	clear_bit(num, enabled_enter_syscalls);
 	if (!sys_refcount_enter)
-		unregister_trace_syscall_enter(ftrace_syscall_enter);
+		unregister_trace_sys_enter(ftrace_syscall_enter);
 	mutex_unlock(&syscall_trace_lock);
 }
 
@@ -327,7 +328,7 @@ int reg_event_syscall_exit(void *ptr)
 		return -ENOSYS;
 	mutex_lock(&syscall_trace_lock);
 	if (!sys_refcount_exit)
-		ret = register_trace_syscall_exit(ftrace_syscall_exit);
+		ret = register_trace_sys_exit(ftrace_syscall_exit);
 	if (ret) {
 		pr_info("event trace: Could not activate"
 				"syscall exit trace point");
@@ -352,7 +353,7 @@ void unreg_event_syscall_exit(void *ptr)
 	sys_refcount_exit--;
 	clear_bit(num, enabled_exit_syscalls);
 	if (!sys_refcount_exit)
-		unregister_trace_syscall_exit(ftrace_syscall_exit);
+		unregister_trace_sys_exit(ftrace_syscall_exit);
 	mutex_unlock(&syscall_trace_lock);
 }
 
@@ -418,7 +419,7 @@ int reg_prof_syscall_enter(char *name)
 
 	mutex_lock(&syscall_trace_lock);
 	if (!sys_prof_refcount_enter)
-		ret = register_trace_syscall_enter(prof_syscall_enter);
+		ret = register_trace_sys_enter(prof_syscall_enter);
 	if (ret) {
 		pr_info("event trace: Could not activate"
 				"syscall entry trace point");
@@ -442,7 +443,7 @@ void unreg_prof_syscall_enter(char *name)
 	sys_prof_refcount_enter--;
 	clear_bit(num, enabled_prof_enter_syscalls);
 	if (!sys_prof_refcount_enter)
-		unregister_trace_syscall_enter(prof_syscall_enter);
+		unregister_trace_sys_enter(prof_syscall_enter);
 	mutex_unlock(&syscall_trace_lock);
 }
 
@@ -479,7 +480,7 @@ int reg_prof_syscall_exit(char *name)
 
 	mutex_lock(&syscall_trace_lock);
 	if (!sys_prof_refcount_exit)
-		ret = register_trace_syscall_exit(prof_syscall_exit);
+		ret = register_trace_sys_exit(prof_syscall_exit);
 	if (ret) {
 		pr_info("event trace: Could not activate"
 				"syscall entry trace point");
@@ -503,7 +504,7 @@ void unreg_prof_syscall_exit(char *name)
 	sys_prof_refcount_exit--;
 	clear_bit(num, enabled_prof_exit_syscalls);
 	if (!sys_prof_refcount_exit)
-		unregister_trace_syscall_exit(prof_syscall_exit);
+		unregister_trace_sys_exit(prof_syscall_exit);
 	mutex_unlock(&syscall_trace_lock);
 }
 
-- 
1.6.2.5


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

* Re: [PATCH v2 1/2] tracing: Move tracepoint callbacks into DEFINE
  2009-08-20 19:09 ` [PATCH v2 1/2] " Josh Stone
  2009-08-20 19:09   ` [PATCH v2 2/2] tracing: Create generic syscall TRACE_EVENTs Josh Stone
@ 2009-08-21 14:47   ` Ingo Molnar
  2009-08-21 19:34     ` Josh Stone
  2009-08-21 17:52   ` Jason Baron
  2009-08-22  4:58   ` [PATCH v3 0/4] tracing: tweaks for generic syscall events Josh Stone
  3 siblings, 1 reply; 70+ messages in thread
From: Ingo Molnar @ 2009-08-21 14:47 UTC (permalink / raw)
  To: Josh Stone
  Cc: linux-kernel, fweisbec, laijs, rostedt, peterz,
	mathieu.desnoyers, jiayingz, mbligh, lizf, Jason Baron


* Josh Stone <jistone@redhat.com> wrote:

> It's not strictly correct for the tracepoint reg/unreg callbacks 
> to occur when a client is hooking up, because the actual 
> tracepoint may no be present yet.  This happens to be fine for 
> syscall, since that's in the core kernel, but it would cause 
> problems for tracepoints defined in a module that hasn't been 
> loaded yet.  It also means the reg/unreg has to be EXPORTed for 
> any modules to use the tracepoint (as in SystemTap).
> 
> This patch removes DECLARE_TRACE_WITH_CALLBACK, and instead 
> introduces DEFINE_TRACE_WITH_CALLBACK which stores the callbacks 
> in struct tracepoint.  The callbacks are used now when the active 
> state of the tracepoint changes in set_tracepoint & 
> disable_tracepoint.
> 
> This also introduces TRACE_EVENT_WITH_CALLBACK, so those events 
> can also provide callbacks if needed.

i think something shorter would be nicer, such as:

 DECLARE_TRACE_FN
 TRACE_EVENT_FN

	Ingo

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

* Re: [PATCH v2 1/2] tracing: Move tracepoint callbacks into DEFINE
  2009-08-20 19:09 ` [PATCH v2 1/2] " Josh Stone
  2009-08-20 19:09   ` [PATCH v2 2/2] tracing: Create generic syscall TRACE_EVENTs Josh Stone
  2009-08-21 14:47   ` [PATCH v2 1/2] tracing: Move tracepoint callbacks into DEFINE Ingo Molnar
@ 2009-08-21 17:52   ` Jason Baron
  2009-08-21 19:34     ` Josh Stone
  2009-08-22  4:58   ` [PATCH v3 0/4] tracing: tweaks for generic syscall events Josh Stone
  3 siblings, 1 reply; 70+ messages in thread
From: Jason Baron @ 2009-08-21 17:52 UTC (permalink / raw)
  To: Josh Stone
  Cc: linux-kernel, fweisbec, mingo, laijs, rostedt, peterz,
	mathieu.desnoyers, jiayingz, mbligh, lizf

On Thu, Aug 20, 2009 at 12:09:32PM -0700, Josh Stone wrote:
> 
> It's not strictly correct for the tracepoint reg/unreg callbacks to
> occur when a client is hooking up, because the actual tracepoint may no
> be present yet.  This happens to be fine for syscall, since that's in
> the core kernel, but it would cause problems for tracepoints defined in
> a module that hasn't been loaded yet.  It also means the reg/unreg has
> to be EXPORTed for any modules to use the tracepoint (as in SystemTap).
> 
> This patch removes DECLARE_TRACE_WITH_CALLBACK, and instead introduces
> DEFINE_TRACE_WITH_CALLBACK which stores the callbacks in struct
> tracepoint.  The callbacks are used now when the active state of the
> tracepoint changes in set_tracepoint & disable_tracepoint.
> 
> This also introduces TRACE_EVENT_WITH_CALLBACK, so those events can also
> provide callbacks if needed.
> 
> Signed-off-by: Josh Stone <jistone@redhat.com>
> Cc: Jason Baron <jbaron@redhat.com>
> ---
>  arch/s390/kernel/ptrace.c    |    4 +-
>  arch/x86/kernel/ptrace.c     |    4 +-
>  include/linux/tracepoint.h   |   46 ++++++++++++++++-------------------------
>  include/trace/define_trace.h |    5 ++++
>  include/trace/ftrace.h       |    9 ++++++++
>  include/trace/syscall.h      |   12 +++-------
>  kernel/tracepoint.c          |   18 +++++++++++-----
>  7 files changed, 52 insertions(+), 46 deletions(-)
> 
> diff --git a/arch/s390/kernel/ptrace.c b/arch/s390/kernel/ptrace.c
> index c5e87d8..26194b0 100644
> --- a/arch/s390/kernel/ptrace.c
> +++ b/arch/s390/kernel/ptrace.c
> @@ -51,8 +51,8 @@
>  #include "compat_ptrace.h"
>  #endif
>  
> -DEFINE_TRACE(syscall_enter);
> -DEFINE_TRACE(syscall_exit);
> +DEFINE_TRACE_WITH_CALLBACK(syscall_enter, syscall_regfunc, syscall_unregfunc);
> +DEFINE_TRACE_WITH_CALLBACK(syscall_exit, syscall_regfunc, syscall_unregfunc);
>  
>  enum s390_regset {
>  	REGSET_GENERAL,
> diff --git a/arch/x86/kernel/ptrace.c b/arch/x86/kernel/ptrace.c
> index 34dd6f1..692fc14 100644
> --- a/arch/x86/kernel/ptrace.c
> +++ b/arch/x86/kernel/ptrace.c
> @@ -37,8 +37,8 @@
>  
>  #include <trace/syscall.h>
>  
> -DEFINE_TRACE(syscall_enter);
> -DEFINE_TRACE(syscall_exit);
> +DEFINE_TRACE_WITH_CALLBACK(syscall_enter, syscall_regfunc, syscall_unregfunc);
> +DEFINE_TRACE_WITH_CALLBACK(syscall_exit, syscall_regfunc, syscall_unregfunc);
>  
>  #include "tls.h"
>  
> diff --git a/include/linux/tracepoint.h b/include/linux/tracepoint.h
> index 5984ed0..3604b44 100644
> --- a/include/linux/tracepoint.h
> +++ b/include/linux/tracepoint.h
> @@ -23,6 +23,8 @@ struct tracepoint;
>  struct tracepoint {
>  	const char *name;		/* Tracepoint name */
>  	int state;			/* State. */
> +	void (*regfunc)(void);
> +	void (*unregfunc)(void);
>  	void **funcs;
>  } __attribute__((aligned(32)));		/*
>  					 * Aligned on 32 bytes because it is
> @@ -60,10 +62,8 @@ struct tracepoint {
>   * Make sure the alignment of the structure in the __tracepoints section will
>   * not add unwanted padding between the beginning of the section and the
>   * structure. Force alignment to the same alignment as the section start.
> - * An optional set of (un)registration functions can be passed to perform any
> - * additional (un)registration work.
>   */
> -#define DECLARE_TRACE_WITH_CALLBACK(name, proto, args, reg, unreg)	\
> +#define DECLARE_TRACE(name, proto, args)				\
>  	extern struct tracepoint __tracepoint_##name;			\
>  	static inline void trace_##name(proto)				\
>  	{								\
> @@ -73,36 +73,23 @@ struct tracepoint {
>  	}								\
>  	static inline int register_trace_##name(void (*probe)(proto))	\
>  	{								\
> -		int ret;						\
> -		void (*func)(void) = reg;				\
> -									\
> -		ret = tracepoint_probe_register(#name, (void *)probe);	\
> -		if (func && !ret)					\
> -			func();						\
> -		return ret;						\
> +		return tracepoint_probe_register(#name, (void *)probe);	\
>  	}								\
>  	static inline int unregister_trace_##name(void (*probe)(proto))	\
>  	{								\
> -		int ret;						\
> -		void (*func)(void) = unreg;				\
> -									\
> -		ret = tracepoint_probe_unregister(#name, (void *)probe);\
> -		if (func && !ret)					\
> -			func();						\
> -		return ret;						\
> +		return tracepoint_probe_unregister(#name, (void *)probe);\
>  	}
>  
>  
> -#define DECLARE_TRACE(name, proto, args)				 \
> -	DECLARE_TRACE_WITH_CALLBACK(name, TP_PROTO(proto), TP_ARGS(args),\
> -					NULL, NULL);
> -
> -#define DEFINE_TRACE(name)						\
> +#define DEFINE_TRACE_WITH_CALLBACK(name, reg, unreg)			\
>  	static const char __tpstrtab_##name[]				\
>  	__attribute__((section("__tracepoints_strings"))) = #name;	\
>  	struct tracepoint __tracepoint_##name				\
>  	__attribute__((section("__tracepoints"), aligned(32))) =	\
> -		{ __tpstrtab_##name, 0, NULL }
> +		{ __tpstrtab_##name, 0, reg, unreg, NULL }
> +
> +#define DEFINE_TRACE(name)						\
> +	DEFINE_TRACE_WITH_CALLBACK(name, NULL, NULL);
>  
>  #define EXPORT_TRACEPOINT_SYMBOL_GPL(name)				\
>  	EXPORT_SYMBOL_GPL(__tracepoint_##name)
> @@ -113,7 +100,7 @@ extern void tracepoint_update_probe_range(struct tracepoint *begin,
>  	struct tracepoint *end);
>  
>  #else /* !CONFIG_TRACEPOINTS */
> -#define DECLARE_TRACE_WITH_CALLBACK(name, proto, args, reg, unreg)	\
> +#define DECLARE_TRACE(name, proto, args)				\
>  	static inline void _do_trace_##name(struct tracepoint *tp, proto) \
>  	{ }								\
>  	static inline void trace_##name(proto)				\
> @@ -127,10 +114,7 @@ extern void tracepoint_update_probe_range(struct tracepoint *begin,
>  		return -ENOSYS;						\
>  	}
>  
> -#define DECLARE_TRACE(name, proto, args)				 \
> -	DECLARE_TRACE_WITH_CALLBACK(name, TP_PROTO(proto), TP_ARGS(args),\
> -					NULL, NULL);
> -
> +#define DEFINE_TRACE_WITH_CALLBACK(name, reg, unreg)
>  #define DEFINE_TRACE(name)
>  #define EXPORT_TRACEPOINT_SYMBOL_GPL(name)
>  #define EXPORT_TRACEPOINT_SYMBOL(name)
> @@ -282,10 +266,16 @@ static inline void tracepoint_synchronize_unregister(void)
>   * can also by used by generic instrumentation like SystemTap), and
>   * it is also used to expose a structured trace record in
>   * /sys/kernel/debug/tracing/events/.
> + *
> + * A set of (un)registration functions can be passed to the variant
> + * TRACE_EVENT_WITH_CALLBACK to perform any (un)registration work.
>   */
>  
>  #define TRACE_EVENT(name, proto, args, struct, assign, print)	\
>  	DECLARE_TRACE(name, PARAMS(proto), PARAMS(args))
> +#define TRACE_EVENT_WITH_CALLBACK(name, proto, args, struct,	\
> +		assign, print, reg, unreg)			\
> +	DECLARE_TRACE(name, PARAMS(proto), PARAMS(args))
>  #endif
>  
>  #endif
> diff --git a/include/trace/define_trace.h b/include/trace/define_trace.h
> index f7a7ae1..82c623a 100644
> --- a/include/trace/define_trace.h
> +++ b/include/trace/define_trace.h
> @@ -26,6 +26,11 @@
>  #define TRACE_EVENT(name, proto, args, tstruct, assign, print)	\
>  	DEFINE_TRACE(name)
>  
> +#undef TRACE_EVENT_WITH_CALLBACK
> +#define TRACE_EVENT_WITH_CALLBACK(name, proto, args, tstruct,	\
> +		assign, print, reg, unreg)			\
> +	DEFINE_TRACE_WITH_CALLBACK(name, reg, unreg)
> +
>  #undef DECLARE_TRACE
>  #define DECLARE_TRACE(name, proto, args)	\
>  	DEFINE_TRACE(name)
> diff --git a/include/trace/ftrace.h b/include/trace/ftrace.h
> index 1274002..7b9738c 100644
> --- a/include/trace/ftrace.h
> +++ b/include/trace/ftrace.h
> @@ -42,6 +42,15 @@
>  	};							\
>  	static struct ftrace_event_call event_##name
>  
> +/* Callbacks are meaningless to ftrace. */
> +#undef TRACE_EVENT_WITH_CALLBACK
> +#define TRACE_EVENT_WITH_CALLBACK(name, proto, args, tstruct,	\
> +		assign, print, reg, unreg)			\
> +	TRACE_EVENT(name, TP_PROTO(proto), TP_ARGS(args),	\
> +		TP_STRUCT__entry(tstruct),			\
> +		TP_fast_assign(assign),				\
> +		TP_printk(print))
> +
>  #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
>  
>  
> diff --git a/include/trace/syscall.h b/include/trace/syscall.h
> index 9661dd4..c10e1f5 100644
> --- a/include/trace/syscall.h
> +++ b/include/trace/syscall.h
> @@ -11,18 +11,14 @@
>  extern void syscall_regfunc(void);
>  extern void syscall_unregfunc(void);
>  
> -DECLARE_TRACE_WITH_CALLBACK(syscall_enter,
> +DECLARE_TRACE(syscall_enter,
>  	TP_PROTO(struct pt_regs *regs, long id),
> -	TP_ARGS(regs, id),
> -	syscall_regfunc,
> -	syscall_unregfunc
> +	TP_ARGS(regs, id)
>  );
>  
> -DECLARE_TRACE_WITH_CALLBACK(syscall_exit,
> +DECLARE_TRACE(syscall_exit,
>  	TP_PROTO(struct pt_regs *regs, long ret),
> -	TP_ARGS(regs, ret),
> -	syscall_regfunc,
> -	syscall_unregfunc
> +	TP_ARGS(regs, ret)
>  );
>  
>  /*
> diff --git a/kernel/tracepoint.c b/kernel/tracepoint.c
> index 35dd27a..98fc3ac 100644
> --- a/kernel/tracepoint.c
> +++ b/kernel/tracepoint.c
> @@ -243,6 +243,11 @@ static void set_tracepoint(struct tracepoint_entry **entry,
>  {
>  	WARN_ON(strcmp((*entry)->name, elem->name) != 0);
>  
> +	if (elem->regfunc && !elem->state && active)
> +		elem->regfunc();
> +	else if (elem->unregfunc && elem->state && !active)
> +		elem->unregfunc();
> +
>  	/*
>  	 * rcu_assign_pointer has a smp_wmb() which makes sure that the new
>  	 * probe callbacks array is consistent before setting a pointer to it.
> @@ -262,6 +267,9 @@ static void set_tracepoint(struct tracepoint_entry **entry,
>   */
>  static void disable_tracepoint(struct tracepoint *elem)
>  {
> +	if (elem->unregfunc && elem->state)
> +		elem->unregfunc();
> +
>  	elem->state = 0;
>  	rcu_assign_pointer(elem->funcs, NULL);
>  }
> @@ -581,15 +589,13 @@ __initcall(init_tracepoints);
>  
>  #ifdef CONFIG_FTRACE_SYSCALLS
>  
> -static DEFINE_MUTEX(regfunc_mutex);
> -static int sys_tracepoint_refcount;
> +static int sys_tracepoint_refcount; /* guarded by tracepoints_mutex */
>  
>  void syscall_regfunc(void)
>  {
>  	unsigned long flags;
>  	struct task_struct *g, *t;
>  
> -	mutex_lock(&regfunc_mutex);
>  	if (!sys_tracepoint_refcount) {
>  		read_lock_irqsave(&tasklist_lock, flags);
>  		do_each_thread(g, t) {
> @@ -598,7 +604,6 @@ void syscall_regfunc(void)
>  		read_unlock_irqrestore(&tasklist_lock, flags);
>  	}
>  	sys_tracepoint_refcount++;
> -	mutex_unlock(&regfunc_mutex);
>  }
>  
>  void syscall_unregfunc(void)
> @@ -606,7 +611,6 @@ void syscall_unregfunc(void)
>  	unsigned long flags;
>  	struct task_struct *g, *t;
>  
> -	mutex_lock(&regfunc_mutex);
>  	sys_tracepoint_refcount--;
>  	if (!sys_tracepoint_refcount) {
>  		read_lock_irqsave(&tasklist_lock, flags);
> @@ -615,6 +619,8 @@ void syscall_unregfunc(void)
>  		} while_each_thread(g, t);
>  		read_unlock_irqrestore(&tasklist_lock, flags);
>  	}
> -	mutex_unlock(&regfunc_mutex);
>  }
> +#else
> +void syscall_regfunc(void) {}
> +void syscall_unregfunc(void) {}
>  #endif

hi,

this means that when CONFIG_EVENT_TRACING is set, the 'generic' syscall
enter/exit will show up as events in the debugfs, but enabling them
wouldn't do anything. I think we should simply drop the
'CONFIG_FTRACE_SYSCALLS' 'ifdef' and 'else' clause. That will give us
what we want - tying these callbacks directly to tracepoint.

thanks,

-Jason

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

* Re: [PATCH v2 2/2] tracing: Create generic syscall TRACE_EVENTs
  2009-08-20 19:09   ` [PATCH v2 2/2] tracing: Create generic syscall TRACE_EVENTs Josh Stone
@ 2009-08-21 17:57     ` Jason Baron
  2009-08-21 19:37       ` Josh Stone
  0 siblings, 1 reply; 70+ messages in thread
From: Jason Baron @ 2009-08-21 17:57 UTC (permalink / raw)
  To: Josh Stone
  Cc: linux-kernel, fweisbec, mingo, laijs, rostedt, peterz,
	mathieu.desnoyers, jiayingz, mbligh, lizf

On Thu, Aug 20, 2009 at 12:09:33PM -0700, Josh Stone wrote:
> This converts the syscall_enter/exit tracepoints into TRACE_EVENTs, so
> you can have generic ftrace events that capture all system calls with
> arguments and return values.  These generic events are also renamed to
> sys_enter/exit, so they're more closely aligned to the specific
> sys_enter_foo events.
> 
> Signed-off-by: Josh Stone <jistone@redhat.com>
> Cc: Jason Baron <jbaron@redhat.com>
> ---
>  arch/s390/kernel/ptrace.c       |    8 ++--
>  arch/x86/kernel/ptrace.c        |   12 +++----
>  include/trace/events/syscalls.h |   66 +++++++++++++++++++++++++++++++++++++++
>  include/trace/syscall.h         |   13 --------
>  kernel/trace/trace_syscalls.c   |   17 +++++-----
>  5 files changed, 84 insertions(+), 32 deletions(-)
>  create mode 100644 include/trace/events/syscalls.h
> 
> diff --git a/arch/s390/kernel/ptrace.c b/arch/s390/kernel/ptrace.c
> index 26194b0..8e578a9 100644
> --- a/arch/s390/kernel/ptrace.c
> +++ b/arch/s390/kernel/ptrace.c
> @@ -51,8 +51,8 @@
>  #include "compat_ptrace.h"
>  #endif
>  
> -DEFINE_TRACE_WITH_CALLBACK(syscall_enter, syscall_regfunc, syscall_unregfunc);
> -DEFINE_TRACE_WITH_CALLBACK(syscall_exit, syscall_regfunc, syscall_unregfunc);
> +#define CREATE_TRACE_POINTS
> +#include <trace/events/syscalls.h>
>  
>  enum s390_regset {
>  	REGSET_GENERAL,
> @@ -665,7 +665,7 @@ asmlinkage long do_syscall_trace_enter(struct pt_regs *regs)
>  	}
>  
>  	if (unlikely(test_thread_flag(TIF_SYSCALL_FTRACE)))
> -		trace_syscall_enter(regs, regs->gprs[2]);
> +		trace_sys_enter(regs, regs->gprs[2]);
>  
>  	if (unlikely(current->audit_context))
>  		audit_syscall_entry(is_compat_task() ?
> @@ -683,7 +683,7 @@ asmlinkage void do_syscall_trace_exit(struct pt_regs *regs)
>  				   regs->gprs[2]);
>  
>  	if (unlikely(test_thread_flag(TIF_SYSCALL_FTRACE)))
> -		trace_syscall_exit(regs, regs->gprs[2]);
> +		trace_sys_exit(regs, regs->gprs[2]);
>  
>  	if (test_thread_flag(TIF_SYSCALL_TRACE))
>  		tracehook_report_syscall_exit(regs, 0);
> diff --git a/arch/x86/kernel/ptrace.c b/arch/x86/kernel/ptrace.c
> index 692fc14..dc87a04 100644
> --- a/arch/x86/kernel/ptrace.c
> +++ b/arch/x86/kernel/ptrace.c
> @@ -35,13 +35,11 @@
>  #include <asm/proto.h>
>  #include <asm/ds.h>
>  
> -#include <trace/syscall.h>
> -
> -DEFINE_TRACE_WITH_CALLBACK(syscall_enter, syscall_regfunc, syscall_unregfunc);
> -DEFINE_TRACE_WITH_CALLBACK(syscall_exit, syscall_regfunc, syscall_unregfunc);
> -
>  #include "tls.h"
>  
> +#define CREATE_TRACE_POINTS
> +#include <trace/events/syscalls.h>
> +
>  enum x86_regset {
>  	REGSET_GENERAL,
>  	REGSET_FP,
> @@ -1501,7 +1499,7 @@ asmregparm long syscall_trace_enter(struct pt_regs *regs)
>  		ret = -1L;
>  
>  	if (unlikely(test_thread_flag(TIF_SYSCALL_FTRACE)))
> -		trace_syscall_enter(regs, regs->orig_ax);
> +		trace_sys_enter(regs, regs->orig_ax);
>  
>  	if (unlikely(current->audit_context)) {
>  		if (IS_IA32)
> @@ -1527,7 +1525,7 @@ asmregparm void syscall_trace_leave(struct pt_regs *regs)
>  		audit_syscall_exit(AUDITSC_RESULT(regs->ax), regs->ax);
>  
>  	if (unlikely(test_thread_flag(TIF_SYSCALL_FTRACE)))
> -		trace_syscall_exit(regs, regs->ax);
> +		trace_sys_exit(regs, regs->ax);
>  
>  	if (test_thread_flag(TIF_SYSCALL_TRACE))
>  		tracehook_report_syscall_exit(regs, 0);
> diff --git a/include/trace/events/syscalls.h b/include/trace/events/syscalls.h
> new file mode 100644
> index 0000000..9cd78fc
> --- /dev/null
> +++ b/include/trace/events/syscalls.h
> @@ -0,0 +1,66 @@
> +#undef TRACE_SYSTEM
> +#define TRACE_SYSTEM syscalls
> +
> +#if !defined(_TRACE_EVENTS_SYSCALLS_H) || defined(TRACE_HEADER_MULTI_READ)
> +#define _TRACE_EVENTS_SYSCALLS_H
> +
> +#include <linux/tracepoint.h>
> +
> +#include <asm/ptrace.h>
> +#include <asm/syscall.h>
> +
> +extern void syscall_regfunc(void);
> +extern void syscall_unregfunc(void);
> +
> +
> +TRACE_EVENT_WITH_CALLBACK(sys_enter,

don't we want to change this to something like 'sys_enter_generic'?
otherwise, looks good.

thanks,

-Jason


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

* Re: [PATCH v2 1/2] tracing: Move tracepoint callbacks into DEFINE
  2009-08-21 14:47   ` [PATCH v2 1/2] tracing: Move tracepoint callbacks into DEFINE Ingo Molnar
@ 2009-08-21 19:34     ` Josh Stone
  0 siblings, 0 replies; 70+ messages in thread
From: Josh Stone @ 2009-08-21 19:34 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: linux-kernel, fweisbec, laijs, rostedt, peterz,
	mathieu.desnoyers, jiayingz, mbligh, lizf, Jason Baron

On 08/21/2009 07:47 AM, Ingo Molnar wrote:
> 
> * Josh Stone <jistone@redhat.com> wrote:
> 
>> It's not strictly correct for the tracepoint reg/unreg callbacks 
>> to occur when a client is hooking up, because the actual 
>> tracepoint may no be present yet.  This happens to be fine for 
>> syscall, since that's in the core kernel, but it would cause 
>> problems for tracepoints defined in a module that hasn't been 
>> loaded yet.  It also means the reg/unreg has to be EXPORTed for 
>> any modules to use the tracepoint (as in SystemTap).
>>
>> This patch removes DECLARE_TRACE_WITH_CALLBACK, and instead 
>> introduces DEFINE_TRACE_WITH_CALLBACK which stores the callbacks 
>> in struct tracepoint.  The callbacks are used now when the active 
>> state of the tracepoint changes in set_tracepoint & 
>> disable_tracepoint.
>>
>> This also introduces TRACE_EVENT_WITH_CALLBACK, so those events 
>> can also provide callbacks if needed.
> 
> i think something shorter would be nicer, such as:
> 
>  DECLARE_TRACE_FN
>  TRACE_EVENT_FN

Well I took out the DECLARE_TRACE_ part, but sure, DEFINE_TRACE_FN and
TRACE_EVENT_FN sound fine to me.

Josh

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

* Re: [PATCH v2 1/2] tracing: Move tracepoint callbacks into DEFINE
  2009-08-21 17:52   ` Jason Baron
@ 2009-08-21 19:34     ` Josh Stone
  2009-08-21 20:06       ` Jason Baron
  2009-08-23 20:15       ` Frederic Weisbecker
  0 siblings, 2 replies; 70+ messages in thread
From: Josh Stone @ 2009-08-21 19:34 UTC (permalink / raw)
  To: Jason Baron
  Cc: linux-kernel, fweisbec, mingo, laijs, rostedt, peterz,
	mathieu.desnoyers, jiayingz, mbligh, lizf

On 08/21/2009 10:52 AM, Jason Baron wrote:
> this means that when CONFIG_EVENT_TRACING is set, the 'generic' syscall
> enter/exit will show up as events in the debugfs, but enabling them
> wouldn't do anything. I think we should simply drop the
> 'CONFIG_FTRACE_SYSCALLS' 'ifdef' and 'else' clause. That will give us
> what we want - tying these callbacks directly to tracepoint.

But only x86 and s390 have TIF_SYSCALL_FTRACE, while kernel/tracepoint.c
must still compile everywhere that has CONFIG_TRACEPOINTS=y.

Maybe it would be better to make that #ifdef TIF_SYSCALL_FTRACE, and
then also #ifdef the TRACE_EVENT declaration, so it will only show up on
kernels that actually support it.

Also, since this event is now usable outside of ftrace, would you object
to renaming the flag TIF_SYSCALL_TRACEPOINT?

Josh

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

* Re: [PATCH v2 2/2] tracing: Create generic syscall TRACE_EVENTs
  2009-08-21 17:57     ` Jason Baron
@ 2009-08-21 19:37       ` Josh Stone
  2009-08-21 20:08         ` Jason Baron
  0 siblings, 1 reply; 70+ messages in thread
From: Josh Stone @ 2009-08-21 19:37 UTC (permalink / raw)
  To: Jason Baron
  Cc: linux-kernel, fweisbec, mingo, laijs, rostedt, peterz,
	mathieu.desnoyers, jiayingz, mbligh, lizf

On 08/21/2009 10:57 AM, Jason Baron wrote:
>> +TRACE_EVENT_WITH_CALLBACK(sys_enter,
> 
> don't we want to change this to something like 'sys_enter_generic'?
> otherwise, looks good.

Since all of the specific events are named "sys_enter_foo", I thought
that it would be clear that an unadorned "sys_enter" was the more
generic syscall event.  Calling it "sys_enter_generic" seems to me by
convention to mean a system call named "generic".

I don't want to bikeshed this though -- if you still think
"sys_enter_generic" is better, then I'll change it.

Thanks,

Josh

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

* Re: [PATCH v2 1/2] tracing: Move tracepoint callbacks into DEFINE
  2009-08-21 19:34     ` Josh Stone
@ 2009-08-21 20:06       ` Jason Baron
  2009-08-23 20:29         ` Frederic Weisbecker
  2009-08-23 20:15       ` Frederic Weisbecker
  1 sibling, 1 reply; 70+ messages in thread
From: Jason Baron @ 2009-08-21 20:06 UTC (permalink / raw)
  To: Josh Stone
  Cc: linux-kernel, fweisbec, mingo, laijs, rostedt, peterz,
	mathieu.desnoyers, jiayingz, mbligh, lizf

On Fri, Aug 21, 2009 at 12:34:28PM -0700, Josh Stone wrote:
> On 08/21/2009 10:52 AM, Jason Baron wrote:
> > this means that when CONFIG_EVENT_TRACING is set, the 'generic' syscall
> > enter/exit will show up as events in the debugfs, but enabling them
> > wouldn't do anything. I think we should simply drop the
> > 'CONFIG_FTRACE_SYSCALLS' 'ifdef' and 'else' clause. That will give us
> > what we want - tying these callbacks directly to tracepoint.
> 
> But only x86 and s390 have TIF_SYSCALL_FTRACE, while kernel/tracepoint.c
> must still compile everywhere that has CONFIG_TRACEPOINTS=y.
> 

ok.

> Maybe it would be better to make that #ifdef TIF_SYSCALL_FTRACE, and
> then also #ifdef the TRACE_EVENT declaration, so it will only show up on
> kernels that actually support it.
> 

hmm...maybe then we move these functions to an arch specific file, such
as arch/x86{s390}/kernel/ftrace.c, making the code contigent on
CONFIG_TRACEPOINTS? (I think that required less ifdefs...).

> Also, since this event is now usable outside of ftrace, would you object
> to renaming the flag TIF_SYSCALL_TRACEPOINT?
> 

sure.

thanks,

-Jason

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

* Re: [PATCH v2 2/2] tracing: Create generic syscall TRACE_EVENTs
  2009-08-21 19:37       ` Josh Stone
@ 2009-08-21 20:08         ` Jason Baron
  0 siblings, 0 replies; 70+ messages in thread
From: Jason Baron @ 2009-08-21 20:08 UTC (permalink / raw)
  To: Josh Stone
  Cc: linux-kernel, fweisbec, mingo, laijs, rostedt, peterz,
	mathieu.desnoyers, jiayingz, mbligh, lizf

On Fri, Aug 21, 2009 at 12:37:09PM -0700, Josh Stone wrote:
> On 08/21/2009 10:57 AM, Jason Baron wrote:
> >> +TRACE_EVENT_WITH_CALLBACK(sys_enter,
> > 
> > don't we want to change this to something like 'sys_enter_generic'?
> > otherwise, looks good.
> 
> Since all of the specific events are named "sys_enter_foo", I thought
> that it would be clear that an unadorned "sys_enter" was the more
> generic syscall event.  Calling it "sys_enter_generic" seems to me by
> convention to mean a system call named "generic".
> 
> I don't want to bikeshed this though -- if you still think
> "sys_enter_generic" is better, then I'll change it.
> 

no I don't feel strongly about it...whatever the consensus is...

thanks,

-Jason

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

* [PATCH v3 0/4] tracing: tweaks for generic syscall events
  2009-08-20 19:09 ` [PATCH v2 1/2] " Josh Stone
                     ` (2 preceding siblings ...)
  2009-08-21 17:52   ` Jason Baron
@ 2009-08-22  4:58   ` Josh Stone
  2009-08-22  4:58     ` [PATCH v3 1/4] tracing: Rename TIF_SYSCALL_FTRACE->_TRACEPOINT Josh Stone
  2009-08-24 21:43     ` [PATCH v4 0/4] tracing: tweaks for generic syscall events Josh Stone
  3 siblings, 2 replies; 70+ messages in thread
From: Josh Stone @ 2009-08-22  4:58 UTC (permalink / raw)
  To: linux-kernel

This patch series moves the callbacks for the syscall tracepoints to the
definition site, and adds generic TRACE_EVENTs which capture all syscall
arguments.

New in v3:
- Give the thread flag a more generic name: TIF_SYSCALL_TRACEPOINT.
- Move the regfuncs to arch-specific files, per Jason's suggestion.
- Change _WITH_CALLBACK to just _FN, per Ingo's suggestion.


Sample trace output:
        sendmail-974   [000] 55665.464492: sys_enter: NR 14 (1, 7fff60f3af40, 7fff60f3aec0, 8, 0, 7fb1b6a05161)

        sendmail-974   [000] 55665.464496: sys_exit: NR 14 = 0

        sendmail-974   [000] 55665.464507: sys_enter: NR 23 (5, 7fff60f3b0d0, 0, 0, 7fff60f3b150, 7fff60f3ef01)

            sshd-978   [000] 55667.845359: sys_exit: NR 23 = 1

            sshd-978   [000] 55667.845373: sys_enter: NR 14 (0, 7fffc645ce90, 7fffc645cf10, 8, 0, 101010101010101)

            sshd-978   [000] 55667.845381: sys_exit: NR 14 = 0

            sshd-978   [000] 55667.845383: sys_enter: NR 14 (2, 7fffc645cf10, 0, 8, 0, 101010101010101)

            sshd-978   [000] 55667.845386: sys_exit: NR 14 = 0

            sshd-978   [000] 55667.845395: sys_enter: NR 0 (3, 7fffc6458f80, 4000, 1, 0, 0)

            sshd-978   [000] 55667.845478: sys_exit: NR 0 = 48


---
 arch/s390/include/asm/thread_info.h |    4 +-
 arch/s390/kernel/entry.S            |    2 +-
 arch/s390/kernel/entry64.S          |    2 +-
 arch/s390/kernel/ptrace.c           |   51 +++++++++++++++++++++++---
 arch/x86/include/asm/thread_info.h  |   13 ++++---
 arch/x86/kernel/ptrace.c            |   53 +++++++++++++++++++++++----
 include/linux/tracepoint.h          |   46 +++++++++--------------
 include/trace/define_trace.h        |    5 +++
 include/trace/events/syscalls.h     |   68 +++++++++++++++++++++++++++++++++++
 include/trace/ftrace.h              |    9 +++++
 include/trace/syscall.h             |   17 ---------
 kernel/trace/trace_syscalls.c       |   17 +++++----
 kernel/tracepoint.c                 |   48 ++++--------------------
 13 files changed, 218 insertions(+), 117 deletions(-)



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

* [PATCH v3 1/4] tracing: Rename TIF_SYSCALL_FTRACE->_TRACEPOINT
  2009-08-22  4:58   ` [PATCH v3 0/4] tracing: tweaks for generic syscall events Josh Stone
@ 2009-08-22  4:58     ` Josh Stone
  2009-08-22  4:58       ` [PATCH v3 2/4] tracing: Make syscall_(un)regfunc arch-specific Josh Stone
  2009-08-23 21:16       ` [PATCH v3 1/4] tracing: Rename TIF_SYSCALL_FTRACE->_TRACEPOINT Frederic Weisbecker
  2009-08-24 21:43     ` [PATCH v4 0/4] tracing: tweaks for generic syscall events Josh Stone
  1 sibling, 2 replies; 70+ messages in thread
From: Josh Stone @ 2009-08-22  4:58 UTC (permalink / raw)
  To: linux-kernel
  Cc: Josh Stone, Jason Baron, Frederic Weisbecker, Ingo Molnar,
	Li Zefan, Steven Rostedt, Peter Zijlstra, Mathieu Desnoyers,
	Jiaying Zhang, Martin Bligh, Lai Jiangshan

This thread flag is no longer specific to just ftrace, so
TIF_SYSCALL_TRACEPOINT may be a more apt name.

Signed-off-by: Josh Stone <jistone@redhat.com>
Cc: Jason Baron <jbaron@redhat.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Li Zefan <lizf@cn.fujitsu.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
Cc: Jiaying Zhang <jiayingz@google.com>
Cc: Martin Bligh <mbligh@google.com>
Cc: Lai Jiangshan <laijs@cn.fujitsu.com>
---
 arch/s390/include/asm/thread_info.h |    4 ++--
 arch/s390/kernel/entry.S            |    2 +-
 arch/s390/kernel/entry64.S          |    2 +-
 arch/s390/kernel/ptrace.c           |    4 ++--
 arch/x86/include/asm/thread_info.h  |   13 +++++++------
 arch/x86/kernel/ptrace.c            |    4 ++--
 kernel/tracepoint.c                 |    4 ++--
 7 files changed, 17 insertions(+), 16 deletions(-)

diff --git a/arch/s390/include/asm/thread_info.h b/arch/s390/include/asm/thread_info.h
index ba1cab9..07eb61b 100644
--- a/arch/s390/include/asm/thread_info.h
+++ b/arch/s390/include/asm/thread_info.h
@@ -92,7 +92,7 @@ static inline struct thread_info *current_thread_info(void)
 #define TIF_SYSCALL_TRACE	8	/* syscall trace active */
 #define TIF_SYSCALL_AUDIT	9	/* syscall auditing active */
 #define TIF_SECCOMP		10	/* secure computing */
-#define TIF_SYSCALL_FTRACE	11	/* ftrace syscall instrumentation */
+#define TIF_SYSCALL_TRACEPOINT	11	/* syscall tracepoint instrumentation */
 #define TIF_USEDFPU		16	/* FPU was used by this task this quantum (SMP) */
 #define TIF_POLLING_NRFLAG	17	/* true if poll_idle() is polling 
 					   TIF_NEED_RESCHED */
@@ -111,7 +111,7 @@ static inline struct thread_info *current_thread_info(void)
 #define _TIF_SYSCALL_TRACE	(1<<TIF_SYSCALL_TRACE)
 #define _TIF_SYSCALL_AUDIT	(1<<TIF_SYSCALL_AUDIT)
 #define _TIF_SECCOMP		(1<<TIF_SECCOMP)
-#define _TIF_SYSCALL_FTRACE	(1<<TIF_SYSCALL_FTRACE)
+#define _TIF_SYSCALL_TRACEPOINT	(1<<TIF_SYSCALL_TRACEPOINT)
 #define _TIF_USEDFPU		(1<<TIF_USEDFPU)
 #define _TIF_POLLING_NRFLAG	(1<<TIF_POLLING_NRFLAG)
 #define _TIF_31BIT		(1<<TIF_31BIT)
diff --git a/arch/s390/kernel/entry.S b/arch/s390/kernel/entry.S
index c4c80a2..5d40fce 100644
--- a/arch/s390/kernel/entry.S
+++ b/arch/s390/kernel/entry.S
@@ -54,7 +54,7 @@ _TIF_WORK_SVC = (_TIF_SIGPENDING | _TIF_NOTIFY_RESUME | _TIF_NEED_RESCHED | \
 _TIF_WORK_INT = (_TIF_SIGPENDING | _TIF_NOTIFY_RESUME | _TIF_NEED_RESCHED | \
 		 _TIF_MCCK_PENDING)
 _TIF_SYSCALL = (_TIF_SYSCALL_TRACE>>8 | _TIF_SYSCALL_AUDIT>>8 | \
-		_TIF_SECCOMP>>8 | _TIF_SYSCALL_FTRACE>>8)
+		_TIF_SECCOMP>>8 | _TIF_SYSCALL_TRACEPOINT>>8)
 
 STACK_SHIFT = PAGE_SHIFT + THREAD_ORDER
 STACK_SIZE  = 1 << STACK_SHIFT
diff --git a/arch/s390/kernel/entry64.S b/arch/s390/kernel/entry64.S
index f6618e9..3ceb53c 100644
--- a/arch/s390/kernel/entry64.S
+++ b/arch/s390/kernel/entry64.S
@@ -57,7 +57,7 @@ _TIF_WORK_SVC = (_TIF_SIGPENDING | _TIF_NOTIFY_RESUME | _TIF_NEED_RESCHED | \
 _TIF_WORK_INT = (_TIF_SIGPENDING | _TIF_NOTIFY_RESUME | _TIF_NEED_RESCHED | \
 		 _TIF_MCCK_PENDING)
 _TIF_SYSCALL = (_TIF_SYSCALL_TRACE>>8 | _TIF_SYSCALL_AUDIT>>8 | \
-		_TIF_SECCOMP>>8 | _TIF_SYSCALL_FTRACE>>8)
+		_TIF_SECCOMP>>8 | _TIF_SYSCALL_TRACEPOINT>>8)
 
 #define BASED(name) name-system_call(%r13)
 
diff --git a/arch/s390/kernel/ptrace.c b/arch/s390/kernel/ptrace.c
index c5e87d8..9d3dcfa 100644
--- a/arch/s390/kernel/ptrace.c
+++ b/arch/s390/kernel/ptrace.c
@@ -664,7 +664,7 @@ asmlinkage long do_syscall_trace_enter(struct pt_regs *regs)
 		ret = -1;
 	}
 
-	if (unlikely(test_thread_flag(TIF_SYSCALL_FTRACE)))
+	if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
 		trace_syscall_enter(regs, regs->gprs[2]);
 
 	if (unlikely(current->audit_context))
@@ -682,7 +682,7 @@ asmlinkage void do_syscall_trace_exit(struct pt_regs *regs)
 		audit_syscall_exit(AUDITSC_RESULT(regs->gprs[2]),
 				   regs->gprs[2]);
 
-	if (unlikely(test_thread_flag(TIF_SYSCALL_FTRACE)))
+	if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
 		trace_syscall_exit(regs, regs->gprs[2]);
 
 	if (test_thread_flag(TIF_SYSCALL_TRACE))
diff --git a/arch/x86/include/asm/thread_info.h b/arch/x86/include/asm/thread_info.h
index fad7d40..6f7786a 100644
--- a/arch/x86/include/asm/thread_info.h
+++ b/arch/x86/include/asm/thread_info.h
@@ -95,7 +95,7 @@ struct thread_info {
 #define TIF_DEBUGCTLMSR		25	/* uses thread_struct.debugctlmsr */
 #define TIF_DS_AREA_MSR		26      /* uses thread_struct.ds_area_msr */
 #define TIF_LAZY_MMU_UPDATES	27	/* task is updating the mmu lazily */
-#define TIF_SYSCALL_FTRACE	28	/* for ftrace syscall instrumentation */
+#define TIF_SYSCALL_TRACEPOINT	28	/* syscall tracepoint instrumentation */
 
 #define _TIF_SYSCALL_TRACE	(1 << TIF_SYSCALL_TRACE)
 #define _TIF_NOTIFY_RESUME	(1 << TIF_NOTIFY_RESUME)
@@ -118,17 +118,17 @@ struct thread_info {
 #define _TIF_DEBUGCTLMSR	(1 << TIF_DEBUGCTLMSR)
 #define _TIF_DS_AREA_MSR	(1 << TIF_DS_AREA_MSR)
 #define _TIF_LAZY_MMU_UPDATES	(1 << TIF_LAZY_MMU_UPDATES)
-#define _TIF_SYSCALL_FTRACE	(1 << TIF_SYSCALL_FTRACE)
+#define _TIF_SYSCALL_TRACEPOINT	(1 << TIF_SYSCALL_TRACEPOINT)
 
 /* work to do in syscall_trace_enter() */
 #define _TIF_WORK_SYSCALL_ENTRY	\
-	(_TIF_SYSCALL_TRACE | _TIF_SYSCALL_EMU | _TIF_SYSCALL_FTRACE |	\
-	 _TIF_SYSCALL_AUDIT | _TIF_SECCOMP | _TIF_SINGLESTEP)
+	(_TIF_SYSCALL_TRACE | _TIF_SYSCALL_EMU | _TIF_SYSCALL_AUDIT |	\
+	 _TIF_SECCOMP | _TIF_SINGLESTEP | _TIF_SYSCALL_TRACEPOINT)
 
 /* work to do in syscall_trace_leave() */
 #define _TIF_WORK_SYSCALL_EXIT	\
 	(_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | _TIF_SINGLESTEP |	\
-	 _TIF_SYSCALL_FTRACE)
+	 _TIF_SYSCALL_TRACEPOINT)
 
 /* work to do on interrupt/exception return */
 #define _TIF_WORK_MASK							\
@@ -137,7 +137,8 @@ struct thread_info {
 	   _TIF_SINGLESTEP|_TIF_SECCOMP|_TIF_SYSCALL_EMU))
 
 /* work to do on any return to user space */
-#define _TIF_ALLWORK_MASK ((0x0000FFFF & ~_TIF_SECCOMP) | _TIF_SYSCALL_FTRACE)
+#define _TIF_ALLWORK_MASK						\
+	((0x0000FFFF & ~_TIF_SECCOMP) | _TIF_SYSCALL_TRACEPOINT)
 
 /* Only used for 64 bit */
 #define _TIF_DO_NOTIFY_MASK						\
diff --git a/arch/x86/kernel/ptrace.c b/arch/x86/kernel/ptrace.c
index 34dd6f1..a909afe 100644
--- a/arch/x86/kernel/ptrace.c
+++ b/arch/x86/kernel/ptrace.c
@@ -1500,7 +1500,7 @@ asmregparm long syscall_trace_enter(struct pt_regs *regs)
 	    tracehook_report_syscall_entry(regs))
 		ret = -1L;
 
-	if (unlikely(test_thread_flag(TIF_SYSCALL_FTRACE)))
+	if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
 		trace_syscall_enter(regs, regs->orig_ax);
 
 	if (unlikely(current->audit_context)) {
@@ -1526,7 +1526,7 @@ asmregparm void syscall_trace_leave(struct pt_regs *regs)
 	if (unlikely(current->audit_context))
 		audit_syscall_exit(AUDITSC_RESULT(regs->ax), regs->ax);
 
-	if (unlikely(test_thread_flag(TIF_SYSCALL_FTRACE)))
+	if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
 		trace_syscall_exit(regs, regs->ax);
 
 	if (test_thread_flag(TIF_SYSCALL_TRACE))
diff --git a/kernel/tracepoint.c b/kernel/tracepoint.c
index 35dd27a..43bca1f 100644
--- a/kernel/tracepoint.c
+++ b/kernel/tracepoint.c
@@ -593,7 +593,7 @@ void syscall_regfunc(void)
 	if (!sys_tracepoint_refcount) {
 		read_lock_irqsave(&tasklist_lock, flags);
 		do_each_thread(g, t) {
-			set_tsk_thread_flag(t, TIF_SYSCALL_FTRACE);
+			set_tsk_thread_flag(t, TIF_SYSCALL_TRACEPOINT);
 		} while_each_thread(g, t);
 		read_unlock_irqrestore(&tasklist_lock, flags);
 	}
@@ -611,7 +611,7 @@ void syscall_unregfunc(void)
 	if (!sys_tracepoint_refcount) {
 		read_lock_irqsave(&tasklist_lock, flags);
 		do_each_thread(g, t) {
-			clear_tsk_thread_flag(t, TIF_SYSCALL_FTRACE);
+			clear_tsk_thread_flag(t, TIF_SYSCALL_TRACEPOINT);
 		} while_each_thread(g, t);
 		read_unlock_irqrestore(&tasklist_lock, flags);
 	}
-- 
1.6.2.5


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

* [PATCH v3 2/4] tracing: Make syscall_(un)regfunc arch-specific
  2009-08-22  4:58     ` [PATCH v3 1/4] tracing: Rename TIF_SYSCALL_FTRACE->_TRACEPOINT Josh Stone
@ 2009-08-22  4:58       ` Josh Stone
  2009-08-22  4:58         ` [PATCH v3 3/4] tracing: Move tracepoint callbacks into DEFINE Josh Stone
  2009-08-23 21:14         ` [PATCH v3 2/4] tracing: Make syscall_(un)regfunc arch-specific Frederic Weisbecker
  2009-08-23 21:16       ` [PATCH v3 1/4] tracing: Rename TIF_SYSCALL_FTRACE->_TRACEPOINT Frederic Weisbecker
  1 sibling, 2 replies; 70+ messages in thread
From: Josh Stone @ 2009-08-22  4:58 UTC (permalink / raw)
  To: linux-kernel
  Cc: Josh Stone, Jason Baron, Frederic Weisbecker, Ingo Molnar,
	Li Zefan, Steven Rostedt, Peter Zijlstra, Mathieu Desnoyers,
	Jiaying Zhang, Martin Bligh, Lai Jiangshan

The bodies of syscall_regfunc and syscall_unregfunc need the
arch-specific flag TIF_SYSCALL_TRACEPOINT, which only exists
on x86 and s390, so they should live in arch-specific files.

Signed-off-by: Josh Stone <jistone@redhat.com>
Cc: Jason Baron <jbaron@redhat.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Li Zefan <lizf@cn.fujitsu.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
Cc: Jiaying Zhang <jiayingz@google.com>
Cc: Martin Bligh <mbligh@google.com>
Cc: Lai Jiangshan <laijs@cn.fujitsu.com>
---
 arch/s390/kernel/ptrace.c |   40 ++++++++++++++++++++++++++++++++++++++++
 arch/x86/kernel/ptrace.c  |   40 ++++++++++++++++++++++++++++++++++++++++
 kernel/tracepoint.c       |   40 ----------------------------------------
 3 files changed, 80 insertions(+), 40 deletions(-)

diff --git a/arch/s390/kernel/ptrace.c b/arch/s390/kernel/ptrace.c
index 9d3dcfa..b6dcd72 100644
--- a/arch/s390/kernel/ptrace.c
+++ b/arch/s390/kernel/ptrace.c
@@ -925,3 +925,43 @@ const struct user_regset_view *task_user_regset_view(struct task_struct *task)
 #endif
 	return &user_s390_view;
 }
+
+#ifdef CONFIG_TRACEPOINTS
+
+static DEFINE_MUTEX(regfunc_mutex);
+static int sys_tracepoint_refcount;
+
+void syscall_regfunc(void)
+{
+	unsigned long flags;
+	struct task_struct *g, *t;
+
+	mutex_lock(&regfunc_mutex);
+	if (!sys_tracepoint_refcount) {
+		read_lock_irqsave(&tasklist_lock, flags);
+		do_each_thread(g, t) {
+			set_tsk_thread_flag(t, TIF_SYSCALL_TRACEPOINT);
+		} while_each_thread(g, t);
+		read_unlock_irqrestore(&tasklist_lock, flags);
+	}
+	sys_tracepoint_refcount++;
+	mutex_unlock(&regfunc_mutex);
+}
+
+void syscall_unregfunc(void)
+{
+	unsigned long flags;
+	struct task_struct *g, *t;
+
+	mutex_lock(&regfunc_mutex);
+	sys_tracepoint_refcount--;
+	if (!sys_tracepoint_refcount) {
+		read_lock_irqsave(&tasklist_lock, flags);
+		do_each_thread(g, t) {
+			clear_tsk_thread_flag(t, TIF_SYSCALL_TRACEPOINT);
+		} while_each_thread(g, t);
+		read_unlock_irqrestore(&tasklist_lock, flags);
+	}
+	mutex_unlock(&regfunc_mutex);
+}
+#endif
diff --git a/arch/x86/kernel/ptrace.c b/arch/x86/kernel/ptrace.c
index a909afe..c2adbed 100644
--- a/arch/x86/kernel/ptrace.c
+++ b/arch/x86/kernel/ptrace.c
@@ -1549,3 +1549,43 @@ asmregparm void syscall_trace_leave(struct pt_regs *regs)
 	    tracehook_consider_fatal_signal(current, SIGTRAP))
 		send_sigtrap(current, regs, 0, TRAP_BRKPT);
 }
+
+#ifdef CONFIG_TRACEPOINTS
+
+static DEFINE_MUTEX(regfunc_mutex);
+static int sys_tracepoint_refcount;
+
+void syscall_regfunc(void)
+{
+	unsigned long flags;
+	struct task_struct *g, *t;
+
+	mutex_lock(&regfunc_mutex);
+	if (!sys_tracepoint_refcount) {
+		read_lock_irqsave(&tasklist_lock, flags);
+		do_each_thread(g, t) {
+			set_tsk_thread_flag(t, TIF_SYSCALL_TRACEPOINT);
+		} while_each_thread(g, t);
+		read_unlock_irqrestore(&tasklist_lock, flags);
+	}
+	sys_tracepoint_refcount++;
+	mutex_unlock(&regfunc_mutex);
+}
+
+void syscall_unregfunc(void)
+{
+	unsigned long flags;
+	struct task_struct *g, *t;
+
+	mutex_lock(&regfunc_mutex);
+	sys_tracepoint_refcount--;
+	if (!sys_tracepoint_refcount) {
+		read_lock_irqsave(&tasklist_lock, flags);
+		do_each_thread(g, t) {
+			clear_tsk_thread_flag(t, TIF_SYSCALL_TRACEPOINT);
+		} while_each_thread(g, t);
+		read_unlock_irqrestore(&tasklist_lock, flags);
+	}
+	mutex_unlock(&regfunc_mutex);
+}
+#endif
diff --git a/kernel/tracepoint.c b/kernel/tracepoint.c
index 43bca1f..2ce4d38 100644
--- a/kernel/tracepoint.c
+++ b/kernel/tracepoint.c
@@ -578,43 +578,3 @@ static int init_tracepoints(void)
 __initcall(init_tracepoints);
 
 #endif /* CONFIG_MODULES */
-
-#ifdef CONFIG_FTRACE_SYSCALLS
-
-static DEFINE_MUTEX(regfunc_mutex);
-static int sys_tracepoint_refcount;
-
-void syscall_regfunc(void)
-{
-	unsigned long flags;
-	struct task_struct *g, *t;
-
-	mutex_lock(&regfunc_mutex);
-	if (!sys_tracepoint_refcount) {
-		read_lock_irqsave(&tasklist_lock, flags);
-		do_each_thread(g, t) {
-			set_tsk_thread_flag(t, TIF_SYSCALL_TRACEPOINT);
-		} while_each_thread(g, t);
-		read_unlock_irqrestore(&tasklist_lock, flags);
-	}
-	sys_tracepoint_refcount++;
-	mutex_unlock(&regfunc_mutex);
-}
-
-void syscall_unregfunc(void)
-{
-	unsigned long flags;
-	struct task_struct *g, *t;
-
-	mutex_lock(&regfunc_mutex);
-	sys_tracepoint_refcount--;
-	if (!sys_tracepoint_refcount) {
-		read_lock_irqsave(&tasklist_lock, flags);
-		do_each_thread(g, t) {
-			clear_tsk_thread_flag(t, TIF_SYSCALL_TRACEPOINT);
-		} while_each_thread(g, t);
-		read_unlock_irqrestore(&tasklist_lock, flags);
-	}
-	mutex_unlock(&regfunc_mutex);
-}
-#endif
-- 
1.6.2.5


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

* [PATCH v3 3/4] tracing: Move tracepoint callbacks into DEFINE
  2009-08-22  4:58       ` [PATCH v3 2/4] tracing: Make syscall_(un)regfunc arch-specific Josh Stone
@ 2009-08-22  4:58         ` Josh Stone
  2009-08-22  4:58           ` [PATCH v3 4/4] tracing: Create generic syscall TRACE_EVENTs Josh Stone
  2009-08-23 21:14         ` [PATCH v3 2/4] tracing: Make syscall_(un)regfunc arch-specific Frederic Weisbecker
  1 sibling, 1 reply; 70+ messages in thread
From: Josh Stone @ 2009-08-22  4:58 UTC (permalink / raw)
  To: linux-kernel
  Cc: Josh Stone, Jason Baron, Frederic Weisbecker, Ingo Molnar,
	Li Zefan, Steven Rostedt, Peter Zijlstra, Mathieu Desnoyers,
	Jiaying Zhang, Martin Bligh, Lai Jiangshan

It's not strictly correct for the tracepoint reg/unreg callbacks to
occur when a client is hooking up, because the actual tracepoint may no
be present yet.  This happens to be fine for syscall, since that's in
the core kernel, but it would cause problems for tracepoints defined in
a module that hasn't been loaded yet.  It also means the reg/unreg has
to be EXPORTed for any modules to use the tracepoint (as in SystemTap).

This patch removes DECLARE_TRACE_WITH_CALLBACK, and instead introduces
DEFINE_TRACE_FN which stores the callbacks in struct tracepoint.  The
callbacks are used now when the active state of the tracepoint changes
in set_tracepoint & disable_tracepoint.

This also introduces TRACE_EVENT_FN, so those events can also provide
callbacks if needed.

Signed-off-by: Josh Stone <jistone@redhat.com>
Cc: Jason Baron <jbaron@redhat.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Li Zefan <lizf@cn.fujitsu.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
Cc: Jiaying Zhang <jiayingz@google.com>
Cc: Martin Bligh <mbligh@google.com>
Cc: Lai Jiangshan <laijs@cn.fujitsu.com>
---
 arch/s390/kernel/ptrace.c    |   17 +++++++--------
 arch/x86/kernel/ptrace.c     |   17 +++++++--------
 include/linux/tracepoint.h   |   46 ++++++++++++++++-------------------------
 include/trace/define_trace.h |    5 ++++
 include/trace/ftrace.h       |    9 ++++++++
 include/trace/syscall.h      |   15 +++----------
 kernel/tracepoint.c          |    8 +++++++
 7 files changed, 60 insertions(+), 57 deletions(-)

diff --git a/arch/s390/kernel/ptrace.c b/arch/s390/kernel/ptrace.c
index b6dcd72..e515c8b 100644
--- a/arch/s390/kernel/ptrace.c
+++ b/arch/s390/kernel/ptrace.c
@@ -51,8 +51,11 @@
 #include "compat_ptrace.h"
 #endif
 
-DEFINE_TRACE(syscall_enter);
-DEFINE_TRACE(syscall_exit);
+static void syscall_regfunc(void);
+static void syscall_unregfunc(void);
+
+DEFINE_TRACE_FN(syscall_enter, syscall_regfunc, syscall_unregfunc);
+DEFINE_TRACE_FN(syscall_exit, syscall_regfunc, syscall_unregfunc);
 
 enum s390_regset {
 	REGSET_GENERAL,
@@ -928,15 +931,14 @@ const struct user_regset_view *task_user_regset_view(struct task_struct *task)
 
 #ifdef CONFIG_TRACEPOINTS
 
-static DEFINE_MUTEX(regfunc_mutex);
+/* NB: reg/unreg are called while guarded with the tracepoints_mutex */
 static int sys_tracepoint_refcount;
 
-void syscall_regfunc(void)
+static void syscall_regfunc(void)
 {
 	unsigned long flags;
 	struct task_struct *g, *t;
 
-	mutex_lock(&regfunc_mutex);
 	if (!sys_tracepoint_refcount) {
 		read_lock_irqsave(&tasklist_lock, flags);
 		do_each_thread(g, t) {
@@ -945,15 +947,13 @@ void syscall_regfunc(void)
 		read_unlock_irqrestore(&tasklist_lock, flags);
 	}
 	sys_tracepoint_refcount++;
-	mutex_unlock(&regfunc_mutex);
 }
 
-void syscall_unregfunc(void)
+static void syscall_unregfunc(void)
 {
 	unsigned long flags;
 	struct task_struct *g, *t;
 
-	mutex_lock(&regfunc_mutex);
 	sys_tracepoint_refcount--;
 	if (!sys_tracepoint_refcount) {
 		read_lock_irqsave(&tasklist_lock, flags);
@@ -962,6 +962,5 @@ void syscall_unregfunc(void)
 		} while_each_thread(g, t);
 		read_unlock_irqrestore(&tasklist_lock, flags);
 	}
-	mutex_unlock(&regfunc_mutex);
 }
 #endif
diff --git a/arch/x86/kernel/ptrace.c b/arch/x86/kernel/ptrace.c
index c2adbed..cef009a 100644
--- a/arch/x86/kernel/ptrace.c
+++ b/arch/x86/kernel/ptrace.c
@@ -37,8 +37,11 @@
 
 #include <trace/syscall.h>
 
-DEFINE_TRACE(syscall_enter);
-DEFINE_TRACE(syscall_exit);
+static void syscall_regfunc(void);
+static void syscall_unregfunc(void);
+
+DEFINE_TRACE_FN(syscall_enter, syscall_regfunc, syscall_unregfunc);
+DEFINE_TRACE_FN(syscall_exit, syscall_regfunc, syscall_unregfunc);
 
 #include "tls.h"
 
@@ -1552,15 +1555,14 @@ asmregparm void syscall_trace_leave(struct pt_regs *regs)
 
 #ifdef CONFIG_TRACEPOINTS
 
-static DEFINE_MUTEX(regfunc_mutex);
+/* NB: reg/unreg are called while guarded with the tracepoints_mutex */
 static int sys_tracepoint_refcount;
 
-void syscall_regfunc(void)
+static void syscall_regfunc(void)
 {
 	unsigned long flags;
 	struct task_struct *g, *t;
 
-	mutex_lock(&regfunc_mutex);
 	if (!sys_tracepoint_refcount) {
 		read_lock_irqsave(&tasklist_lock, flags);
 		do_each_thread(g, t) {
@@ -1569,15 +1571,13 @@ void syscall_regfunc(void)
 		read_unlock_irqrestore(&tasklist_lock, flags);
 	}
 	sys_tracepoint_refcount++;
-	mutex_unlock(&regfunc_mutex);
 }
 
-void syscall_unregfunc(void)
+static void syscall_unregfunc(void)
 {
 	unsigned long flags;
 	struct task_struct *g, *t;
 
-	mutex_lock(&regfunc_mutex);
 	sys_tracepoint_refcount--;
 	if (!sys_tracepoint_refcount) {
 		read_lock_irqsave(&tasklist_lock, flags);
@@ -1586,6 +1586,5 @@ void syscall_unregfunc(void)
 		} while_each_thread(g, t);
 		read_unlock_irqrestore(&tasklist_lock, flags);
 	}
-	mutex_unlock(&regfunc_mutex);
 }
 #endif
diff --git a/include/linux/tracepoint.h b/include/linux/tracepoint.h
index 5984ed0..846a4ae 100644
--- a/include/linux/tracepoint.h
+++ b/include/linux/tracepoint.h
@@ -23,6 +23,8 @@ struct tracepoint;
 struct tracepoint {
 	const char *name;		/* Tracepoint name */
 	int state;			/* State. */
+	void (*regfunc)(void);
+	void (*unregfunc)(void);
 	void **funcs;
 } __attribute__((aligned(32)));		/*
 					 * Aligned on 32 bytes because it is
@@ -60,10 +62,8 @@ struct tracepoint {
  * Make sure the alignment of the structure in the __tracepoints section will
  * not add unwanted padding between the beginning of the section and the
  * structure. Force alignment to the same alignment as the section start.
- * An optional set of (un)registration functions can be passed to perform any
- * additional (un)registration work.
  */
-#define DECLARE_TRACE_WITH_CALLBACK(name, proto, args, reg, unreg)	\
+#define DECLARE_TRACE(name, proto, args)				\
 	extern struct tracepoint __tracepoint_##name;			\
 	static inline void trace_##name(proto)				\
 	{								\
@@ -73,36 +73,23 @@ struct tracepoint {
 	}								\
 	static inline int register_trace_##name(void (*probe)(proto))	\
 	{								\
-		int ret;						\
-		void (*func)(void) = reg;				\
-									\
-		ret = tracepoint_probe_register(#name, (void *)probe);	\
-		if (func && !ret)					\
-			func();						\
-		return ret;						\
+		return tracepoint_probe_register(#name, (void *)probe);	\
 	}								\
 	static inline int unregister_trace_##name(void (*probe)(proto))	\
 	{								\
-		int ret;						\
-		void (*func)(void) = unreg;				\
-									\
-		ret = tracepoint_probe_unregister(#name, (void *)probe);\
-		if (func && !ret)					\
-			func();						\
-		return ret;						\
+		return tracepoint_probe_unregister(#name, (void *)probe);\
 	}
 
 
-#define DECLARE_TRACE(name, proto, args)				 \
-	DECLARE_TRACE_WITH_CALLBACK(name, TP_PROTO(proto), TP_ARGS(args),\
-					NULL, NULL);
-
-#define DEFINE_TRACE(name)						\
+#define DEFINE_TRACE_FN(name, reg, unreg)				\
 	static const char __tpstrtab_##name[]				\
 	__attribute__((section("__tracepoints_strings"))) = #name;	\
 	struct tracepoint __tracepoint_##name				\
 	__attribute__((section("__tracepoints"), aligned(32))) =	\
-		{ __tpstrtab_##name, 0, NULL }
+		{ __tpstrtab_##name, 0, reg, unreg, NULL }
+
+#define DEFINE_TRACE(name)						\
+	DEFINE_TRACE_FN(name, NULL, NULL);
 
 #define EXPORT_TRACEPOINT_SYMBOL_GPL(name)				\
 	EXPORT_SYMBOL_GPL(__tracepoint_##name)
@@ -113,7 +100,7 @@ extern void tracepoint_update_probe_range(struct tracepoint *begin,
 	struct tracepoint *end);
 
 #else /* !CONFIG_TRACEPOINTS */
-#define DECLARE_TRACE_WITH_CALLBACK(name, proto, args, reg, unreg)	\
+#define DECLARE_TRACE(name, proto, args)				\
 	static inline void _do_trace_##name(struct tracepoint *tp, proto) \
 	{ }								\
 	static inline void trace_##name(proto)				\
@@ -127,10 +114,7 @@ extern void tracepoint_update_probe_range(struct tracepoint *begin,
 		return -ENOSYS;						\
 	}
 
-#define DECLARE_TRACE(name, proto, args)				 \
-	DECLARE_TRACE_WITH_CALLBACK(name, TP_PROTO(proto), TP_ARGS(args),\
-					NULL, NULL);
-
+#define DEFINE_TRACE_FN(name, reg, unreg)
 #define DEFINE_TRACE(name)
 #define EXPORT_TRACEPOINT_SYMBOL_GPL(name)
 #define EXPORT_TRACEPOINT_SYMBOL(name)
@@ -282,10 +266,16 @@ static inline void tracepoint_synchronize_unregister(void)
  * can also by used by generic instrumentation like SystemTap), and
  * it is also used to expose a structured trace record in
  * /sys/kernel/debug/tracing/events/.
+ *
+ * A set of (un)registration functions can be passed to the variant
+ * TRACE_EVENT_FN to perform any (un)registration work.
  */
 
 #define TRACE_EVENT(name, proto, args, struct, assign, print)	\
 	DECLARE_TRACE(name, PARAMS(proto), PARAMS(args))
+#define TRACE_EVENT_FN(name, proto, args, struct,		\
+		assign, print, reg, unreg)			\
+	DECLARE_TRACE(name, PARAMS(proto), PARAMS(args))
 #endif
 
 #endif
diff --git a/include/trace/define_trace.h b/include/trace/define_trace.h
index f7a7ae1..2a96985 100644
--- a/include/trace/define_trace.h
+++ b/include/trace/define_trace.h
@@ -26,6 +26,11 @@
 #define TRACE_EVENT(name, proto, args, tstruct, assign, print)	\
 	DEFINE_TRACE(name)
 
+#undef TRACE_EVENT_FN
+#define TRACE_EVENT_FN(name, proto, args, tstruct,		\
+		assign, print, reg, unreg)			\
+	DEFINE_TRACE_FN(name, reg, unreg)
+
 #undef DECLARE_TRACE
 #define DECLARE_TRACE(name, proto, args)	\
 	DEFINE_TRACE(name)
diff --git a/include/trace/ftrace.h b/include/trace/ftrace.h
index 1274002..3a0b44b 100644
--- a/include/trace/ftrace.h
+++ b/include/trace/ftrace.h
@@ -42,6 +42,15 @@
 	};							\
 	static struct ftrace_event_call event_##name
 
+/* Callbacks are meaningless to ftrace. */
+#undef TRACE_EVENT_FN
+#define TRACE_EVENT_FN(name, proto, args, tstruct,		\
+		assign, print, reg, unreg)			\
+	TRACE_EVENT(name, TP_PROTO(proto), TP_ARGS(args),	\
+		TP_STRUCT__entry(tstruct),			\
+		TP_fast_assign(assign),				\
+		TP_printk(print))
+
 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
 
 
diff --git a/include/trace/syscall.h b/include/trace/syscall.h
index 9661dd4..f3d8555 100644
--- a/include/trace/syscall.h
+++ b/include/trace/syscall.h
@@ -8,21 +8,14 @@
 #include <asm/ptrace.h>
 
 
-extern void syscall_regfunc(void);
-extern void syscall_unregfunc(void);
-
-DECLARE_TRACE_WITH_CALLBACK(syscall_enter,
+DECLARE_TRACE(syscall_enter,
 	TP_PROTO(struct pt_regs *regs, long id),
-	TP_ARGS(regs, id),
-	syscall_regfunc,
-	syscall_unregfunc
+	TP_ARGS(regs, id)
 );
 
-DECLARE_TRACE_WITH_CALLBACK(syscall_exit,
+DECLARE_TRACE(syscall_exit,
 	TP_PROTO(struct pt_regs *regs, long ret),
-	TP_ARGS(regs, ret),
-	syscall_regfunc,
-	syscall_unregfunc
+	TP_ARGS(regs, ret)
 );
 
 /*
diff --git a/kernel/tracepoint.c b/kernel/tracepoint.c
index 2ce4d38..5375e0f 100644
--- a/kernel/tracepoint.c
+++ b/kernel/tracepoint.c
@@ -243,6 +243,11 @@ static void set_tracepoint(struct tracepoint_entry **entry,
 {
 	WARN_ON(strcmp((*entry)->name, elem->name) != 0);
 
+	if (elem->regfunc && !elem->state && active)
+		elem->regfunc();
+	else if (elem->unregfunc && elem->state && !active)
+		elem->unregfunc();
+
 	/*
 	 * rcu_assign_pointer has a smp_wmb() which makes sure that the new
 	 * probe callbacks array is consistent before setting a pointer to it.
@@ -262,6 +267,9 @@ static void set_tracepoint(struct tracepoint_entry **entry,
  */
 static void disable_tracepoint(struct tracepoint *elem)
 {
+	if (elem->unregfunc && elem->state)
+		elem->unregfunc();
+
 	elem->state = 0;
 	rcu_assign_pointer(elem->funcs, NULL);
 }
-- 
1.6.2.5


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

* [PATCH v3 4/4] tracing: Create generic syscall TRACE_EVENTs
  2009-08-22  4:58         ` [PATCH v3 3/4] tracing: Move tracepoint callbacks into DEFINE Josh Stone
@ 2009-08-22  4:58           ` Josh Stone
  0 siblings, 0 replies; 70+ messages in thread
From: Josh Stone @ 2009-08-22  4:58 UTC (permalink / raw)
  To: linux-kernel
  Cc: Josh Stone, Jason Baron, Frederic Weisbecker, Ingo Molnar,
	Li Zefan, Steven Rostedt, Peter Zijlstra, Mathieu Desnoyers,
	Jiaying Zhang, Martin Bligh, Lai Jiangshan

This converts the syscall_enter/exit tracepoints into TRACE_EVENTs, so
you can have generic ftrace events that capture all system calls with
arguments and return values.  These generic events are also renamed to
sys_enter/exit, so they're more closely aligned to the specific
sys_enter_foo events.

Signed-off-by: Josh Stone <jistone@redhat.com>
Cc: Jason Baron <jbaron@redhat.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Li Zefan <lizf@cn.fujitsu.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
Cc: Jiaying Zhang <jiayingz@google.com>
Cc: Martin Bligh <mbligh@google.com>
Cc: Lai Jiangshan <laijs@cn.fujitsu.com>
---
 arch/s390/kernel/ptrace.c       |    8 ++--
 arch/x86/kernel/ptrace.c        |   12 +++----
 include/trace/events/syscalls.h |   68 +++++++++++++++++++++++++++++++++++++++
 include/trace/syscall.h         |   10 ------
 kernel/trace/trace_syscalls.c   |   17 +++++----
 5 files changed, 86 insertions(+), 29 deletions(-)
 create mode 100644 include/trace/events/syscalls.h

diff --git a/arch/s390/kernel/ptrace.c b/arch/s390/kernel/ptrace.c
index e515c8b..7180ef8 100644
--- a/arch/s390/kernel/ptrace.c
+++ b/arch/s390/kernel/ptrace.c
@@ -54,8 +54,8 @@
 static void syscall_regfunc(void);
 static void syscall_unregfunc(void);
 
-DEFINE_TRACE_FN(syscall_enter, syscall_regfunc, syscall_unregfunc);
-DEFINE_TRACE_FN(syscall_exit, syscall_regfunc, syscall_unregfunc);
+#define CREATE_TRACE_POINTS
+#include <trace/events/syscalls.h>
 
 enum s390_regset {
 	REGSET_GENERAL,
@@ -668,7 +668,7 @@ asmlinkage long do_syscall_trace_enter(struct pt_regs *regs)
 	}
 
 	if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
-		trace_syscall_enter(regs, regs->gprs[2]);
+		trace_sys_enter(regs, regs->gprs[2]);
 
 	if (unlikely(current->audit_context))
 		audit_syscall_entry(is_compat_task() ?
@@ -686,7 +686,7 @@ asmlinkage void do_syscall_trace_exit(struct pt_regs *regs)
 				   regs->gprs[2]);
 
 	if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
-		trace_syscall_exit(regs, regs->gprs[2]);
+		trace_sys_exit(regs, regs->gprs[2]);
 
 	if (test_thread_flag(TIF_SYSCALL_TRACE))
 		tracehook_report_syscall_exit(regs, 0);
diff --git a/arch/x86/kernel/ptrace.c b/arch/x86/kernel/ptrace.c
index cef009a..81cce90 100644
--- a/arch/x86/kernel/ptrace.c
+++ b/arch/x86/kernel/ptrace.c
@@ -35,15 +35,13 @@
 #include <asm/proto.h>
 #include <asm/ds.h>
 
-#include <trace/syscall.h>
+#include "tls.h"
 
 static void syscall_regfunc(void);
 static void syscall_unregfunc(void);
 
-DEFINE_TRACE_FN(syscall_enter, syscall_regfunc, syscall_unregfunc);
-DEFINE_TRACE_FN(syscall_exit, syscall_regfunc, syscall_unregfunc);
-
-#include "tls.h"
+#define CREATE_TRACE_POINTS
+#include <trace/events/syscalls.h>
 
 enum x86_regset {
 	REGSET_GENERAL,
@@ -1504,7 +1502,7 @@ asmregparm long syscall_trace_enter(struct pt_regs *regs)
 		ret = -1L;
 
 	if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
-		trace_syscall_enter(regs, regs->orig_ax);
+		trace_sys_enter(regs, regs->orig_ax);
 
 	if (unlikely(current->audit_context)) {
 		if (IS_IA32)
@@ -1530,7 +1528,7 @@ asmregparm void syscall_trace_leave(struct pt_regs *regs)
 		audit_syscall_exit(AUDITSC_RESULT(regs->ax), regs->ax);
 
 	if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
-		trace_syscall_exit(regs, regs->ax);
+		trace_sys_exit(regs, regs->ax);
 
 	if (test_thread_flag(TIF_SYSCALL_TRACE))
 		tracehook_report_syscall_exit(regs, 0);
diff --git a/include/trace/events/syscalls.h b/include/trace/events/syscalls.h
new file mode 100644
index 0000000..b647a38
--- /dev/null
+++ b/include/trace/events/syscalls.h
@@ -0,0 +1,68 @@
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM syscalls
+
+#if !defined(_TRACE_EVENTS_SYSCALLS_H) || defined(TRACE_HEADER_MULTI_READ)
+#define _TRACE_EVENTS_SYSCALLS_H
+
+#include <linux/tracepoint.h>
+
+#include <asm/ptrace.h>
+#include <asm/syscall.h>
+
+
+/* Currently, only archs with TIF_SYSCALL_TRACEPOINT support these. */
+#ifdef TIF_SYSCALL_TRACEPOINT
+
+TRACE_EVENT_FN(sys_enter,
+
+	TP_PROTO(struct pt_regs *regs, long id),
+
+	TP_ARGS(regs, id),
+
+	TP_STRUCT__entry(
+		__field(	long,		id		)
+		__array(	unsigned long,	args,	6	)
+	),
+
+	TP_fast_assign(
+		__entry->id	= id;
+		syscall_get_arguments(current, regs, 0, 6, __entry->args);
+	),
+
+	TP_printk("NR %ld (%lx, %lx, %lx, %lx, %lx, %lx)",
+		  __entry->id,
+		  __entry->args[0], __entry->args[1], __entry->args[2],
+		  __entry->args[3], __entry->args[4], __entry->args[5]),
+
+	syscall_regfunc, syscall_unregfunc
+);
+
+TRACE_EVENT_FN(sys_exit,
+
+	TP_PROTO(struct pt_regs *regs, long ret),
+
+	TP_ARGS(regs, ret),
+
+	TP_STRUCT__entry(
+		__field(	long,	id	)
+		__field(	long,	ret	)
+	),
+
+	TP_fast_assign(
+		__entry->id	= syscall_get_nr(current, regs);
+		__entry->ret	= ret;
+	),
+
+	TP_printk("NR %ld = %ld",
+		  __entry->id, __entry->ret),
+
+	syscall_regfunc, syscall_unregfunc
+);
+
+#endif /* TIF_SYSCALL_TRACEPOINT */
+
+#endif /* _TRACE_EVENTS_SYSCALLS_H */
+
+/* This part must be outside protection */
+#include <trace/define_trace.h>
+
diff --git a/include/trace/syscall.h b/include/trace/syscall.h
index f3d8555..5dc283b 100644
--- a/include/trace/syscall.h
+++ b/include/trace/syscall.h
@@ -8,16 +8,6 @@
 #include <asm/ptrace.h>
 
 
-DECLARE_TRACE(syscall_enter,
-	TP_PROTO(struct pt_regs *regs, long id),
-	TP_ARGS(regs, id)
-);
-
-DECLARE_TRACE(syscall_exit,
-	TP_PROTO(struct pt_regs *regs, long ret),
-	TP_ARGS(regs, ret)
-);
-
 /*
  * A syscall entry in the ftrace syscalls array.
  *
diff --git a/kernel/trace/trace_syscalls.c b/kernel/trace/trace_syscalls.c
index 46c1b97..2698fe4 100644
--- a/kernel/trace/trace_syscalls.c
+++ b/kernel/trace/trace_syscalls.c
@@ -1,4 +1,5 @@
 #include <trace/syscall.h>
+#include <trace/events/syscalls.h>
 #include <linux/kernel.h>
 #include <linux/ftrace.h>
 #include <linux/perf_counter.h>
@@ -286,7 +287,7 @@ int reg_event_syscall_enter(void *ptr)
 		return -ENOSYS;
 	mutex_lock(&syscall_trace_lock);
 	if (!sys_refcount_enter)
-		ret = register_trace_syscall_enter(ftrace_syscall_enter);
+		ret = register_trace_sys_enter(ftrace_syscall_enter);
 	if (ret) {
 		pr_info("event trace: Could not activate"
 				"syscall entry trace point");
@@ -311,7 +312,7 @@ void unreg_event_syscall_enter(void *ptr)
 	sys_refcount_enter--;
 	clear_bit(num, enabled_enter_syscalls);
 	if (!sys_refcount_enter)
-		unregister_trace_syscall_enter(ftrace_syscall_enter);
+		unregister_trace_sys_enter(ftrace_syscall_enter);
 	mutex_unlock(&syscall_trace_lock);
 }
 
@@ -327,7 +328,7 @@ int reg_event_syscall_exit(void *ptr)
 		return -ENOSYS;
 	mutex_lock(&syscall_trace_lock);
 	if (!sys_refcount_exit)
-		ret = register_trace_syscall_exit(ftrace_syscall_exit);
+		ret = register_trace_sys_exit(ftrace_syscall_exit);
 	if (ret) {
 		pr_info("event trace: Could not activate"
 				"syscall exit trace point");
@@ -352,7 +353,7 @@ void unreg_event_syscall_exit(void *ptr)
 	sys_refcount_exit--;
 	clear_bit(num, enabled_exit_syscalls);
 	if (!sys_refcount_exit)
-		unregister_trace_syscall_exit(ftrace_syscall_exit);
+		unregister_trace_sys_exit(ftrace_syscall_exit);
 	mutex_unlock(&syscall_trace_lock);
 }
 
@@ -418,7 +419,7 @@ int reg_prof_syscall_enter(char *name)
 
 	mutex_lock(&syscall_trace_lock);
 	if (!sys_prof_refcount_enter)
-		ret = register_trace_syscall_enter(prof_syscall_enter);
+		ret = register_trace_sys_enter(prof_syscall_enter);
 	if (ret) {
 		pr_info("event trace: Could not activate"
 				"syscall entry trace point");
@@ -442,7 +443,7 @@ void unreg_prof_syscall_enter(char *name)
 	sys_prof_refcount_enter--;
 	clear_bit(num, enabled_prof_enter_syscalls);
 	if (!sys_prof_refcount_enter)
-		unregister_trace_syscall_enter(prof_syscall_enter);
+		unregister_trace_sys_enter(prof_syscall_enter);
 	mutex_unlock(&syscall_trace_lock);
 }
 
@@ -479,7 +480,7 @@ int reg_prof_syscall_exit(char *name)
 
 	mutex_lock(&syscall_trace_lock);
 	if (!sys_prof_refcount_exit)
-		ret = register_trace_syscall_exit(prof_syscall_exit);
+		ret = register_trace_sys_exit(prof_syscall_exit);
 	if (ret) {
 		pr_info("event trace: Could not activate"
 				"syscall entry trace point");
@@ -503,7 +504,7 @@ void unreg_prof_syscall_exit(char *name)
 	sys_prof_refcount_exit--;
 	clear_bit(num, enabled_prof_exit_syscalls);
 	if (!sys_prof_refcount_exit)
-		unregister_trace_syscall_exit(prof_syscall_exit);
+		unregister_trace_sys_exit(prof_syscall_exit);
 	mutex_unlock(&syscall_trace_lock);
 }
 
-- 
1.6.2.5


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

* Re: [PATCH v2 1/2] tracing: Move tracepoint callbacks into DEFINE
  2009-08-21 19:34     ` Josh Stone
  2009-08-21 20:06       ` Jason Baron
@ 2009-08-23 20:15       ` Frederic Weisbecker
  1 sibling, 0 replies; 70+ messages in thread
From: Frederic Weisbecker @ 2009-08-23 20:15 UTC (permalink / raw)
  To: Josh Stone
  Cc: Jason Baron, linux-kernel, mingo, laijs, rostedt, peterz,
	mathieu.desnoyers, jiayingz, mbligh, lizf

On Fri, Aug 21, 2009 at 12:34:28PM -0700, Josh Stone wrote:
> On 08/21/2009 10:52 AM, Jason Baron wrote:
> > this means that when CONFIG_EVENT_TRACING is set, the 'generic' syscall
> > enter/exit will show up as events in the debugfs, but enabling them
> > wouldn't do anything. I think we should simply drop the
> > 'CONFIG_FTRACE_SYSCALLS' 'ifdef' and 'else' clause. That will give us
> > what we want - tying these callbacks directly to tracepoint.
> 
> But only x86 and s390 have TIF_SYSCALL_FTRACE, while kernel/tracepoint.c
> must still compile everywhere that has CONFIG_TRACEPOINTS=y.
> 
> Maybe it would be better to make that #ifdef TIF_SYSCALL_FTRACE, and
> then also #ifdef the TRACE_EVENT declaration, so it will only show up on
> kernels that actually support it.


Instead of testing TIF_SYSCALL_FTRACE, I'd suggest testing HAVE_FTRACE_SYSCALLS.
This makes more sense and is more verbose wrt its role in the conditionnal definition,
given its macro name.

 
> Also, since this event is now usable outside of ftrace, would you object
> to renaming the flag TIF_SYSCALL_TRACEPOINT?
> 
> Josh


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

* Re: [PATCH v2 1/2] tracing: Move tracepoint callbacks into DEFINE
  2009-08-21 20:06       ` Jason Baron
@ 2009-08-23 20:29         ` Frederic Weisbecker
  0 siblings, 0 replies; 70+ messages in thread
From: Frederic Weisbecker @ 2009-08-23 20:29 UTC (permalink / raw)
  To: Jason Baron
  Cc: Josh Stone, linux-kernel, mingo, laijs, rostedt, peterz,
	mathieu.desnoyers, jiayingz, mbligh, lizf

On Fri, Aug 21, 2009 at 04:06:44PM -0400, Jason Baron wrote:
> On Fri, Aug 21, 2009 at 12:34:28PM -0700, Josh Stone wrote:
> > On 08/21/2009 10:52 AM, Jason Baron wrote:
> > > this means that when CONFIG_EVENT_TRACING is set, the 'generic' syscall
> > > enter/exit will show up as events in the debugfs, but enabling them
> > > wouldn't do anything. I think we should simply drop the
> > > 'CONFIG_FTRACE_SYSCALLS' 'ifdef' and 'else' clause. That will give us
> > > what we want - tying these callbacks directly to tracepoint.
> > 
> > But only x86 and s390 have TIF_SYSCALL_FTRACE, while kernel/tracepoint.c
> > must still compile everywhere that has CONFIG_TRACEPOINTS=y.
> > 
> 
> ok.
> 
> > Maybe it would be better to make that #ifdef TIF_SYSCALL_FTRACE, and
> > then also #ifdef the TRACE_EVENT declaration, so it will only show up on
> > kernels that actually support it.
> > 
> 
> hmm...maybe then we move these functions to an arch specific file, such
> as arch/x86{s390}/kernel/ftrace.c, making the code contigent on
> CONFIG_TRACEPOINTS? (I think that required less ifdefs...).


But the code of these functions is generic and should then keep beeing
factorized.

We could put them in kernel/trace/trace_syscalls.c and keep ftrace related
things inside CONFIG_TRACE_SYSCALLS and the above inside
CONFIG_TRACEPOINT + CONFIG_HAVE_SYSCALL_TRACING (then also change
the Makefile).

Or if you find that too dirty, may be create a separate file in kernel/trace/.


> 
> > Also, since this event is now usable outside of ftrace, would you object
> > to renaming the flag TIF_SYSCALL_TRACEPOINT?
> > 
> 
> sure.
> 
> thanks,
> 
> -Jason


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

* Re: [PATCH v3 2/4] tracing: Make syscall_(un)regfunc arch-specific
  2009-08-22  4:58       ` [PATCH v3 2/4] tracing: Make syscall_(un)regfunc arch-specific Josh Stone
  2009-08-22  4:58         ` [PATCH v3 3/4] tracing: Move tracepoint callbacks into DEFINE Josh Stone
@ 2009-08-23 21:14         ` Frederic Weisbecker
  2009-08-24  1:40           ` Paul Mundt
  2009-08-24 19:31           ` Josh Stone
  1 sibling, 2 replies; 70+ messages in thread
From: Frederic Weisbecker @ 2009-08-23 21:14 UTC (permalink / raw)
  To: Josh Stone
  Cc: linux-kernel, Jason Baron, Ingo Molnar, Li Zefan, Steven Rostedt,
	Peter Zijlstra, Mathieu Desnoyers, Jiaying Zhang, Martin Bligh,
	Lai Jiangshan, Paul Mundt

On Fri, Aug 21, 2009 at 09:58:43PM -0700, Josh Stone wrote:
> The bodies of syscall_regfunc and syscall_unregfunc need the
> arch-specific flag TIF_SYSCALL_TRACEPOINT, which only exists
> on x86 and s390, so they should live in arch-specific files.


Sh also does, but currently in a seperate development branch.
(Adding Paul Mundt in Cc to prevent from further linux-next breakage).


 
> +
> +#ifdef CONFIG_TRACEPOINTS
> +
> +static DEFINE_MUTEX(regfunc_mutex);
> +static int sys_tracepoint_refcount;
> +
> +void syscall_regfunc(void)
> +{
> +	unsigned long flags;
> +	struct task_struct *g, *t;
> +
> +	mutex_lock(&regfunc_mutex);
> +	if (!sys_tracepoint_refcount) {
> +		read_lock_irqsave(&tasklist_lock, flags);
> +		do_each_thread(g, t) {
> +			set_tsk_thread_flag(t, TIF_SYSCALL_TRACEPOINT);
> +		} while_each_thread(g, t);
> +		read_unlock_irqrestore(&tasklist_lock, flags);
> +	}
> +	sys_tracepoint_refcount++;
> +	mutex_unlock(&regfunc_mutex);
> +}
> +
> +void syscall_unregfunc(void)
> +{
> +	unsigned long flags;
> +	struct task_struct *g, *t;
> +
> +	mutex_lock(&regfunc_mutex);
> +	sys_tracepoint_refcount--;
> +	if (!sys_tracepoint_refcount) {
> +		read_lock_irqsave(&tasklist_lock, flags);
> +		do_each_thread(g, t) {
> +			clear_tsk_thread_flag(t, TIF_SYSCALL_TRACEPOINT);
> +		} while_each_thread(g, t);
> +		read_unlock_irqrestore(&tasklist_lock, flags);
> +	}
> +	mutex_unlock(&regfunc_mutex);
> +}
> +#endif
> diff --git a/arch/x86/kernel/ptrace.c b/arch/x86/kernel/ptrace.c
> index a909afe..c2adbed 100644
> --- a/arch/x86/kernel/ptrace.c
> +++ b/arch/x86/kernel/ptrace.c
> @@ -1549,3 +1549,43 @@ asmregparm void syscall_trace_leave(struct pt_regs *regs)
>  	    tracehook_consider_fatal_signal(current, SIGTRAP))
>  		send_sigtrap(current, regs, 0, TRAP_BRKPT);
>  }
> +
> +#ifdef CONFIG_TRACEPOINTS
> +
> +static DEFINE_MUTEX(regfunc_mutex);
> +static int sys_tracepoint_refcount;
> +
> +void syscall_regfunc(void)
> +{
> +	unsigned long flags;
> +	struct task_struct *g, *t;
> +
> +	mutex_lock(&regfunc_mutex);
> +	if (!sys_tracepoint_refcount) {
> +		read_lock_irqsave(&tasklist_lock, flags);
> +		do_each_thread(g, t) {
> +			set_tsk_thread_flag(t, TIF_SYSCALL_TRACEPOINT);
> +		} while_each_thread(g, t);
> +		read_unlock_irqrestore(&tasklist_lock, flags);
> +	}
> +	sys_tracepoint_refcount++;
> +	mutex_unlock(&regfunc_mutex);
> +}
> +
> +void syscall_unregfunc(void)
> +{
> +	unsigned long flags;
> +	struct task_struct *g, *t;
> +
> +	mutex_lock(&regfunc_mutex);
> +	sys_tracepoint_refcount--;
> +	if (!sys_tracepoint_refcount) {
> +		read_lock_irqsave(&tasklist_lock, flags);
> +		do_each_thread(g, t) {
> +			clear_tsk_thread_flag(t, TIF_SYSCALL_TRACEPOINT);
> +		} while_each_thread(g, t);
> +		read_unlock_irqrestore(&tasklist_lock, flags);
> +	}
> +	mutex_unlock(&regfunc_mutex);
> +}
> +#endif



I really don't like that.
See how the s390 and x86 version of the above code are completely
identical?

Please put this in kernel/ptrace.c

Thanks.


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

* Re: [PATCH v3 1/4] tracing: Rename TIF_SYSCALL_FTRACE->_TRACEPOINT
  2009-08-22  4:58     ` [PATCH v3 1/4] tracing: Rename TIF_SYSCALL_FTRACE->_TRACEPOINT Josh Stone
  2009-08-22  4:58       ` [PATCH v3 2/4] tracing: Make syscall_(un)regfunc arch-specific Josh Stone
@ 2009-08-23 21:16       ` Frederic Weisbecker
  2009-08-24  8:42         ` Ingo Molnar
  1 sibling, 1 reply; 70+ messages in thread
From: Frederic Weisbecker @ 2009-08-23 21:16 UTC (permalink / raw)
  To: Josh Stone
  Cc: linux-kernel, Jason Baron, Ingo Molnar, Li Zefan, Steven Rostedt,
	Peter Zijlstra, Mathieu Desnoyers, Jiaying Zhang, Martin Bligh,
	Lai Jiangshan

On Fri, Aug 21, 2009 at 09:58:42PM -0700, Josh Stone wrote:
> This thread flag is no longer specific to just ftrace, so
> TIF_SYSCALL_TRACEPOINT may be a more apt name.


Adding Paul Mundt <lethal@linux-sh.org> in Cc, the sh
tree also has the syscalls tracing support (in a seperate
branch).

Thanks.


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

* Re: [PATCH v3 2/4] tracing: Make syscall_(un)regfunc arch-specific
  2009-08-23 21:14         ` [PATCH v3 2/4] tracing: Make syscall_(un)regfunc arch-specific Frederic Weisbecker
@ 2009-08-24  1:40           ` Paul Mundt
  2009-08-24  8:41             ` Ingo Molnar
  2009-08-24 19:31           ` Josh Stone
  1 sibling, 1 reply; 70+ messages in thread
From: Paul Mundt @ 2009-08-24  1:40 UTC (permalink / raw)
  To: Frederic Weisbecker
  Cc: Josh Stone, linux-kernel, Jason Baron, Ingo Molnar, Li Zefan,
	Steven Rostedt, Peter Zijlstra, Mathieu Desnoyers, Jiaying Zhang,
	Martin Bligh, Lai Jiangshan

On Sun, Aug 23, 2009 at 11:14:24PM +0200, Frederic Weisbecker wrote:
> On Fri, Aug 21, 2009 at 09:58:43PM -0700, Josh Stone wrote:
> > The bodies of syscall_regfunc and syscall_unregfunc need the
> > arch-specific flag TIF_SYSCALL_TRACEPOINT, which only exists
> > on x86 and s390, so they should live in arch-specific files.
> 
> Sh also does, but currently in a seperate development branch.
> (Adding Paul Mundt in Cc to prevent from further linux-next breakage).
> 
Thanks, I'll take care of this as well as the other ftrace syscalls
breakage during the merge window. At the moment I don't have any good
ideas on how to fix the workflow issues, and -tip likewise doesn't care
about -next impact, so there's somewhat of an impasse.

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

* Re: [PATCH v3 2/4] tracing: Make syscall_(un)regfunc arch-specific
  2009-08-24  1:40           ` Paul Mundt
@ 2009-08-24  8:41             ` Ingo Molnar
  2009-08-24  8:59               ` Paul Mundt
  0 siblings, 1 reply; 70+ messages in thread
From: Ingo Molnar @ 2009-08-24  8:41 UTC (permalink / raw)
  To: Paul Mundt, Frederic Weisbecker, Josh Stone, linux-kernel,
	Jason Baron, Li Zefan, Steven Rostedt, Peter Zijlstra,
	Mathieu Desnoyers, Jiaying Zhang, Martin Bligh, Lai Jiangshan


* Paul Mundt <lethal@linux-sh.org> wrote:

> On Sun, Aug 23, 2009 at 11:14:24PM +0200, Frederic Weisbecker wrote:
> > On Fri, Aug 21, 2009 at 09:58:43PM -0700, Josh Stone wrote:
> > > The bodies of syscall_regfunc and syscall_unregfunc need the
> > > arch-specific flag TIF_SYSCALL_TRACEPOINT, which only exists
> > > on x86 and s390, so they should live in arch-specific files.
> > 
> > Sh also does, but currently in a seperate development branch. 
> > (Adding Paul Mundt in Cc to prevent from further linux-next 
> > breakage).
> 
> Thanks, I'll take care of this as well as the other ftrace 
> syscalls breakage during the merge window. At the moment I don't 
> have any good ideas on how to fix the workflow issues, and -tip 
> likewise doesn't care about -next impact, so there's somewhat of 
> an impasse.

Where did you take the nonsense from that '-tip likewise doesn't 
care about -next impact'? It's a false statement on several levels.

The thing is, there is just a single 'breakage' here (SH does not 
build if the tracing tree is mixed with the SH tree), and you 
inflicted it upon yourself: you mixed ftrace development into the SH 
tree (thinking that the syscall-tracing facility was a stable API - 
where did _that_ nonsense come from?), while the tracing tree did 
development of ftrace too (surprise), so when the two versions were 
mixed in linux-next it broke.

There's numerous ways to resolve this and i'm willing to help out 
with any of the solutions your chose (or with some other variant if 
it makes sense):

 - Easiest: you can turn off the old-API based ftrace bits in the SH 
   tree, in your for-next branch. This is the easiest, but keeps new 
   SH ftrace bits untested in linux-next.

 - Most conservative route: you wait with your new bits until the 
   new tracing facilities hit upstream in the merge window. The
   disadvantage is that this delays your code and there's no 
   guarantee that it cannot collide with new changes.

 - The proper workflow: you can actually help out the development of 
   tracing facilities by doing tracing development in the tracing 
   tree. We merged a number of architecture ftrace improvements via 
   the tracing tree already, as long as it's acked by the maintainer 
   (which is a given here - you maintain SH) and as long as it does 
   not touch non-ftrace bits of the architecture unreasonably.

   This is the most natural workflow and the fastest one as well. 
   The ftrace bits are well separated (or should be well separated). 
   We didnt do ftrace development via the x86 tree either.

I'd favor the third one as it's the most intelligent variant and we 
used that in a number of other cases - but it's up to you.

	Ingo

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

* Re: [PATCH v3 1/4] tracing: Rename TIF_SYSCALL_FTRACE->_TRACEPOINT
  2009-08-23 21:16       ` [PATCH v3 1/4] tracing: Rename TIF_SYSCALL_FTRACE->_TRACEPOINT Frederic Weisbecker
@ 2009-08-24  8:42         ` Ingo Molnar
  2009-08-24 11:11           ` Frederic Weisbecker
  0 siblings, 1 reply; 70+ messages in thread
From: Ingo Molnar @ 2009-08-24  8:42 UTC (permalink / raw)
  To: Frederic Weisbecker
  Cc: Josh Stone, linux-kernel, Jason Baron, Li Zefan, Steven Rostedt,
	Peter Zijlstra, Mathieu Desnoyers, Jiaying Zhang, Martin Bligh,
	Lai Jiangshan


* Frederic Weisbecker <fweisbec@gmail.com> wrote:

> On Fri, Aug 21, 2009 at 09:58:42PM -0700, Josh Stone wrote:
>
> > This thread flag is no longer specific to just ftrace, so 
> > TIF_SYSCALL_TRACEPOINT may be a more apt name.
> 
> Adding Paul Mundt <lethal@linux-sh.org> in Cc, the sh tree also 
> has the syscalls tracing support (in a seperate branch).

Btw., is there an URI for that separate branch?

	Ingo

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

* Re: [PATCH v3 2/4] tracing: Make syscall_(un)regfunc arch-specific
  2009-08-24  8:41             ` Ingo Molnar
@ 2009-08-24  8:59               ` Paul Mundt
  2009-08-24  9:56                 ` Ingo Molnar
  0 siblings, 1 reply; 70+ messages in thread
From: Paul Mundt @ 2009-08-24  8:59 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: Frederic Weisbecker, Josh Stone, linux-kernel, Jason Baron,
	Li Zefan, Steven Rostedt, Peter Zijlstra, Mathieu Desnoyers,
	Jiaying Zhang, Martin Bligh, Lai Jiangshan

On Mon, Aug 24, 2009 at 10:41:01AM +0200, Ingo Molnar wrote:
> * Paul Mundt <lethal@linux-sh.org> wrote:
> > On Sun, Aug 23, 2009 at 11:14:24PM +0200, Frederic Weisbecker wrote:
> > > On Fri, Aug 21, 2009 at 09:58:43PM -0700, Josh Stone wrote:
> > > > The bodies of syscall_regfunc and syscall_unregfunc need the
> > > > arch-specific flag TIF_SYSCALL_TRACEPOINT, which only exists
> > > > on x86 and s390, so they should live in arch-specific files.
> > > 
> > > Sh also does, but currently in a seperate development branch. 
> > > (Adding Paul Mundt in Cc to prevent from further linux-next 
> > > breakage).
> > 
> > Thanks, I'll take care of this as well as the other ftrace 
> > syscalls breakage during the merge window. At the moment I don't 
> > have any good ideas on how to fix the workflow issues, and -tip 
> > likewise doesn't care about -next impact, so there's somewhat of 
> > an impasse.
> 
> Where did you take the nonsense from that '-tip likewise doesn't 
> care about -next impact'? It's a false statement on several levels.
> 
> The thing is, there is just a single 'breakage' here (SH does not 
> build if the tracing tree is mixed with the SH tree), and you 
> inflicted it upon yourself: you mixed ftrace development into the SH 
> tree (thinking that the syscall-tracing facility was a stable API - 
> where did _that_ nonsense come from?), while the tracing tree did 
> development of ftrace too (surprise), so when the two versions were 
> mixed in linux-next it broke.
> 
I think this is the source of confusion, given that I expected the
interface would remain reasonable stable until all of the existing users
had had a chance to catch up. As it is now it is impossible to make any
changes to things that are taken over by -tip given that the first sign
of there being any changes are failures introduced through -next, which
would have been avoided if folks eagerly merging things in to -tip
considered the implications for -next.

Pointing fingers however is rather pointless at this stage, and is not
what I am trying to do. I've lost count of the number of times -tip has
broken things in -next that were easily avoidable, and at this point I
don't even care anymore (as I've stated before, it's not just -tip,
people in general seem to be doing a lot of aggressive merging without
even a cursory grep to check for the build implications). I fix them up
as I encounter them, and try to keep my configs in general buildable
shape. You call that nonsense, I call it statistics.

In any event, at least some of these issues are self-inflicted given that
some feature implementation is done in my tree directly without passing
through -tip first, but none of that changes the fact that -tip is
merging things in to -next without any consideration of the impact it
will have. This is what I have a fundamental issue with, given that there
are a lot more trees than just -tip being merged, and at least some
effort should be made to permit things to co-exist rather than just
blaming it all on workflow.

> There's numerous ways to resolve this and i'm willing to help out 
> with any of the solutions your chose (or with some other variant if 
> it makes sense):
> 
>  - Easiest: you can turn off the old-API based ftrace bits in the SH 
>    tree, in your for-next branch. This is the easiest, but keeps new 
>    SH ftrace bits untested in linux-next.
> 
I've already done this.

>  - The proper workflow: you can actually help out the development of 
>    tracing facilities by doing tracing development in the tracing 
>    tree. We merged a number of architecture ftrace improvements via 
>    the tracing tree already, as long as it's acked by the maintainer 
>    (which is a given here - you maintain SH) and as long as it does 
>    not touch non-ftrace bits of the architecture unreasonably.
> 
>    This is the most natural workflow and the fastest one as well. 
>    The ftrace bits are well separated (or should be well separated). 
>    We didnt do ftrace development via the x86 tree either.
> 
> I'd favor the third one as it's the most intelligent variant and we 
> used that in a number of other cases - but it's up to you.
> 
Agreed, this is the way we will try to handle ftrace bits for sh from now
on. There is not much to be done about the present mess other than
waiting for things to sync up in the merge window, which I'm fine with at
present given that it's not so far off.

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

* Re: [PATCH v3 2/4] tracing: Make syscall_(un)regfunc arch-specific
  2009-08-24  8:59               ` Paul Mundt
@ 2009-08-24  9:56                 ` Ingo Molnar
  2009-08-24 10:32                   ` Paul Mundt
  2009-08-24 11:01                   ` Ingo Molnar
  0 siblings, 2 replies; 70+ messages in thread
From: Ingo Molnar @ 2009-08-24  9:56 UTC (permalink / raw)
  To: Paul Mundt, Frederic Weisbecker, Josh Stone, linux-kernel,
	Jason Baron, Li Zefan, Steven Rostedt, Peter Zijlstra,
	Mathieu Desnoyers, Jiaying Zhang, Martin Bligh, Lai Jiangshan


* Paul Mundt <lethal@linux-sh.org> wrote:

> On Mon, Aug 24, 2009 at 10:41:01AM +0200, Ingo Molnar wrote:
> > * Paul Mundt <lethal@linux-sh.org> wrote:
> > > On Sun, Aug 23, 2009 at 11:14:24PM +0200, Frederic Weisbecker wrote:
> > > > On Fri, Aug 21, 2009 at 09:58:43PM -0700, Josh Stone wrote:
> > > > > The bodies of syscall_regfunc and syscall_unregfunc need the
> > > > > arch-specific flag TIF_SYSCALL_TRACEPOINT, which only exists
> > > > > on x86 and s390, so they should live in arch-specific files.
> > > > 
> > > > Sh also does, but currently in a seperate development branch. 
> > > > (Adding Paul Mundt in Cc to prevent from further linux-next 
> > > > breakage).
> > > 
> > > Thanks, I'll take care of this as well as the other ftrace 
> > > syscalls breakage during the merge window. At the moment I don't 
> > > have any good ideas on how to fix the workflow issues, and -tip 
> > > likewise doesn't care about -next impact, so there's somewhat of 
> > > an impasse.
> > 
> > Where did you take the nonsense from that '-tip likewise doesn't 
> > care about -next impact'? It's a false statement on several levels.
> > 
> > The thing is, there is just a single 'breakage' here (SH does 
> > not build if the tracing tree is mixed with the SH tree), and 
> > you inflicted it upon yourself: you mixed ftrace development 
> > into the SH tree (thinking that the syscall-tracing facility was 
> > a stable API - where did _that_ nonsense come from?), while the 
> > tracing tree did development of ftrace too (surprise), so when 
> > the two versions were mixed in linux-next it broke.
> 
> I think this is the source of confusion, given that I expected the 
> interface would remain reasonable stable until all of the existing 
> users had had a chance to catch up. [...]

All existing upstream users of APIs were fixed up. Which was x86 and 
s390. (and yes, we initially missed s390)

Stable APIs are not how upstream Linux kernel development works - it 
would be way too inflexible.

Instead facility trees (such as the tracing tree) are either 
expected to convert all upstream API uses (which we did), or are 
supposed to provide different versions of APIs, if an API is so 
widespread (used by hundreds of callsites, etc.) that it's not 
reasonable to convert it in one go.

> [...] As it is now it is impossible to make any changes to things 
> that are taken over by -tip given that the first sign of there 
> being any changes are failures introduced through -next, which 
> would have been avoided if folks eagerly merging things in to -tip 
> considered the implications for -next.

Paul, what you say is not making any sense to me. All those ftrace 
patches were sent to lkml multiple times (as all ftrace patches), so 
if you wanted you could have known about them.

If there's someone who failed to notify it was _you_. You might as 
well have Cc:-ed the guys who wrote the code you started using in 
SH.

> Pointing fingers however is rather pointless at this stage, and is 
> not what I am trying to do. [...]

( Hey what was the purpose of the previous 3 paragraphs then? ;-)

> [...] I've lost count of the number of times -tip has broken 
> things in -next that were easily avoidable, [...]

Do you realize that 1) what you say is false 2) we push thousands of 
commits so even if it was true it would be natural relative to the 
number of kernel developers who work on the various -tip based 
trees?

I know it as i always cross-build SH (too) before i push out to 
linux-next. I dont remember a _single_ SH breakage in the past few 
months, and we push thousands of commits. In fact the last time the 
ftrace tree broke linux-next was 8 months ago:

  Date: Wed, 7 Jan 2009 10:55:05 +0100
  From: Ingo Molnar <mingo@elte.hu>
  To: Stephen Rothwell <sfr@canb.auug.org.au>
  Subject: Re: linux-next: ftrace tree build failure

and that too was a breakage already fixed by the time it got 
reported.

So i'd really like you to back up your claims with facts. Your mail 
is basically unsubstantiated FUD right now and i'll just ignore you 
if you continue this pattern of unsubstantiated attacks and 
unconstructive behavior.

( Also, could you please fix your mailer so that it does not damage 
  threads? It generates such bogus headers:

    Mail-Followup-To: Paul Mundt <lethal@linux-sh.org>,
        Ingo Molnar <mingo@elte.hu>,
        Frederic Weisbecker <fweisbec@gmail.com>,
        Josh Stone <jistone@redhat.com>, linux-kernel@vger.kernel.org,
        Jason Baron <jbaron@redhat.com>, Li Zefan <lizf@cn.fujitsu.com>,
       	Steven Rostedt <rostedt@goodmis.org>,
        Peter Zijlstra <peterz@infradead.org>,
        Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>,
        Jiaying Zhang <jiayingz@google.com>,
        Martin Bligh <mbligh@google.com>,
        Lai Jiangshan <laijs@cn.fujitsu.com>

  which messes up replies. )

Thanks,

	Ingo

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

* Re: [PATCH v3 2/4] tracing: Make syscall_(un)regfunc arch-specific
  2009-08-24  9:56                 ` Ingo Molnar
@ 2009-08-24 10:32                   ` Paul Mundt
  2009-08-24 11:00                     ` Ingo Molnar
  2009-08-24 11:52                     ` Ingo Molnar
  2009-08-24 11:01                   ` Ingo Molnar
  1 sibling, 2 replies; 70+ messages in thread
From: Paul Mundt @ 2009-08-24 10:32 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: Frederic Weisbecker, Josh Stone, linux-kernel, Jason Baron,
	Li Zefan, Steven Rostedt, Peter Zijlstra, Mathieu Desnoyers,
	Jiaying Zhang, Martin Bligh, Lai Jiangshan

On Mon, Aug 24, 2009 at 11:56:52AM +0200, Ingo Molnar wrote:
> * Paul Mundt <lethal@linux-sh.org> wrote:
> > I think this is the source of confusion, given that I expected the 
> > interface would remain reasonable stable until all of the existing 
> > users had had a chance to catch up. [...]
> 
> All existing upstream users of APIs were fixed up. Which was x86 and 
> s390. (and yes, we initially missed s390)
> 
> Stable APIs are not how upstream Linux kernel development works - it 
> would be way too inflexible.
> 
> Instead facility trees (such as the tracing tree) are either 
> expected to convert all upstream API uses (which we did), or are 
> supposed to provide different versions of APIs, if an API is so 
> widespread (used by hundreds of callsites, etc.) that it's not 
> reasonable to convert it in one go.
> 
No Ingo, this is not what you did, this is what you did after the
breakage was pointed out to you. And before that, you had:

commit 60d970c254b95ec7a0fc4c590b510253987b64a0
Author: Ingo Molnar <mingo@elte.hu>
Date:   Thu Aug 13 23:37:26 2009 +0200

    tracing: Fix syscall tracing on !HAVE_FTRACE_SYSCALLS architectures

    The new syscall_regfunc()/unregfunc() functions rely on
    the existence of TIF_SYSCALL_FTRACE - but that TIF flag
    is only offered by HAVE_FTRACE_SYSCALLS.

    Cc: Frederic Weisbecker <fweisbec@gmail.com>
    Cc: Jason Baron <jbaron@redhat.com>
    Cc: Steven Rostedt <rostedt@goodmis.org>
    Cc: Peter Zijlstra <peterz@infradead.org>
    LKML-Reference: <new-submission>
    Signed-off-by: Ingo Molnar <mingo@elte.hu>

Which you at least managed to catch before it went in to -next.

At the time that this patch series was pulled in to -tip, it was basically
broken for 21 out of 22 architectures. And while it's great that you caught
this during your builds and so only a couple were broken instead, it still
should never have made it in to the tree when it was clear it had had precisely
zero testing. What happens if anyone is unfortunate enough to bisect in between
these versions now? It's this sort of development methodology I take issue
with, regardless of how you want to pass it off.

> > [...] As it is now it is impossible to make any changes to things 
> > that are taken over by -tip given that the first sign of there 
> > being any changes are failures introduced through -next, which 
> > would have been avoided if folks eagerly merging things in to -tip 
> > considered the implications for -next.
> 
> Paul, what you say is not making any sense to me. All those ftrace 
> patches were sent to lkml multiple times (as all ftrace patches), so 
> if you wanted you could have known about them.
> 
> If there's someone who failed to notify it was _you_. You might as 
> well have Cc:-ed the guys who wrote the code you started using in 
> SH.
> 
And for what purpose? When has adding feature support to an architecture _ever_
worked that way? The expectation is that a new feature is added, folks add
support for it, and as changes are made in the future, a reasonable attempt is
made to keep folks using it aware of the changes being planned. Ok, in the
future I will be more proactive with Ccing ftrace people on these changes, but
it doesn't change the fact that _no one_ on the -tip side paid any attention at
all to the impact it would have on -next. The s390 case also had to be pointed
out to you, and you don't have the excuse that it was out of tree there.

If this doesn't make sense to you, I'm not sure how else to phrase it. Blindly
merging crap in to -next with zero regard for the impact on others is simply
unacceptable as far as I'm concerned. If enough people feel otherwise, then
there's not much to be done about it.

> > Pointing fingers however is rather pointless at this stage, and is 
> > not what I am trying to do. [...]
> 
> ( Hey what was the purpose of the previous 3 paragraphs then? ;-)
> 
The purpose of the previous 3 paragraphs was pointing out that there is an
issue with untested code being regularly merged in to -next, and that people
are not doing even basic due diligence to ensure that things will not break
before pushing to their trees. -tip is only the current case, my point is that
I am not attempting to make an example of -tip specifically, only that this is
a problem in general.

> I know it as i always cross-build SH (too) before i push out to 
> linux-next. I dont remember a _single_ SH breakage in the past few 
> months, and we push thousands of commits. In fact the last time the 
> ftrace tree broke linux-next was 8 months ago:
> 
But you probably only build -tip and not -next. The point is that the end
result in -next ends up broken, so whether -tip builds or not is not the issue
(although of course I'm glad that you build sh for -tip too, that probably
catches a lot more of these issues before they end up popping up in
-next at least).

> So i'd really like you to back up your claims with facts. Your mail 
> is basically unsubstantiated FUD right now and i'll just ignore you 
> if you continue this pattern of unsubstantiated attacks and 
> unconstructive behavior.
> 
I could sit here and itemize individual breakages all day long, but what would
be the point? Is it likely to force -tip people to even do a cursory grep to
check for what they are going to end up breaking? You obviously have your
perspective on -tip and -next interaction which differs wildly for anyone on
the receiving end. This doesn't seem likely to change, and I am growing weary
of trying to even get you to acknowledge that there is a problem.

Rather than wasting any more of my time on this, I'll just go back to fixing up
all of the breakage introduced in -next by others who likewise couldn't be
bothered doing the bare minimum.

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

* Re: [PATCH v3 2/4] tracing: Make syscall_(un)regfunc arch-specific
  2009-08-24 10:32                   ` Paul Mundt
@ 2009-08-24 11:00                     ` Ingo Molnar
  2009-08-24 11:15                       ` Paul Mundt
  2009-08-24 11:52                     ` Ingo Molnar
  1 sibling, 1 reply; 70+ messages in thread
From: Ingo Molnar @ 2009-08-24 11:00 UTC (permalink / raw)
  To: Paul Mundt, Frederic Weisbecker, Josh Stone, linux-kernel,
	Jason Baron, Li Zefan, Steven Rostedt, Peter Zijlstra,
	Mathieu Desnoyers, Jiaying Zhang, Martin Bligh, Lai Jiangshan


* Paul Mundt <lethal@linux-sh.org> wrote:

> On Mon, Aug 24, 2009 at 11:56:52AM +0200, Ingo Molnar wrote:
> > * Paul Mundt <lethal@linux-sh.org> wrote:
> > > I think this is the source of confusion, given that I expected the 
> > > interface would remain reasonable stable until all of the existing 
> > > users had had a chance to catch up. [...]
> > 
> > All existing upstream users of APIs were fixed up. Which was x86 and 
> > s390. (and yes, we initially missed s390)
> > 
> > Stable APIs are not how upstream Linux kernel development works - it 
> > would be way too inflexible.
> > 
> > Instead facility trees (such as the tracing tree) are either 
> > expected to convert all upstream API uses (which we did), or are 
> > supposed to provide different versions of APIs, if an API is so 
> > widespread (used by hundreds of callsites, etc.) that it's not 
> > reasonable to convert it in one go.
> 
> No Ingo, this is not what you did, this is what you did after the 
> breakage was pointed out to you. [...]

As i explained it to you back then the s390 support was 1) a few 
weeks old 2) got masked due to an unrelated thing. In any case the 
bug was real and it was fixed very quickly within an hour or so of 
the report in the usual workflow and without any argument about it, 
and in total agreement with the s390 folks.

And the thing is, s390 was always a pleasure to deal with. I cannot 
say the same about anything SH. SH always was a huge PITA to deal 
with (to me at least), mainly because you seem to have a false sense 
of entitlement: you think everyone else must be perfect and must not 
affect you while you can sit on your own little island not worrying 
about the rest of the world - who develops and tests core kernel 
facilities for you. It doesnt work like that.

> [...] And before that, you had:
> 
> commit 60d970c254b95ec7a0fc4c590b510253987b64a0
> Author: Ingo Molnar <mingo@elte.hu>
> Date:   Thu Aug 13 23:37:26 2009 +0200
> 
>     tracing: Fix syscall tracing on !HAVE_FTRACE_SYSCALLS architectures
> 
>     The new syscall_regfunc()/unregfunc() functions rely on
>     the existence of TIF_SYSCALL_FTRACE - but that TIF flag
>     is only offered by HAVE_FTRACE_SYSCALLS.
> 
>     Cc: Frederic Weisbecker <fweisbec@gmail.com>
>     Cc: Jason Baron <jbaron@redhat.com>
>     Cc: Steven Rostedt <rostedt@goodmis.org>
>     Cc: Peter Zijlstra <peterz@infradead.org>
>     LKML-Reference: <new-submission>
>     Signed-off-by: Ingo Molnar <mingo@elte.hu>
> 
> Which you at least managed to catch before it went in to -next.

See that LKML-Reference tag? That patch too went out to lkml. Had 
you chosen to participate instead of just complaining you could 
have.

Then you intentionally chose the wrong workflow and now you are 
complaining 1) about an easily fixed bug that got addressed within 
an hour of it reported 2) about a workflow situation you yourself 
created. [and to which i suggested several alternatives how to fix 
it.]

You are not being constructive at all.

	Ingo

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

* Re: [PATCH v3 2/4] tracing: Make syscall_(un)regfunc arch-specific
  2009-08-24  9:56                 ` Ingo Molnar
  2009-08-24 10:32                   ` Paul Mundt
@ 2009-08-24 11:01                   ` Ingo Molnar
  2009-08-24 11:02                     ` Paul Mundt
  1 sibling, 1 reply; 70+ messages in thread
From: Ingo Molnar @ 2009-08-24 11:01 UTC (permalink / raw)
  To: Paul Mundt, Frederic Weisbecker, Josh Stone, linux-kernel,
	Jason Baron, Li Zefan, Steven Rostedt, Peter Zijlstra,
	Mathieu Desnoyers, Jiaying Zhang, Martin Bligh, Lai Jiangshan


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

> ( Also, could you please fix your mailer so that it does not damage 
>   threads? It generates such bogus headers:
> 
>     Mail-Followup-To: Paul Mundt <lethal@linux-sh.org>,
>         Ingo Molnar <mingo@elte.hu>,
>         Frederic Weisbecker <fweisbec@gmail.com>,
>         Josh Stone <jistone@redhat.com>, linux-kernel@vger.kernel.org,
>         Jason Baron <jbaron@redhat.com>, Li Zefan <lizf@cn.fujitsu.com>,
>        	Steven Rostedt <rostedt@goodmis.org>,
>         Peter Zijlstra <peterz@infradead.org>,
>         Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>,
>         Jiaying Zhang <jiayingz@google.com>,
>         Martin Bligh <mbligh@google.com>,
>         Lai Jiangshan <laijs@cn.fujitsu.com>
> 
>   which messes up replies. )

Paul, you forgot to reply to this bit. Mail-Followup-To is quite a 
PITA on lkml.

	Ingo

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

* Re: [PATCH v3 2/4] tracing: Make syscall_(un)regfunc arch-specific
  2009-08-24 11:01                   ` Ingo Molnar
@ 2009-08-24 11:02                     ` Paul Mundt
  0 siblings, 0 replies; 70+ messages in thread
From: Paul Mundt @ 2009-08-24 11:02 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: Frederic Weisbecker, Josh Stone, linux-kernel, Jason Baron,
	Li Zefan, Steven Rostedt, Peter Zijlstra, Mathieu Desnoyers,
	Jiaying Zhang, Martin Bligh, Lai Jiangshan

On Mon, Aug 24, 2009 at 01:01:23PM +0200, Ingo Molnar wrote:
> 
> * Ingo Molnar <mingo@elte.hu> wrote:
> 
> > ( Also, could you please fix your mailer so that it does not damage 
> >   threads? It generates such bogus headers:
> > 
> >     Mail-Followup-To: Paul Mundt <lethal@linux-sh.org>,
> >         Ingo Molnar <mingo@elte.hu>,
> >         Frederic Weisbecker <fweisbec@gmail.com>,
> >         Josh Stone <jistone@redhat.com>, linux-kernel@vger.kernel.org,
> >         Jason Baron <jbaron@redhat.com>, Li Zefan <lizf@cn.fujitsu.com>,
> >        	Steven Rostedt <rostedt@goodmis.org>,
> >         Peter Zijlstra <peterz@infradead.org>,
> >         Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>,
> >         Jiaying Zhang <jiayingz@google.com>,
> >         Martin Bligh <mbligh@google.com>,
> >         Lai Jiangshan <laijs@cn.fujitsu.com>
> > 
> >   which messes up replies. )
> 
> Paul, you forgot to reply to this bit. Mail-Followup-To is quite a 
> PITA on lkml.
> 
Yes, this is the first I realized it was doing this, I'll look in to it,
thanks.

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

* Re: [PATCH v3 1/4] tracing: Rename TIF_SYSCALL_FTRACE->_TRACEPOINT
  2009-08-24  8:42         ` Ingo Molnar
@ 2009-08-24 11:11           ` Frederic Weisbecker
  2009-08-24 11:24             ` Ingo Molnar
  0 siblings, 1 reply; 70+ messages in thread
From: Frederic Weisbecker @ 2009-08-24 11:11 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: Josh Stone, linux-kernel, Jason Baron, Li Zefan, Steven Rostedt,
	Peter Zijlstra, Mathieu Desnoyers, Jiaying Zhang, Martin Bligh,
	Lai Jiangshan

On Mon, Aug 24, 2009 at 10:42:45AM +0200, Ingo Molnar wrote:
> 
> * Frederic Weisbecker <fweisbec@gmail.com> wrote:
> 
> > On Fri, Aug 21, 2009 at 09:58:42PM -0700, Josh Stone wrote:
> >
> > > This thread flag is no longer specific to just ftrace, so 
> > > TIF_SYSCALL_TRACEPOINT may be a more apt name.
> > 
> > Adding Paul Mundt <lethal@linux-sh.org> in Cc, the sh tree also 
> > has the syscalls tracing support (in a seperate branch).
> 
> Btw., is there an URI for that separate branch?
> 
> 	Ingo

I guess it's:

git://git.kernel.org/pub/scm/linux/kernel/git/lethal/sh-2.6.git \
	sh/ftrace


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

* Re: [PATCH v3 2/4] tracing: Make syscall_(un)regfunc arch-specific
  2009-08-24 11:00                     ` Ingo Molnar
@ 2009-08-24 11:15                       ` Paul Mundt
  2009-08-24 11:32                         ` Ingo Molnar
  0 siblings, 1 reply; 70+ messages in thread
From: Paul Mundt @ 2009-08-24 11:15 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: Frederic Weisbecker, Josh Stone, linux-kernel, Jason Baron,
	Li Zefan, Steven Rostedt, Peter Zijlstra, Mathieu Desnoyers,
	Jiaying Zhang, Martin Bligh, Lai Jiangshan

On Mon, Aug 24, 2009 at 01:00:40PM +0200, Ingo Molnar wrote:
> And the thing is, s390 was always a pleasure to deal with. I cannot 
> say the same about anything SH. SH always was a huge PITA to deal 
> with (to me at least), mainly because you seem to have a false sense 
> of entitlement: you think everyone else must be perfect and must not 
> affect you while you can sit on your own little island not worrying 
> about the rest of the world - who develops and tests core kernel 
> facilities for you. It doesnt work like that.
> 
If you had bothered to read any of my earlier mail you would realize that
this is complete and utter nonsense. I expect there to be breakage, and I
expect that I will be the one fixing it up (even when most of the time
that breakage is not even in my own tree). Unsurprisingly, this is
largely a result of SH being one of the first architectures testing these
new core kernel facilities, which is something you seem intent on just
writing off completely. I can imagine why s390 is a pleasure to deal
with in a -tip context, when you break their tree, no one complains.

Where I take issue with -next is that this is not an isolated thing, and
over time it has only become more frequent. In the case of -mm, releases
were infrequent, but we did have this thing called quality control,
something that is utterly lacking in -next and which the trees being
sucked in seem unable to adhere to on their own.

Rather than wasting any more time on this, we can continue this at kernel
summit during the -next session. If the consensus is that I'm just being
unconstructive and my workflow is inherently broken, I can live with
that.

> You are not being constructive at all.
> 
Nor have been any of your responses. At least we've found something to
agree on!

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

* Re: [PATCH v3 1/4] tracing: Rename TIF_SYSCALL_FTRACE->_TRACEPOINT
  2009-08-24 11:11           ` Frederic Weisbecker
@ 2009-08-24 11:24             ` Ingo Molnar
  2009-08-24 11:29               ` Paul Mundt
  0 siblings, 1 reply; 70+ messages in thread
From: Ingo Molnar @ 2009-08-24 11:24 UTC (permalink / raw)
  To: Frederic Weisbecker
  Cc: Josh Stone, linux-kernel, Jason Baron, Li Zefan, Steven Rostedt,
	Peter Zijlstra, Mathieu Desnoyers, Jiaying Zhang, Martin Bligh,
	Lai Jiangshan


* Frederic Weisbecker <fweisbec@gmail.com> wrote:

> On Mon, Aug 24, 2009 at 10:42:45AM +0200, Ingo Molnar wrote:
> > 
> > * Frederic Weisbecker <fweisbec@gmail.com> wrote:
> > 
> > > On Fri, Aug 21, 2009 at 09:58:42PM -0700, Josh Stone wrote:
> > >
> > > > This thread flag is no longer specific to just ftrace, so 
> > > > TIF_SYSCALL_TRACEPOINT may be a more apt name.
> > > 
> > > Adding Paul Mundt <lethal@linux-sh.org> in Cc, the sh tree also 
> > > has the syscalls tracing support (in a seperate branch).
> > 
> > Btw., is there an URI for that separate branch?
> > 
> > 	Ingo
> 
> I guess it's:
> 
> git://git.kernel.org/pub/scm/linux/kernel/git/lethal/sh-2.6.git \
> 	sh/ftrace

ok, i checked - this is not a pure topical tree, it's intermingled 
with other SH changes, so it cannot be pulled into the tracing tree.

Obviously only such trees can be pulled into the tracing tree that 
limit their role to tracing and are non-rebasing.

	Ingo

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

* Re: [PATCH v3 1/4] tracing: Rename TIF_SYSCALL_FTRACE->_TRACEPOINT
  2009-08-24 11:24             ` Ingo Molnar
@ 2009-08-24 11:29               ` Paul Mundt
  2009-08-24 11:36                 ` Ingo Molnar
  0 siblings, 1 reply; 70+ messages in thread
From: Paul Mundt @ 2009-08-24 11:29 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: Frederic Weisbecker, Josh Stone, linux-kernel, Jason Baron,
	Li Zefan, Steven Rostedt, Peter Zijlstra, Mathieu Desnoyers,
	Jiaying Zhang, Martin Bligh, Lai Jiangshan

On Mon, Aug 24, 2009 at 01:24:26PM +0200, Ingo Molnar wrote:
> * Frederic Weisbecker <fweisbec@gmail.com> wrote:
> > On Mon, Aug 24, 2009 at 10:42:45AM +0200, Ingo Molnar wrote:
> > > 
> > > * Frederic Weisbecker <fweisbec@gmail.com> wrote:
> > > 
> > > > On Fri, Aug 21, 2009 at 09:58:42PM -0700, Josh Stone wrote:
> > > >
> > > > > This thread flag is no longer specific to just ftrace, so 
> > > > > TIF_SYSCALL_TRACEPOINT may be a more apt name.
> > > > 
> > > > Adding Paul Mundt <lethal@linux-sh.org> in Cc, the sh tree also 
> > > > has the syscalls tracing support (in a seperate branch).
> > > 
> > > Btw., is there an URI for that separate branch?
> > > 
> > > 	Ingo
> > 
> > I guess it's:
> > 
> > git://git.kernel.org/pub/scm/linux/kernel/git/lethal/sh-2.6.git \
> > 	sh/ftrace
> 
> ok, i checked - this is not a pure topical tree, it's intermingled 
> with other SH changes, so it cannot be pulled into the tracing tree.
> 
> Obviously only such trees can be pulled into the tracing tree that 
> limit their role to tracing and are non-rebasing.
> 
Yes, post-2.6.32 merge window I'll keep the sh/ftrace branch isolated
from the rest of the sh changes, at which point it should be possible to
pull in to -tip directly. I generally do not rebase topic branches.

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

* Re: [PATCH v3 2/4] tracing: Make syscall_(un)regfunc arch-specific
  2009-08-24 11:15                       ` Paul Mundt
@ 2009-08-24 11:32                         ` Ingo Molnar
  0 siblings, 0 replies; 70+ messages in thread
From: Ingo Molnar @ 2009-08-24 11:32 UTC (permalink / raw)
  To: Paul Mundt, Frederic Weisbecker, Josh Stone, linux-kernel,
	Jason Baron, Li Zefan, Steven Rostedt, Peter Zijlstra,
	Mathieu Desnoyers, Jiaying Zhang, Martin Bligh, Lai Jiangshan


* Paul Mundt <lethal@linux-sh.org> wrote:

> On Mon, Aug 24, 2009 at 01:00:40PM +0200, Ingo Molnar wrote:
>
> > And the thing is, s390 was always a pleasure to deal with. I 
> > cannot say the same about anything SH. SH always was a huge PITA 
> > to deal with (to me at least), mainly because you seem to have a 
> > false sense of entitlement: you think everyone else must be 
> > perfect and must not affect you while you can sit on your own 
> > little island not worrying about the rest of the world - who 
> > develops and tests core kernel facilities for you. It doesnt 
> > work like that.
> 
> If you had bothered to read any of my earlier mail you would 
> realize that this is complete and utter nonsense.

first you say it's nonsense, then you basically back up my points:

> [...] I expect there to be breakage, and I expect that I will be 
> the one fixing it up (even when most of the time that breakage is 
> not even in my own tree). Unsurprisingly, this is largely a result 
> of SH being one of the first architectures testing these new core 
> kernel facilities, which is something you seem intent on just 
> writing off completely. [...]

... the thing is, you didnt Cc: any of the tracing commits in the SH 
tree either to lkml or to the tracing folks who are developing those 
facilities:

  c652d78: sh: Add ftrace syscall tracing support

  From: Matt Fleming <matt@console-pimps.org>
  Date: Mon, 6 Jul 2009 20:16:33 +0900
  Subject: [PATCH] sh: Add ftrace syscall tracing support

  [...]

  Signed-off-by: Matt Fleming <matt@console-pimps.org>
  Signed-off-by: Paul Mundt <lethal@linux-sh.org>

That 'could' have been Cc:-ed to Frederic and Steve, perhaps Jason 
and me as well.

You basically treat SH as your own private tree, with little need to 
communicate with anyone outside the SH hackers. Which is fine, as 
long as you are willing to deal with the other side of the coin: 
that others wont be aware of your changes.

Or, at minimum, to not scream loudly when the flip side beats you.

	Ingo

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

* Re: [PATCH v3 1/4] tracing: Rename TIF_SYSCALL_FTRACE->_TRACEPOINT
  2009-08-24 11:29               ` Paul Mundt
@ 2009-08-24 11:36                 ` Ingo Molnar
  0 siblings, 0 replies; 70+ messages in thread
From: Ingo Molnar @ 2009-08-24 11:36 UTC (permalink / raw)
  To: Paul Mundt, Frederic Weisbecker, Josh Stone, linux-kernel,
	Jason Baron, Li Zefan, Steven Rostedt, Peter Zijlstra,
	Mathieu Desnoyers, Jiaying Zhang, Martin Bligh, Lai Jiangshan


* Paul Mundt <lethal@linux-sh.org> wrote:

> On Mon, Aug 24, 2009 at 01:24:26PM +0200, Ingo Molnar wrote:
> > * Frederic Weisbecker <fweisbec@gmail.com> wrote:
> > > On Mon, Aug 24, 2009 at 10:42:45AM +0200, Ingo Molnar wrote:
> > > > 
> > > > * Frederic Weisbecker <fweisbec@gmail.com> wrote:
> > > > 
> > > > > On Fri, Aug 21, 2009 at 09:58:42PM -0700, Josh Stone wrote:
> > > > >
> > > > > > This thread flag is no longer specific to just ftrace, so 
> > > > > > TIF_SYSCALL_TRACEPOINT may be a more apt name.
> > > > > 
> > > > > Adding Paul Mundt <lethal@linux-sh.org> in Cc, the sh tree also 
> > > > > has the syscalls tracing support (in a seperate branch).
> > > > 
> > > > Btw., is there an URI for that separate branch?
> > > > 
> > > > 	Ingo
> > > 
> > > I guess it's:
> > > 
> > > git://git.kernel.org/pub/scm/linux/kernel/git/lethal/sh-2.6.git \
> > > 	sh/ftrace
> > 
> > ok, i checked - this is not a pure topical tree, it's intermingled 
> > with other SH changes, so it cannot be pulled into the tracing tree.
> > 
> > Obviously only such trees can be pulled into the tracing tree that 
> > limit their role to tracing and are non-rebasing.
> 
> Yes, post-2.6.32 merge window I'll keep the sh/ftrace branch 
> isolated from the rest of the sh changes, at which point it should 
> be possible to pull in to -tip directly. I generally do not rebase 
> topic branches.

Next time we can accelerate it all and push it into linux-next as 
well and not limit anyone's workflow, by using the tracing tree as 
the point to merge tracing related changes. If it's acked by you 
then we can do tracing related SH changes too just fine.

	Ingo

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

* Re: [PATCH v3 2/4] tracing: Make syscall_(un)regfunc arch-specific
  2009-08-24 10:32                   ` Paul Mundt
  2009-08-24 11:00                     ` Ingo Molnar
@ 2009-08-24 11:52                     ` Ingo Molnar
  2009-08-24 12:14                       ` Peter Zijlstra
  1 sibling, 1 reply; 70+ messages in thread
From: Ingo Molnar @ 2009-08-24 11:52 UTC (permalink / raw)
  To: Paul Mundt, Frederic Weisbecker, Josh Stone, linux-kernel,
	Jason Baron, Li Zefan, Steven Rostedt, Peter Zijlstra,
	Mathieu Desnoyers, Jiaying Zhang, Martin Bligh, Lai Jiangshan


* Paul Mundt <lethal@linux-sh.org> wrote:

> On Mon, Aug 24, 2009 at 11:56:52AM +0200, Ingo Molnar wrote:

> > So i'd really like you to back up your claims with facts. Your 
> > mail is basically unsubstantiated FUD right now and i'll just 
> > ignore you if you continue this pattern of unsubstantiated 
> > attacks and unconstructive behavior.
> 
> I could sit here and itemize individual breakages all day long, 
> but what would be the point? [...]

The point would be to prove your so far unsubstantiated (and IMO 
unfair) attacks.

	Ingo

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

* Re: [PATCH v3 2/4] tracing: Make syscall_(un)regfunc arch-specific
  2009-08-24 11:52                     ` Ingo Molnar
@ 2009-08-24 12:14                       ` Peter Zijlstra
  0 siblings, 0 replies; 70+ messages in thread
From: Peter Zijlstra @ 2009-08-24 12:14 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: Paul Mundt, Frederic Weisbecker, Josh Stone, linux-kernel,
	Jason Baron, Li Zefan, Steven Rostedt, Mathieu Desnoyers,
	Jiaying Zhang, Martin Bligh, Lai Jiangshan

On Mon, 2009-08-24 at 13:52 +0200, Ingo Molnar wrote:
> * Paul Mundt <lethal@linux-sh.org> wrote:
> 
> > On Mon, Aug 24, 2009 at 11:56:52AM +0200, Ingo Molnar wrote:
> 
> > > So i'd really like you to back up your claims with facts. Your 
> > > mail is basically unsubstantiated FUD right now and i'll just 
> > > ignore you if you continue this pattern of unsubstantiated 
> > > attacks and unconstructive behavior.
> > 
> > I could sit here and itemize individual breakages all day long, 
> > but what would be the point? [...]
> 
> The point would be to prove your so far unsubstantiated (and IMO 
> unfair) attacks.

Guys, can we get over this already.. really every linux developer runs
x86, except the very few that don't. We all try to ensure we don't
accidentally break things, shit happens, deal with it.

!x86 breaking more often than x86 is a simple consequence of statistics,
if you don't like it, make your hardware sexy and send it to more
devs ;-)

Build breakages aren't a big deal, they get sorted, life moves on. If
they wouldn't get sorted there might be something to complain about, but
afaict that doesn't happen.

Paul, you put a tracing patch into the sh tree, didn't cc the tracing
folks and then found it broke when the tracing tree was added, *gosh*!?

That will happen with pretty much every other subsystem too, that's what
we have subsystem tree's for, I think enough has been arranged to
mitigate this issue in the future - lets go fix some real bugs now? :-)



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

* Re: [PATCH v3 2/4] tracing: Make syscall_(un)regfunc arch-specific
  2009-08-23 21:14         ` [PATCH v3 2/4] tracing: Make syscall_(un)regfunc arch-specific Frederic Weisbecker
  2009-08-24  1:40           ` Paul Mundt
@ 2009-08-24 19:31           ` Josh Stone
  2009-08-24 19:58             ` Frederic Weisbecker
  1 sibling, 1 reply; 70+ messages in thread
From: Josh Stone @ 2009-08-24 19:31 UTC (permalink / raw)
  To: Frederic Weisbecker
  Cc: linux-kernel, Jason Baron, Ingo Molnar, Li Zefan, Steven Rostedt,
	Peter Zijlstra, Mathieu Desnoyers, Jiaying Zhang, Martin Bligh,
	Lai Jiangshan, Paul Mundt

On 08/23/2009 02:14 PM, Frederic Weisbecker wrote:
> I really don't like that.
> See how the s390 and x86 version of the above code are completely
> identical?
> 
> Please put this in kernel/ptrace.c

Yes, I see your point, and I think kernel/ptrace.c is a fine place for
it.  Making it conditional on CONFIG_TRACEPOINTS and
CONFIG_HAVE_FTRACE_SYSCALLS is probably best too, though I think the
latter should now be HAVE_SYSCALL_TRACEPOINTS.

Thanks,

Josh

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

* Re: [PATCH v3 2/4] tracing: Make syscall_(un)regfunc arch-specific
  2009-08-24 19:31           ` Josh Stone
@ 2009-08-24 19:58             ` Frederic Weisbecker
  2009-08-24 20:00               ` Josh Stone
  0 siblings, 1 reply; 70+ messages in thread
From: Frederic Weisbecker @ 2009-08-24 19:58 UTC (permalink / raw)
  To: Josh Stone
  Cc: linux-kernel, Jason Baron, Ingo Molnar, Li Zefan, Steven Rostedt,
	Peter Zijlstra, Mathieu Desnoyers, Jiaying Zhang, Martin Bligh,
	Lai Jiangshan, Paul Mundt

On Mon, Aug 24, 2009 at 12:31:26PM -0700, Josh Stone wrote:
> On 08/23/2009 02:14 PM, Frederic Weisbecker wrote:
> > I really don't like that.
> > See how the s390 and x86 version of the above code are completely
> > identical?
> > 
> > Please put this in kernel/ptrace.c
> 
> Yes, I see your point, and I think kernel/ptrace.c is a fine place for
> it.  Making it conditional on CONFIG_TRACEPOINTS and
> CONFIG_HAVE_FTRACE_SYSCALLS is probably best too, though I think the
> latter should now be HAVE_SYSCALL_TRACEPOINTS.


As you prefer, this new name can be indeed more verbose.

Thanks.

 
> Thanks,
> 
> Josh


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

* Re: [PATCH v3 2/4] tracing: Make syscall_(un)regfunc arch-specific
  2009-08-24 19:58             ` Frederic Weisbecker
@ 2009-08-24 20:00               ` Josh Stone
  2009-08-24 20:12                 ` Frederic Weisbecker
  0 siblings, 1 reply; 70+ messages in thread
From: Josh Stone @ 2009-08-24 20:00 UTC (permalink / raw)
  To: Frederic Weisbecker
  Cc: linux-kernel, Jason Baron, Ingo Molnar, Li Zefan, Steven Rostedt,
	Peter Zijlstra, Mathieu Desnoyers, Jiaying Zhang, Martin Bligh,
	Lai Jiangshan, Paul Mundt

On 08/24/2009 12:58 PM, Frederic Weisbecker wrote:
> On Mon, Aug 24, 2009 at 12:31:26PM -0700, Josh Stone wrote:
>> On 08/23/2009 02:14 PM, Frederic Weisbecker wrote:
>>> I really don't like that.
>>> See how the s390 and x86 version of the above code are completely
>>> identical?
>>>
>>> Please put this in kernel/ptrace.c
>>
>> Yes, I see your point, and I think kernel/ptrace.c is a fine place for
>> it.  Making it conditional on CONFIG_TRACEPOINTS and
>> CONFIG_HAVE_FTRACE_SYSCALLS is probably best too, though I think the
>> latter should now be HAVE_SYSCALL_TRACEPOINTS.
> 
> 
> As you prefer, this new name can be indeed more verbose.

Actually, now I'm second-guessing the need to move these at all.  Since
they only make sense for CONFIG_TRACEPOINTS, can't they stay in
kernel/tracepoint.c and just be conditional on HAVE_SYSCALL_TRACEPOINTS?
 The only real change needed is for the tracepoint declarations to also
be conditional.

Josh


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

* Re: [PATCH v3 2/4] tracing: Make syscall_(un)regfunc arch-specific
  2009-08-24 20:00               ` Josh Stone
@ 2009-08-24 20:12                 ` Frederic Weisbecker
  0 siblings, 0 replies; 70+ messages in thread
From: Frederic Weisbecker @ 2009-08-24 20:12 UTC (permalink / raw)
  To: Josh Stone
  Cc: linux-kernel, Jason Baron, Ingo Molnar, Li Zefan, Steven Rostedt,
	Peter Zijlstra, Mathieu Desnoyers, Jiaying Zhang, Martin Bligh,
	Lai Jiangshan, Paul Mundt

On Mon, Aug 24, 2009 at 01:00:23PM -0700, Josh Stone wrote:
> On 08/24/2009 12:58 PM, Frederic Weisbecker wrote:
> > On Mon, Aug 24, 2009 at 12:31:26PM -0700, Josh Stone wrote:
> >> On 08/23/2009 02:14 PM, Frederic Weisbecker wrote:
> >>> I really don't like that.
> >>> See how the s390 and x86 version of the above code are completely
> >>> identical?
> >>>
> >>> Please put this in kernel/ptrace.c
> >>
> >> Yes, I see your point, and I think kernel/ptrace.c is a fine place for
> >> it.  Making it conditional on CONFIG_TRACEPOINTS and
> >> CONFIG_HAVE_FTRACE_SYSCALLS is probably best too, though I think the
> >> latter should now be HAVE_SYSCALL_TRACEPOINTS.
> > 
> > 
> > As you prefer, this new name can be indeed more verbose.
> 
> Actually, now I'm second-guessing the need to move these at all.  Since
> they only make sense for CONFIG_TRACEPOINTS, can't they stay in
> kernel/tracepoint.c and just be conditional on HAVE_SYSCALL_TRACEPOINTS?
>  The only real change needed is for the tracepoint declarations to also
> be conditional.
> 
> Josh
> 

Both ways make sense to me, although I generally see the role of
kernel/tracepoint.c to only host the general core tracepoints mechanism.

And here these two callbacks are more about specific tracepoints coverage,
somewhat tied to the ptrace background because we are using a ptrace
bridge to reach these tracepoints.

Well, either ways look good:

- tracepoint.c: to solve the lack of a functionnality in very
  specific cases.

- ptrace.c: because it's part of a ptrace mechanism.


I don't feel strongly about that :-)


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

* [PATCH v4 0/4] tracing: tweaks for generic syscall events
  2009-08-22  4:58   ` [PATCH v3 0/4] tracing: tweaks for generic syscall events Josh Stone
  2009-08-22  4:58     ` [PATCH v3 1/4] tracing: Rename TIF_SYSCALL_FTRACE->_TRACEPOINT Josh Stone
@ 2009-08-24 21:43     ` Josh Stone
  2009-08-24 21:43       ` [PATCH v4 1/4] tracing: Rename FTRACE_SYSCALLS for tracepoints Josh Stone
                         ` (2 more replies)
  1 sibling, 3 replies; 70+ messages in thread
From: Josh Stone @ 2009-08-24 21:43 UTC (permalink / raw)
  To: linux-kernel
  Cc: Josh Stone, Jason Baron, Frederic Weisbecker, Ingo Molnar,
	Li Zefan, Steven Rostedt, Peter Zijlstra, Mathieu Desnoyers,
	Jiaying Zhang, Martin Bligh, Lai Jiangshan, Paul Mundt

This patch series moves the callbacks for the syscall tracepoints to the
definition site, and adds generic TRACE_EVENTs which capture all syscall
arguments.

New in v3:
- Give the thread flag a more generic name: TIF_SYSCALL_TRACEPOINT.
- Move the regfuncs to arch-specific files, per Jason's suggestion.
- Change _WITH_CALLBACK to just _FN, per Ingo's suggestion.

New in v4:
- Give the config flag a more generic name: HAVE_SYSCALL_TRACEPOINTS.
- Undo the arch reorg of the regfuncs, but conditionalize on above.


Sample trace output:
        sendmail-974   [000] 55665.464492: sys_enter: NR 14 (1, 7fff60f3af40, 7fff60f3aec0, 8, 0, 7fb1b6a05161)

        sendmail-974   [000] 55665.464496: sys_exit: NR 14 = 0

        sendmail-974   [000] 55665.464507: sys_enter: NR 23 (5, 7fff60f3b0d0, 0, 0, 7fff60f3b150, 7fff60f3ef01)

            sshd-978   [000] 55667.845359: sys_exit: NR 23 = 1

            sshd-978   [000] 55667.845373: sys_enter: NR 14 (0, 7fffc645ce90, 7fffc645cf10, 8, 0, 101010101010101)

            sshd-978   [000] 55667.845381: sys_exit: NR 14 = 0

            sshd-978   [000] 55667.845383: sys_enter: NR 14 (2, 7fffc645cf10, 0, 8, 0, 101010101010101)

            sshd-978   [000] 55667.845386: sys_exit: NR 14 = 0

            sshd-978   [000] 55667.845395: sys_enter: NR 0 (3, 7fffc6458f80, 4000, 1, 0, 0)

            sshd-978   [000] 55667.845478: sys_exit: NR 0 = 48


Signed-off-by: Josh Stone <jistone@redhat.com>
Cc: Jason Baron <jbaron@redhat.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Li Zefan <lizf@cn.fujitsu.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
Cc: Jiaying Zhang <jiayingz@google.com>
Cc: Martin Bligh <mbligh@google.com>
Cc: Lai Jiangshan <laijs@cn.fujitsu.com>
Cc: Paul Mundt <lethal@linux-sh.org>
---
 arch/s390/Kconfig                   |    2 +-
 arch/s390/defconfig                 |    2 +-
 arch/s390/include/asm/thread_info.h |    4 +-
 arch/s390/kernel/entry.S            |    2 +-
 arch/s390/kernel/entry64.S          |    2 +-
 arch/s390/kernel/ptrace.c           |   12 +++---
 arch/x86/Kconfig                    |    2 +-
 arch/x86/configs/i386_defconfig     |    2 +-
 arch/x86/configs/x86_64_defconfig   |    2 +-
 arch/x86/include/asm/thread_info.h  |   13 +++---
 arch/x86/kernel/ptrace.c            |   16 +++----
 include/linux/tracepoint.h          |   46 +++++++++--------------
 include/trace/define_trace.h        |    5 ++
 include/trace/events/syscalls.h     |   70 +++++++++++++++++++++++++++++++++++
 include/trace/ftrace.h              |    9 ++++
 include/trace/syscall.h             |   17 --------
 kernel/trace/Kconfig                |    4 +-
 kernel/trace/trace_syscalls.c       |   17 ++++----
 kernel/tracepoint.c                 |   20 ++++++----


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

* [PATCH v4 1/4] tracing: Rename FTRACE_SYSCALLS for tracepoints
  2009-08-24 21:43     ` [PATCH v4 0/4] tracing: tweaks for generic syscall events Josh Stone
@ 2009-08-24 21:43       ` Josh Stone
  2009-08-24 21:43         ` [PATCH v4 2/4] tracing: Make syscall tracepoints conditional Josh Stone
  2009-08-26  7:21         ` [tip:tracing/core] tracing: Rename FTRACE_SYSCALLS for tracepoints tip-bot for Josh Stone
  2009-08-24 23:05       ` [PATCH v4 0/4] tracing: tweaks for generic syscall events Frederic Weisbecker
  2009-08-25 21:44       ` Frederic Weisbecker
  2 siblings, 2 replies; 70+ messages in thread
From: Josh Stone @ 2009-08-24 21:43 UTC (permalink / raw)
  To: linux-kernel
  Cc: Josh Stone, Jason Baron, Frederic Weisbecker, Ingo Molnar,
	Li Zefan, Steven Rostedt, Peter Zijlstra, Mathieu Desnoyers,
	Jiaying Zhang, Martin Bligh, Lai Jiangshan, Paul Mundt

s/HAVE_FTRACE_SYSCALLS/HAVE_SYSCALL_TRACEPOINTS/g
s/TIF_SYSCALL_FTRACE/TIF_SYSCALL_TRACEPOINT/g

The syscall enter/exit tracing is no longer specific to just ftrace, so
they now have names that reflect their tie to tracepoints instead.

Signed-off-by: Josh Stone <jistone@redhat.com>
Cc: Jason Baron <jbaron@redhat.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Li Zefan <lizf@cn.fujitsu.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
Cc: Jiaying Zhang <jiayingz@google.com>
Cc: Martin Bligh <mbligh@google.com>
Cc: Lai Jiangshan <laijs@cn.fujitsu.com>
Cc: Paul Mundt <lethal@linux-sh.org>
---
 arch/s390/Kconfig                   |    2 +-
 arch/s390/defconfig                 |    2 +-
 arch/s390/include/asm/thread_info.h |    4 ++--
 arch/s390/kernel/entry.S            |    2 +-
 arch/s390/kernel/entry64.S          |    2 +-
 arch/s390/kernel/ptrace.c           |    4 ++--
 arch/x86/Kconfig                    |    2 +-
 arch/x86/configs/i386_defconfig     |    2 +-
 arch/x86/configs/x86_64_defconfig   |    2 +-
 arch/x86/include/asm/thread_info.h  |   13 +++++++------
 arch/x86/kernel/ptrace.c            |    4 ++--
 kernel/trace/Kconfig                |    4 ++--
 kernel/tracepoint.c                 |    4 ++--
 13 files changed, 24 insertions(+), 23 deletions(-)

diff --git a/arch/s390/Kconfig b/arch/s390/Kconfig
index 2ae5d72..7238ef4 100644
--- a/arch/s390/Kconfig
+++ b/arch/s390/Kconfig
@@ -84,7 +84,7 @@ config S390
 	select HAVE_FUNCTION_TRACER
 	select HAVE_FUNCTION_TRACE_MCOUNT_TEST
 	select HAVE_FTRACE_MCOUNT_RECORD
-	select HAVE_FTRACE_SYSCALLS
+	select HAVE_SYSCALL_TRACEPOINTS
 	select HAVE_DYNAMIC_FTRACE
 	select HAVE_FUNCTION_GRAPH_TRACER
 	select HAVE_DEFAULT_NO_SPIN_MUTEXES
diff --git a/arch/s390/defconfig b/arch/s390/defconfig
index fcba206..4e91a25 100644
--- a/arch/s390/defconfig
+++ b/arch/s390/defconfig
@@ -900,7 +900,7 @@ CONFIG_HAVE_FUNCTION_GRAPH_TRACER=y
 CONFIG_HAVE_FUNCTION_TRACE_MCOUNT_TEST=y
 CONFIG_HAVE_DYNAMIC_FTRACE=y
 CONFIG_HAVE_FTRACE_MCOUNT_RECORD=y
-CONFIG_HAVE_FTRACE_SYSCALLS=y
+CONFIG_HAVE_SYSCALL_TRACEPOINTS=y
 CONFIG_TRACING_SUPPORT=y
 CONFIG_FTRACE=y
 # CONFIG_FUNCTION_TRACER is not set
diff --git a/arch/s390/include/asm/thread_info.h b/arch/s390/include/asm/thread_info.h
index ba1cab9..07eb61b 100644
--- a/arch/s390/include/asm/thread_info.h
+++ b/arch/s390/include/asm/thread_info.h
@@ -92,7 +92,7 @@ static inline struct thread_info *current_thread_info(void)
 #define TIF_SYSCALL_TRACE	8	/* syscall trace active */
 #define TIF_SYSCALL_AUDIT	9	/* syscall auditing active */
 #define TIF_SECCOMP		10	/* secure computing */
-#define TIF_SYSCALL_FTRACE	11	/* ftrace syscall instrumentation */
+#define TIF_SYSCALL_TRACEPOINT	11	/* syscall tracepoint instrumentation */
 #define TIF_USEDFPU		16	/* FPU was used by this task this quantum (SMP) */
 #define TIF_POLLING_NRFLAG	17	/* true if poll_idle() is polling 
 					   TIF_NEED_RESCHED */
@@ -111,7 +111,7 @@ static inline struct thread_info *current_thread_info(void)
 #define _TIF_SYSCALL_TRACE	(1<<TIF_SYSCALL_TRACE)
 #define _TIF_SYSCALL_AUDIT	(1<<TIF_SYSCALL_AUDIT)
 #define _TIF_SECCOMP		(1<<TIF_SECCOMP)
-#define _TIF_SYSCALL_FTRACE	(1<<TIF_SYSCALL_FTRACE)
+#define _TIF_SYSCALL_TRACEPOINT	(1<<TIF_SYSCALL_TRACEPOINT)
 #define _TIF_USEDFPU		(1<<TIF_USEDFPU)
 #define _TIF_POLLING_NRFLAG	(1<<TIF_POLLING_NRFLAG)
 #define _TIF_31BIT		(1<<TIF_31BIT)
diff --git a/arch/s390/kernel/entry.S b/arch/s390/kernel/entry.S
index c4c80a2..5d40fce 100644
--- a/arch/s390/kernel/entry.S
+++ b/arch/s390/kernel/entry.S
@@ -54,7 +54,7 @@ _TIF_WORK_SVC = (_TIF_SIGPENDING | _TIF_NOTIFY_RESUME | _TIF_NEED_RESCHED | \
 _TIF_WORK_INT = (_TIF_SIGPENDING | _TIF_NOTIFY_RESUME | _TIF_NEED_RESCHED | \
 		 _TIF_MCCK_PENDING)
 _TIF_SYSCALL = (_TIF_SYSCALL_TRACE>>8 | _TIF_SYSCALL_AUDIT>>8 | \
-		_TIF_SECCOMP>>8 | _TIF_SYSCALL_FTRACE>>8)
+		_TIF_SECCOMP>>8 | _TIF_SYSCALL_TRACEPOINT>>8)
 
 STACK_SHIFT = PAGE_SHIFT + THREAD_ORDER
 STACK_SIZE  = 1 << STACK_SHIFT
diff --git a/arch/s390/kernel/entry64.S b/arch/s390/kernel/entry64.S
index f6618e9..3ceb53c 100644
--- a/arch/s390/kernel/entry64.S
+++ b/arch/s390/kernel/entry64.S
@@ -57,7 +57,7 @@ _TIF_WORK_SVC = (_TIF_SIGPENDING | _TIF_NOTIFY_RESUME | _TIF_NEED_RESCHED | \
 _TIF_WORK_INT = (_TIF_SIGPENDING | _TIF_NOTIFY_RESUME | _TIF_NEED_RESCHED | \
 		 _TIF_MCCK_PENDING)
 _TIF_SYSCALL = (_TIF_SYSCALL_TRACE>>8 | _TIF_SYSCALL_AUDIT>>8 | \
-		_TIF_SECCOMP>>8 | _TIF_SYSCALL_FTRACE>>8)
+		_TIF_SECCOMP>>8 | _TIF_SYSCALL_TRACEPOINT>>8)
 
 #define BASED(name) name-system_call(%r13)
 
diff --git a/arch/s390/kernel/ptrace.c b/arch/s390/kernel/ptrace.c
index c5e87d8..9d3dcfa 100644
--- a/arch/s390/kernel/ptrace.c
+++ b/arch/s390/kernel/ptrace.c
@@ -664,7 +664,7 @@ asmlinkage long do_syscall_trace_enter(struct pt_regs *regs)
 		ret = -1;
 	}
 
-	if (unlikely(test_thread_flag(TIF_SYSCALL_FTRACE)))
+	if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
 		trace_syscall_enter(regs, regs->gprs[2]);
 
 	if (unlikely(current->audit_context))
@@ -682,7 +682,7 @@ asmlinkage void do_syscall_trace_exit(struct pt_regs *regs)
 		audit_syscall_exit(AUDITSC_RESULT(regs->gprs[2]),
 				   regs->gprs[2]);
 
-	if (unlikely(test_thread_flag(TIF_SYSCALL_FTRACE)))
+	if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
 		trace_syscall_exit(regs, regs->gprs[2]);
 
 	if (test_thread_flag(TIF_SYSCALL_TRACE))
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index 738bdc6..d59cbf7 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -37,7 +37,7 @@ config X86
 	select HAVE_FUNCTION_GRAPH_FP_TEST
 	select HAVE_FUNCTION_TRACE_MCOUNT_TEST
 	select HAVE_FTRACE_NMI_ENTER if DYNAMIC_FTRACE
-	select HAVE_FTRACE_SYSCALLS
+	select HAVE_SYSCALL_TRACEPOINTS
 	select HAVE_KVM
 	select HAVE_ARCH_KGDB
 	select HAVE_ARCH_TRACEHOOK
diff --git a/arch/x86/configs/i386_defconfig b/arch/x86/configs/i386_defconfig
index edb992e..d28fad1 100644
--- a/arch/x86/configs/i386_defconfig
+++ b/arch/x86/configs/i386_defconfig
@@ -2355,7 +2355,7 @@ CONFIG_HAVE_FUNCTION_TRACE_MCOUNT_TEST=y
 CONFIG_HAVE_DYNAMIC_FTRACE=y
 CONFIG_HAVE_FTRACE_MCOUNT_RECORD=y
 CONFIG_HAVE_HW_BRANCH_TRACER=y
-CONFIG_HAVE_FTRACE_SYSCALLS=y
+CONFIG_HAVE_SYSCALL_TRACEPOINTS=y
 CONFIG_RING_BUFFER=y
 CONFIG_TRACING=y
 CONFIG_TRACING_SUPPORT=y
diff --git a/arch/x86/configs/x86_64_defconfig b/arch/x86/configs/x86_64_defconfig
index cee1dd2..6c86acd 100644
--- a/arch/x86/configs/x86_64_defconfig
+++ b/arch/x86/configs/x86_64_defconfig
@@ -2329,7 +2329,7 @@ CONFIG_HAVE_FUNCTION_TRACE_MCOUNT_TEST=y
 CONFIG_HAVE_DYNAMIC_FTRACE=y
 CONFIG_HAVE_FTRACE_MCOUNT_RECORD=y
 CONFIG_HAVE_HW_BRANCH_TRACER=y
-CONFIG_HAVE_FTRACE_SYSCALLS=y
+CONFIG_HAVE_SYSCALL_TRACEPOINTS=y
 CONFIG_RING_BUFFER=y
 CONFIG_TRACING=y
 CONFIG_TRACING_SUPPORT=y
diff --git a/arch/x86/include/asm/thread_info.h b/arch/x86/include/asm/thread_info.h
index fad7d40..6f7786a 100644
--- a/arch/x86/include/asm/thread_info.h
+++ b/arch/x86/include/asm/thread_info.h
@@ -95,7 +95,7 @@ struct thread_info {
 #define TIF_DEBUGCTLMSR		25	/* uses thread_struct.debugctlmsr */
 #define TIF_DS_AREA_MSR		26      /* uses thread_struct.ds_area_msr */
 #define TIF_LAZY_MMU_UPDATES	27	/* task is updating the mmu lazily */
-#define TIF_SYSCALL_FTRACE	28	/* for ftrace syscall instrumentation */
+#define TIF_SYSCALL_TRACEPOINT	28	/* syscall tracepoint instrumentation */
 
 #define _TIF_SYSCALL_TRACE	(1 << TIF_SYSCALL_TRACE)
 #define _TIF_NOTIFY_RESUME	(1 << TIF_NOTIFY_RESUME)
@@ -118,17 +118,17 @@ struct thread_info {
 #define _TIF_DEBUGCTLMSR	(1 << TIF_DEBUGCTLMSR)
 #define _TIF_DS_AREA_MSR	(1 << TIF_DS_AREA_MSR)
 #define _TIF_LAZY_MMU_UPDATES	(1 << TIF_LAZY_MMU_UPDATES)
-#define _TIF_SYSCALL_FTRACE	(1 << TIF_SYSCALL_FTRACE)
+#define _TIF_SYSCALL_TRACEPOINT	(1 << TIF_SYSCALL_TRACEPOINT)
 
 /* work to do in syscall_trace_enter() */
 #define _TIF_WORK_SYSCALL_ENTRY	\
-	(_TIF_SYSCALL_TRACE | _TIF_SYSCALL_EMU | _TIF_SYSCALL_FTRACE |	\
-	 _TIF_SYSCALL_AUDIT | _TIF_SECCOMP | _TIF_SINGLESTEP)
+	(_TIF_SYSCALL_TRACE | _TIF_SYSCALL_EMU | _TIF_SYSCALL_AUDIT |	\
+	 _TIF_SECCOMP | _TIF_SINGLESTEP | _TIF_SYSCALL_TRACEPOINT)
 
 /* work to do in syscall_trace_leave() */
 #define _TIF_WORK_SYSCALL_EXIT	\
 	(_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | _TIF_SINGLESTEP |	\
-	 _TIF_SYSCALL_FTRACE)
+	 _TIF_SYSCALL_TRACEPOINT)
 
 /* work to do on interrupt/exception return */
 #define _TIF_WORK_MASK							\
@@ -137,7 +137,8 @@ struct thread_info {
 	   _TIF_SINGLESTEP|_TIF_SECCOMP|_TIF_SYSCALL_EMU))
 
 /* work to do on any return to user space */
-#define _TIF_ALLWORK_MASK ((0x0000FFFF & ~_TIF_SECCOMP) | _TIF_SYSCALL_FTRACE)
+#define _TIF_ALLWORK_MASK						\
+	((0x0000FFFF & ~_TIF_SECCOMP) | _TIF_SYSCALL_TRACEPOINT)
 
 /* Only used for 64 bit */
 #define _TIF_DO_NOTIFY_MASK						\
diff --git a/arch/x86/kernel/ptrace.c b/arch/x86/kernel/ptrace.c
index 34dd6f1..a909afe 100644
--- a/arch/x86/kernel/ptrace.c
+++ b/arch/x86/kernel/ptrace.c
@@ -1500,7 +1500,7 @@ asmregparm long syscall_trace_enter(struct pt_regs *regs)
 	    tracehook_report_syscall_entry(regs))
 		ret = -1L;
 
-	if (unlikely(test_thread_flag(TIF_SYSCALL_FTRACE)))
+	if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
 		trace_syscall_enter(regs, regs->orig_ax);
 
 	if (unlikely(current->audit_context)) {
@@ -1526,7 +1526,7 @@ asmregparm void syscall_trace_leave(struct pt_regs *regs)
 	if (unlikely(current->audit_context))
 		audit_syscall_exit(AUDITSC_RESULT(regs->ax), regs->ax);
 
-	if (unlikely(test_thread_flag(TIF_SYSCALL_FTRACE)))
+	if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
 		trace_syscall_exit(regs, regs->ax);
 
 	if (test_thread_flag(TIF_SYSCALL_TRACE))
diff --git a/kernel/trace/Kconfig b/kernel/trace/Kconfig
index 019f380..06be85a 100644
--- a/kernel/trace/Kconfig
+++ b/kernel/trace/Kconfig
@@ -41,7 +41,7 @@ config HAVE_FTRACE_MCOUNT_RECORD
 config HAVE_HW_BRANCH_TRACER
 	bool
 
-config HAVE_FTRACE_SYSCALLS
+config HAVE_SYSCALL_TRACEPOINTS
 	bool
 
 config TRACER_MAX_TRACE
@@ -211,7 +211,7 @@ config ENABLE_DEFAULT_TRACERS
 
 config FTRACE_SYSCALLS
 	bool "Trace syscalls"
-	depends on HAVE_FTRACE_SYSCALLS
+	depends on HAVE_SYSCALL_TRACEPOINTS
 	select GENERIC_TRACER
 	select KALLSYMS
 	help
diff --git a/kernel/tracepoint.c b/kernel/tracepoint.c
index 35dd27a..43bca1f 100644
--- a/kernel/tracepoint.c
+++ b/kernel/tracepoint.c
@@ -593,7 +593,7 @@ void syscall_regfunc(void)
 	if (!sys_tracepoint_refcount) {
 		read_lock_irqsave(&tasklist_lock, flags);
 		do_each_thread(g, t) {
-			set_tsk_thread_flag(t, TIF_SYSCALL_FTRACE);
+			set_tsk_thread_flag(t, TIF_SYSCALL_TRACEPOINT);
 		} while_each_thread(g, t);
 		read_unlock_irqrestore(&tasklist_lock, flags);
 	}
@@ -611,7 +611,7 @@ void syscall_unregfunc(void)
 	if (!sys_tracepoint_refcount) {
 		read_lock_irqsave(&tasklist_lock, flags);
 		do_each_thread(g, t) {
-			clear_tsk_thread_flag(t, TIF_SYSCALL_FTRACE);
+			clear_tsk_thread_flag(t, TIF_SYSCALL_TRACEPOINT);
 		} while_each_thread(g, t);
 		read_unlock_irqrestore(&tasklist_lock, flags);
 	}
-- 
1.6.2.5


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

* [PATCH v4 2/4] tracing: Make syscall tracepoints conditional
  2009-08-24 21:43       ` [PATCH v4 1/4] tracing: Rename FTRACE_SYSCALLS for tracepoints Josh Stone
@ 2009-08-24 21:43         ` Josh Stone
  2009-08-24 21:43           ` [PATCH v4 3/4] tracing: Move tracepoint callbacks into DEFINE Josh Stone
  2009-08-26  7:21           ` [tip:tracing/core] tracing: Make syscall tracepoints conditional tip-bot for Josh Stone
  2009-08-26  7:21         ` [tip:tracing/core] tracing: Rename FTRACE_SYSCALLS for tracepoints tip-bot for Josh Stone
  1 sibling, 2 replies; 70+ messages in thread
From: Josh Stone @ 2009-08-24 21:43 UTC (permalink / raw)
  To: linux-kernel
  Cc: Josh Stone, Jason Baron, Frederic Weisbecker, Ingo Molnar,
	Li Zefan, Steven Rostedt, Peter Zijlstra, Mathieu Desnoyers,
	Jiaying Zhang, Martin Bligh, Lai Jiangshan

The syscall enter/exit tracepoints are only supported on archs that
HAVE_SYSCALL_TRACEPOINTS, so the declarations should be #ifdef'ed.
Also, the definition of syscall_regfunc and syscall_unregfunc need the
should use this same flag, rather than the ftrace-specific one.

Signed-off-by: Josh Stone <jistone@redhat.com>
Cc: Jason Baron <jbaron@redhat.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Li Zefan <lizf@cn.fujitsu.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
Cc: Jiaying Zhang <jiayingz@google.com>
Cc: Martin Bligh <mbligh@google.com>
Cc: Lai Jiangshan <laijs@cn.fujitsu.com>
---
 include/trace/syscall.h |    4 ++++
 kernel/tracepoint.c     |    2 +-
 2 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/include/trace/syscall.h b/include/trace/syscall.h
index 9661dd4..5dcb7e3 100644
--- a/include/trace/syscall.h
+++ b/include/trace/syscall.h
@@ -8,6 +8,8 @@
 #include <asm/ptrace.h>
 
 
+#ifdef CONFIG_HAVE_SYSCALL_TRACEPOINTS
+
 extern void syscall_regfunc(void);
 extern void syscall_unregfunc(void);
 
@@ -25,6 +27,8 @@ DECLARE_TRACE_WITH_CALLBACK(syscall_exit,
 	syscall_unregfunc
 );
 
+#endif
+
 /*
  * A syscall entry in the ftrace syscalls array.
  *
diff --git a/kernel/tracepoint.c b/kernel/tracepoint.c
index 43bca1f..6c2e12c 100644
--- a/kernel/tracepoint.c
+++ b/kernel/tracepoint.c
@@ -579,7 +579,7 @@ __initcall(init_tracepoints);
 
 #endif /* CONFIG_MODULES */
 
-#ifdef CONFIG_FTRACE_SYSCALLS
+#ifdef CONFIG_HAVE_SYSCALL_TRACEPOINTS
 
 static DEFINE_MUTEX(regfunc_mutex);
 static int sys_tracepoint_refcount;
-- 
1.6.2.5


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

* [PATCH v4 3/4] tracing: Move tracepoint callbacks into DEFINE
  2009-08-24 21:43         ` [PATCH v4 2/4] tracing: Make syscall tracepoints conditional Josh Stone
@ 2009-08-24 21:43           ` Josh Stone
  2009-08-24 21:43             ` [PATCH v4 4/4] tracing: Create generic syscall TRACE_EVENTs Josh Stone
  2009-08-26  7:22             ` [tip:tracing/core] tracing: Move tracepoint callbacks from declaration to definition tip-bot for Josh Stone
  2009-08-26  7:21           ` [tip:tracing/core] tracing: Make syscall tracepoints conditional tip-bot for Josh Stone
  1 sibling, 2 replies; 70+ messages in thread
From: Josh Stone @ 2009-08-24 21:43 UTC (permalink / raw)
  To: linux-kernel
  Cc: Josh Stone, Jason Baron, Frederic Weisbecker, Ingo Molnar,
	Li Zefan, Steven Rostedt, Peter Zijlstra, Mathieu Desnoyers,
	Jiaying Zhang, Martin Bligh, Lai Jiangshan, Paul Mundt

It's not strictly correct for the tracepoint reg/unreg callbacks to
occur when a client is hooking up, because the actual tracepoint may not
be present yet.  This happens to be fine for syscall, since that's in
the core kernel, but it would cause problems for tracepoints defined in
a module that hasn't been loaded yet.  It also means the reg/unreg has
to be EXPORTed for any modules to use the tracepoint (as in SystemTap).

This patch removes DECLARE_TRACE_WITH_CALLBACK, and instead introduces
DEFINE_TRACE_FN which stores the callbacks in struct tracepoint.  The
callbacks are used now when the active state of the tracepoint changes
in set_tracepoint & disable_tracepoint.

This also introduces TRACE_EVENT_FN, so those events can also provide
callbacks if needed.

Signed-off-by: Josh Stone <jistone@redhat.com>
Cc: Jason Baron <jbaron@redhat.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Li Zefan <lizf@cn.fujitsu.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
Cc: Jiaying Zhang <jiayingz@google.com>
Cc: Martin Bligh <mbligh@google.com>
Cc: Lai Jiangshan <laijs@cn.fujitsu.com>
Cc: Paul Mundt <lethal@linux-sh.org>
---
 arch/s390/kernel/ptrace.c    |    4 +-
 arch/x86/kernel/ptrace.c     |    4 +-
 include/linux/tracepoint.h   |   46 ++++++++++++++++-------------------------
 include/trace/define_trace.h |    5 ++++
 include/trace/ftrace.h       |    9 ++++++++
 include/trace/syscall.h      |   12 +++-------
 kernel/tracepoint.c          |   14 ++++++++----
 7 files changed, 49 insertions(+), 45 deletions(-)

diff --git a/arch/s390/kernel/ptrace.c b/arch/s390/kernel/ptrace.c
index 9d3dcfa..c05b44b 100644
--- a/arch/s390/kernel/ptrace.c
+++ b/arch/s390/kernel/ptrace.c
@@ -51,8 +51,8 @@
 #include "compat_ptrace.h"
 #endif
 
-DEFINE_TRACE(syscall_enter);
-DEFINE_TRACE(syscall_exit);
+DEFINE_TRACE_FN(syscall_enter, syscall_regfunc, syscall_unregfunc);
+DEFINE_TRACE_FN(syscall_exit, syscall_regfunc, syscall_unregfunc);
 
 enum s390_regset {
 	REGSET_GENERAL,
diff --git a/arch/x86/kernel/ptrace.c b/arch/x86/kernel/ptrace.c
index a909afe..31e9b97 100644
--- a/arch/x86/kernel/ptrace.c
+++ b/arch/x86/kernel/ptrace.c
@@ -37,8 +37,8 @@
 
 #include <trace/syscall.h>
 
-DEFINE_TRACE(syscall_enter);
-DEFINE_TRACE(syscall_exit);
+DEFINE_TRACE_FN(syscall_enter, syscall_regfunc, syscall_unregfunc);
+DEFINE_TRACE_FN(syscall_exit, syscall_regfunc, syscall_unregfunc);
 
 #include "tls.h"
 
diff --git a/include/linux/tracepoint.h b/include/linux/tracepoint.h
index 5984ed0..846a4ae 100644
--- a/include/linux/tracepoint.h
+++ b/include/linux/tracepoint.h
@@ -23,6 +23,8 @@ struct tracepoint;
 struct tracepoint {
 	const char *name;		/* Tracepoint name */
 	int state;			/* State. */
+	void (*regfunc)(void);
+	void (*unregfunc)(void);
 	void **funcs;
 } __attribute__((aligned(32)));		/*
 					 * Aligned on 32 bytes because it is
@@ -60,10 +62,8 @@ struct tracepoint {
  * Make sure the alignment of the structure in the __tracepoints section will
  * not add unwanted padding between the beginning of the section and the
  * structure. Force alignment to the same alignment as the section start.
- * An optional set of (un)registration functions can be passed to perform any
- * additional (un)registration work.
  */
-#define DECLARE_TRACE_WITH_CALLBACK(name, proto, args, reg, unreg)	\
+#define DECLARE_TRACE(name, proto, args)				\
 	extern struct tracepoint __tracepoint_##name;			\
 	static inline void trace_##name(proto)				\
 	{								\
@@ -73,36 +73,23 @@ struct tracepoint {
 	}								\
 	static inline int register_trace_##name(void (*probe)(proto))	\
 	{								\
-		int ret;						\
-		void (*func)(void) = reg;				\
-									\
-		ret = tracepoint_probe_register(#name, (void *)probe);	\
-		if (func && !ret)					\
-			func();						\
-		return ret;						\
+		return tracepoint_probe_register(#name, (void *)probe);	\
 	}								\
 	static inline int unregister_trace_##name(void (*probe)(proto))	\
 	{								\
-		int ret;						\
-		void (*func)(void) = unreg;				\
-									\
-		ret = tracepoint_probe_unregister(#name, (void *)probe);\
-		if (func && !ret)					\
-			func();						\
-		return ret;						\
+		return tracepoint_probe_unregister(#name, (void *)probe);\
 	}
 
 
-#define DECLARE_TRACE(name, proto, args)				 \
-	DECLARE_TRACE_WITH_CALLBACK(name, TP_PROTO(proto), TP_ARGS(args),\
-					NULL, NULL);
-
-#define DEFINE_TRACE(name)						\
+#define DEFINE_TRACE_FN(name, reg, unreg)				\
 	static const char __tpstrtab_##name[]				\
 	__attribute__((section("__tracepoints_strings"))) = #name;	\
 	struct tracepoint __tracepoint_##name				\
 	__attribute__((section("__tracepoints"), aligned(32))) =	\
-		{ __tpstrtab_##name, 0, NULL }
+		{ __tpstrtab_##name, 0, reg, unreg, NULL }
+
+#define DEFINE_TRACE(name)						\
+	DEFINE_TRACE_FN(name, NULL, NULL);
 
 #define EXPORT_TRACEPOINT_SYMBOL_GPL(name)				\
 	EXPORT_SYMBOL_GPL(__tracepoint_##name)
@@ -113,7 +100,7 @@ extern void tracepoint_update_probe_range(struct tracepoint *begin,
 	struct tracepoint *end);
 
 #else /* !CONFIG_TRACEPOINTS */
-#define DECLARE_TRACE_WITH_CALLBACK(name, proto, args, reg, unreg)	\
+#define DECLARE_TRACE(name, proto, args)				\
 	static inline void _do_trace_##name(struct tracepoint *tp, proto) \
 	{ }								\
 	static inline void trace_##name(proto)				\
@@ -127,10 +114,7 @@ extern void tracepoint_update_probe_range(struct tracepoint *begin,
 		return -ENOSYS;						\
 	}
 
-#define DECLARE_TRACE(name, proto, args)				 \
-	DECLARE_TRACE_WITH_CALLBACK(name, TP_PROTO(proto), TP_ARGS(args),\
-					NULL, NULL);
-
+#define DEFINE_TRACE_FN(name, reg, unreg)
 #define DEFINE_TRACE(name)
 #define EXPORT_TRACEPOINT_SYMBOL_GPL(name)
 #define EXPORT_TRACEPOINT_SYMBOL(name)
@@ -282,10 +266,16 @@ static inline void tracepoint_synchronize_unregister(void)
  * can also by used by generic instrumentation like SystemTap), and
  * it is also used to expose a structured trace record in
  * /sys/kernel/debug/tracing/events/.
+ *
+ * A set of (un)registration functions can be passed to the variant
+ * TRACE_EVENT_FN to perform any (un)registration work.
  */
 
 #define TRACE_EVENT(name, proto, args, struct, assign, print)	\
 	DECLARE_TRACE(name, PARAMS(proto), PARAMS(args))
+#define TRACE_EVENT_FN(name, proto, args, struct,		\
+		assign, print, reg, unreg)			\
+	DECLARE_TRACE(name, PARAMS(proto), PARAMS(args))
 #endif
 
 #endif
diff --git a/include/trace/define_trace.h b/include/trace/define_trace.h
index f7a7ae1..2a96985 100644
--- a/include/trace/define_trace.h
+++ b/include/trace/define_trace.h
@@ -26,6 +26,11 @@
 #define TRACE_EVENT(name, proto, args, tstruct, assign, print)	\
 	DEFINE_TRACE(name)
 
+#undef TRACE_EVENT_FN
+#define TRACE_EVENT_FN(name, proto, args, tstruct,		\
+		assign, print, reg, unreg)			\
+	DEFINE_TRACE_FN(name, reg, unreg)
+
 #undef DECLARE_TRACE
 #define DECLARE_TRACE(name, proto, args)	\
 	DEFINE_TRACE(name)
diff --git a/include/trace/ftrace.h b/include/trace/ftrace.h
index 1274002..3a0b44b 100644
--- a/include/trace/ftrace.h
+++ b/include/trace/ftrace.h
@@ -42,6 +42,15 @@
 	};							\
 	static struct ftrace_event_call event_##name
 
+/* Callbacks are meaningless to ftrace. */
+#undef TRACE_EVENT_FN
+#define TRACE_EVENT_FN(name, proto, args, tstruct,		\
+		assign, print, reg, unreg)			\
+	TRACE_EVENT(name, TP_PROTO(proto), TP_ARGS(args),	\
+		TP_STRUCT__entry(tstruct),			\
+		TP_fast_assign(assign),				\
+		TP_printk(print))
+
 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
 
 
diff --git a/include/trace/syscall.h b/include/trace/syscall.h
index 5dcb7e3..4e19430 100644
--- a/include/trace/syscall.h
+++ b/include/trace/syscall.h
@@ -13,18 +13,14 @@
 extern void syscall_regfunc(void);
 extern void syscall_unregfunc(void);
 
-DECLARE_TRACE_WITH_CALLBACK(syscall_enter,
+DECLARE_TRACE(syscall_enter,
 	TP_PROTO(struct pt_regs *regs, long id),
-	TP_ARGS(regs, id),
-	syscall_regfunc,
-	syscall_unregfunc
+	TP_ARGS(regs, id)
 );
 
-DECLARE_TRACE_WITH_CALLBACK(syscall_exit,
+DECLARE_TRACE(syscall_exit,
 	TP_PROTO(struct pt_regs *regs, long ret),
-	TP_ARGS(regs, ret),
-	syscall_regfunc,
-	syscall_unregfunc
+	TP_ARGS(regs, ret)
 );
 
 #endif
diff --git a/kernel/tracepoint.c b/kernel/tracepoint.c
index 6c2e12c..8ec0e26 100644
--- a/kernel/tracepoint.c
+++ b/kernel/tracepoint.c
@@ -243,6 +243,11 @@ static void set_tracepoint(struct tracepoint_entry **entry,
 {
 	WARN_ON(strcmp((*entry)->name, elem->name) != 0);
 
+	if (elem->regfunc && !elem->state && active)
+		elem->regfunc();
+	else if (elem->unregfunc && elem->state && !active)
+		elem->unregfunc();
+
 	/*
 	 * rcu_assign_pointer has a smp_wmb() which makes sure that the new
 	 * probe callbacks array is consistent before setting a pointer to it.
@@ -262,6 +267,9 @@ static void set_tracepoint(struct tracepoint_entry **entry,
  */
 static void disable_tracepoint(struct tracepoint *elem)
 {
+	if (elem->unregfunc && elem->state)
+		elem->unregfunc();
+
 	elem->state = 0;
 	rcu_assign_pointer(elem->funcs, NULL);
 }
@@ -581,7 +589,7 @@ __initcall(init_tracepoints);
 
 #ifdef CONFIG_HAVE_SYSCALL_TRACEPOINTS
 
-static DEFINE_MUTEX(regfunc_mutex);
+/* NB: reg/unreg are called while guarded with the tracepoints_mutex */
 static int sys_tracepoint_refcount;
 
 void syscall_regfunc(void)
@@ -589,7 +597,6 @@ void syscall_regfunc(void)
 	unsigned long flags;
 	struct task_struct *g, *t;
 
-	mutex_lock(&regfunc_mutex);
 	if (!sys_tracepoint_refcount) {
 		read_lock_irqsave(&tasklist_lock, flags);
 		do_each_thread(g, t) {
@@ -598,7 +605,6 @@ void syscall_regfunc(void)
 		read_unlock_irqrestore(&tasklist_lock, flags);
 	}
 	sys_tracepoint_refcount++;
-	mutex_unlock(&regfunc_mutex);
 }
 
 void syscall_unregfunc(void)
@@ -606,7 +612,6 @@ void syscall_unregfunc(void)
 	unsigned long flags;
 	struct task_struct *g, *t;
 
-	mutex_lock(&regfunc_mutex);
 	sys_tracepoint_refcount--;
 	if (!sys_tracepoint_refcount) {
 		read_lock_irqsave(&tasklist_lock, flags);
@@ -615,6 +620,5 @@ void syscall_unregfunc(void)
 		} while_each_thread(g, t);
 		read_unlock_irqrestore(&tasklist_lock, flags);
 	}
-	mutex_unlock(&regfunc_mutex);
 }
 #endif
-- 
1.6.2.5


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

* [PATCH v4 4/4] tracing: Create generic syscall TRACE_EVENTs
  2009-08-24 21:43           ` [PATCH v4 3/4] tracing: Move tracepoint callbacks into DEFINE Josh Stone
@ 2009-08-24 21:43             ` Josh Stone
  2009-08-26  7:22               ` [tip:tracing/core] " tip-bot for Josh Stone
  2009-08-26  7:22             ` [tip:tracing/core] tracing: Move tracepoint callbacks from declaration to definition tip-bot for Josh Stone
  1 sibling, 1 reply; 70+ messages in thread
From: Josh Stone @ 2009-08-24 21:43 UTC (permalink / raw)
  To: linux-kernel
  Cc: Josh Stone, Jason Baron, Frederic Weisbecker, Ingo Molnar,
	Li Zefan, Steven Rostedt, Peter Zijlstra, Mathieu Desnoyers,
	Jiaying Zhang, Martin Bligh, Lai Jiangshan, Paul Mundt

This converts the syscall_enter/exit tracepoints into TRACE_EVENTs, so
you can have generic ftrace events that capture all system calls with
arguments and return values.  These generic events are also renamed to
sys_enter/exit, so they're more closely aligned to the specific
sys_enter_foo events.

Signed-off-by: Josh Stone <jistone@redhat.com>
Cc: Jason Baron <jbaron@redhat.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Li Zefan <lizf@cn.fujitsu.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
Cc: Jiaying Zhang <jiayingz@google.com>
Cc: Martin Bligh <mbligh@google.com>
Cc: Lai Jiangshan <laijs@cn.fujitsu.com>
Cc: Paul Mundt <lethal@linux-sh.org>
---
 arch/s390/kernel/ptrace.c       |    8 ++--
 arch/x86/kernel/ptrace.c        |   12 +++----
 include/trace/events/syscalls.h |   70 +++++++++++++++++++++++++++++++++++++++
 include/trace/syscall.h         |   17 ---------
 kernel/trace/trace_syscalls.c   |   17 +++++----
 5 files changed, 88 insertions(+), 36 deletions(-)
 create mode 100644 include/trace/events/syscalls.h

diff --git a/arch/s390/kernel/ptrace.c b/arch/s390/kernel/ptrace.c
index c05b44b..f3ddd7a 100644
--- a/arch/s390/kernel/ptrace.c
+++ b/arch/s390/kernel/ptrace.c
@@ -51,8 +51,8 @@
 #include "compat_ptrace.h"
 #endif
 
-DEFINE_TRACE_FN(syscall_enter, syscall_regfunc, syscall_unregfunc);
-DEFINE_TRACE_FN(syscall_exit, syscall_regfunc, syscall_unregfunc);
+#define CREATE_TRACE_POINTS
+#include <trace/events/syscalls.h>
 
 enum s390_regset {
 	REGSET_GENERAL,
@@ -665,7 +665,7 @@ asmlinkage long do_syscall_trace_enter(struct pt_regs *regs)
 	}
 
 	if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
-		trace_syscall_enter(regs, regs->gprs[2]);
+		trace_sys_enter(regs, regs->gprs[2]);
 
 	if (unlikely(current->audit_context))
 		audit_syscall_entry(is_compat_task() ?
@@ -683,7 +683,7 @@ asmlinkage void do_syscall_trace_exit(struct pt_regs *regs)
 				   regs->gprs[2]);
 
 	if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
-		trace_syscall_exit(regs, regs->gprs[2]);
+		trace_sys_exit(regs, regs->gprs[2]);
 
 	if (test_thread_flag(TIF_SYSCALL_TRACE))
 		tracehook_report_syscall_exit(regs, 0);
diff --git a/arch/x86/kernel/ptrace.c b/arch/x86/kernel/ptrace.c
index 31e9b97..8d7d5c9 100644
--- a/arch/x86/kernel/ptrace.c
+++ b/arch/x86/kernel/ptrace.c
@@ -35,13 +35,11 @@
 #include <asm/proto.h>
 #include <asm/ds.h>
 
-#include <trace/syscall.h>
-
-DEFINE_TRACE_FN(syscall_enter, syscall_regfunc, syscall_unregfunc);
-DEFINE_TRACE_FN(syscall_exit, syscall_regfunc, syscall_unregfunc);
-
 #include "tls.h"
 
+#define CREATE_TRACE_POINTS
+#include <trace/events/syscalls.h>
+
 enum x86_regset {
 	REGSET_GENERAL,
 	REGSET_FP,
@@ -1501,7 +1499,7 @@ asmregparm long syscall_trace_enter(struct pt_regs *regs)
 		ret = -1L;
 
 	if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
-		trace_syscall_enter(regs, regs->orig_ax);
+		trace_sys_enter(regs, regs->orig_ax);
 
 	if (unlikely(current->audit_context)) {
 		if (IS_IA32)
@@ -1527,7 +1525,7 @@ asmregparm void syscall_trace_leave(struct pt_regs *regs)
 		audit_syscall_exit(AUDITSC_RESULT(regs->ax), regs->ax);
 
 	if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
-		trace_syscall_exit(regs, regs->ax);
+		trace_sys_exit(regs, regs->ax);
 
 	if (test_thread_flag(TIF_SYSCALL_TRACE))
 		tracehook_report_syscall_exit(regs, 0);
diff --git a/include/trace/events/syscalls.h b/include/trace/events/syscalls.h
new file mode 100644
index 0000000..397dff2
--- /dev/null
+++ b/include/trace/events/syscalls.h
@@ -0,0 +1,70 @@
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM syscalls
+
+#if !defined(_TRACE_EVENTS_SYSCALLS_H) || defined(TRACE_HEADER_MULTI_READ)
+#define _TRACE_EVENTS_SYSCALLS_H
+
+#include <linux/tracepoint.h>
+
+#include <asm/ptrace.h>
+#include <asm/syscall.h>
+
+
+#ifdef CONFIG_HAVE_SYSCALL_TRACEPOINTS
+
+extern void syscall_regfunc(void);
+extern void syscall_unregfunc(void);
+
+TRACE_EVENT_FN(sys_enter,
+
+	TP_PROTO(struct pt_regs *regs, long id),
+
+	TP_ARGS(regs, id),
+
+	TP_STRUCT__entry(
+		__field(	long,		id		)
+		__array(	unsigned long,	args,	6	)
+	),
+
+	TP_fast_assign(
+		__entry->id	= id;
+		syscall_get_arguments(current, regs, 0, 6, __entry->args);
+	),
+
+	TP_printk("NR %ld (%lx, %lx, %lx, %lx, %lx, %lx)",
+		  __entry->id,
+		  __entry->args[0], __entry->args[1], __entry->args[2],
+		  __entry->args[3], __entry->args[4], __entry->args[5]),
+
+	syscall_regfunc, syscall_unregfunc
+);
+
+TRACE_EVENT_FN(sys_exit,
+
+	TP_PROTO(struct pt_regs *regs, long ret),
+
+	TP_ARGS(regs, ret),
+
+	TP_STRUCT__entry(
+		__field(	long,	id	)
+		__field(	long,	ret	)
+	),
+
+	TP_fast_assign(
+		__entry->id	= syscall_get_nr(current, regs);
+		__entry->ret	= ret;
+	),
+
+	TP_printk("NR %ld = %ld",
+		  __entry->id, __entry->ret),
+
+	syscall_regfunc, syscall_unregfunc
+);
+
+#endif /* CONFIG_HAVE_SYSCALL_TRACEPOINTS */
+
+#endif /* _TRACE_EVENTS_SYSCALLS_H */
+
+/* This part must be outside protection */
+#include <trace/define_trace.h>
+
diff --git a/include/trace/syscall.h b/include/trace/syscall.h
index 4e19430..5dc283b 100644
--- a/include/trace/syscall.h
+++ b/include/trace/syscall.h
@@ -8,23 +8,6 @@
 #include <asm/ptrace.h>
 
 
-#ifdef CONFIG_HAVE_SYSCALL_TRACEPOINTS
-
-extern void syscall_regfunc(void);
-extern void syscall_unregfunc(void);
-
-DECLARE_TRACE(syscall_enter,
-	TP_PROTO(struct pt_regs *regs, long id),
-	TP_ARGS(regs, id)
-);
-
-DECLARE_TRACE(syscall_exit,
-	TP_PROTO(struct pt_regs *regs, long ret),
-	TP_ARGS(regs, ret)
-);
-
-#endif
-
 /*
  * A syscall entry in the ftrace syscalls array.
  *
diff --git a/kernel/trace/trace_syscalls.c b/kernel/trace/trace_syscalls.c
index 46c1b97..2698fe4 100644
--- a/kernel/trace/trace_syscalls.c
+++ b/kernel/trace/trace_syscalls.c
@@ -1,4 +1,5 @@
 #include <trace/syscall.h>
+#include <trace/events/syscalls.h>
 #include <linux/kernel.h>
 #include <linux/ftrace.h>
 #include <linux/perf_counter.h>
@@ -286,7 +287,7 @@ int reg_event_syscall_enter(void *ptr)
 		return -ENOSYS;
 	mutex_lock(&syscall_trace_lock);
 	if (!sys_refcount_enter)
-		ret = register_trace_syscall_enter(ftrace_syscall_enter);
+		ret = register_trace_sys_enter(ftrace_syscall_enter);
 	if (ret) {
 		pr_info("event trace: Could not activate"
 				"syscall entry trace point");
@@ -311,7 +312,7 @@ void unreg_event_syscall_enter(void *ptr)
 	sys_refcount_enter--;
 	clear_bit(num, enabled_enter_syscalls);
 	if (!sys_refcount_enter)
-		unregister_trace_syscall_enter(ftrace_syscall_enter);
+		unregister_trace_sys_enter(ftrace_syscall_enter);
 	mutex_unlock(&syscall_trace_lock);
 }
 
@@ -327,7 +328,7 @@ int reg_event_syscall_exit(void *ptr)
 		return -ENOSYS;
 	mutex_lock(&syscall_trace_lock);
 	if (!sys_refcount_exit)
-		ret = register_trace_syscall_exit(ftrace_syscall_exit);
+		ret = register_trace_sys_exit(ftrace_syscall_exit);
 	if (ret) {
 		pr_info("event trace: Could not activate"
 				"syscall exit trace point");
@@ -352,7 +353,7 @@ void unreg_event_syscall_exit(void *ptr)
 	sys_refcount_exit--;
 	clear_bit(num, enabled_exit_syscalls);
 	if (!sys_refcount_exit)
-		unregister_trace_syscall_exit(ftrace_syscall_exit);
+		unregister_trace_sys_exit(ftrace_syscall_exit);
 	mutex_unlock(&syscall_trace_lock);
 }
 
@@ -418,7 +419,7 @@ int reg_prof_syscall_enter(char *name)
 
 	mutex_lock(&syscall_trace_lock);
 	if (!sys_prof_refcount_enter)
-		ret = register_trace_syscall_enter(prof_syscall_enter);
+		ret = register_trace_sys_enter(prof_syscall_enter);
 	if (ret) {
 		pr_info("event trace: Could not activate"
 				"syscall entry trace point");
@@ -442,7 +443,7 @@ void unreg_prof_syscall_enter(char *name)
 	sys_prof_refcount_enter--;
 	clear_bit(num, enabled_prof_enter_syscalls);
 	if (!sys_prof_refcount_enter)
-		unregister_trace_syscall_enter(prof_syscall_enter);
+		unregister_trace_sys_enter(prof_syscall_enter);
 	mutex_unlock(&syscall_trace_lock);
 }
 
@@ -479,7 +480,7 @@ int reg_prof_syscall_exit(char *name)
 
 	mutex_lock(&syscall_trace_lock);
 	if (!sys_prof_refcount_exit)
-		ret = register_trace_syscall_exit(prof_syscall_exit);
+		ret = register_trace_sys_exit(prof_syscall_exit);
 	if (ret) {
 		pr_info("event trace: Could not activate"
 				"syscall entry trace point");
@@ -503,7 +504,7 @@ void unreg_prof_syscall_exit(char *name)
 	sys_prof_refcount_exit--;
 	clear_bit(num, enabled_prof_exit_syscalls);
 	if (!sys_prof_refcount_exit)
-		unregister_trace_syscall_exit(prof_syscall_exit);
+		unregister_trace_sys_exit(prof_syscall_exit);
 	mutex_unlock(&syscall_trace_lock);
 }
 
-- 
1.6.2.5


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

* Re: [PATCH v4 0/4] tracing: tweaks for generic syscall events
  2009-08-24 21:43     ` [PATCH v4 0/4] tracing: tweaks for generic syscall events Josh Stone
  2009-08-24 21:43       ` [PATCH v4 1/4] tracing: Rename FTRACE_SYSCALLS for tracepoints Josh Stone
@ 2009-08-24 23:05       ` Frederic Weisbecker
  2009-08-25 10:28         ` Ingo Molnar
  2009-08-25 21:44       ` Frederic Weisbecker
  2 siblings, 1 reply; 70+ messages in thread
From: Frederic Weisbecker @ 2009-08-24 23:05 UTC (permalink / raw)
  To: Josh Stone
  Cc: linux-kernel, Jason Baron, Ingo Molnar, Li Zefan, Steven Rostedt,
	Peter Zijlstra, Mathieu Desnoyers, Jiaying Zhang, Martin Bligh,
	Lai Jiangshan, Paul Mundt

On Mon, Aug 24, 2009 at 02:43:10PM -0700, Josh Stone wrote:
> This patch series moves the callbacks for the syscall tracepoints to the
> definition site, and adds generic TRACE_EVENTs which capture all syscall
> arguments.
> 
> New in v3:
> - Give the thread flag a more generic name: TIF_SYSCALL_TRACEPOINT.
> - Move the regfuncs to arch-specific files, per Jason's suggestion.
> - Change _WITH_CALLBACK to just _FN, per Ingo's suggestion.
> 
> New in v4:
> - Give the config flag a more generic name: HAVE_SYSCALL_TRACEPOINTS.
> - Undo the arch reorg of the regfuncs, but conditionalize on above.
> 
> 
> Sample trace output:
>         sendmail-974   [000] 55665.464492: sys_enter: NR 14 (1, 7fff60f3af40, 7fff60f3aec0, 8, 0, 7fb1b6a05161)
> 
>         sendmail-974   [000] 55665.464496: sys_exit: NR 14 = 0
> 
>         sendmail-974   [000] 55665.464507: sys_enter: NR 23 (5, 7fff60f3b0d0, 0, 0, 7fff60f3b150, 7fff60f3ef01)
> 
>             sshd-978   [000] 55667.845359: sys_exit: NR 23 = 1
> 
>             sshd-978   [000] 55667.845373: sys_enter: NR 14 (0, 7fffc645ce90, 7fffc645cf10, 8, 0, 101010101010101)
> 
>             sshd-978   [000] 55667.845381: sys_exit: NR 14 = 0
> 
>             sshd-978   [000] 55667.845383: sys_enter: NR 14 (2, 7fffc645cf10, 0, 8, 0, 101010101010101)
> 
>             sshd-978   [000] 55667.845386: sys_exit: NR 14 = 0
> 
>             sshd-978   [000] 55667.845395: sys_enter: NR 0 (3, 7fffc6458f80, 4000, 1, 0, 0)
> 
>             sshd-978   [000] 55667.845478: sys_exit: NR 0 = 48
> 
> 
> Signed-off-by: Josh Stone <jistone@redhat.com>
> Cc: Jason Baron <jbaron@redhat.com>
> Cc: Frederic Weisbecker <fweisbec@gmail.com>
> Cc: Ingo Molnar <mingo@elte.hu>
> Cc: Li Zefan <lizf@cn.fujitsu.com>
> Cc: Steven Rostedt <rostedt@goodmis.org>
> Cc: Peter Zijlstra <peterz@infradead.org>
> Cc: Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
> Cc: Jiaying Zhang <jiayingz@google.com>
> Cc: Martin Bligh <mbligh@google.com>
> Cc: Lai Jiangshan <laijs@cn.fujitsu.com>
> Cc: Paul Mundt <lethal@linux-sh.org>


Acked-by: Frederic Weisbecker <fweisbec@gmail.com>


Thanks!


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

* Re: [PATCH v4 0/4] tracing: tweaks for generic syscall events
  2009-08-24 23:05       ` [PATCH v4 0/4] tracing: tweaks for generic syscall events Frederic Weisbecker
@ 2009-08-25 10:28         ` Ingo Molnar
  2009-08-25 13:42           ` Frederic Weisbecker
  0 siblings, 1 reply; 70+ messages in thread
From: Ingo Molnar @ 2009-08-25 10:28 UTC (permalink / raw)
  To: Frederic Weisbecker
  Cc: Josh Stone, linux-kernel, Jason Baron, Li Zefan, Steven Rostedt,
	Peter Zijlstra, Mathieu Desnoyers, Jiaying Zhang, Martin Bligh,
	Lai Jiangshan, Paul Mundt


* Frederic Weisbecker <fweisbec@gmail.com> wrote:

> On Mon, Aug 24, 2009 at 02:43:10PM -0700, Josh Stone wrote:
> > This patch series moves the callbacks for the syscall tracepoints to the
> > definition site, and adds generic TRACE_EVENTs which capture all syscall
> > arguments.
> > 
> > New in v3:
> > - Give the thread flag a more generic name: TIF_SYSCALL_TRACEPOINT.
> > - Move the regfuncs to arch-specific files, per Jason's suggestion.
> > - Change _WITH_CALLBACK to just _FN, per Ingo's suggestion.
> > 
> > New in v4:
> > - Give the config flag a more generic name: HAVE_SYSCALL_TRACEPOINTS.
> > - Undo the arch reorg of the regfuncs, but conditionalize on above.
> > 
> > 
> > Sample trace output:
> >         sendmail-974   [000] 55665.464492: sys_enter: NR 14 (1, 7fff60f3af40, 7fff60f3aec0, 8, 0, 7fb1b6a05161)
> > 
> >         sendmail-974   [000] 55665.464496: sys_exit: NR 14 = 0
> > 
> >         sendmail-974   [000] 55665.464507: sys_enter: NR 23 (5, 7fff60f3b0d0, 0, 0, 7fff60f3b150, 7fff60f3ef01)
> > 
> >             sshd-978   [000] 55667.845359: sys_exit: NR 23 = 1
> > 
> >             sshd-978   [000] 55667.845373: sys_enter: NR 14 (0, 7fffc645ce90, 7fffc645cf10, 8, 0, 101010101010101)
> > 
> >             sshd-978   [000] 55667.845381: sys_exit: NR 14 = 0
> > 
> >             sshd-978   [000] 55667.845383: sys_enter: NR 14 (2, 7fffc645cf10, 0, 8, 0, 101010101010101)
> > 
> >             sshd-978   [000] 55667.845386: sys_exit: NR 14 = 0
> > 
> >             sshd-978   [000] 55667.845395: sys_enter: NR 0 (3, 7fffc6458f80, 4000, 1, 0, 0)
> > 
> >             sshd-978   [000] 55667.845478: sys_exit: NR 0 = 48
> > 
> > 
> > Signed-off-by: Josh Stone <jistone@redhat.com>
> > Cc: Jason Baron <jbaron@redhat.com>
> > Cc: Frederic Weisbecker <fweisbec@gmail.com>
> > Cc: Ingo Molnar <mingo@elte.hu>
> > Cc: Li Zefan <lizf@cn.fujitsu.com>
> > Cc: Steven Rostedt <rostedt@goodmis.org>
> > Cc: Peter Zijlstra <peterz@infradead.org>
> > Cc: Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
> > Cc: Jiaying Zhang <jiayingz@google.com>
> > Cc: Martin Bligh <mbligh@google.com>
> > Cc: Lai Jiangshan <laijs@cn.fujitsu.com>
> > Cc: Paul Mundt <lethal@linux-sh.org>
> 
> 
> Acked-by: Frederic Weisbecker <fweisbec@gmail.com>

How about compat syscalls? If we touch this code we better cover 
them as well.

	Ingo

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

* Re: [PATCH v4 0/4] tracing: tweaks for generic syscall events
  2009-08-25 10:28         ` Ingo Molnar
@ 2009-08-25 13:42           ` Frederic Weisbecker
  2009-08-25 14:41             ` Jason Baron
  0 siblings, 1 reply; 70+ messages in thread
From: Frederic Weisbecker @ 2009-08-25 13:42 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: Josh Stone, linux-kernel, Jason Baron, Li Zefan, Steven Rostedt,
	Peter Zijlstra, Mathieu Desnoyers, Jiaying Zhang, Martin Bligh,
	Lai Jiangshan, Paul Mundt

On Tue, Aug 25, 2009 at 12:28:58PM +0200, Ingo Molnar wrote:
> 
> * Frederic Weisbecker <fweisbec@gmail.com> wrote:
> 
> > On Mon, Aug 24, 2009 at 02:43:10PM -0700, Josh Stone wrote:
> > > This patch series moves the callbacks for the syscall tracepoints to the
> > > definition site, and adds generic TRACE_EVENTs which capture all syscall
> > > arguments.
> > > 
> > > New in v3:
> > > - Give the thread flag a more generic name: TIF_SYSCALL_TRACEPOINT.
> > > - Move the regfuncs to arch-specific files, per Jason's suggestion.
> > > - Change _WITH_CALLBACK to just _FN, per Ingo's suggestion.
> > > 
> > > New in v4:
> > > - Give the config flag a more generic name: HAVE_SYSCALL_TRACEPOINTS.
> > > - Undo the arch reorg of the regfuncs, but conditionalize on above.
> > > 
> > > 
> > > Sample trace output:
> > >         sendmail-974   [000] 55665.464492: sys_enter: NR 14 (1, 7fff60f3af40, 7fff60f3aec0, 8, 0, 7fb1b6a05161)
> > > 
> > >         sendmail-974   [000] 55665.464496: sys_exit: NR 14 = 0
> > > 
> > >         sendmail-974   [000] 55665.464507: sys_enter: NR 23 (5, 7fff60f3b0d0, 0, 0, 7fff60f3b150, 7fff60f3ef01)
> > > 
> > >             sshd-978   [000] 55667.845359: sys_exit: NR 23 = 1
> > > 
> > >             sshd-978   [000] 55667.845373: sys_enter: NR 14 (0, 7fffc645ce90, 7fffc645cf10, 8, 0, 101010101010101)
> > > 
> > >             sshd-978   [000] 55667.845381: sys_exit: NR 14 = 0
> > > 
> > >             sshd-978   [000] 55667.845383: sys_enter: NR 14 (2, 7fffc645cf10, 0, 8, 0, 101010101010101)
> > > 
> > >             sshd-978   [000] 55667.845386: sys_exit: NR 14 = 0
> > > 
> > >             sshd-978   [000] 55667.845395: sys_enter: NR 0 (3, 7fffc6458f80, 4000, 1, 0, 0)
> > > 
> > >             sshd-978   [000] 55667.845478: sys_exit: NR 0 = 48
> > > 
> > > 
> > > Signed-off-by: Josh Stone <jistone@redhat.com>
> > > Cc: Jason Baron <jbaron@redhat.com>
> > > Cc: Frederic Weisbecker <fweisbec@gmail.com>
> > > Cc: Ingo Molnar <mingo@elte.hu>
> > > Cc: Li Zefan <lizf@cn.fujitsu.com>
> > > Cc: Steven Rostedt <rostedt@goodmis.org>
> > > Cc: Peter Zijlstra <peterz@infradead.org>
> > > Cc: Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
> > > Cc: Jiaying Zhang <jiayingz@google.com>
> > > Cc: Martin Bligh <mbligh@google.com>
> > > Cc: Lai Jiangshan <laijs@cn.fujitsu.com>
> > > Cc: Paul Mundt <lethal@linux-sh.org>
> > 
> > 
> > Acked-by: Frederic Weisbecker <fweisbec@gmail.com>
> 
> How about compat syscalls? If we touch this code we better cover 
> them as well.
> 
> 	Ingo


They should be covered by these generic tracepoint I guess.
The remaining bits that are necessary to cover individual compat syscall
tracepoints are the missing DEFINE_SYSCALL() uses in fs/compat.c

Is someone willing to cover them?

Thanks,
Frederic.


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

* Re: [PATCH v4 0/4] tracing: tweaks for generic syscall events
  2009-08-25 13:42           ` Frederic Weisbecker
@ 2009-08-25 14:41             ` Jason Baron
  2009-08-25 21:08               ` Frederic Weisbecker
  0 siblings, 1 reply; 70+ messages in thread
From: Jason Baron @ 2009-08-25 14:41 UTC (permalink / raw)
  To: Frederic Weisbecker
  Cc: Ingo Molnar, Josh Stone, linux-kernel, Li Zefan, Steven Rostedt,
	Peter Zijlstra, Mathieu Desnoyers, Jiaying Zhang, Martin Bligh,
	Lai Jiangshan, Paul Mundt

On Tue, Aug 25, 2009 at 03:42:08PM +0200, Frederic Weisbecker wrote:
> > * Frederic Weisbecker <fweisbec@gmail.com> wrote:
> > 
> > > On Mon, Aug 24, 2009 at 02:43:10PM -0700, Josh Stone wrote:
> > > > This patch series moves the callbacks for the syscall tracepoints to the
> > > > definition site, and adds generic TRACE_EVENTs which capture all syscall
> > > > arguments.
> > > > 
> > > > New in v3:
> > > > - Give the thread flag a more generic name: TIF_SYSCALL_TRACEPOINT.
> > > > - Move the regfuncs to arch-specific files, per Jason's suggestion.
> > > > - Change _WITH_CALLBACK to just _FN, per Ingo's suggestion.
> > > > 
> > > > New in v4:
> > > > - Give the config flag a more generic name: HAVE_SYSCALL_TRACEPOINTS.
> > > > - Undo the arch reorg of the regfuncs, but conditionalize on above.
> > > > 
> > > > 
> > > > Sample trace output:
> > > >         sendmail-974   [000] 55665.464492: sys_enter: NR 14 (1, 7fff60f3af40, 7fff60f3aec0, 8, 0, 7fb1b6a05161)
> > > > 
> > > >         sendmail-974   [000] 55665.464496: sys_exit: NR 14 = 0
> > > > 
> > > >         sendmail-974   [000] 55665.464507: sys_enter: NR 23 (5, 7fff60f3b0d0, 0, 0, 7fff60f3b150, 7fff60f3ef01)
> > > > 
> > > >             sshd-978   [000] 55667.845359: sys_exit: NR 23 = 1
> > > > 
> > > >             sshd-978   [000] 55667.845373: sys_enter: NR 14 (0, 7fffc645ce90, 7fffc645cf10, 8, 0, 101010101010101)
> > > > 
> > > >             sshd-978   [000] 55667.845381: sys_exit: NR 14 = 0
> > > > 
> > > >             sshd-978   [000] 55667.845383: sys_enter: NR 14 (2, 7fffc645cf10, 0, 8, 0, 101010101010101)
> > > > 
> > > >             sshd-978   [000] 55667.845386: sys_exit: NR 14 = 0
> > > > 
> > > >             sshd-978   [000] 55667.845395: sys_enter: NR 0 (3, 7fffc6458f80, 4000, 1, 0, 0)
> > > > 
> > > >             sshd-978   [000] 55667.845478: sys_exit: NR 0 = 48
> > > > 
> > > > 
> > > > Signed-off-by: Josh Stone <jistone@redhat.com>
> > > > Cc: Jason Baron <jbaron@redhat.com>
> > > > Cc: Frederic Weisbecker <fweisbec@gmail.com>
> > > > Cc: Ingo Molnar <mingo@elte.hu>
> > > > Cc: Li Zefan <lizf@cn.fujitsu.com>
> > > > Cc: Steven Rostedt <rostedt@goodmis.org>
> > > > Cc: Peter Zijlstra <peterz@infradead.org>
> > > > Cc: Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
> > > > Cc: Jiaying Zhang <jiayingz@google.com>
> > > > Cc: Martin Bligh <mbligh@google.com>
> > > > Cc: Lai Jiangshan <laijs@cn.fujitsu.com>
> > > > Cc: Paul Mundt <lethal@linux-sh.org>
> > > 
> > > 
> > > Acked-by: Frederic Weisbecker <fweisbec@gmail.com>
> > 
> > How about compat syscalls? If we touch this code we better cover 
> > them as well.
> > 
> > 	Ingo
> 
> 
> They should be covered by these generic tracepoint I guess.
> The remaining bits that are necessary to cover individual compat syscall
> tracepoints are the missing DEFINE_SYSCALL() uses in fs/compat.c
> 

right, the compat layer as well as the core kernel need additional
DEFINE_SYSCALL() macros to catch all the the syscalls. However, I think
the compat layer is a bit more involved in that it often makes use of
the core kernel syscalls, but the mapping between syscall number is
different. So, we need another array, or to augment the existing one, to
cover the compat syscalls. We also need to detect 32-bit processes in
the syscall entry path to determine which array to use, and we need to
grab the arguments differently. So there is a bunch of work here.

Also, we have the question of whether we need separate entries in the
events/syscalls directly for 32-bit process syscalls that call the same
64-bit syscall interfaces. Should they be parsed as 64-bit argument
values event thought they are 32-bit? To reduce complexity, I would say
the 32-bit syscall entries should be the same as the 64-bit ones. That
said there will be a bunch of new "compat_sys*" etc. entries.


> Is someone willing to cover them?
> 

I can take a stab at it.

thanks,

-Jason

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

* Re: [PATCH v4 0/4] tracing: tweaks for generic syscall events
  2009-08-25 14:41             ` Jason Baron
@ 2009-08-25 21:08               ` Frederic Weisbecker
  0 siblings, 0 replies; 70+ messages in thread
From: Frederic Weisbecker @ 2009-08-25 21:08 UTC (permalink / raw)
  To: Jason Baron
  Cc: Ingo Molnar, Josh Stone, linux-kernel, Li Zefan, Steven Rostedt,
	Peter Zijlstra, Mathieu Desnoyers, Jiaying Zhang, Martin Bligh,
	Lai Jiangshan, Paul Mundt

On Tue, Aug 25, 2009 at 10:41:22AM -0400, Jason Baron wrote:
> right, the compat layer as well as the core kernel need additional
> DEFINE_SYSCALL() macros to catch all the the syscalls. However, I think
> the compat layer is a bit more involved in that it often makes use of
> the core kernel syscalls, but the mapping between syscall number is
> different. So, we need another array, or to augment the existing one, to
> cover the compat syscalls. We also need to detect 32-bit processes in
> the syscall entry path to determine which array to use, and we need to
> grab the arguments differently. So there is a bunch of work here.


Hmm, indeed we may need a parallel compat_syscall_table for the metadata
and other kind of special treatements.
I wonder how ptrace sort it out in syscall_trace_enter() to guess the
origin of the syscall (ia32 or normal), since the table is not mapped
with the same numbers.

 
> Also, we have the question of whether we need separate entries in the
> events/syscalls directly for 32-bit process syscalls that call the same
> 64-bit syscall interfaces. Should they be parsed as 64-bit argument
> values event thought they are 32-bit? To reduce complexity, I would say
> the 32-bit syscall entries should be the same as the 64-bit ones. That
> said there will be a bunch of new "compat_sys*" etc. entries.
> 


We could probably re-route the compat syscall tracing to their
homologuous 64 bits tracepoints, but one may want to only trace the
compat_syscalls, use filters only on them, activate only some of them,
etc...

To do such routing, we could have a simple table that resolves
a compat syscall number to its real 64 bits syscall number and we could
then pass this number plus a flag that set its compat state in the ring
buffer entry.
That would avoid the need of using the DEFINE_SYSCALLx() in fs/compat.c

But such ghost tracepoints would also complexify too much the filter
processing, the individual tracepoints toggling, etc...
So I think having real compat tracepoints would actually be more simple.

We could still use shortcuts in userspace if we want to enable
sys_enter_open and sys_enter_compat_open at the same time.

Hmm?

> > Is someone willing to cover them?
> > 
> 
> I can take a stab at it.


Thanks a lot!


> thanks,
> 
> -Jason


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

* Re: [PATCH v4 0/4] tracing: tweaks for generic syscall events
  2009-08-24 21:43     ` [PATCH v4 0/4] tracing: tweaks for generic syscall events Josh Stone
  2009-08-24 21:43       ` [PATCH v4 1/4] tracing: Rename FTRACE_SYSCALLS for tracepoints Josh Stone
  2009-08-24 23:05       ` [PATCH v4 0/4] tracing: tweaks for generic syscall events Frederic Weisbecker
@ 2009-08-25 21:44       ` Frederic Weisbecker
  2 siblings, 0 replies; 70+ messages in thread
From: Frederic Weisbecker @ 2009-08-25 21:44 UTC (permalink / raw)
  To: Josh Stone
  Cc: linux-kernel, Jason Baron, Ingo Molnar, Li Zefan, Steven Rostedt,
	Peter Zijlstra, Mathieu Desnoyers, Jiaying Zhang, Martin Bligh,
	Lai Jiangshan, Paul Mundt

On Mon, Aug 24, 2009 at 02:43:10PM -0700, Josh Stone wrote:
> This patch series moves the callbacks for the syscall tracepoints to the
> definition site, and adds generic TRACE_EVENTs which capture all syscall
> arguments.
> 
> New in v3:
> - Give the thread flag a more generic name: TIF_SYSCALL_TRACEPOINT.
> - Move the regfuncs to arch-specific files, per Jason's suggestion.
> - Change _WITH_CALLBACK to just _FN, per Ingo's suggestion.
> 
> New in v4:
> - Give the config flag a more generic name: HAVE_SYSCALL_TRACEPOINTS.
> - Undo the arch reorg of the regfuncs, but conditionalize on above.
> 
> 
> Sample trace output:
>         sendmail-974   [000] 55665.464492: sys_enter: NR 14 (1, 7fff60f3af40, 7fff60f3aec0, 8, 0, 7fb1b6a05161)
> 
>         sendmail-974   [000] 55665.464496: sys_exit: NR 14 = 0
> 
>         sendmail-974   [000] 55665.464507: sys_enter: NR 23 (5, 7fff60f3b0d0, 0, 0, 7fff60f3b150, 7fff60f3ef01)
> 
>             sshd-978   [000] 55667.845359: sys_exit: NR 23 = 1
> 
>             sshd-978   [000] 55667.845373: sys_enter: NR 14 (0, 7fffc645ce90, 7fffc645cf10, 8, 0, 101010101010101)
> 
>             sshd-978   [000] 55667.845381: sys_exit: NR 14 = 0
> 
>             sshd-978   [000] 55667.845383: sys_enter: NR 14 (2, 7fffc645cf10, 0, 8, 0, 101010101010101)
> 
>             sshd-978   [000] 55667.845386: sys_exit: NR 14 = 0
> 
>             sshd-978   [000] 55667.845395: sys_enter: NR 0 (3, 7fffc6458f80, 4000, 1, 0, 0)
> 
>             sshd-978   [000] 55667.845478: sys_exit: NR 0 = 48
> 
> 
> Signed-off-by: Josh Stone <jistone@redhat.com>
> Cc: Jason Baron <jbaron@redhat.com>
> Cc: Frederic Weisbecker <fweisbec@gmail.com>
> Cc: Ingo Molnar <mingo@elte.hu>
> Cc: Li Zefan <lizf@cn.fujitsu.com>
> Cc: Steven Rostedt <rostedt@goodmis.org>
> Cc: Peter Zijlstra <peterz@infradead.org>
> Cc: Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
> Cc: Jiaying Zhang <jiayingz@google.com>
> Cc: Martin Bligh <mbligh@google.com>
> Cc: Lai Jiangshan <laijs@cn.fujitsu.com>
> Cc: Paul Mundt <lethal@linux-sh.org>


Queued for .32, thanks!


> ---
>  arch/s390/Kconfig                   |    2 +-
>  arch/s390/defconfig                 |    2 +-
>  arch/s390/include/asm/thread_info.h |    4 +-
>  arch/s390/kernel/entry.S            |    2 +-
>  arch/s390/kernel/entry64.S          |    2 +-
>  arch/s390/kernel/ptrace.c           |   12 +++---
>  arch/x86/Kconfig                    |    2 +-
>  arch/x86/configs/i386_defconfig     |    2 +-
>  arch/x86/configs/x86_64_defconfig   |    2 +-
>  arch/x86/include/asm/thread_info.h  |   13 +++---
>  arch/x86/kernel/ptrace.c            |   16 +++----
>  include/linux/tracepoint.h          |   46 +++++++++--------------
>  include/trace/define_trace.h        |    5 ++
>  include/trace/events/syscalls.h     |   70 +++++++++++++++++++++++++++++++++++
>  include/trace/ftrace.h              |    9 ++++
>  include/trace/syscall.h             |   17 --------
>  kernel/trace/Kconfig                |    4 +-
>  kernel/trace/trace_syscalls.c       |   17 ++++----
>  kernel/tracepoint.c                 |   20 ++++++----
> 


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

* [tip:tracing/core] tracing: Rename FTRACE_SYSCALLS for tracepoints
  2009-08-24 21:43       ` [PATCH v4 1/4] tracing: Rename FTRACE_SYSCALLS for tracepoints Josh Stone
  2009-08-24 21:43         ` [PATCH v4 2/4] tracing: Make syscall tracepoints conditional Josh Stone
@ 2009-08-26  7:21         ` tip-bot for Josh Stone
  1 sibling, 0 replies; 70+ messages in thread
From: tip-bot for Josh Stone @ 2009-08-26  7:21 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: mathieu.desnoyers, mingo, schwidefsky, peterz, fweisbec, rostedt,
	heiko.carstens, tglx, jbaron, laijs, linux-kernel, hpa, jiayingz,
	lizf, lethal, jistone, mingo, mbligh

Commit-ID:  667000011927b4fcc359beac4a2447889db6d349
Gitweb:     http://git.kernel.org/tip/667000011927b4fcc359beac4a2447889db6d349
Author:     Josh Stone <jistone@redhat.com>
AuthorDate: Mon, 24 Aug 2009 14:43:11 -0700
Committer:  Frederic Weisbecker <fweisbec@gmail.com>
CommitDate: Wed, 26 Aug 2009 00:17:35 +0200

tracing: Rename FTRACE_SYSCALLS for tracepoints

s/HAVE_FTRACE_SYSCALLS/HAVE_SYSCALL_TRACEPOINTS/g
s/TIF_SYSCALL_FTRACE/TIF_SYSCALL_TRACEPOINT/g

The syscall enter/exit tracing is no longer specific to just ftrace, so
they now have names that reflect their tie to tracepoints instead.

Signed-off-by: Josh Stone <jistone@redhat.com>
Cc: Jason Baron <jbaron@redhat.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Li Zefan <lizf@cn.fujitsu.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
Cc: Jiaying Zhang <jiayingz@google.com>
Cc: Martin Bligh <mbligh@google.com>
Cc: Lai Jiangshan <laijs@cn.fujitsu.com>
Cc: Paul Mundt <lethal@linux-sh.org>
Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
LKML-Reference: <1251150194-1713-2-git-send-email-jistone@redhat.com>
Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>


---
 arch/s390/Kconfig                   |    2 +-
 arch/s390/defconfig                 |    2 +-
 arch/s390/include/asm/thread_info.h |    4 ++--
 arch/s390/kernel/entry.S            |    2 +-
 arch/s390/kernel/entry64.S          |    2 +-
 arch/s390/kernel/ptrace.c           |    4 ++--
 arch/x86/Kconfig                    |    2 +-
 arch/x86/configs/i386_defconfig     |    2 +-
 arch/x86/configs/x86_64_defconfig   |    2 +-
 arch/x86/include/asm/thread_info.h  |   13 +++++++------
 arch/x86/kernel/ptrace.c            |    4 ++--
 kernel/trace/Kconfig                |    4 ++--
 kernel/tracepoint.c                 |    4 ++--
 13 files changed, 24 insertions(+), 23 deletions(-)

diff --git a/arch/s390/Kconfig b/arch/s390/Kconfig
index 2ae5d72..7238ef4 100644
--- a/arch/s390/Kconfig
+++ b/arch/s390/Kconfig
@@ -84,7 +84,7 @@ config S390
 	select HAVE_FUNCTION_TRACER
 	select HAVE_FUNCTION_TRACE_MCOUNT_TEST
 	select HAVE_FTRACE_MCOUNT_RECORD
-	select HAVE_FTRACE_SYSCALLS
+	select HAVE_SYSCALL_TRACEPOINTS
 	select HAVE_DYNAMIC_FTRACE
 	select HAVE_FUNCTION_GRAPH_TRACER
 	select HAVE_DEFAULT_NO_SPIN_MUTEXES
diff --git a/arch/s390/defconfig b/arch/s390/defconfig
index fcba206..4e91a25 100644
--- a/arch/s390/defconfig
+++ b/arch/s390/defconfig
@@ -900,7 +900,7 @@ CONFIG_HAVE_FUNCTION_GRAPH_TRACER=y
 CONFIG_HAVE_FUNCTION_TRACE_MCOUNT_TEST=y
 CONFIG_HAVE_DYNAMIC_FTRACE=y
 CONFIG_HAVE_FTRACE_MCOUNT_RECORD=y
-CONFIG_HAVE_FTRACE_SYSCALLS=y
+CONFIG_HAVE_SYSCALL_TRACEPOINTS=y
 CONFIG_TRACING_SUPPORT=y
 CONFIG_FTRACE=y
 # CONFIG_FUNCTION_TRACER is not set
diff --git a/arch/s390/include/asm/thread_info.h b/arch/s390/include/asm/thread_info.h
index ba1cab9..07eb61b 100644
--- a/arch/s390/include/asm/thread_info.h
+++ b/arch/s390/include/asm/thread_info.h
@@ -92,7 +92,7 @@ static inline struct thread_info *current_thread_info(void)
 #define TIF_SYSCALL_TRACE	8	/* syscall trace active */
 #define TIF_SYSCALL_AUDIT	9	/* syscall auditing active */
 #define TIF_SECCOMP		10	/* secure computing */
-#define TIF_SYSCALL_FTRACE	11	/* ftrace syscall instrumentation */
+#define TIF_SYSCALL_TRACEPOINT	11	/* syscall tracepoint instrumentation */
 #define TIF_USEDFPU		16	/* FPU was used by this task this quantum (SMP) */
 #define TIF_POLLING_NRFLAG	17	/* true if poll_idle() is polling 
 					   TIF_NEED_RESCHED */
@@ -111,7 +111,7 @@ static inline struct thread_info *current_thread_info(void)
 #define _TIF_SYSCALL_TRACE	(1<<TIF_SYSCALL_TRACE)
 #define _TIF_SYSCALL_AUDIT	(1<<TIF_SYSCALL_AUDIT)
 #define _TIF_SECCOMP		(1<<TIF_SECCOMP)
-#define _TIF_SYSCALL_FTRACE	(1<<TIF_SYSCALL_FTRACE)
+#define _TIF_SYSCALL_TRACEPOINT	(1<<TIF_SYSCALL_TRACEPOINT)
 #define _TIF_USEDFPU		(1<<TIF_USEDFPU)
 #define _TIF_POLLING_NRFLAG	(1<<TIF_POLLING_NRFLAG)
 #define _TIF_31BIT		(1<<TIF_31BIT)
diff --git a/arch/s390/kernel/entry.S b/arch/s390/kernel/entry.S
index c4c80a2..5d40fce 100644
--- a/arch/s390/kernel/entry.S
+++ b/arch/s390/kernel/entry.S
@@ -54,7 +54,7 @@ _TIF_WORK_SVC = (_TIF_SIGPENDING | _TIF_NOTIFY_RESUME | _TIF_NEED_RESCHED | \
 _TIF_WORK_INT = (_TIF_SIGPENDING | _TIF_NOTIFY_RESUME | _TIF_NEED_RESCHED | \
 		 _TIF_MCCK_PENDING)
 _TIF_SYSCALL = (_TIF_SYSCALL_TRACE>>8 | _TIF_SYSCALL_AUDIT>>8 | \
-		_TIF_SECCOMP>>8 | _TIF_SYSCALL_FTRACE>>8)
+		_TIF_SECCOMP>>8 | _TIF_SYSCALL_TRACEPOINT>>8)
 
 STACK_SHIFT = PAGE_SHIFT + THREAD_ORDER
 STACK_SIZE  = 1 << STACK_SHIFT
diff --git a/arch/s390/kernel/entry64.S b/arch/s390/kernel/entry64.S
index f6618e9..3ceb53c 100644
--- a/arch/s390/kernel/entry64.S
+++ b/arch/s390/kernel/entry64.S
@@ -57,7 +57,7 @@ _TIF_WORK_SVC = (_TIF_SIGPENDING | _TIF_NOTIFY_RESUME | _TIF_NEED_RESCHED | \
 _TIF_WORK_INT = (_TIF_SIGPENDING | _TIF_NOTIFY_RESUME | _TIF_NEED_RESCHED | \
 		 _TIF_MCCK_PENDING)
 _TIF_SYSCALL = (_TIF_SYSCALL_TRACE>>8 | _TIF_SYSCALL_AUDIT>>8 | \
-		_TIF_SECCOMP>>8 | _TIF_SYSCALL_FTRACE>>8)
+		_TIF_SECCOMP>>8 | _TIF_SYSCALL_TRACEPOINT>>8)
 
 #define BASED(name) name-system_call(%r13)
 
diff --git a/arch/s390/kernel/ptrace.c b/arch/s390/kernel/ptrace.c
index c5e87d8..9d3dcfa 100644
--- a/arch/s390/kernel/ptrace.c
+++ b/arch/s390/kernel/ptrace.c
@@ -664,7 +664,7 @@ asmlinkage long do_syscall_trace_enter(struct pt_regs *regs)
 		ret = -1;
 	}
 
-	if (unlikely(test_thread_flag(TIF_SYSCALL_FTRACE)))
+	if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
 		trace_syscall_enter(regs, regs->gprs[2]);
 
 	if (unlikely(current->audit_context))
@@ -682,7 +682,7 @@ asmlinkage void do_syscall_trace_exit(struct pt_regs *regs)
 		audit_syscall_exit(AUDITSC_RESULT(regs->gprs[2]),
 				   regs->gprs[2]);
 
-	if (unlikely(test_thread_flag(TIF_SYSCALL_FTRACE)))
+	if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
 		trace_syscall_exit(regs, regs->gprs[2]);
 
 	if (test_thread_flag(TIF_SYSCALL_TRACE))
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index 738bdc6..d59cbf7 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -37,7 +37,7 @@ config X86
 	select HAVE_FUNCTION_GRAPH_FP_TEST
 	select HAVE_FUNCTION_TRACE_MCOUNT_TEST
 	select HAVE_FTRACE_NMI_ENTER if DYNAMIC_FTRACE
-	select HAVE_FTRACE_SYSCALLS
+	select HAVE_SYSCALL_TRACEPOINTS
 	select HAVE_KVM
 	select HAVE_ARCH_KGDB
 	select HAVE_ARCH_TRACEHOOK
diff --git a/arch/x86/configs/i386_defconfig b/arch/x86/configs/i386_defconfig
index edb992e..d28fad1 100644
--- a/arch/x86/configs/i386_defconfig
+++ b/arch/x86/configs/i386_defconfig
@@ -2355,7 +2355,7 @@ CONFIG_HAVE_FUNCTION_TRACE_MCOUNT_TEST=y
 CONFIG_HAVE_DYNAMIC_FTRACE=y
 CONFIG_HAVE_FTRACE_MCOUNT_RECORD=y
 CONFIG_HAVE_HW_BRANCH_TRACER=y
-CONFIG_HAVE_FTRACE_SYSCALLS=y
+CONFIG_HAVE_SYSCALL_TRACEPOINTS=y
 CONFIG_RING_BUFFER=y
 CONFIG_TRACING=y
 CONFIG_TRACING_SUPPORT=y
diff --git a/arch/x86/configs/x86_64_defconfig b/arch/x86/configs/x86_64_defconfig
index cee1dd2..6c86acd 100644
--- a/arch/x86/configs/x86_64_defconfig
+++ b/arch/x86/configs/x86_64_defconfig
@@ -2329,7 +2329,7 @@ CONFIG_HAVE_FUNCTION_TRACE_MCOUNT_TEST=y
 CONFIG_HAVE_DYNAMIC_FTRACE=y
 CONFIG_HAVE_FTRACE_MCOUNT_RECORD=y
 CONFIG_HAVE_HW_BRANCH_TRACER=y
-CONFIG_HAVE_FTRACE_SYSCALLS=y
+CONFIG_HAVE_SYSCALL_TRACEPOINTS=y
 CONFIG_RING_BUFFER=y
 CONFIG_TRACING=y
 CONFIG_TRACING_SUPPORT=y
diff --git a/arch/x86/include/asm/thread_info.h b/arch/x86/include/asm/thread_info.h
index fad7d40..6f7786a 100644
--- a/arch/x86/include/asm/thread_info.h
+++ b/arch/x86/include/asm/thread_info.h
@@ -95,7 +95,7 @@ struct thread_info {
 #define TIF_DEBUGCTLMSR		25	/* uses thread_struct.debugctlmsr */
 #define TIF_DS_AREA_MSR		26      /* uses thread_struct.ds_area_msr */
 #define TIF_LAZY_MMU_UPDATES	27	/* task is updating the mmu lazily */
-#define TIF_SYSCALL_FTRACE	28	/* for ftrace syscall instrumentation */
+#define TIF_SYSCALL_TRACEPOINT	28	/* syscall tracepoint instrumentation */
 
 #define _TIF_SYSCALL_TRACE	(1 << TIF_SYSCALL_TRACE)
 #define _TIF_NOTIFY_RESUME	(1 << TIF_NOTIFY_RESUME)
@@ -118,17 +118,17 @@ struct thread_info {
 #define _TIF_DEBUGCTLMSR	(1 << TIF_DEBUGCTLMSR)
 #define _TIF_DS_AREA_MSR	(1 << TIF_DS_AREA_MSR)
 #define _TIF_LAZY_MMU_UPDATES	(1 << TIF_LAZY_MMU_UPDATES)
-#define _TIF_SYSCALL_FTRACE	(1 << TIF_SYSCALL_FTRACE)
+#define _TIF_SYSCALL_TRACEPOINT	(1 << TIF_SYSCALL_TRACEPOINT)
 
 /* work to do in syscall_trace_enter() */
 #define _TIF_WORK_SYSCALL_ENTRY	\
-	(_TIF_SYSCALL_TRACE | _TIF_SYSCALL_EMU | _TIF_SYSCALL_FTRACE |	\
-	 _TIF_SYSCALL_AUDIT | _TIF_SECCOMP | _TIF_SINGLESTEP)
+	(_TIF_SYSCALL_TRACE | _TIF_SYSCALL_EMU | _TIF_SYSCALL_AUDIT |	\
+	 _TIF_SECCOMP | _TIF_SINGLESTEP | _TIF_SYSCALL_TRACEPOINT)
 
 /* work to do in syscall_trace_leave() */
 #define _TIF_WORK_SYSCALL_EXIT	\
 	(_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | _TIF_SINGLESTEP |	\
-	 _TIF_SYSCALL_FTRACE)
+	 _TIF_SYSCALL_TRACEPOINT)
 
 /* work to do on interrupt/exception return */
 #define _TIF_WORK_MASK							\
@@ -137,7 +137,8 @@ struct thread_info {
 	   _TIF_SINGLESTEP|_TIF_SECCOMP|_TIF_SYSCALL_EMU))
 
 /* work to do on any return to user space */
-#define _TIF_ALLWORK_MASK ((0x0000FFFF & ~_TIF_SECCOMP) | _TIF_SYSCALL_FTRACE)
+#define _TIF_ALLWORK_MASK						\
+	((0x0000FFFF & ~_TIF_SECCOMP) | _TIF_SYSCALL_TRACEPOINT)
 
 /* Only used for 64 bit */
 #define _TIF_DO_NOTIFY_MASK						\
diff --git a/arch/x86/kernel/ptrace.c b/arch/x86/kernel/ptrace.c
index 34dd6f1..a909afe 100644
--- a/arch/x86/kernel/ptrace.c
+++ b/arch/x86/kernel/ptrace.c
@@ -1500,7 +1500,7 @@ asmregparm long syscall_trace_enter(struct pt_regs *regs)
 	    tracehook_report_syscall_entry(regs))
 		ret = -1L;
 
-	if (unlikely(test_thread_flag(TIF_SYSCALL_FTRACE)))
+	if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
 		trace_syscall_enter(regs, regs->orig_ax);
 
 	if (unlikely(current->audit_context)) {
@@ -1526,7 +1526,7 @@ asmregparm void syscall_trace_leave(struct pt_regs *regs)
 	if (unlikely(current->audit_context))
 		audit_syscall_exit(AUDITSC_RESULT(regs->ax), regs->ax);
 
-	if (unlikely(test_thread_flag(TIF_SYSCALL_FTRACE)))
+	if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
 		trace_syscall_exit(regs, regs->ax);
 
 	if (test_thread_flag(TIF_SYSCALL_TRACE))
diff --git a/kernel/trace/Kconfig b/kernel/trace/Kconfig
index 019f380..06be85a 100644
--- a/kernel/trace/Kconfig
+++ b/kernel/trace/Kconfig
@@ -41,7 +41,7 @@ config HAVE_FTRACE_MCOUNT_RECORD
 config HAVE_HW_BRANCH_TRACER
 	bool
 
-config HAVE_FTRACE_SYSCALLS
+config HAVE_SYSCALL_TRACEPOINTS
 	bool
 
 config TRACER_MAX_TRACE
@@ -211,7 +211,7 @@ config ENABLE_DEFAULT_TRACERS
 
 config FTRACE_SYSCALLS
 	bool "Trace syscalls"
-	depends on HAVE_FTRACE_SYSCALLS
+	depends on HAVE_SYSCALL_TRACEPOINTS
 	select GENERIC_TRACER
 	select KALLSYMS
 	help
diff --git a/kernel/tracepoint.c b/kernel/tracepoint.c
index 06f165a..be86b9a 100644
--- a/kernel/tracepoint.c
+++ b/kernel/tracepoint.c
@@ -590,7 +590,7 @@ void syscall_regfunc(void)
 	if (!sys_tracepoint_refcount) {
 		read_lock_irqsave(&tasklist_lock, flags);
 		do_each_thread(g, t) {
-			set_tsk_thread_flag(t, TIF_SYSCALL_FTRACE);
+			set_tsk_thread_flag(t, TIF_SYSCALL_TRACEPOINT);
 		} while_each_thread(g, t);
 		read_unlock_irqrestore(&tasklist_lock, flags);
 	}
@@ -608,7 +608,7 @@ void syscall_unregfunc(void)
 	if (!sys_tracepoint_refcount) {
 		read_lock_irqsave(&tasklist_lock, flags);
 		do_each_thread(g, t) {
-			clear_tsk_thread_flag(t, TIF_SYSCALL_FTRACE);
+			clear_tsk_thread_flag(t, TIF_SYSCALL_TRACEPOINT);
 		} while_each_thread(g, t);
 		read_unlock_irqrestore(&tasklist_lock, flags);
 	}

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

* [tip:tracing/core] tracing: Make syscall tracepoints conditional
  2009-08-24 21:43         ` [PATCH v4 2/4] tracing: Make syscall tracepoints conditional Josh Stone
  2009-08-24 21:43           ` [PATCH v4 3/4] tracing: Move tracepoint callbacks into DEFINE Josh Stone
@ 2009-08-26  7:21           ` tip-bot for Josh Stone
  1 sibling, 0 replies; 70+ messages in thread
From: tip-bot for Josh Stone @ 2009-08-26  7:21 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, jiayingz, mathieu.desnoyers, hpa, mingo, lizf,
	peterz, jistone, fweisbec, rostedt, tglx, jbaron, laijs, mbligh,
	mingo

Commit-ID:  3d27d8cb34fc156beb86de2338ca4029873a5cc6
Gitweb:     http://git.kernel.org/tip/3d27d8cb34fc156beb86de2338ca4029873a5cc6
Author:     Josh Stone <jistone@redhat.com>
AuthorDate: Mon, 24 Aug 2009 14:43:12 -0700
Committer:  Frederic Weisbecker <fweisbec@gmail.com>
CommitDate: Wed, 26 Aug 2009 00:24:19 +0200

tracing: Make syscall tracepoints conditional

The syscall enter/exit tracepoints are only supported on archs that
HAVE_SYSCALL_TRACEPOINTS, so the declarations should be #ifdef'ed.
Also, the definition of syscall_regfunc and syscall_unregfunc should
depend on this same config, rather than the ftrace-specific one.

Signed-off-by: Josh Stone <jistone@redhat.com>
Cc: Jason Baron <jbaron@redhat.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Li Zefan <lizf@cn.fujitsu.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
Cc: Jiaying Zhang <jiayingz@google.com>
Cc: Martin Bligh <mbligh@google.com>
Cc: Lai Jiangshan <laijs@cn.fujitsu.com>
LKML-Reference: <1251150194-1713-3-git-send-email-jistone@redhat.com>
Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>


---
 include/trace/syscall.h |    4 ++++
 kernel/tracepoint.c     |    2 +-
 2 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/include/trace/syscall.h b/include/trace/syscall.h
index 9661dd4..5dcb7e3 100644
--- a/include/trace/syscall.h
+++ b/include/trace/syscall.h
@@ -8,6 +8,8 @@
 #include <asm/ptrace.h>
 
 
+#ifdef CONFIG_HAVE_SYSCALL_TRACEPOINTS
+
 extern void syscall_regfunc(void);
 extern void syscall_unregfunc(void);
 
@@ -25,6 +27,8 @@ DECLARE_TRACE_WITH_CALLBACK(syscall_exit,
 	syscall_unregfunc
 );
 
+#endif
+
 /*
  * A syscall entry in the ftrace syscalls array.
  *
diff --git a/kernel/tracepoint.c b/kernel/tracepoint.c
index be86b9a..9e0a36f 100644
--- a/kernel/tracepoint.c
+++ b/kernel/tracepoint.c
@@ -576,7 +576,7 @@ __initcall(init_tracepoints);
 
 #endif /* CONFIG_MODULES */
 
-#ifdef CONFIG_FTRACE_SYSCALLS
+#ifdef CONFIG_HAVE_SYSCALL_TRACEPOINTS
 
 static DEFINE_MUTEX(regfunc_mutex);
 static int sys_tracepoint_refcount;

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

* [tip:tracing/core] tracing: Move tracepoint callbacks from declaration to definition
  2009-08-24 21:43           ` [PATCH v4 3/4] tracing: Move tracepoint callbacks into DEFINE Josh Stone
  2009-08-24 21:43             ` [PATCH v4 4/4] tracing: Create generic syscall TRACE_EVENTs Josh Stone
@ 2009-08-26  7:22             ` tip-bot for Josh Stone
  2009-08-27 22:50               ` [PATCH] tracing: Fix double CPP substitution in TRACE_EVENT_FN Frederic Weisbecker
  1 sibling, 1 reply; 70+ messages in thread
From: tip-bot for Josh Stone @ 2009-08-26  7:22 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: mathieu.desnoyers, mingo, schwidefsky, peterz, fweisbec, rostedt,
	heiko.carstens, tglx, jbaron, laijs, linux-kernel, hpa, jiayingz,
	lizf, lethal, jistone, mingo, mbligh

Commit-ID:  97419875865859fd2403e66266c02ce028e2f5ab
Gitweb:     http://git.kernel.org/tip/97419875865859fd2403e66266c02ce028e2f5ab
Author:     Josh Stone <jistone@redhat.com>
AuthorDate: Mon, 24 Aug 2009 14:43:13 -0700
Committer:  Frederic Weisbecker <fweisbec@gmail.com>
CommitDate: Wed, 26 Aug 2009 00:36:41 +0200

tracing: Move tracepoint callbacks from declaration to definition

It's not strictly correct for the tracepoint reg/unreg callbacks to
occur when a client is hooking up, because the actual tracepoint may not
be present yet.  This happens to be fine for syscall, since that's in
the core kernel, but it would cause problems for tracepoints defined in
a module that hasn't been loaded yet.  It also means the reg/unreg has
to be EXPORTed for any modules to use the tracepoint (as in SystemTap).

This patch removes DECLARE_TRACE_WITH_CALLBACK, and instead introduces
DEFINE_TRACE_FN which stores the callbacks in struct tracepoint.  The
callbacks are used now when the active state of the tracepoint changes
in set_tracepoint & disable_tracepoint.

This also introduces TRACE_EVENT_FN, so ftrace events can also provide
registration callbacks if needed.

Signed-off-by: Josh Stone <jistone@redhat.com>
Cc: Jason Baron <jbaron@redhat.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Li Zefan <lizf@cn.fujitsu.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
Cc: Jiaying Zhang <jiayingz@google.com>
Cc: Martin Bligh <mbligh@google.com>
Cc: Lai Jiangshan <laijs@cn.fujitsu.com>
Cc: Paul Mundt <lethal@linux-sh.org>
Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
LKML-Reference: <1251150194-1713-4-git-send-email-jistone@redhat.com>
Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>


---
 arch/s390/kernel/ptrace.c    |    4 +-
 arch/x86/kernel/ptrace.c     |    4 +-
 include/linux/tracepoint.h   |   46 ++++++++++++++++-------------------------
 include/trace/define_trace.h |    5 ++++
 include/trace/ftrace.h       |    9 ++++++++
 include/trace/syscall.h      |   12 +++-------
 kernel/tracepoint.c          |   14 ++++++++----
 7 files changed, 49 insertions(+), 45 deletions(-)

diff --git a/arch/s390/kernel/ptrace.c b/arch/s390/kernel/ptrace.c
index 9d3dcfa..c05b44b 100644
--- a/arch/s390/kernel/ptrace.c
+++ b/arch/s390/kernel/ptrace.c
@@ -51,8 +51,8 @@
 #include "compat_ptrace.h"
 #endif
 
-DEFINE_TRACE(syscall_enter);
-DEFINE_TRACE(syscall_exit);
+DEFINE_TRACE_FN(syscall_enter, syscall_regfunc, syscall_unregfunc);
+DEFINE_TRACE_FN(syscall_exit, syscall_regfunc, syscall_unregfunc);
 
 enum s390_regset {
 	REGSET_GENERAL,
diff --git a/arch/x86/kernel/ptrace.c b/arch/x86/kernel/ptrace.c
index a909afe..31e9b97 100644
--- a/arch/x86/kernel/ptrace.c
+++ b/arch/x86/kernel/ptrace.c
@@ -37,8 +37,8 @@
 
 #include <trace/syscall.h>
 
-DEFINE_TRACE(syscall_enter);
-DEFINE_TRACE(syscall_exit);
+DEFINE_TRACE_FN(syscall_enter, syscall_regfunc, syscall_unregfunc);
+DEFINE_TRACE_FN(syscall_exit, syscall_regfunc, syscall_unregfunc);
 
 #include "tls.h"
 
diff --git a/include/linux/tracepoint.h b/include/linux/tracepoint.h
index 5984ed0..846a4ae 100644
--- a/include/linux/tracepoint.h
+++ b/include/linux/tracepoint.h
@@ -23,6 +23,8 @@ struct tracepoint;
 struct tracepoint {
 	const char *name;		/* Tracepoint name */
 	int state;			/* State. */
+	void (*regfunc)(void);
+	void (*unregfunc)(void);
 	void **funcs;
 } __attribute__((aligned(32)));		/*
 					 * Aligned on 32 bytes because it is
@@ -60,10 +62,8 @@ struct tracepoint {
  * Make sure the alignment of the structure in the __tracepoints section will
  * not add unwanted padding between the beginning of the section and the
  * structure. Force alignment to the same alignment as the section start.
- * An optional set of (un)registration functions can be passed to perform any
- * additional (un)registration work.
  */
-#define DECLARE_TRACE_WITH_CALLBACK(name, proto, args, reg, unreg)	\
+#define DECLARE_TRACE(name, proto, args)				\
 	extern struct tracepoint __tracepoint_##name;			\
 	static inline void trace_##name(proto)				\
 	{								\
@@ -73,36 +73,23 @@ struct tracepoint {
 	}								\
 	static inline int register_trace_##name(void (*probe)(proto))	\
 	{								\
-		int ret;						\
-		void (*func)(void) = reg;				\
-									\
-		ret = tracepoint_probe_register(#name, (void *)probe);	\
-		if (func && !ret)					\
-			func();						\
-		return ret;						\
+		return tracepoint_probe_register(#name, (void *)probe);	\
 	}								\
 	static inline int unregister_trace_##name(void (*probe)(proto))	\
 	{								\
-		int ret;						\
-		void (*func)(void) = unreg;				\
-									\
-		ret = tracepoint_probe_unregister(#name, (void *)probe);\
-		if (func && !ret)					\
-			func();						\
-		return ret;						\
+		return tracepoint_probe_unregister(#name, (void *)probe);\
 	}
 
 
-#define DECLARE_TRACE(name, proto, args)				 \
-	DECLARE_TRACE_WITH_CALLBACK(name, TP_PROTO(proto), TP_ARGS(args),\
-					NULL, NULL);
-
-#define DEFINE_TRACE(name)						\
+#define DEFINE_TRACE_FN(name, reg, unreg)				\
 	static const char __tpstrtab_##name[]				\
 	__attribute__((section("__tracepoints_strings"))) = #name;	\
 	struct tracepoint __tracepoint_##name				\
 	__attribute__((section("__tracepoints"), aligned(32))) =	\
-		{ __tpstrtab_##name, 0, NULL }
+		{ __tpstrtab_##name, 0, reg, unreg, NULL }
+
+#define DEFINE_TRACE(name)						\
+	DEFINE_TRACE_FN(name, NULL, NULL);
 
 #define EXPORT_TRACEPOINT_SYMBOL_GPL(name)				\
 	EXPORT_SYMBOL_GPL(__tracepoint_##name)
@@ -113,7 +100,7 @@ extern void tracepoint_update_probe_range(struct tracepoint *begin,
 	struct tracepoint *end);
 
 #else /* !CONFIG_TRACEPOINTS */
-#define DECLARE_TRACE_WITH_CALLBACK(name, proto, args, reg, unreg)	\
+#define DECLARE_TRACE(name, proto, args)				\
 	static inline void _do_trace_##name(struct tracepoint *tp, proto) \
 	{ }								\
 	static inline void trace_##name(proto)				\
@@ -127,10 +114,7 @@ extern void tracepoint_update_probe_range(struct tracepoint *begin,
 		return -ENOSYS;						\
 	}
 
-#define DECLARE_TRACE(name, proto, args)				 \
-	DECLARE_TRACE_WITH_CALLBACK(name, TP_PROTO(proto), TP_ARGS(args),\
-					NULL, NULL);
-
+#define DEFINE_TRACE_FN(name, reg, unreg)
 #define DEFINE_TRACE(name)
 #define EXPORT_TRACEPOINT_SYMBOL_GPL(name)
 #define EXPORT_TRACEPOINT_SYMBOL(name)
@@ -282,10 +266,16 @@ static inline void tracepoint_synchronize_unregister(void)
  * can also by used by generic instrumentation like SystemTap), and
  * it is also used to expose a structured trace record in
  * /sys/kernel/debug/tracing/events/.
+ *
+ * A set of (un)registration functions can be passed to the variant
+ * TRACE_EVENT_FN to perform any (un)registration work.
  */
 
 #define TRACE_EVENT(name, proto, args, struct, assign, print)	\
 	DECLARE_TRACE(name, PARAMS(proto), PARAMS(args))
+#define TRACE_EVENT_FN(name, proto, args, struct,		\
+		assign, print, reg, unreg)			\
+	DECLARE_TRACE(name, PARAMS(proto), PARAMS(args))
 #endif
 
 #endif
diff --git a/include/trace/define_trace.h b/include/trace/define_trace.h
index f7a7ae1..2a96985 100644
--- a/include/trace/define_trace.h
+++ b/include/trace/define_trace.h
@@ -26,6 +26,11 @@
 #define TRACE_EVENT(name, proto, args, tstruct, assign, print)	\
 	DEFINE_TRACE(name)
 
+#undef TRACE_EVENT_FN
+#define TRACE_EVENT_FN(name, proto, args, tstruct,		\
+		assign, print, reg, unreg)			\
+	DEFINE_TRACE_FN(name, reg, unreg)
+
 #undef DECLARE_TRACE
 #define DECLARE_TRACE(name, proto, args)	\
 	DEFINE_TRACE(name)
diff --git a/include/trace/ftrace.h b/include/trace/ftrace.h
index 1274002..3a0b44b 100644
--- a/include/trace/ftrace.h
+++ b/include/trace/ftrace.h
@@ -42,6 +42,15 @@
 	};							\
 	static struct ftrace_event_call event_##name
 
+/* Callbacks are meaningless to ftrace. */
+#undef TRACE_EVENT_FN
+#define TRACE_EVENT_FN(name, proto, args, tstruct,		\
+		assign, print, reg, unreg)			\
+	TRACE_EVENT(name, TP_PROTO(proto), TP_ARGS(args),	\
+		TP_STRUCT__entry(tstruct),			\
+		TP_fast_assign(assign),				\
+		TP_printk(print))
+
 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
 
 
diff --git a/include/trace/syscall.h b/include/trace/syscall.h
index 5dcb7e3..4e19430 100644
--- a/include/trace/syscall.h
+++ b/include/trace/syscall.h
@@ -13,18 +13,14 @@
 extern void syscall_regfunc(void);
 extern void syscall_unregfunc(void);
 
-DECLARE_TRACE_WITH_CALLBACK(syscall_enter,
+DECLARE_TRACE(syscall_enter,
 	TP_PROTO(struct pt_regs *regs, long id),
-	TP_ARGS(regs, id),
-	syscall_regfunc,
-	syscall_unregfunc
+	TP_ARGS(regs, id)
 );
 
-DECLARE_TRACE_WITH_CALLBACK(syscall_exit,
+DECLARE_TRACE(syscall_exit,
 	TP_PROTO(struct pt_regs *regs, long ret),
-	TP_ARGS(regs, ret),
-	syscall_regfunc,
-	syscall_unregfunc
+	TP_ARGS(regs, ret)
 );
 
 #endif
diff --git a/kernel/tracepoint.c b/kernel/tracepoint.c
index 9e0a36f..1a6a453 100644
--- a/kernel/tracepoint.c
+++ b/kernel/tracepoint.c
@@ -243,6 +243,11 @@ static void set_tracepoint(struct tracepoint_entry **entry,
 {
 	WARN_ON(strcmp((*entry)->name, elem->name) != 0);
 
+	if (elem->regfunc && !elem->state && active)
+		elem->regfunc();
+	else if (elem->unregfunc && elem->state && !active)
+		elem->unregfunc();
+
 	/*
 	 * rcu_assign_pointer has a smp_wmb() which makes sure that the new
 	 * probe callbacks array is consistent before setting a pointer to it.
@@ -262,6 +267,9 @@ static void set_tracepoint(struct tracepoint_entry **entry,
  */
 static void disable_tracepoint(struct tracepoint *elem)
 {
+	if (elem->unregfunc && elem->state)
+		elem->unregfunc();
+
 	elem->state = 0;
 	rcu_assign_pointer(elem->funcs, NULL);
 }
@@ -578,7 +586,7 @@ __initcall(init_tracepoints);
 
 #ifdef CONFIG_HAVE_SYSCALL_TRACEPOINTS
 
-static DEFINE_MUTEX(regfunc_mutex);
+/* NB: reg/unreg are called while guarded with the tracepoints_mutex */
 static int sys_tracepoint_refcount;
 
 void syscall_regfunc(void)
@@ -586,7 +594,6 @@ void syscall_regfunc(void)
 	unsigned long flags;
 	struct task_struct *g, *t;
 
-	mutex_lock(&regfunc_mutex);
 	if (!sys_tracepoint_refcount) {
 		read_lock_irqsave(&tasklist_lock, flags);
 		do_each_thread(g, t) {
@@ -595,7 +602,6 @@ void syscall_regfunc(void)
 		read_unlock_irqrestore(&tasklist_lock, flags);
 	}
 	sys_tracepoint_refcount++;
-	mutex_unlock(&regfunc_mutex);
 }
 
 void syscall_unregfunc(void)
@@ -603,7 +609,6 @@ void syscall_unregfunc(void)
 	unsigned long flags;
 	struct task_struct *g, *t;
 
-	mutex_lock(&regfunc_mutex);
 	sys_tracepoint_refcount--;
 	if (!sys_tracepoint_refcount) {
 		read_lock_irqsave(&tasklist_lock, flags);
@@ -612,6 +617,5 @@ void syscall_unregfunc(void)
 		} while_each_thread(g, t);
 		read_unlock_irqrestore(&tasklist_lock, flags);
 	}
-	mutex_unlock(&regfunc_mutex);
 }
 #endif

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

* [tip:tracing/core] tracing: Create generic syscall TRACE_EVENTs
  2009-08-24 21:43             ` [PATCH v4 4/4] tracing: Create generic syscall TRACE_EVENTs Josh Stone
@ 2009-08-26  7:22               ` tip-bot for Josh Stone
  0 siblings, 0 replies; 70+ messages in thread
From: tip-bot for Josh Stone @ 2009-08-26  7:22 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: mathieu.desnoyers, mingo, schwidefsky, peterz, fweisbec, rostedt,
	heiko.carstens, tglx, jbaron, laijs, linux-kernel, hpa, jiayingz,
	lizf, lethal, jistone, mingo, mbligh

Commit-ID:  1c569f0264ea629c10bbab471dd0626ce4d3f19f
Gitweb:     http://git.kernel.org/tip/1c569f0264ea629c10bbab471dd0626ce4d3f19f
Author:     Josh Stone <jistone@redhat.com>
AuthorDate: Mon, 24 Aug 2009 14:43:14 -0700
Committer:  Frederic Weisbecker <fweisbec@gmail.com>
CommitDate: Wed, 26 Aug 2009 00:41:48 +0200

tracing: Create generic syscall TRACE_EVENTs

This converts the syscall_enter/exit tracepoints into TRACE_EVENTs, so
you can have generic ftrace events that capture all system calls with
arguments and return values.  These generic events are also renamed to
sys_enter/exit, so they're more closely aligned to the specific
sys_enter_foo events.

Signed-off-by: Josh Stone <jistone@redhat.com>
Cc: Jason Baron <jbaron@redhat.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Li Zefan <lizf@cn.fujitsu.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
Cc: Jiaying Zhang <jiayingz@google.com>
Cc: Martin Bligh <mbligh@google.com>
Cc: Lai Jiangshan <laijs@cn.fujitsu.com>
Cc: Paul Mundt <lethal@linux-sh.org>
Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
LKML-Reference: <1251150194-1713-5-git-send-email-jistone@redhat.com>
Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>


---
 arch/s390/kernel/ptrace.c       |    8 ++--
 arch/x86/kernel/ptrace.c        |   12 +++----
 include/trace/events/syscalls.h |   70 +++++++++++++++++++++++++++++++++++++++
 include/trace/syscall.h         |   17 ---------
 kernel/trace/trace_syscalls.c   |   17 +++++----
 5 files changed, 88 insertions(+), 36 deletions(-)

diff --git a/arch/s390/kernel/ptrace.c b/arch/s390/kernel/ptrace.c
index c05b44b..f3ddd7a 100644
--- a/arch/s390/kernel/ptrace.c
+++ b/arch/s390/kernel/ptrace.c
@@ -51,8 +51,8 @@
 #include "compat_ptrace.h"
 #endif
 
-DEFINE_TRACE_FN(syscall_enter, syscall_regfunc, syscall_unregfunc);
-DEFINE_TRACE_FN(syscall_exit, syscall_regfunc, syscall_unregfunc);
+#define CREATE_TRACE_POINTS
+#include <trace/events/syscalls.h>
 
 enum s390_regset {
 	REGSET_GENERAL,
@@ -665,7 +665,7 @@ asmlinkage long do_syscall_trace_enter(struct pt_regs *regs)
 	}
 
 	if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
-		trace_syscall_enter(regs, regs->gprs[2]);
+		trace_sys_enter(regs, regs->gprs[2]);
 
 	if (unlikely(current->audit_context))
 		audit_syscall_entry(is_compat_task() ?
@@ -683,7 +683,7 @@ asmlinkage void do_syscall_trace_exit(struct pt_regs *regs)
 				   regs->gprs[2]);
 
 	if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
-		trace_syscall_exit(regs, regs->gprs[2]);
+		trace_sys_exit(regs, regs->gprs[2]);
 
 	if (test_thread_flag(TIF_SYSCALL_TRACE))
 		tracehook_report_syscall_exit(regs, 0);
diff --git a/arch/x86/kernel/ptrace.c b/arch/x86/kernel/ptrace.c
index 31e9b97..8d7d5c9 100644
--- a/arch/x86/kernel/ptrace.c
+++ b/arch/x86/kernel/ptrace.c
@@ -35,13 +35,11 @@
 #include <asm/proto.h>
 #include <asm/ds.h>
 
-#include <trace/syscall.h>
-
-DEFINE_TRACE_FN(syscall_enter, syscall_regfunc, syscall_unregfunc);
-DEFINE_TRACE_FN(syscall_exit, syscall_regfunc, syscall_unregfunc);
-
 #include "tls.h"
 
+#define CREATE_TRACE_POINTS
+#include <trace/events/syscalls.h>
+
 enum x86_regset {
 	REGSET_GENERAL,
 	REGSET_FP,
@@ -1501,7 +1499,7 @@ asmregparm long syscall_trace_enter(struct pt_regs *regs)
 		ret = -1L;
 
 	if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
-		trace_syscall_enter(regs, regs->orig_ax);
+		trace_sys_enter(regs, regs->orig_ax);
 
 	if (unlikely(current->audit_context)) {
 		if (IS_IA32)
@@ -1527,7 +1525,7 @@ asmregparm void syscall_trace_leave(struct pt_regs *regs)
 		audit_syscall_exit(AUDITSC_RESULT(regs->ax), regs->ax);
 
 	if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
-		trace_syscall_exit(regs, regs->ax);
+		trace_sys_exit(regs, regs->ax);
 
 	if (test_thread_flag(TIF_SYSCALL_TRACE))
 		tracehook_report_syscall_exit(regs, 0);
diff --git a/include/trace/events/syscalls.h b/include/trace/events/syscalls.h
new file mode 100644
index 0000000..397dff2
--- /dev/null
+++ b/include/trace/events/syscalls.h
@@ -0,0 +1,70 @@
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM syscalls
+
+#if !defined(_TRACE_EVENTS_SYSCALLS_H) || defined(TRACE_HEADER_MULTI_READ)
+#define _TRACE_EVENTS_SYSCALLS_H
+
+#include <linux/tracepoint.h>
+
+#include <asm/ptrace.h>
+#include <asm/syscall.h>
+
+
+#ifdef CONFIG_HAVE_SYSCALL_TRACEPOINTS
+
+extern void syscall_regfunc(void);
+extern void syscall_unregfunc(void);
+
+TRACE_EVENT_FN(sys_enter,
+
+	TP_PROTO(struct pt_regs *regs, long id),
+
+	TP_ARGS(regs, id),
+
+	TP_STRUCT__entry(
+		__field(	long,		id		)
+		__array(	unsigned long,	args,	6	)
+	),
+
+	TP_fast_assign(
+		__entry->id	= id;
+		syscall_get_arguments(current, regs, 0, 6, __entry->args);
+	),
+
+	TP_printk("NR %ld (%lx, %lx, %lx, %lx, %lx, %lx)",
+		  __entry->id,
+		  __entry->args[0], __entry->args[1], __entry->args[2],
+		  __entry->args[3], __entry->args[4], __entry->args[5]),
+
+	syscall_regfunc, syscall_unregfunc
+);
+
+TRACE_EVENT_FN(sys_exit,
+
+	TP_PROTO(struct pt_regs *regs, long ret),
+
+	TP_ARGS(regs, ret),
+
+	TP_STRUCT__entry(
+		__field(	long,	id	)
+		__field(	long,	ret	)
+	),
+
+	TP_fast_assign(
+		__entry->id	= syscall_get_nr(current, regs);
+		__entry->ret	= ret;
+	),
+
+	TP_printk("NR %ld = %ld",
+		  __entry->id, __entry->ret),
+
+	syscall_regfunc, syscall_unregfunc
+);
+
+#endif /* CONFIG_HAVE_SYSCALL_TRACEPOINTS */
+
+#endif /* _TRACE_EVENTS_SYSCALLS_H */
+
+/* This part must be outside protection */
+#include <trace/define_trace.h>
+
diff --git a/include/trace/syscall.h b/include/trace/syscall.h
index 4e19430..5dc283b 100644
--- a/include/trace/syscall.h
+++ b/include/trace/syscall.h
@@ -8,23 +8,6 @@
 #include <asm/ptrace.h>
 
 
-#ifdef CONFIG_HAVE_SYSCALL_TRACEPOINTS
-
-extern void syscall_regfunc(void);
-extern void syscall_unregfunc(void);
-
-DECLARE_TRACE(syscall_enter,
-	TP_PROTO(struct pt_regs *regs, long id),
-	TP_ARGS(regs, id)
-);
-
-DECLARE_TRACE(syscall_exit,
-	TP_PROTO(struct pt_regs *regs, long ret),
-	TP_ARGS(regs, ret)
-);
-
-#endif
-
 /*
  * A syscall entry in the ftrace syscalls array.
  *
diff --git a/kernel/trace/trace_syscalls.c b/kernel/trace/trace_syscalls.c
index 46c1b97..2698fe4 100644
--- a/kernel/trace/trace_syscalls.c
+++ b/kernel/trace/trace_syscalls.c
@@ -1,4 +1,5 @@
 #include <trace/syscall.h>
+#include <trace/events/syscalls.h>
 #include <linux/kernel.h>
 #include <linux/ftrace.h>
 #include <linux/perf_counter.h>
@@ -286,7 +287,7 @@ int reg_event_syscall_enter(void *ptr)
 		return -ENOSYS;
 	mutex_lock(&syscall_trace_lock);
 	if (!sys_refcount_enter)
-		ret = register_trace_syscall_enter(ftrace_syscall_enter);
+		ret = register_trace_sys_enter(ftrace_syscall_enter);
 	if (ret) {
 		pr_info("event trace: Could not activate"
 				"syscall entry trace point");
@@ -311,7 +312,7 @@ void unreg_event_syscall_enter(void *ptr)
 	sys_refcount_enter--;
 	clear_bit(num, enabled_enter_syscalls);
 	if (!sys_refcount_enter)
-		unregister_trace_syscall_enter(ftrace_syscall_enter);
+		unregister_trace_sys_enter(ftrace_syscall_enter);
 	mutex_unlock(&syscall_trace_lock);
 }
 
@@ -327,7 +328,7 @@ int reg_event_syscall_exit(void *ptr)
 		return -ENOSYS;
 	mutex_lock(&syscall_trace_lock);
 	if (!sys_refcount_exit)
-		ret = register_trace_syscall_exit(ftrace_syscall_exit);
+		ret = register_trace_sys_exit(ftrace_syscall_exit);
 	if (ret) {
 		pr_info("event trace: Could not activate"
 				"syscall exit trace point");
@@ -352,7 +353,7 @@ void unreg_event_syscall_exit(void *ptr)
 	sys_refcount_exit--;
 	clear_bit(num, enabled_exit_syscalls);
 	if (!sys_refcount_exit)
-		unregister_trace_syscall_exit(ftrace_syscall_exit);
+		unregister_trace_sys_exit(ftrace_syscall_exit);
 	mutex_unlock(&syscall_trace_lock);
 }
 
@@ -418,7 +419,7 @@ int reg_prof_syscall_enter(char *name)
 
 	mutex_lock(&syscall_trace_lock);
 	if (!sys_prof_refcount_enter)
-		ret = register_trace_syscall_enter(prof_syscall_enter);
+		ret = register_trace_sys_enter(prof_syscall_enter);
 	if (ret) {
 		pr_info("event trace: Could not activate"
 				"syscall entry trace point");
@@ -442,7 +443,7 @@ void unreg_prof_syscall_enter(char *name)
 	sys_prof_refcount_enter--;
 	clear_bit(num, enabled_prof_enter_syscalls);
 	if (!sys_prof_refcount_enter)
-		unregister_trace_syscall_enter(prof_syscall_enter);
+		unregister_trace_sys_enter(prof_syscall_enter);
 	mutex_unlock(&syscall_trace_lock);
 }
 
@@ -479,7 +480,7 @@ int reg_prof_syscall_exit(char *name)
 
 	mutex_lock(&syscall_trace_lock);
 	if (!sys_prof_refcount_exit)
-		ret = register_trace_syscall_exit(prof_syscall_exit);
+		ret = register_trace_sys_exit(prof_syscall_exit);
 	if (ret) {
 		pr_info("event trace: Could not activate"
 				"syscall entry trace point");
@@ -503,7 +504,7 @@ void unreg_prof_syscall_exit(char *name)
 	sys_prof_refcount_exit--;
 	clear_bit(num, enabled_prof_exit_syscalls);
 	if (!sys_prof_refcount_exit)
-		unregister_trace_syscall_exit(prof_syscall_exit);
+		unregister_trace_sys_exit(prof_syscall_exit);
 	mutex_unlock(&syscall_trace_lock);
 }
 

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

* [PATCH] tracing: Fix double CPP substitution in TRACE_EVENT_FN
  2009-08-26  7:22             ` [tip:tracing/core] tracing: Move tracepoint callbacks from declaration to definition tip-bot for Josh Stone
@ 2009-08-27 22:50               ` Frederic Weisbecker
  2009-08-28  0:38                 ` Josh Stone
  2009-08-28 12:29                 ` [tip:tracing/core] " tip-bot for Frederic Weisbecker
  0 siblings, 2 replies; 70+ messages in thread
From: Frederic Weisbecker @ 2009-08-27 22:50 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: LKML, Frederic Weisbecker, Josh Stone, Li Zefan, Steven Rostedt,
	Jason Baron

TRACE_EVENT_FN relays on TRACE_EVENT by reprocessing its parameters
into the ftrace events CPP macro. This leads to a double substitution
in some cases.

For example, a bad consequence is a format always prefixed by
"%s, %s\n" for every TRACE_EVENT_FN based events.

Eg:
	cat /debug/tracing/events/syscalls/sys_enter/format
	[...]
	print fmt: "%s, %s\n", "\"NR %ld (%lx, %lx, %lx, %lx, %lx, %lx)\"",\
	"REC->id, REC->args[0], REC->args[1], REC->args[2], REC->args[3],\
	REC->args[4], REC->args[5]"

This creates a failure in post-processing tools such as perf trace or
trace-cmd.

Then drop this double substitution and replace it by a new __cpparg()
macro that relays CPP arguments containing commas.

Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Josh Stone <jistone@redhat.com>
Cc: Li Zefan <lizf@cn.fujitsu.com>
Cc: Steven Rostedt <srostedt@redhat.com>
Cc: Jason Baron <jbaron@redhat.com>
---
 include/trace/ftrace.h |   13 +++++++------
 1 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/include/trace/ftrace.h b/include/trace/ftrace.h
index 360a77a..57c56a9 100644
--- a/include/trace/ftrace.h
+++ b/include/trace/ftrace.h
@@ -45,14 +45,15 @@
 	};							\
 	static struct ftrace_event_call event_##name
 
+#undef __cpparg
+#define __cpparg(arg...) arg
+
 /* Callbacks are meaningless to ftrace. */
 #undef TRACE_EVENT_FN
-#define TRACE_EVENT_FN(name, proto, args, tstruct,		\
-		assign, print, reg, unreg)			\
-	TRACE_EVENT(name, TP_PROTO(proto), TP_ARGS(args),	\
-		TP_STRUCT__entry(tstruct),			\
-		TP_fast_assign(assign),				\
-		TP_printk(print))
+#define TRACE_EVENT_FN(name, proto, args, tstruct,			\
+		assign, print, reg, unreg)				\
+	TRACE_EVENT(name, __cpparg(proto), __cpparg(args),		\
+		__cpparg(tstruct), __cpparg(assign), __cpparg(print))	\
 
 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
 
-- 
1.6.2.3


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

* Re: [PATCH] tracing: Fix double CPP substitution in TRACE_EVENT_FN
  2009-08-27 22:50               ` [PATCH] tracing: Fix double CPP substitution in TRACE_EVENT_FN Frederic Weisbecker
@ 2009-08-28  0:38                 ` Josh Stone
  2009-08-28 12:29                 ` [tip:tracing/core] " tip-bot for Frederic Weisbecker
  1 sibling, 0 replies; 70+ messages in thread
From: Josh Stone @ 2009-08-28  0:38 UTC (permalink / raw)
  To: Frederic Weisbecker
  Cc: Ingo Molnar, LKML, Li Zefan, Steven Rostedt, Jason Baron

On 08/27/2009 03:50 PM, Frederic Weisbecker wrote:
> TRACE_EVENT_FN relays on TRACE_EVENT by reprocessing its parameters
> into the ftrace events CPP macro. This leads to a double substitution
> in some cases.
> 
> For example, a bad consequence is a format always prefixed by
> "%s, %s\n" for every TRACE_EVENT_FN based events.
> 
> Eg:
> 	cat /debug/tracing/events/syscalls/sys_enter/format
> 	[...]
> 	print fmt: "%s, %s\n", "\"NR %ld (%lx, %lx, %lx, %lx, %lx, %lx)\"",\
> 	"REC->id, REC->args[0], REC->args[1], REC->args[2], REC->args[3],\
> 	REC->args[4], REC->args[5]"
> 
> This creates a failure in post-processing tools such as perf trace or
> trace-cmd.

Fun - I didn't think about TP_printk and friends doing anything beside
passing their contents along.

> 
> Then drop this double substitution and replace it by a new __cpparg()
> macro that relays CPP arguments containing commas.

Looks good to me.

> 
> Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
> Cc: Josh Stone <jistone@redhat.com>
> Cc: Li Zefan <lizf@cn.fujitsu.com>
> Cc: Steven Rostedt <srostedt@redhat.com>
> Cc: Jason Baron <jbaron@redhat.com>

Reviewed-by: Josh Stone <jistone@redhat.com>

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

* [tip:tracing/core] tracing: Fix double CPP substitution in TRACE_EVENT_FN
  2009-08-27 22:50               ` [PATCH] tracing: Fix double CPP substitution in TRACE_EVENT_FN Frederic Weisbecker
  2009-08-28  0:38                 ` Josh Stone
@ 2009-08-28 12:29                 ` tip-bot for Frederic Weisbecker
  1 sibling, 0 replies; 70+ messages in thread
From: tip-bot for Frederic Weisbecker @ 2009-08-28 12:29 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, hpa, mingo, lizf, jistone, fweisbec, srostedt,
	tglx, jbaron, mingo

Commit-ID:  0dd7b74787eaf7858c6c573353a83c3e2766e674
Gitweb:     http://git.kernel.org/tip/0dd7b74787eaf7858c6c573353a83c3e2766e674
Author:     Frederic Weisbecker <fweisbec@gmail.com>
AuthorDate: Fri, 28 Aug 2009 00:50:06 +0200
Committer:  Ingo Molnar <mingo@elte.hu>
CommitDate: Fri, 28 Aug 2009 13:55:04 +0200

tracing: Fix double CPP substitution in TRACE_EVENT_FN

TRACE_EVENT_FN relays on TRACE_EVENT by reprocessing its parameters
into the ftrace events CPP macro. This leads to a double substitution
in some cases.

For example, a bad consequence is a format always prefixed by
"%s, %s\n" for every TRACE_EVENT_FN based events.

Eg:
	cat /debug/tracing/events/syscalls/sys_enter/format
	[...]
	print fmt: "%s, %s\n", "\"NR %ld (%lx, %lx, %lx, %lx, %lx, %lx)\"",\
	"REC->id, REC->args[0], REC->args[1], REC->args[2], REC->args[3],\
	REC->args[4], REC->args[5]"

This creates a failure in post-processing tools such as perf trace or
trace-cmd.

Then drop this double substitution and replace it by a new __cpparg()
macro that relays CPP arguments containing commas.

Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Josh Stone <jistone@redhat.com>
Cc: Li Zefan <lizf@cn.fujitsu.com>
Cc: Steven Rostedt <srostedt@redhat.com>
Cc: Jason Baron <jbaron@redhat.com>
LKML-Reference: <1251413406-6704-1-git-send-email-fweisbec@gmail.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>


---
 include/trace/ftrace.h |   13 +++++++------
 1 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/include/trace/ftrace.h b/include/trace/ftrace.h
index 360a77a..57c56a9 100644
--- a/include/trace/ftrace.h
+++ b/include/trace/ftrace.h
@@ -45,14 +45,15 @@
 	};							\
 	static struct ftrace_event_call event_##name
 
+#undef __cpparg
+#define __cpparg(arg...) arg
+
 /* Callbacks are meaningless to ftrace. */
 #undef TRACE_EVENT_FN
-#define TRACE_EVENT_FN(name, proto, args, tstruct,		\
-		assign, print, reg, unreg)			\
-	TRACE_EVENT(name, TP_PROTO(proto), TP_ARGS(args),	\
-		TP_STRUCT__entry(tstruct),			\
-		TP_fast_assign(assign),				\
-		TP_printk(print))
+#define TRACE_EVENT_FN(name, proto, args, tstruct,			\
+		assign, print, reg, unreg)				\
+	TRACE_EVENT(name, __cpparg(proto), __cpparg(args),		\
+		__cpparg(tstruct), __cpparg(assign), __cpparg(print))	\
 
 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
 

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

end of thread, other threads:[~2009-08-28 12:29 UTC | newest]

Thread overview: 70+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-08-18  7:23 [PATCH] tracing: Move tracepoint callbacks into DEFINE Josh Stone
2009-08-18 14:19 ` Jason Baron
2009-08-18 22:11   ` Josh Stone
2009-08-18 22:25 ` [PATCH] tracing: Create generic syscall TRACE_EVENTs Josh Stone
2009-08-19  1:32   ` Li Zefan
2009-08-19  3:05     ` Josh Stone
2009-08-19 13:05       ` Ingo Molnar
2009-08-19 13:50         ` Mathieu Desnoyers
2009-08-19 16:16   ` Jason Baron
2009-08-19 17:43     ` Frederic Weisbecker
2009-08-19 16:13 ` [PATCH] tracing: Move tracepoint callbacks into DEFINE Jason Baron
2009-08-20 17:25   ` Josh Stone
2009-08-20 19:09 ` [PATCH v2 1/2] " Josh Stone
2009-08-20 19:09   ` [PATCH v2 2/2] tracing: Create generic syscall TRACE_EVENTs Josh Stone
2009-08-21 17:57     ` Jason Baron
2009-08-21 19:37       ` Josh Stone
2009-08-21 20:08         ` Jason Baron
2009-08-21 14:47   ` [PATCH v2 1/2] tracing: Move tracepoint callbacks into DEFINE Ingo Molnar
2009-08-21 19:34     ` Josh Stone
2009-08-21 17:52   ` Jason Baron
2009-08-21 19:34     ` Josh Stone
2009-08-21 20:06       ` Jason Baron
2009-08-23 20:29         ` Frederic Weisbecker
2009-08-23 20:15       ` Frederic Weisbecker
2009-08-22  4:58   ` [PATCH v3 0/4] tracing: tweaks for generic syscall events Josh Stone
2009-08-22  4:58     ` [PATCH v3 1/4] tracing: Rename TIF_SYSCALL_FTRACE->_TRACEPOINT Josh Stone
2009-08-22  4:58       ` [PATCH v3 2/4] tracing: Make syscall_(un)regfunc arch-specific Josh Stone
2009-08-22  4:58         ` [PATCH v3 3/4] tracing: Move tracepoint callbacks into DEFINE Josh Stone
2009-08-22  4:58           ` [PATCH v3 4/4] tracing: Create generic syscall TRACE_EVENTs Josh Stone
2009-08-23 21:14         ` [PATCH v3 2/4] tracing: Make syscall_(un)regfunc arch-specific Frederic Weisbecker
2009-08-24  1:40           ` Paul Mundt
2009-08-24  8:41             ` Ingo Molnar
2009-08-24  8:59               ` Paul Mundt
2009-08-24  9:56                 ` Ingo Molnar
2009-08-24 10:32                   ` Paul Mundt
2009-08-24 11:00                     ` Ingo Molnar
2009-08-24 11:15                       ` Paul Mundt
2009-08-24 11:32                         ` Ingo Molnar
2009-08-24 11:52                     ` Ingo Molnar
2009-08-24 12:14                       ` Peter Zijlstra
2009-08-24 11:01                   ` Ingo Molnar
2009-08-24 11:02                     ` Paul Mundt
2009-08-24 19:31           ` Josh Stone
2009-08-24 19:58             ` Frederic Weisbecker
2009-08-24 20:00               ` Josh Stone
2009-08-24 20:12                 ` Frederic Weisbecker
2009-08-23 21:16       ` [PATCH v3 1/4] tracing: Rename TIF_SYSCALL_FTRACE->_TRACEPOINT Frederic Weisbecker
2009-08-24  8:42         ` Ingo Molnar
2009-08-24 11:11           ` Frederic Weisbecker
2009-08-24 11:24             ` Ingo Molnar
2009-08-24 11:29               ` Paul Mundt
2009-08-24 11:36                 ` Ingo Molnar
2009-08-24 21:43     ` [PATCH v4 0/4] tracing: tweaks for generic syscall events Josh Stone
2009-08-24 21:43       ` [PATCH v4 1/4] tracing: Rename FTRACE_SYSCALLS for tracepoints Josh Stone
2009-08-24 21:43         ` [PATCH v4 2/4] tracing: Make syscall tracepoints conditional Josh Stone
2009-08-24 21:43           ` [PATCH v4 3/4] tracing: Move tracepoint callbacks into DEFINE Josh Stone
2009-08-24 21:43             ` [PATCH v4 4/4] tracing: Create generic syscall TRACE_EVENTs Josh Stone
2009-08-26  7:22               ` [tip:tracing/core] " tip-bot for Josh Stone
2009-08-26  7:22             ` [tip:tracing/core] tracing: Move tracepoint callbacks from declaration to definition tip-bot for Josh Stone
2009-08-27 22:50               ` [PATCH] tracing: Fix double CPP substitution in TRACE_EVENT_FN Frederic Weisbecker
2009-08-28  0:38                 ` Josh Stone
2009-08-28 12:29                 ` [tip:tracing/core] " tip-bot for Frederic Weisbecker
2009-08-26  7:21           ` [tip:tracing/core] tracing: Make syscall tracepoints conditional tip-bot for Josh Stone
2009-08-26  7:21         ` [tip:tracing/core] tracing: Rename FTRACE_SYSCALLS for tracepoints tip-bot for Josh Stone
2009-08-24 23:05       ` [PATCH v4 0/4] tracing: tweaks for generic syscall events Frederic Weisbecker
2009-08-25 10:28         ` Ingo Molnar
2009-08-25 13:42           ` Frederic Weisbecker
2009-08-25 14:41             ` Jason Baron
2009-08-25 21:08               ` Frederic Weisbecker
2009-08-25 21:44       ` Frederic Weisbecker

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.