public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
To: Ingo Molnar <mingo@elte.hu>, linux-kernel@vger.kernel.org
Cc: akpm@linux-foundation.org,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>,
	Lai Jiangshan <laijs@cn.fujitsu.com>
Subject: [patch 07/16] Markers : create DEFINE_MARKER and GET_MARKER (new API)
Date: Fri, 14 Nov 2008 17:47:40 -0500	[thread overview]
Message-ID: <20081114224948.293222043@polymtl.ca> (raw)
In-Reply-To: 20081114224733.364965865@polymtl.ca

[-- Attachment #1: markers-define-get.patch --]
[-- Type: text/plain, Size: 4925 bytes --]

Allow markers to be used only for declaration, without function call associated.
Useful to create specialized probes.

The problem we had is that two function calls were required when one wanted to
put a marker in a tracepoint probe. Now the marker can be used simply for trace
data type declaration, leaving the trace write work within the tracepoint probe
without any additional function call.

Impact: new API.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
CC: 'Ingo Molnar' <mingo@elte.hu>
CC: Lai Jiangshan <laijs@cn.fujitsu.com>
---
 Documentation/markers.txt |   14 ++++++++++++++
 include/linux/marker.h    |   39 +++++++++++++++++++++++----------------
 2 files changed, 37 insertions(+), 16 deletions(-)

Index: linux-2.6-lttng/include/linux/marker.h
===================================================================
--- linux-2.6-lttng.orig/include/linux/marker.h	2008-11-14 16:59:26.000000000 -0500
+++ linux-2.6-lttng/include/linux/marker.h	2008-11-14 16:59:28.000000000 -0500
@@ -55,6 +55,22 @@ struct marker {
 
 #ifdef CONFIG_MARKERS
 
+#define _DEFINE_MARKER(name, tp_name_str, tp_cb, format)		\
+		static const char __mstrtab_##name[]			\
+		__attribute__((section("__markers_strings")))		\
+		= #name "\0" format;					\
+		static struct marker __mark_##name			\
+		__attribute__((section("__markers"), aligned(8))) =	\
+		{ __mstrtab_##name, &__mstrtab_##name[sizeof(#name)],	\
+		  0, 0, marker_probe_cb, { __mark_empty_function, NULL},\
+		  NULL, tp_name_str, tp_cb }
+
+#define DEFINE_MARKER(name, format)					\
+		_DEFINE_MARKER(name, NULL, NULL, format)
+
+#define DEFINE_MARKER_TP(name, tp_name, tp_cb, format)			\
+		_DEFINE_MARKER(name, #tp_name, tp_cb, format)
+
 /*
  * Note : the empty asm volatile with read constraint is used here instead of a
  * "used" attribute to fix a gcc 4.1.x bug.
@@ -68,14 +84,7 @@ struct marker {
  */
 #define __trace_mark(generic, name, call_private, format, args...)	\
 	do {								\
-		static const char __mstrtab_##name[]			\
-		__attribute__((section("__markers_strings")))		\
-		= #name "\0" format;					\
-		static struct marker __mark_##name			\
-		__attribute__((section("__markers"), aligned(8))) =	\
-		{ __mstrtab_##name, &__mstrtab_##name[sizeof(#name)],	\
-		0, 0, marker_probe_cb,					\
-		{ __mark_empty_function, NULL}, NULL, NULL, NULL };	\
+		DEFINE_MARKER(name, format);				\
 		__mark_check_format(format, ## args);			\
 		if (unlikely(__mark_##name.state)) {			\
 			(*__mark_##name.call)				\
@@ -89,14 +98,7 @@ struct marker {
 		{							\
 			register_trace_##tp_name(tp_cb);		\
 		}							\
-		static const char __mstrtab_##name[]			\
-		__attribute__((section("__markers_strings")))		\
-		= #name "\0" format;					\
-		static struct marker __mark_##name			\
-		__attribute__((section("__markers"), aligned(8))) =	\
-		{ __mstrtab_##name, &__mstrtab_##name[sizeof(#name)],	\
-		0, 0, marker_probe_cb,					\
-		{ __mark_empty_function, NULL}, NULL, #tp_name, tp_cb };\
+		DEFINE_MARKER_TP(name, tp_name, tp_cb, format);		\
 		__mark_check_format(format, ## args);			\
 		(*__mark_##name.call)(&__mark_##name, call_private,	\
 					## args);			\
@@ -104,7 +106,11 @@ struct marker {
 
 extern void marker_update_probe_range(struct marker *begin,
 	struct marker *end);
+
+#define GET_MARKER(name)	(__mark_##name)
+
 #else /* !CONFIG_MARKERS */
+#define DEFINE_MARKER(name, tp_name, tp_cb, format)
 #define __trace_mark(generic, name, call_private, format, args...) \
 		__mark_check_format(format, ## args)
 #define __trace_mark_tp(name, call_private, tp_name, tp_cb, format, args...) \
@@ -118,6 +124,7 @@ extern void marker_update_probe_range(st
 static inline void marker_update_probe_range(struct marker *begin,
 	struct marker *end)
 { }
+#define GET_MARKER(name)
 #endif /* CONFIG_MARKERS */
 
 /**
Index: linux-2.6-lttng/Documentation/markers.txt
===================================================================
--- linux-2.6-lttng.orig/Documentation/markers.txt	2008-11-14 16:59:26.000000000 -0500
+++ linux-2.6-lttng/Documentation/markers.txt	2008-11-14 16:59:28.000000000 -0500
@@ -70,6 +70,20 @@ a printk warning which identifies the in
 
 "Format mismatch for probe probe_name (format), marker (format)"
 
+Another way to use markers is to simply define the marker without generating any
+function call to actually call into the marker. This is useful in combination
+with tracepoint probes in a scheme like this :
+
+void probe_tracepoint_name(unsigned int arg1, struct task_struct *tsk);
+
+DEFINE_MARKER_TP(marker_eventname, tracepoint_name, probe_tracepoint_name,
+	"arg1 %u pid %d");
+
+notrace void probe_tracepoint_name(unsigned int arg1, struct task_struct *tsk)
+{
+	struct marker *marker = &GET_MARKER(kernel_irq_entry);
+	/* write data to trace buffers ... */
+}
 
 * Probe / marker example
 

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

  parent reply	other threads:[~2008-11-14 23:02 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-11-14 22:47 [patch 00/16] Markers and Tracepoints Updates for -tip Mathieu Desnoyers
2008-11-14 22:47 ` [patch 01/16] RCU read sched notrace Mathieu Desnoyers
2008-11-16  4:00   ` Paul E. McKenney
2008-11-14 22:47 ` [patch 02/16] Marker fix unregister Mathieu Desnoyers
2008-11-14 22:47 ` [patch 03/16] markers: Add missing stdargs.h include, needed due to va_list usage Mathieu Desnoyers
2008-11-14 22:47 ` [patch 04/16] Markers use rcu_*_sched_notrace and notrace Mathieu Desnoyers
2008-11-14 22:47 ` [patch 05/16] Markers use module notifier Mathieu Desnoyers
2008-11-16  8:52   ` [PATCH] markers/tracpoints: fix non-modular build Ingo Molnar
2008-11-17  5:39     ` Mathieu Desnoyers
2008-11-14 22:47 ` [patch 06/16] Markers auto enable tracepoints (new API : trace_mark_tp()) Mathieu Desnoyers
2008-11-16  7:59   ` Ingo Molnar
2008-11-18  4:44     ` Mathieu Desnoyers
2008-11-18 16:30       ` Ingo Molnar
2008-11-23 16:40         ` Mathieu Desnoyers
2008-11-23 16:49           ` Ingo Molnar
2008-11-24  8:05             ` Mathieu Desnoyers
2008-11-25 12:23     ` KOSAKI Motohiro
2008-11-25 17:24       ` Frank Ch. Eigler
2008-11-14 22:47 ` Mathieu Desnoyers [this message]
2008-11-14 22:47 ` [patch 08/16] Tracepoints : Samples fix teardown Mathieu Desnoyers
2008-11-14 22:47 ` [patch 09/16] Tracepoint fix disable Mathieu Desnoyers
2008-11-14 22:47 ` [patch 10/16] Tracepoints use rcu_*_sched_notrace Mathieu Desnoyers
2008-11-14 22:47 ` [patch 11/16] Tracepoint Use Unregister Return Value Mathieu Desnoyers
2008-11-14 22:47 ` [patch 12/16] Tracepoint do not put arguments in name Mathieu Desnoyers
2008-11-14 22:47 ` [patch 13/16] Tracepoints : use modules notifiers Mathieu Desnoyers
2008-11-14 22:47 ` [patch 14/16] Tracepoints : add DECLARE_TRACE() and DEFINE_TRACE() Mathieu Desnoyers
2008-11-14 22:47 ` [patch 15/16] Tracepoints : documentation fix teardown Mathieu Desnoyers
2008-11-14 22:47 ` [patch 16/16] marker_synchronize_unregister->tracepoint_synchronize_unregister Mathieu Desnoyers
2008-11-16  7:48   ` Ingo Molnar
2008-11-17  5:36     ` Mathieu Desnoyers

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20081114224948.293222043@polymtl.ca \
    --to=mathieu.desnoyers@polymtl.ca \
    --cc=akpm@linux-foundation.org \
    --cc=laijs@cn.fujitsu.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=torvalds@linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox