LKML Archive mirror
 help / color / mirror / Atom feed
* [PATCH] tracepoints: add check trace callback type
@ 2010-04-30 16:59 Mathieu Desnoyers
  2010-05-21 17:09 ` [tip:perf/core] tracepoints: Add " tip-bot for Mathieu Desnoyers
  0 siblings, 1 reply; 2+ messages in thread
From: Mathieu Desnoyers @ 2010-04-30 16:59 UTC (permalink / raw
  To: Steven Rostedt
  Cc: linux-kernel, Ingo Molnar, Andrew Morton, Thomas Gleixner,
	Peter Zijlstra, Frederic Weisbecker, Arnaldo Carvalho de Melo,
	Lai Jiangshan, Li Zefan, Masami Hiramatsu, Christoph Hellwig

This check is meant to be used by tracepoint users which do a direct cast of
callbacks to (void *) for direct registration, thus bypassing the
register_trace_##name and unregister_trace_##name checks.

This permits to ensure that the callback type matches the function type at the
call site, but without generating any code.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
CC: Steven Rostedt <rostedt@goodmis.org>
CC: Ingo Molnar <mingo@elte.hu> 
CC: Andrew Morton <akpm@linux-foundation.org> 
CC: Thomas Gleixner <tglx@linutronix.de> 
CC: Peter Zijlstra <peterz@infradead.org> 
CC: Frederic Weisbecker <fweisbec@gmail.com> 
CC: Arnaldo Carvalho de Melo <acme@redhat.com> 
CC: Lai Jiangshan <laijs@cn.fujitsu.com> 
CC: Li Zefan <lizf@cn.fujitsu.com> 
CC: Masami Hiramatsu <mhiramat@redhat.com> 
CC: Christoph Hellwig <hch@lst.de>
---
 include/linux/tracepoint.h |    7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

Index: linux.trees.git/include/linux/tracepoint.h
===================================================================
--- linux.trees.git.orig/include/linux/tracepoint.h	2010-04-30 12:32:39.000000000 -0400
+++ linux.trees.git/include/linux/tracepoint.h	2010-04-30 12:57:55.000000000 -0400
@@ -78,9 +78,11 @@ struct tracepoint {
 	static inline int unregister_trace_##name(void (*probe)(proto))	\
 	{								\
 		return tracepoint_probe_unregister(#name, (void *)probe);\
+	}								\
+	static inline void check_trace_callback_type_##name(void (*cb)(proto)) \
+	{								\
 	}
 
-
 #define DEFINE_TRACE_FN(name, reg, unreg)				\
 	static const char __tpstrtab_##name[]				\
 	__attribute__((section("__tracepoints_strings"))) = #name;	\
@@ -112,6 +114,9 @@ extern void tracepoint_update_probe_rang
 	static inline int unregister_trace_##name(void (*probe)(proto))	\
 	{								\
 		return -ENOSYS;						\
+	}								\
+	static inline void check_trace_callback_type_##name(void (*cb)(proto)) \
+	{								\
 	}
 
 #define DEFINE_TRACE_FN(name, reg, unreg)

-- 
Mathieu Desnoyers
Operating System Efficiency R&D Consultant
EfficiOS Inc.
http://www.efficios.com

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

* [tip:perf/core] tracepoints: Add check trace callback type
  2010-04-30 16:59 [PATCH] tracepoints: add check trace callback type Mathieu Desnoyers
@ 2010-05-21 17:09 ` tip-bot for Mathieu Desnoyers
  0 siblings, 0 replies; 2+ messages in thread
From: tip-bot for Mathieu Desnoyers @ 2010-05-21 17:09 UTC (permalink / raw
  To: linux-tip-commits
  Cc: acme, linux-kernel, hpa, mingo, mathieu.desnoyers, lizf, peterz,
	fweisbec, rostedt, hch, akpm, tglx, laijs, mhiramat, mingo

Commit-ID:  53da59aa6dd881fd0bbdd058a8a299d90ce9dd1d
Gitweb:     http://git.kernel.org/tip/53da59aa6dd881fd0bbdd058a8a299d90ce9dd1d
Author:     Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
AuthorDate: Fri, 30 Apr 2010 12:59:59 -0400
Committer:  Steven Rostedt <rostedt@goodmis.org>
CommitDate: Fri, 14 May 2010 09:34:26 -0400

tracepoints: Add check trace callback type

This check is meant to be used by tracepoint users which do a direct cast of
callbacks to (void *) for direct registration, thus bypassing the
register_trace_##name and unregister_trace_##name checks.

This permits to ensure that the callback type matches the function type at the
call site, but without generating any code.

Acked-by: Masami Hiramatsu <mhiramat@redhat.com>
Acked-by: Frederic Weisbecker <fweisbec@gmail.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
LKML-Reference: <20100430165959.GA25605@Krystal>
CC: Ingo Molnar <mingo@elte.hu>
CC: Andrew Morton <akpm@linux-foundation.org>
CC: Thomas Gleixner <tglx@linutronix.de>
CC: Peter Zijlstra <peterz@infradead.org>
CC: Arnaldo Carvalho de Melo <acme@redhat.com>
CC: Lai Jiangshan <laijs@cn.fujitsu.com>
CC: Li Zefan <lizf@cn.fujitsu.com>
CC: Christoph Hellwig <hch@lst.de>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
 include/linux/tracepoint.h |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/include/linux/tracepoint.h b/include/linux/tracepoint.h
index 1d85f9a..8d5e4f6 100644
--- a/include/linux/tracepoint.h
+++ b/include/linux/tracepoint.h
@@ -137,9 +137,11 @@ static inline void tracepoint_update_probe_range(struct tracepoint *begin,
 	static inline int unregister_trace_##name(void (*probe)(proto))	\
 	{								\
 		return tracepoint_probe_unregister(#name, (void *)probe);\
+	}								\
+	static inline void check_trace_callback_type_##name(void (*cb)(proto)) \
+	{								\
 	}
 
-
 #define DEFINE_TRACE_FN(name, reg, unreg)				\
 	static const char __tpstrtab_##name[]				\
 	__attribute__((section("__tracepoints_strings"))) = #name;	\
@@ -168,6 +170,9 @@ static inline void tracepoint_update_probe_range(struct tracepoint *begin,
 	static inline int unregister_trace_##name(void (*probe)(proto))	\
 	{								\
 		return -ENOSYS;						\
+	}								\
+	static inline void check_trace_callback_type_##name(void (*cb)(proto)) \
+	{								\
 	}
 
 #define DEFINE_TRACE_FN(name, reg, unreg)

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

end of thread, other threads:[~2010-05-21 17:11 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-04-30 16:59 [PATCH] tracepoints: add check trace callback type Mathieu Desnoyers
2010-05-21 17:09 ` [tip:perf/core] tracepoints: Add " tip-bot for Mathieu Desnoyers

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).