All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH] markers-generic-doc-section-fix-flags
Date: Tue, 10 Apr 2007 19:11:26 -0400	[thread overview]
Message-ID: <20070410231126.GC7092@Krystal> (raw)

Documents the linux/marker.h header. Fix a bitwise flag manipulation mistake
in the MARK_GENERIC macro.

Use the __marker (ro), new __marker_strings (ro) and __marker_data (rw)
sections. It depends on the linker modification which defines this last
section.

It allows the use of a probe "private" data : upon probe connexion, it
can provide a pointer to its own data structure which will be available
at the probe call site as the pdata field of the mdata structure.

With the new __marker_data section, much less data has to be defined in
the kernel .data segment : only the enable flag, in non-optimized
markers, is left in .data because it is used very often.

The marker flags now only define MF_* which are bitmasks. There is no
way to use the bitmask shift value, so it is less error prone.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>

--- a/include/linux/marker.h
+++ b/include/linux/marker.h
@@ -16,48 +16,59 @@
 
 #ifdef __KERNEL__
 
-typedef void marker_probe_func(const char *fmt, ...);
+struct __mark_marker_data;
 
-struct __mark_marker_c {
+typedef void marker_probe_func(const struct __mark_marker_data *mdata,
+	const char *fmt, ...);
+
+struct __mark_marker_data {
 	const char *name;
-	marker_probe_func **call;
 	const char *format;
 	int flags;
+	marker_probe_func *call;
+	void *pdata;
 } __attribute__((packed));
 
 struct __mark_marker {
-	const struct __mark_marker_c *cmark;
+	struct __mark_marker_data *mdata;
 	void *enable;
 } __attribute__((packed));
 
-/* Generic marker flavor always available */
 #ifdef CONFIG_MARKERS
 
-#define MF_OPTIMIZED 1	/* Use optimized markers */
-#define MF_LOCKDEP 2	/* Can call lockdep */
-#define MF_PRINTK 3	/* vprintk can be called in the probe */
+/* Marker flags : selects the mechanism used to connect the probes to the
+ * markers and what can be executed within the probes. This is primarily
+ * used at reentrancy-unfriendly sites. */
+#define MF_OPTIMIZED	(1 << 0)	/* Use optimized markers */
+#define MF_LOCKDEP	(1 << 1)	/* Can call lockdep */
+#define MF_PRINTK	(1 << 2)	/* vprintk can be called in the probe */
+#define _MF_NR		3		/* Number of marker flags */
 
-#define _MF_OPTIMIZED (1 << MF_OPTIMIZED)
-#define _MF_LOCKDEP (1 << MF_LOCKDEP)
-#define _MF_PRINTK (1 << MF_PRINTK)
+#define DECLARE_MARKER_DATA(flags, name, format) \
 
+/* Generic marker flavor always available */
 #define MARK_GENERIC(flags, name, format, args...) \
 	do { \
-		static marker_probe_func *__mark_call_##name = \
-					__mark_empty_function; \
+		static const char __mstrtab_name_##name[] \
+		__attribute__((section("__markers_strings"))) \
+		= #name; \
+		static const char __mstrtab_format_##name[] \
+		__attribute__((section("__markers_strings"))) \
+		= format; \
+		static struct __mark_marker_data __mark_data_##name \
+		__attribute__((section("__markers_data"))) = \
+		{ __mstrtab_name_##name,  __mstrtab_format_##name, \
+		(flags) & ~MF_OPTIMIZED, __mark_empty_function, NULL }; \
 		static char __marker_enable_##name = 0; \
-		static const struct __mark_marker_c __mark_c_##name \
-			__attribute__((section(".markers.c"))) = \
-			{ #name, &__mark_call_##name, format, \
-			(flags) | ~_MF_OPTIMIZED } ; \
 		static const struct __mark_marker __mark_##name \
-			__attribute__((section(".markers"))) = \
-			{ &__mark_c_##name, &__marker_enable_##name } ; \
+			__attribute__((section("__markers"))) = \
+			{ &__mark_data_##name, &__marker_enable_##name } ; \
 		asm volatile ( "" : : "i" (&__mark_##name)); \
 		__mark_check_format(format, ## args); \
 		if (unlikely(__marker_enable_##name)) { \
 			preempt_disable(); \
-			(*__mark_call_##name)(format, ## args); \
+			(*__mark_data_##name.call)(&__mark_data_##name, \
+						format, ## args); \
 			preempt_enable(); \
 		} \
 	} while (0)
@@ -87,21 +98,23 @@ static inline int marker_generic_set_enable(void *address, char enable)
 #endif
 
 #define MARK_MAX_FORMAT_LEN	1024
+/* Pass this as a format string for a marker with no argument */
 #define MARK_NOARGS " "
 
-static inline __attribute__ ((format (printf, 1, 2)))
+/* To be used for string format validity checking with sparse */
+static inline
 void __mark_check_format(const char *fmt, ...)
 { }
 
 extern marker_probe_func __mark_empty_function;
 
 extern int _marker_set_probe(int flags, const char *name, const char *format,
-				marker_probe_func *probe);
+				marker_probe_func *probe, void *pdata);
 
-#define marker_set_probe(name, format, probe) \
-	_marker_set_probe(_MF_DEFAULT, name, format, probe)
+#define marker_set_probe(name, format, probe, pdata) \
+	_marker_set_probe(MF_DEFAULT, name, format, probe, pdata)
 
-extern int marker_remove_probe(marker_probe_func *probe);
+extern int marker_remove_probe(const char *name);
 extern int marker_list_probe(marker_probe_func *probe);
 
 #endif /* __KERNEL__ */
-- 
Mathieu Desnoyers
Computer Engineering Ph.D. Student, Ecole Polytechnique de Montreal
OpenPGP key fingerprint: 8CD5 52C3 8E3C 4140 715F  BA06 3F25 A8FE 3BAE 9A68

             reply	other threads:[~2007-04-10 23:11 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-04-10 23:11 Mathieu Desnoyers [this message]
2007-04-10 23:20 ` [PATCH] markers-i386-doc-section-flags-optimized-state-change Mathieu Desnoyers
2007-04-10 23:22 ` [PATCH] markers-powerpc-doc-section-flags Mathieu Desnoyers
2007-04-10 23:24 ` [PATCH] markers-non-opt-arch-alpha-arm26-doc-flags Mathieu Desnoyers
2007-04-10 23:26 ` [PATCH] markers-doc-update-flags-example Mathieu Desnoyers
2007-04-11  2:37   ` Randy Dunlap
2007-04-11 18:57     ` [PATCH] Linux Kernel Markers documentation fix typo and use ARRAY_SIZE Mathieu Desnoyers
2007-04-10 23:27 ` [PATCH] build-avr32-marker-menu Mathieu Desnoyers
2007-04-10 23:29 ` [PATCH] markers-module.c-doc-flags 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=20070410231126.GC7092@Krystal \
    --to=mathieu.desnoyers@polymtl.ca \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.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 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.