Re: [patch 2/5] Linux Kernel Markers
On Fri, 2007-09-28 at 10:28 -0400, Mathieu Desnoyers wrote: > +struct __mark_marker; Hi Mathieu, How about, "struct marker". You've taken the "marker*" namespace, so all these underscores are __gratuitious__ :) > +/* > + * module_mutex nests inside markers_mutex. Markers mutex protects the > builtin > + * and module markers, the hash table and deferred_sync. > + */ > +DEFINE_MUTEX(markers_mutex); This can be static AFAICT. The rest looks fine. Cheers, Rusty. - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[patch 2/5] Linux Kernel Markers
The marker activation functions sits in kernel/marker.c. A hash table is used to keep track of the registered probes and armed markers, so the markers within a newly loaded module that should be active can be activated at module load time. marker_query has been removed. marker_get_first, marker_get_next and marker_release should be used as iterators on the markers. Changelog: - markers_mutex now nests inside module_mutex rather than the opposite. - Iteration on modules is now done in module.c. - module_mutex is not exported anymore. - Don't declare a __markers_strings section. - Simplified: do not use immediate values, just a simple variable read. (removed dependency on immediate values). - Removed the args field in the marker structure : it was not used. - Removed the iterators. Will come back with the actual users. - Merge the markers menu entry. Signed-off-by: Mathieu Desnoyers <[EMAIL PROTECTED]> Acked-by: "Frank Ch. Eigler" <[EMAIL PROTECTED]> CC: Christoph Hellwig <[EMAIL PROTECTED]> CC: Rusty Russell <[EMAIL PROTECTED]> --- include/asm-generic/vmlinux.lds.h |7 include/linux/marker.h| 130 + include/linux/module.h| 12 kernel/Kconfig.instrumentation|6 kernel/Makefile |1 kernel/marker.c | 527 ++ kernel/module.c | 30 ++ 7 files changed, 711 insertions(+), 2 deletions(-) Index: linux-2.6-lttng/include/asm-generic/vmlinux.lds.h === --- linux-2.6-lttng.orig/include/asm-generic/vmlinux.lds.h 2007-09-25 07:17:49.0 -0400 +++ linux-2.6-lttng/include/asm-generic/vmlinux.lds.h 2007-09-25 07:18:50.0 -0400 @@ -12,7 +12,11 @@ /* .data section */ #define DATA_DATA \ *(.data)\ - *(.data.init.refok) + *(.data.init.refok) \ + . = ALIGN(8); \ + VMLINUX_SYMBOL(__start___markers) = .; \ + *(__markers)\ + VMLINUX_SYMBOL(__stop___markers) = .; #define RO_DATA(align) \ . = ALIGN((align)); \ @@ -20,6 +24,7 @@ VMLINUX_SYMBOL(__start_rodata) = .; \ *(.rodata) *(.rodata.*) \ *(__vermagic) /* Kernel version magic */ \ + *(__markers_strings)/* Markers: strings */ \ } \ \ .rodata1 : AT(ADDR(.rodata1) - LOAD_OFFSET) { \ Index: linux-2.6-lttng/include/linux/marker.h === --- /dev/null 1970-01-01 00:00:00.0 + +++ linux-2.6-lttng/include/linux/marker.h 2007-09-25 07:18:50.0 -0400 @@ -0,0 +1,130 @@ +#ifndef _LINUX_MARKER_H +#define _LINUX_MARKER_H + +/* + * Code markup for dynamic and static tracing. + * + * See Documentation/marker.txt. + * + * (C) Copyright 2006 Mathieu Desnoyers <[EMAIL PROTECTED]> + * + * This file is released under the GPLv2. + * See the file COPYING for more details. + */ + +#include + +struct module; +struct __mark_marker; + +/** + * marker_probe_func - Type of a marker probe function + * @mdata: pointer of type struct __mark_marker + * @private_data: caller site private data + * @fmt: format string + * @...: variable argument list + * + * Type of marker probe functions. They receive the mdata and need to parse the + * format string to recover the variable argument list. + */ +typedef void marker_probe_func(const struct __mark_marker *mdata, + void *private_data, const char *fmt, ...); + +struct __mark_marker { + const char *name; /* Marker name */ + const char *format; /* Marker format string, describing the +* variable argument list. +*/ + char state; /* Marker state. */ + marker_probe_func *call;/* Probe handler function pointer */ + void *private; /* Private probe data */ +} __attribute__((aligned(8))); + +#ifdef CONFIG_MARKERS + +/* + * Note : the empty asm volatile with read constraint is used here instead of a + * "used" attribute to fix a gcc 4.1.x bug. + * Make sure the alignment of the structure in the __markers 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. + */ +#define __trace_mark(name, call_data,
[patch 2/5] Linux Kernel Markers
The marker activation functions sits in kernel/marker.c. A hash table is used to keep track of the registered probes and armed markers, so the markers within a newly loaded module that should be active can be activated at module load time. marker_query has been removed. marker_get_first, marker_get_next and marker_release should be used as iterators on the markers. Changelog: - markers_mutex now nests inside module_mutex rather than the opposite. - Iteration on modules is now done in module.c. - module_mutex is not exported anymore. - Don't declare a __markers_strings section. - Simplified: do not use immediate values, just a simple variable read. (removed dependency on immediate values). - Removed the args field in the marker structure : it was not used. - Removed the iterators. Will come back with the actual users. - Merge the markers menu entry. Signed-off-by: Mathieu Desnoyers <[EMAIL PROTECTED]> Acked-by: "Frank Ch. Eigler" <[EMAIL PROTECTED]> CC: Christoph Hellwig <[EMAIL PROTECTED]> CC: Rusty Russell <[EMAIL PROTECTED]> --- include/asm-generic/vmlinux.lds.h |7 include/linux/marker.h| 130 + include/linux/module.h| 12 kernel/Kconfig.instrumentation|6 kernel/Makefile |1 kernel/marker.c | 527 ++ kernel/module.c | 30 ++ 7 files changed, 711 insertions(+), 2 deletions(-) Index: linux-2.6-lttng/include/asm-generic/vmlinux.lds.h === --- linux-2.6-lttng.orig/include/asm-generic/vmlinux.lds.h 2007-09-25 07:17:49.0 -0400 +++ linux-2.6-lttng/include/asm-generic/vmlinux.lds.h 2007-09-25 07:18:50.0 -0400 @@ -12,7 +12,11 @@ /* .data section */ #define DATA_DATA \ *(.data)\ - *(.data.init.refok) + *(.data.init.refok) \ + . = ALIGN(8); \ + VMLINUX_SYMBOL(__start___markers) = .; \ + *(__markers)\ + VMLINUX_SYMBOL(__stop___markers) = .; #define RO_DATA(align) \ . = ALIGN((align)); \ @@ -20,6 +24,7 @@ VMLINUX_SYMBOL(__start_rodata) = .; \ *(.rodata) *(.rodata.*) \ *(__vermagic) /* Kernel version magic */ \ + *(__markers_strings)/* Markers: strings */ \ } \ \ .rodata1 : AT(ADDR(.rodata1) - LOAD_OFFSET) { \ Index: linux-2.6-lttng/include/linux/marker.h === --- /dev/null 1970-01-01 00:00:00.0 + +++ linux-2.6-lttng/include/linux/marker.h 2007-09-25 07:18:50.0 -0400 @@ -0,0 +1,130 @@ +#ifndef _LINUX_MARKER_H +#define _LINUX_MARKER_H + +/* + * Code markup for dynamic and static tracing. + * + * See Documentation/marker.txt. + * + * (C) Copyright 2006 Mathieu Desnoyers <[EMAIL PROTECTED]> + * + * This file is released under the GPLv2. + * See the file COPYING for more details. + */ + +#include + +struct module; +struct __mark_marker; + +/** + * marker_probe_func - Type of a marker probe function + * @mdata: pointer of type struct __mark_marker + * @private_data: caller site private data + * @fmt: format string + * @...: variable argument list + * + * Type of marker probe functions. They receive the mdata and need to parse the + * format string to recover the variable argument list. + */ +typedef void marker_probe_func(const struct __mark_marker *mdata, + void *private_data, const char *fmt, ...); + +struct __mark_marker { + const char *name; /* Marker name */ + const char *format; /* Marker format string, describing the +* variable argument list. +*/ + char state; /* Marker state. */ + marker_probe_func *call;/* Probe handler function pointer */ + void *private; /* Private probe data */ +} __attribute__((aligned(8))); + +#ifdef CONFIG_MARKERS + +/* + * Note : the empty asm volatile with read constraint is used here instead of a + * "used" attribute to fix a gcc 4.1.x bug. + * Make sure the alignment of the structure in the __markers 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. + */ +#define __trace_mark(name, call_data,
[patch 2/5] Linux Kernel Markers, architecture independent code.
The marker activation functions sits in kernel/marker.c. A linked list is used to keep track of the armed/disarmed markers, so they can be activated at module load time. Signed-off-by: Mathieu Desnoyers <[EMAIL PROTECTED]> --- include/asm-generic/vmlinux.lds.h | 11 include/linux/marker.h| 108 include/linux/module.h|5 kernel/Makefile |1 kernel/marker.c | 491 ++ kernel/module.c | 19 + 6 files changed, 634 insertions(+), 1 deletion(-) Index: linux-2.6-lttng/include/asm-generic/vmlinux.lds.h === --- linux-2.6-lttng.orig/include/asm-generic/vmlinux.lds.h 2007-06-15 16:14:08.0 -0400 +++ linux-2.6-lttng/include/asm-generic/vmlinux.lds.h 2007-06-15 16:14:10.0 -0400 @@ -129,6 +129,11 @@ VMLINUX_SYMBOL(__stop___immediate) = .; \ } \ \ + /* Markers: strings */ \ +__markers_strings : AT(ADDR(__markers_strings) - LOAD_OFFSET) { \ + *(__markers_strings)\ + } \ + \ /* Kernel symbol table: strings */ \ __ksymtab_strings : AT(ADDR(__ksymtab_strings) - LOAD_OFFSET) { \ *(__ksymtab_strings)\ @@ -153,7 +158,11 @@ /* EXTRARW_DATA adds a place to declare rw data that will not be mixed with the * .data content; therefore limiting data cache pollution when data is put in * the EXTRARW_DATA sections. */ -#define EXTRARW_DATA +#define EXTRARW_DATA \ + . = ALIGN(8); \ + VMLINUX_SYMBOL(__start___markers) = .; \ + *(__markers)\ + VMLINUX_SYMBOL(__stop___markers) = .; #define SECURITY_INIT \ .security_initcall.init : AT(ADDR(.security_initcall.init) - LOAD_OFFSET) { \ Index: linux-2.6-lttng/include/linux/marker.h === --- /dev/null 1970-01-01 00:00:00.0 + +++ linux-2.6-lttng/include/linux/marker.h 2007-06-15 16:14:10.0 -0400 @@ -0,0 +1,108 @@ +#ifndef _LINUX_MARKER_H +#define _LINUX_MARKER_H + +/* + * Code markup for dynamic and static tracing. + * + * See Documentation/marker.txt. + * + * (C) Copyright 2006 Mathieu Desnoyers <[EMAIL PROTECTED]> + * + * This file is released under the GPLv2. + * See the file COPYING for more details. + */ + +#ifdef __KERNEL__ + +#include + +struct module; +struct __mark_marker; + +typedef void marker_probe_func(const struct __mark_marker *mdata, + const char *fmt, ...); + +struct __mark_marker { + const char *name; /* Marker name */ + const char *format; /* Marker format string, describing the +* variable argument list. +*/ + const char *args; /* List of arguments litteraly transformed +* into a string: "arg1, arg2, arg3". +*/ + immediate_t state; /* Immediate value state. */ + int flags; /* Flags controlling the markers flavor. +* Passed to the contidional call declaration +* and used to check that the probe matches the +* markers restrictions at connexion time. */ + marker_probe_func *call;/* Probe handler function pointer */ + void *pdata;/* Private probe data */ +}; + +#ifdef CONFIG_MARKERS + +/* Generic marker flavor always available. + * Note : the empty asm volatile with read constraint is used here instead of a + * "used" attribute to fix a gcc 4.1.x bug. */ +#define _trace_mark(flags, name, format, args...) \ + do {\ + static const char __mstrtab_name_##name[] \ + __attribute__((section("__markers_strings"))) \ + = #name;\ + static const char __mstrtab_format_##name[] \ + __attribute__((section("__markers_strings"))) \ + = format; \ + static const