Linux Kernel Markers - kernel 2.6.20
Subsystems (15)
cover Linux Kernel Markers - kernel 2.6.20
Linux Kernel Markers - kernel 2.6.20
Hi,
You will find, in the following posts, the latest revision of the Linux Kernel Markers. Due to the need some tracing projects (LTTng, SystemTAP) has of this kind of mechanism, it could be nice to consider it for mainstream inclusion.
Recently added : completed correct support for Intel XMC-safe code modification (erratum 49 of the Pentium III). I am not using the kprobe infrastructure because it forbids instrumentation of too much core kernel functions (traps handlers, lockdep.c, ...). I also made the "GEN_MARK" marker available at all time : it will force using the generic version of the markers at a specific instrumentation site. It is intended to be used at instrumentation sites that are not reentrant with respect to the breakpoint handler. lockdep.c/trace_hardirqs_on/off() is a good example of where it is needed :
the breakpoint handler calls hardirq tracing event when it returns.
The following patches apply on 2.6.20.
These patches compile fine against :
arm
i686
ia64
m68k
mips
mipselx86_64
ppc 405
powerpc 970
s390
sparc
sparc64
PATCH 1/5 Linux Kernel Markers : Kconfig menus
Linux Kernel Markers : Kconfig menus
kernel/Kconfig.marker new file +17 -0
@@ -0,0 +1,17 @@ +# Code markers configuration + +config MARKERS + bool "Activate markers" + select MODULES + default n + help + Place an empty function call at each marker site. Can be + dynamically changed for a probe function. + +config MARKERS_ENABLE_OPTIMIZATION + bool "Enable marker optimization" + depends on MARKERS + default y + help + Disable code replacement jump optimisations. Especially useful if your + code is in a read-only rom/flash.
Makefile +2 -1
@@ -308,7 +308,8 @@ AFLAGS_KERNEL = # Needed to be compatible with the O= option LINUXINCLUDE := -Iinclude \ $(if $(KBUILD_SRC),-Iinclude2 -I$(srctree)/include) \ - -include include/linux/autoconf.h + -include include/linux/autoconf.h \ + -include linux/marker.h CPPFLAGS := -D__KERNEL__ $(LINUXINCLUDE)
arch/alpha/Kconfig +6 -0
@@ -638,6 +638,12 @@ source "fs/Kconfig" source "arch/alpha/oprofile/Kconfig" +menu "Instrumentation Support" + +source "kernel/Kconfig.marker" + +endmenu + source "arch/alpha/Kconfig.debug" source "security/Kconfig"
arch/arm26/Kconfig +6 -0
@@ -240,6 +240,12 @@ source "drivers/misc/Kconfig" source "drivers/usb/Kconfig" +menu "Instrumentation Support" + +source "kernel/Kconfig.marker" + +endmenu + source "arch/arm26/Kconfig.debug" source "security/Kconfig"
arch/arm/Kconfig +6 -0
@@ -968,6 +968,12 @@ source "fs/Kconfig" source "arch/arm/oprofile/Kconfig" +menu "Instrumentation Support" + +source "kernel/Kconfig.marker" + +endmenu + source "arch/arm/Kconfig.debug" source "security/Kconfig"
arch/cris/Kconfig +6 -0
@@ -191,6 +191,12 @@ source "sound/Kconfig" source "drivers/usb/Kconfig" +menu "Instrumentation Support" + +source "kernel/Kconfig.marker" + +endmenu + source "arch/cris/Kconfig.debug" source "security/Kconfig"
arch/frv/Kconfig +6 -0
@@ -375,6 +375,12 @@ source "drivers/Kconfig" source "fs/Kconfig" +menu "Instrumentation Support" + +source "kernel/Kconfig.marker" + +endmenu + source "arch/frv/Kconfig.debug" source "security/Kconfig"
arch/h8300/Kconfig +6 -0
@@ -205,6 +205,12 @@ endmenu source "fs/Kconfig" +menu "Instrumentation Support" + +source "kernel/Kconfig.marker" + +endmenu + source "arch/h8300/Kconfig.debug" source "security/Kconfig"
arch/i386/Kconfig +3 -0
@@ -1210,6 +1210,9 @@ config KPROBES a probepoint and specifies the callback. Kprobes is useful for kernel debugging, non-intrusive instrumentation and testing. If in doubt, say "N". + +source "kernel/Kconfig.marker" + endmenu source "arch/i386/Kconfig.debug"
arch/ia64/Kconfig +3 -0
@@ -564,6 +564,9 @@ config KPROBES a probepoint and specifies the callback. Kprobes is useful for kernel debugging, non-intrusive instrumentation and testing. If in doubt, say "N". + +source "kernel/Kconfig.marker" + endmenu source "arch/ia64/Kconfig.debug"
arch/m32r/Kconfig +6 -0
@@ -394,6 +394,12 @@ source "fs/Kconfig" source "arch/m32r/oprofile/Kconfig" +menu "Instrumentation Support" + +source "kernel/Kconfig.marker" + +endmenu + source "arch/m32r/Kconfig.debug" source "security/Kconfig"
arch/m68k/Kconfig +6 -0
@@ -660,6 +660,12 @@ endmenu source "fs/Kconfig" +menu "Instrumentation Support" + +source "kernel/Kconfig.marker" + +endmenu + source "arch/m68k/Kconfig.debug" source "security/Kconfig"
arch/m68knommu/Kconfig +6 -0
@@ -669,6 +669,12 @@ source "drivers/Kconfig" source "fs/Kconfig" +menu "Instrumentation Support" + +source "kernel/Kconfig.marker" + +endmenu + source "arch/m68knommu/Kconfig.debug" source "security/Kconfig"
arch/ppc/Kconfig +6 -0
@@ -1441,8 +1441,14 @@ endmenu source "lib/Kconfig" +menu "Instrumentation Support" + source "arch/powerpc/oprofile/Kconfig" +source "kernel/Kconfig.marker" + +endmenu + source "arch/ppc/Kconfig.debug" source "security/Kconfig"
arch/powerpc/Kconfig +3 -0
@@ -1189,6 +1189,9 @@ config KPROBES a probepoint and specifies the callback. Kprobes is useful for kernel debugging, non-intrusive instrumentation and testing. If in doubt, say "N". + +source "kernel/Kconfig.marker" + endmenu source "arch/powerpc/Kconfig.debug"
arch/parisc/Kconfig +6 -0
@@ -263,6 +263,12 @@ source "fs/Kconfig" source "arch/parisc/oprofile/Kconfig" +menu "Instrumentation Support" + +source "kernel/Kconfig.marker" + +endmenu + source "arch/parisc/Kconfig.debug" source "security/Kconfig"
arch/mips/Kconfig +6 -0
@@ -2082,6 +2082,12 @@ source "fs/Kconfig" source "arch/mips/oprofile/Kconfig" +menu "Instrumentation Support" + +source "kernel/Kconfig.marker" + +endmenu + source "arch/mips/Kconfig.debug" source "security/Kconfig"
arch/s390/Kconfig +2 -0
@@ -518,6 +518,8 @@ config KPROBES for kernel debugging, non-intrusive instrumentation and testing. If in doubt, say "N". +source "kernel/Kconfig.marker" + endmenu source "arch/s390/Kconfig.debug"
arch/sh64/Kconfig +6 -0
@@ -284,6 +284,12 @@ source "fs/Kconfig" source "arch/sh64/oprofile/Kconfig" +menu "Instrumentation Support" + +source "kernel/Kconfig.marker" + +endmenu + source "arch/sh64/Kconfig.debug" source "security/Kconfig"
arch/sh/Kconfig +6 -0
@@ -707,6 +707,12 @@ source "fs/Kconfig" source "arch/sh/oprofile/Kconfig" +menu "Instrumentation Support" + +source "kernel/Kconfig.marker" + +endmenu + source "arch/sh/Kconfig.debug" source "security/Kconfig"
arch/sparc64/Kconfig +3 -0
@@ -443,6 +443,9 @@ config KPROBES a probepoint and specifies the callback. Kprobes is useful for kernel debugging, non-intrusive instrumentation and testing. If in doubt, say "N". + +source "kernel/Kconfig.marker" + endmenu source "arch/sparc64/Kconfig.debug"
arch/sparc/Kconfig +2 -0
@@ -302,6 +302,8 @@ menu "Instrumentation Support" source "arch/sparc/oprofile/Kconfig" +source "kernel/Kconfig.marker" + endmenu source "arch/sparc/Kconfig.debug"
arch/um/Kconfig +6 -0
@@ -344,4 +344,10 @@ config INPUT bool default n +menu "Instrumentation Support" + +source "kernel/Kconfig.marker" + +endmenu + source "arch/um/Kconfig.debug"
arch/v850/Kconfig +6 -0
@@ -332,6 +332,12 @@ source "sound/Kconfig" source "drivers/usb/Kconfig" +menu "Instrumentation Support" + +source "kernel/Kconfig.marker" + +endmenu + source "arch/v850/Kconfig.debug" source "security/Kconfig"
arch/xtensa/Kconfig +6 -0
@@ -244,6 +244,12 @@ config EMBEDDED_RAMDISK_IMAGE provide one yourself. endmenu +menu "Instrumentation Support" + +source "kernel/Kconfig.marker" + +endmenu + source "arch/xtensa/Kconfig.debug" source "security/Kconfig"
arch/x86_64/Kconfig +3 -0
@@ -731,6 +731,9 @@ config KPROBES a probepoint and specifies the callback. Kprobes is useful for kernel debugging, non-intrusive instrumentation and testing. If in doubt, say "N". + +source "kernel/Kconfig.marker" + endmenu source "arch/x86_64/Kconfig.debug"
PATCH 2/5 Linux Kernel Markers, architecture independant code.
In reply to Mathieu DesnoyersLinux Kernel Markers, architecture independant code.
include/asm-generic/vmlinux.lds.h +13 -0
@@ -121,6 +121,19 @@ __ksymtab_strings : AT(ADDR(__ksymtab_strings) - LOAD_OFFSET) { \ *(__ksymtab_strings) \ } \ +/* Kernel markers : pointers */ \ + .markers : AT(ADDR(.markers) - LOAD_OFFSET) { \ + VMLINUX_SYMBOL(__start___markers) = .; \ + *(.markers) \ + VMLINUX_SYMBOL(__stop___markers) = .; \ + } \ + .markers.c : AT(ADDR(.markers.c) - LOAD_OFFSET) { \ + VMLINUX_SYMBOL(__start___markers_c) = .; \ + *(.markers.c) \ + VMLINUX_SYMBOL(__stop___markers_c) = .; \ + } \ + __end_rodata = .; \ + . = ALIGN(4096); \ \/* Built-in module parameters. */ \ __param : AT(ADDR(__param) - LOAD_OFFSET) { \
include/linux/module.h +4 -0
@@ -356,6 +356,9 @@ struct module/* The command line arguments (may be mangled). People like keeping pointers to this stuff */ char *args; + +const struct __mark_marker *markers; +unsigned int num_markers; };/* FIXME: It'd be nice to isolate modules during init, too, so they
@@ -469,6 +472,7 @@ extern void print_modules(void);struct device_driver ;void module_add_driver (struct module *,struct device_driver *);void module_remove_driver (struct device_driver *); +extern void list_modules (void );#else /* !CONFIG_MODULES... */ #define EXPORT_SYMBOL (sym)
include/linux/marker.h new file +97 -0
97 lines not on this page · raw message
kernel/module.c +244 -0
286 lines not on this page · raw message
Re: [PATCH 02/05] Linux Kernel Markers, architecture independant code.
include/linux/marker.h line 75
Quoted 12 lines · On Sun, 11 Feb 2007 15:03:24 -0500 Mathieu Desnoyers…
Linux Kernel Markers, architecture independant code.
Signed-off-by Mathieu Desnoyers <[email protected]>...
include/linux/marker.h new file +6
-0+ +#ifndef MARK +#define MARK GEN_MARK +#define MARK_ENABLE_TYPE GEN_MARK_ENABLE_TYPE +#define MARK_ENABLE_IMMEDIATE_OFFSET GEN_MARK_ENABLE_IMMEDIATE_OFFSET +#endif
Also perhaps this nastiness can go away once each architecture has asm/marker.h?
Quoted 1 line
+#ifdef
MARK_POLYMORPHIC
What's this? Is it commented somewhere? (It should be...)
Quoted 5 lines
kernel/module.c +5
-0+static int marker_set_ins_enable (void *address,char enable) +{ +#ifdef CONFIG_X86_32 +return arch_marker_set_ins_enable (address, enable); +#else
kernel/module.c static struct module *find_module(const char *name) · line 324
Quoted 10 lines
kernel/module.c +10
-0+char newi[MARK_ENABLE_IMMEDIATE_OFFSET +1 ]; +int size =MARK_ENABLE_IMMEDIATE_OFFSET +sizeof (MARK_ENABLE_TYPE ); + +memcpy (newi, address, size); +MARK_ENABLE (&newi[0 ]) = enable; +memcpy (address, newi, size); +flush_icache_range ((unsigned long )address, size); +return 0 ; +#endif //CONFIG_X86_32 +}
eww. Can we put a suitable arch_marker_set_ins_enable() into each arch's marker.h?
Quoted 10 lines
kernel/module.c +7
-0+#else +static int marker_set_ins_enable (void *address,char enable) +{ +return -EPERM ; +} +#endif //MARK_POLYMORPHIC +
Re: [PATCH 02/05] Linux Kernel Markers, architecture independant code.
Quoted 8 lines · * Andrew Morton ([email protected]) wrote:
Quoted 6 lines · On Sun, 11 Feb 2007 15:03:24 -0500 Mathieu Desnoyers…
Linux Kernel Markers, architecture independant code.
Signed-off-by Mathieu Desnoyers <[email protected]>...
Quoted 10 lines
include/linux/marker.h line 75
Quoted 6 lines
include/linux/marker.h new file +6
-0+ +#ifndef MARK +#define MARK GEN_MARK +#define MARK_ENABLE_TYPE GEN_MARK_ENABLE_TYPE +#define MARK_ENABLE_IMMEDIATE_OFFSET GEN_MARK_ENABLE_IMMEDIATE_OFFSET +#endif Also perhaps this nastiness can go away once each architecture has
asm/marker.h?
Yes, absolutely.
Quoted 4 lines
Quoted 1 line
+#ifdef
MARK_POLYMORPHICWhat's this? Is it commented somewhere? (It should be...)
No, but should be : it is defined by the architecture's marker.h when the marker flavor has to do code motification when the marker state is modified.
Quoted 10 lines
Quoted 10 lines
kernel/module.c +10
-0+static int marker_set_ins_enable (void *address,char enable) +{ +#ifdef CONFIG_X86_32 +return arch_marker_set_ins_enable (address, enable); +#else +char newi[MARK_ENABLE_IMMEDIATE_OFFSET +1 ]; +int size =MARK_ENABLE_IMMEDIATE_OFFSET +sizeof (MARK_ENABLE_TYPE ); + +memcpy (newi, address, size); +MARK_ENABLE (&newi[0 ]) = enable;
Quoted 9 lines
kernel/module.c static struct module *find_module(const char *name) · line 324
Quoted 5 lines
kernel/module.c +5
-0+memcpy (address, newi, size); +flush_icache_range ((unsigned long )address, size); +return 0 ; +#endif //CONFIG_X86_32 +}eww. Can we put a suitable
arch_marker_set_ins_enable()into each arch'smarker.h?
Or maybe put that in asm-generic so we do not duplicate code.
Quoted 11 lines
Quoted 10 lines
kernel/module.c +7
-0+#else +static int marker_set_ins_enable (void *address,char enable) +{ +return -EPERM ; +} +#endif //MARK_POLYMORPHIC +
Signature · 3 lines
Mathieu Desnoyers Computer Engineering Ph.D. Candidate, École Polytechnique de Montréal OpenPGP key fingerprint: 8CD5 52C3 8E3C 4140 715F BA06 3F25 A8FE 3BAE 9A68
PATCH 3/5 Linux Kernel Markers : powerpc optimization
In reply to Mathieu DesnoyersLinux Kernel Markers : powerpc optimization
include/asm-powerpc/marker.h new file +49 -0
@@ -0,0 +1,49 @@ +/* +* marker.h +* +* Code markup for dynamic and static tracing. PowerPC architecture +* optimisations. +* +* (C) Copyright 2006 Mathieu Desnoyers <[email protected]> +* +* This file is released under the GPLv2. +* See the file COPYING for more details. +*/ + +#include <asm/asm-compat.h> + +#ifdef CONFIG_MARKERS + +#define MARK(name, format, args...) \ + do { \ + static marker_probe_func *__mark_call_##name = \ + __mark_empty_function; \ + static const struct __mark_marker_c __mark_c_##name \ + __attribute__((section(".markers.c"))) = \ + { #name, &__mark_call_##name, format, \ + MARKER_OPTIMIZED } ; \ + char condition; \ + asm volatile( ".section .markers, \"a\";\n\t" \ + PPC_LONG "%1, 0f;\n\t" \ + ".previous;\n\t" \ + ".align 4\n\t" \ + "0:\n\t" \ + "li %0,0;\n\t" \ + : "=r" (condition) \ + : "i" (&__mark_c_##name)); \ + __mark_check_format(format, ## args); \ + if (unlikely(condition)) { \ + preempt_disable(); \ + (*__mark_call_##name)(format, ## args); \ + preempt_enable(); \ + } \ + } while (0) + + +/* Offset of the immediate value from the start of the addi instruction (result +* of the li mnemonic), in bytes. */ +#define MARK_ENABLE_IMMEDIATE_OFFSET 2 +#define MARK_ENABLE_TYPE short +#define MARK_POLYMORPHIC + +#endif
PATCH 4/5 Linux Kernel Markers : i386 optimization
In reply to Mathieu DesnoyersLinux Kernel Markers : i386 optimization
include/asm-i386/marker.h new file +47 -0
@@ -0,0 +1,47 @@ +/* +* marker.h +* +* Code markup for dynamic and static tracing. i386 architecture optimisations. +* +* (C) Copyright 2006 Mathieu Desnoyers <[email protected]> +* +* This file is released under the GPLv2. +* See the file COPYING for more details. +*/ + + +#ifdef CONFIG_MARKERS +#define MARK(name, format, args...) \ + do { \ + static marker_probe_func *__mark_call_##name = \ + __mark_empty_function; \ + static const struct __mark_marker_c __mark_c_##name \ + __attribute__((section(".markers.c"))) = \ + { #name, &__mark_call_##name, format, \ + MARKER_OPTIMIZED } ; \ + char condition; \ + asm volatile( ".section .markers, \"a\";\n\t" \ + ".long %1, 0f;\n\t" \ + ".previous;\n\t" \ + ".align 2\n\t" \ + "0:\n\t" \ + "movb $0,%0;\n\t" \ + : "=r" (condition) \ + : "m" (__mark_c_##name)); \ + __mark_check_format(format, ## args); \ + if (unlikely(condition)) { \ + preempt_disable(); \ + (*__mark_call_##name)(format, ## args); \ + preempt_enable(); \ + } \ + } while (0) + +/* Offset of the immediate value from the start of the movb instruction, in +* bytes. */ +#define MARK_ENABLE_IMMEDIATE_OFFSET 1 +#define MARK_ENABLE_TYPE char +#define MARK_POLYMORPHIC + +extern int arch_marker_set_ins_enable (void *address,char enable); + +#endif
arch/i386/kernel/marker.c new file +93 -0
93 lines not on this page · raw message
arch/i386/kernel/Makefile +1 -0
@@ -39,6 +39,7 @@ obj-$(CONFIG_VM86) += vm86.o obj-$(CONFIG_EARLY_PRINTK) += early_printk.o obj-$(CONFIG_HPET_TIMER) += hpet.o obj-$(CONFIG_K8_NB) += k8.o +obj-$(CONFIG_MARKERS_ENABLE_OPTIMIZATION) += marker.o # Make sure this is linked after any other paravirt_ops structs: see head.S obj-$(CONFIG_PARAVIRT) += paravirt.o
PATCH 5/5 Linux Kernel Markers, non optimized architectures
In reply to Mathieu DesnoyersLinux Kernel Markers, non optimized architectures
This patch also includes marker code for non optimized architectures.
include/asm-arm/marker.h new file +13 -0
@@ -0,0 +1,13 @@ +/* +* marker.h +* +* Code markup for dynamic and static tracing. Architecture specific +* optimisations. +* +* No optimisation implemented. +* +* This file is released under the GPLv2. +* See the file COPYING for more details. +*/ + +#include <asm-generic/marker.h>
include/asm-cris/marker.h new file +13 -0
@@ -0,0 +1,13 @@ +/* +* marker.h +* +* Code markup for dynamic and static tracing. Architecture specific +* optimisations. +* +* No optimisation implemented. +* +* This file is released under the GPLv2. +* See the file COPYING for more details. +*/ + +#include <asm-generic/marker.h>
include/asm-frv/marker.h new file +13 -0
@@ -0,0 +1,13 @@ +/* +* marker.h +* +* Code markup for dynamic and static tracing. Architecture specific +* optimisations. +* +* No optimisation implemented. +* +* This file is released under the GPLv2. +* See the file COPYING for more details. +*/ + +#include <asm-generic/marker.h>
include/asm-generic/marker.h new file +40 -0
@@ -0,0 +1,40 @@ +/* +* marker.h +* +* Code markup for dynamic and static tracing. Generic header. +* +* This file is released under the GPLv2. +* See the file COPYING for more details. +* +* Note : the empty asm volatile with read constraint is used here instead of a +* "used" attribute to fix a gcc 4.1.x bug. +*/ + +#ifdef CONFIG_MARKERS + +#define GEN_MARK(name, format, args...) \ + do { \ + static marker_probe_func *__mark_call_##name = \ + __mark_empty_function; \ + static char __marker_enable_##name = 0; \ + static const struct __mark_marker_c __mark_c_##name \ + __attribute__((section(".markers.c"))) = \ + { #name, &__mark_call_##name, format, \ + MARKER_GENERIC } ; \ + static const struct __mark_marker __mark_##name \ + __attribute__((section(".markers"))) = \ + { &__mark_c_##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); \ + preempt_enable(); \ + } \ + } while (0) + + +#define GEN_MARK_ENABLE_IMMEDIATE_OFFSET 0 +#define GEN_MARK_ENABLE_TYPE char + +#endif
include/asm-h8300/marker.h new file +13 -0
@@ -0,0 +1,13 @@ +/* +* marker.h +* +* Code markup for dynamic and static tracing. Architecture specific +* optimisations. +* +* No optimisation implemented. +* +* This file is released under the GPLv2. +* See the file COPYING for more details. +*/ + +#include <asm-generic/marker.h>
include/asm-ia64/marker.h new file +13 -0
@@ -0,0 +1,13 @@ +/* +* marker.h +* +* Code markup for dynamic and static tracing. Architecture specific +* optimisations. +* +* No optimisation implemented. +* +* This file is released under the GPLv2. +* See the file COPYING for more details. +*/ + +#include <asm-generic/marker.h>
include/asm-m32r/marker.h new file +13 -0
@@ -0,0 +1,13 @@ +/* +* marker.h +* +* Code markup for dynamic and static tracing. Architecture specific +* optimisations. +* +* No optimisation implemented. +* +* This file is released under the GPLv2. +* See the file COPYING for more details. +*/ + +#include <asm-generic/marker.h>
include/asm-m68k/marker.h new file +13 -0
@@ -0,0 +1,13 @@ +/* +* marker.h +* +* Code markup for dynamic and static tracing. Architecture specific +* optimisations. +* +* No optimisation implemented. +* +* This file is released under the GPLv2. +* See the file COPYING for more details. +*/ + +#include <asm-generic/marker.h>
include/asm-m68knommu/marker.h new file +13 -0
@@ -0,0 +1,13 @@ +/* +* marker.h +* +* Code markup for dynamic and static tracing. Architecture specific +* optimisations. +* +* No optimisation implemented. +* +* This file is released under the GPLv2. +* See the file COPYING for more details. +*/ + +#include <asm-generic/marker.h>
include/asm-mips/marker.h new file +13 -0
@@ -0,0 +1,13 @@ +/* +* marker.h +* +* Code markup for dynamic and static tracing. Architecture specific +* optimisations. +* +* No optimisation implemented. +* +* This file is released under the GPLv2. +* See the file COPYING for more details. +*/ + +#include <asm-generic/marker.h>
include/asm-parisc/marker.h new file +13 -0
@@ -0,0 +1,13 @@ +/* +* marker.h +* +* Code markup for dynamic and static tracing. Architecture specific +* optimisations. +* +* No optimisation implemented. +* +* This file is released under the GPLv2. +* See the file COPYING for more details. +*/ + +#include <asm-generic/marker.h>
include/asm-ppc/marker.h new file +13 -0
@@ -0,0 +1,13 @@ +/* +* marker.h +* +* Code markup for dynamic and static tracing. Architecture specific +* optimisations. +* +* No optimisation implemented. +* +* This file is released under the GPLv2. +* See the file COPYING for more details. +*/ + +#include <asm-generic/marker.h>
include/asm-s390/marker.h new file +13 -0
@@ -0,0 +1,13 @@ +/* +* marker.h +* +* Code markup for dynamic and static tracing. Architecture specific +* optimisations. +* +* No optimisation implemented. +* +* This file is released under the GPLv2. +* See the file COPYING for more details. +*/ + +#include <asm-generic/marker.h>
include/asm-sh64/marker.h new file +13 -0
@@ -0,0 +1,13 @@ +/* +* marker.h +* +* Code markup for dynamic and static tracing. Architecture specific +* optimisations. +* +* No optimisation implemented. +* +* This file is released under the GPLv2. +* See the file COPYING for more details. +*/ + +#include <asm-generic/marker.h>
include/asm-sh/marker.h new file +13 -0
@@ -0,0 +1,13 @@ +/* +* marker.h +* +* Code markup for dynamic and static tracing. Architecture specific +* optimisations. +* +* No optimisation implemented. +* +* This file is released under the GPLv2. +* See the file COPYING for more details. +*/ + +#include <asm-generic/marker.h>
include/asm-sparc64/marker.h new file +13 -0
@@ -0,0 +1,13 @@ +/* +* marker.h +* +* Code markup for dynamic and static tracing. Architecture specific +* optimisations. +* +* No optimisation implemented. +* +* This file is released under the GPLv2. +* See the file COPYING for more details. +*/ + +#include <asm-generic/marker.h>
include/asm-sparc/marker.h new file +13 -0
@@ -0,0 +1,13 @@ +/* +* marker.h +* +* Code markup for dynamic and static tracing. Architecture specific +* optimisations. +* +* No optimisation implemented. +* +* This file is released under the GPLv2. +* See the file COPYING for more details. +*/ + +#include <asm-generic/marker.h>
include/asm-um/marker.h new file +13 -0
@@ -0,0 +1,13 @@ +/* +* marker.h +* +* Code markup for dynamic and static tracing. Architecture specific +* optimisations. +* +* No optimisation implemented. +* +* This file is released under the GPLv2. +* See the file COPYING for more details. +*/ + +#include <asm-generic/marker.h>
include/asm-v850/marker.h new file +13 -0
@@ -0,0 +1,13 @@ +/* +* marker.h +* +* Code markup for dynamic and static tracing. Architecture specific +* optimisations. +* +* No optimisation implemented. +* +* This file is released under the GPLv2. +* See the file COPYING for more details. +*/ + +#include <asm-generic/marker.h>
include/asm-x86_64/marker.h new file +13 -0
@@ -0,0 +1,13 @@ +/* +* marker.h +* +* Code markup for dynamic and static tracing. Architecture specific +* optimisations. +* +* No optimisation implemented. +* +* This file is released under the GPLv2. +* See the file COPYING for more details. +*/ + +#include <asm-generic/marker.h>
include/asm-xtensa/marker.h new file +13 -0
@@ -0,0 +1,13 @@ +/* +* marker.h +* +* Code markup for dynamic and static tracing. Architecture specific +* optimisations. +* +* No optimisation implemented. +* +* This file is released under the GPLv2. +* See the file COPYING for more details. +*/ + +#include <asm-generic/marker.h>
Re: [PATCH 05/05] Linux Kernel Markers, non optimized architectures
Quoted 3 lines · On Sun, 11 Feb 2007 15:03:27 -0500 Mathieu Desnoyers…
Linux Kernel Markers, non optimized architectures
This patch also includes marker code for non optimized architectures.
I think once we've done this we can nuke CONFIG_MARKERS_ENABLE_OPTIMIZATION? (Please, let it be true).
Re: [PATCH 05/05] Linux Kernel Markers, non optimized architectures
Quoted 9 lines · * Andrew Morton ([email protected]) wrote:
Quoted 3 lines · On Sun, 11 Feb 2007 15:03:27 -0500 Mathieu Desnoyers…
Linux Kernel Markers, non optimized architectures
This patch also includes marker code for non optimized architectures.
I think once we've done this we can nuke
CONFIG_MARKERS_ENABLE_OPTIMIZATION? (Please, let it be true).
Hi Andrew,
The main goal of this config option is for embedded systems which doesn't support live code modification. Maybe we can put that under "embedded sytems" menu ?
Signature · 3 lines
Mathieu Desnoyers Computer Engineering Ph.D. Candidate, École Polytechnique de Montréal OpenPGP key fingerprint: 8CD5 52C3 8E3C 4140 715F BA06 3F25 A8FE 3BAE 9A68
Re: Re: [PATCH 05/05] Linux Kernel Markers, non optimized architectures
----- KRYPTIVA PACKAGED MESSAGE -----
PACKAGING TYPE: SIGNED
Quoted 1 line · Mathieu Desnoyers
The main goal of this config option is for embedded systems which doesn't support live code modification. Maybe we can put that under "embedded sytems" menu ?
Not sure whether you had had other feedback on this elsewhere in the rest of the thread, but yes, this would make sense if the "embedded" angle is the only reason we need this (and not, say, performance, etc.) Also, having done that, maybe it would make some sense to have it be a "disable" rather than "enable":CONFIG_MARKERS_DISABLE_OPTIMIZATION?
Karim
----- KRYPTIVA SIGNED MESSAGE -----
This email claims to have been packaged by Kryptiva. To process this email and authenticate its origin, get the free plugin from:
http://www.kryptiva.com/downloads
----- KRYPTIVA SIGNATURE START ----- AvWVqAAAAAIAAAABAAAAAAAATiACAQAAAAC3AQAIAAAAAgAAAAECABTXxT4xHdR4/1uU1hL2 +TaPrqNB0wMAFNa8GHXZWJH5Dz+D76vfh6JhvWLvBAAUpuIZcCAkCC+ldyaBuoAWxK50HiQF ABRI38gc/foDHQsS6X3W0VP4xTukBwYAFDzvzh+u6zVtolglAZrnE7FOmtZDBwAUTxyTas6N WLapdnSnAwVHeC06/ioRABgAAAAAAABOIEXWD8AACTdnAAAAAAAAAN8TAAQAAAAAAAAAggP+ K8Gk1SWj+c67jiJerodkr1gntoa9dJVVN6InxB824CfKC6flE4JMWtffw0Dxh0cJ8iOQ8UeC zoWzTs9Z+K9j1CL11CHkIIit3RK3hnfnby6whr4xoZ9UX/BUUv8FVKZeyRg7SbDKlhEZTwIH 7axjVQJ6MGU7h+0/5dKCDMEtzPY=
----- KRYPTIVA SIGNATURE END -----
Re: [PATCH 05/05] Linux Kernel Markers, non optimized architectures
Quoted 8 lines · * Karim Yaghmour ([email protected]) wrote:
----- KRYPTIVA PACKAGED MESSAGE -----
PACKAGING TYPE: SIGNEDQuoted 1 line · Mathieu Desnoyers
The main goal of this config option is for embedded systems which doesn't
support live code modification. Maybe we can put that under "embedded sytems" menu ?
Quoted 7 lines
Not sure whether you had had other feedback on this elsewhere in the rest of the thread, but yes, this would make sense if the "embedded" angle is the only reason we need this (and not, say, performance, etc.) Also, having done that, maybe it would make some sense to have it be a "disable" rather than "enable":
CONFIG_MARKERS_DISABLE_OPTIMIZATION?
Hi Karim,
Yes, that was indeed the first way I implemented it, as a "disable" option. One of the main thing we have to figure out before I modify this is if we want to have the generic version of markers available in a "forced" manner at the marker site with the GEN_MARK macro instead of the MARK macro (this is the actual implementation). It has proven to be useful to instrument lockdep.c irq enable/disable tracing functions. The reason why is because they are called just before the trap handler returns and I need it to do XMC on x86 and x86_64. It would therefore cause a recursive trap.
I think it makes sense to have this kind of support for hard-to-instrument sites within the marker infrastructure, but the cost is to have two marker flavors : MARK and GEN_MARK (but really GEN_MARK is only intended for a few sites).
Mathieu
Quoted 18 lines
Karim
----- KRYPTIVA SIGNED MESSAGE -----
This email claims to have been packaged by Kryptiva. To process this email and authenticate its origin, get the free plugin from:
http://www.kryptiva.com/downloads----- KRYPTIVA SIGNATURE START ----- AvWVqAAAAAIAAAABAAAAAAAATiACAQAAAAC3AQAIAAAAAgAAAAECABTXxT4xHdR4/1uU1hL2 +TaPrqNB0wMAFNa8GHXZWJH5Dz+D76vfh6JhvWLvBAAUpuIZcCAkCC+ldyaBuoAWxK50HiQF ABRI38gc/foDHQsS6X3W0VP4xTukBwYAFDzvzh+u6zVtolglAZrnE7FOmtZDBwAUTxyTas6N WLapdnSnAwVHeC06/ioRABgAAAAAAABOIEXWD8AACTdnAAAAAAAAAN8TAAQAAAAAAAAAggP+ K8Gk1SWj+c67jiJerodkr1gntoa9dJVVN6InxB824CfKC6flE4JMWtffw0Dxh0cJ8iOQ8UeC zoWzTs9Z+K9j1CL11CHkIIit3RK3hnfnby6whr4xoZ9UX/BUUv8FVKZeyRg7SbDKlhEZTwIH 7axjVQJ6MGU7h+0/5dKCDMEtzPY=
----- KRYPTIVA SIGNATURE END -----
Signature · 3 lines
Mathieu Desnoyers Computer Engineering Ph.D. Candidate, Ecole Polytechnique de Montreal OpenPGP key fingerprint: 8CD5 52C3 8E3C 4140 715F BA06 3F25 A8FE 3BAE 9A68
Re: [PATCH 05/05] Linux Kernel Markers, non optimized architectures
----- KRYPTIVA PACKAGED MESSAGE -----
PACKAGING TYPE: SIGNED
Hello Mathieu,
Quoted 4 lines · Mathieu Desnoyers
Yes, that was indeed the first way I implemented it, as a "disable" option. One of the main thing we have to figure out before I modify this is if we want to have the generic version of markers available in a "forced" manner at the marker site with the
GEN_MARKmacro instead of the MARK macro (this is the actual implementation). It has proven to be useful to instrumentlockdep.cirq enable/disable tracing functions. The reason why is because they are called just before the trap handler returns and I need it to do XMC on x86 andx86_64. It would therefore cause a recursive trap.I think it makes sense to have this kind of support for hard-to-instrument sites within the marker infrastructure, but the cost is to have two marker flavors : MARK and
GEN_MARK(but reallyGEN_MARKis only intended for a few sites).
I must admit that I'm unsure about the use of different marker macros. How about bitwise flags that could be coded as part of the marker at the marker site? Something like "MARKER_TYPE_FORCED". This would still allow some form of toplevel control at the macro definition. Otherwise there's some digging to be done on a per-marker basis ...
Karim
----- KRYPTIVA SIGNED MESSAGE -----
This email claims to have been packaged by Kryptiva. To process this email and authenticate its origin, get the free plugin from:
http://www.kryptiva.com/downloads
----- KRYPTIVA SIGNATURE START ----- AvWVqAAAAAIAAAABAAAAAAAATiACAQAAAAC3AQAIAAAAAgAAAAECABTXxT4xHdR4/1uU1hL2 +TaPrqNB0wMAFNa8GHXZWJH5Dz+D76vfh6JhvWLvBAAUpuIZcCAkCC+ldyaBuoAWxK50HiQF ABRI38gc/foDHQsS6X3W0VP4xTukBwYAFB0lithGcxNZYBHaLDONjp6eo/LoBwAU6OwGS0m1 IVdBt6tKzhaPW8MOfncRABgAAAAAAABOIEXcozcACATMAAAAAAAAABkTAAQAAAAAAAAAggQA mHAJeFbYUzxSX+zkI0DtoVKcqqSp2Ztc9GtY7ZtuLBmeqg5pW0rIbkhutQiztTXlJQ0Ye9bV yzEVWd/m7GhDAgRBmyg3kCOt7g7potr1l5J3X5K8TiqtWXbNo3k6AHRlGZyn0190iIBSvf85 nVh3hKiNPsw8DYs1NKb+KMON+4g=
----- KRYPTIVA SIGNATURE END -----
Re: [PATCH 05/05] Linux Kernel Markers, non optimized architectures
Quoted 21 lines · * Karim Yaghmour ([email protected]) wrote:
----- KRYPTIVA PACKAGED MESSAGE -----
PACKAGING TYPE: SIGNEDHello Mathieu,
Quoted 1 line · Mathieu Desnoyers
Yes, that was indeed the first way I implemented it, as a "disable"
option. One of the main thing we have to figure out before I modify this is if we want to have the generic version of markers available in a "forced" manner at the marker site with the
GEN_MARKmacro instead of the MARK macro (this is the actual implementation). It has proven to be useful to instrumentlockdep.cirqQuoted 1 line
enable/disable tracing functions. The reason why is because they are
called just before the trap handler returns and I need it to do XMC on x86 and
x86_64. It would therefore cause a recursive trap.Quoted 2 lines
I think it makes sense to have this kind of support for
hard-to-instrument sites within the marker infrastructure, but the cost is to have two marker flavors : MARK and
GEN_MARK(but reallyGEN_MARKis only intended for a few sites).
Quoted 7 lines
I must admit that I'm unsure about the use of different marker macros. How about bitwise flags that could be coded as part of the marker at the marker site? Something like "
MARKER_TYPE_FORCED". This would still allow some form of toplevel control at the macro definition. Otherwise there's some digging to be done on a per-marker basis ...
The problem with your proposal, I guess, is that people will have to add a supplementary parameter to the macro.
It is not uncommon to have two slightly versions of macros/functions in the kernel (preempt_enable()/preempt_enable_no_resched(), or macros starting with underscores). Normally, the underscore states that the macro does not do the proper locking itself (this is not our case). Therefore, I would suggest using a name that suggests against what the macro is protected. For instance, a marker pointing to the generic version is only needed to protect against the debug trap handler and should only be used on x86 and x86_64.
So, something like MARK_NO_TRAP() would be appropriate : it would be an optimized version for every architecture except x86 and x86_64. The meaning of this macro is : "This is a marker that will never generate a trap because of its activation" (just as a precision : it doesn't say anything about the probe connected to the marker). It also acts as a strong suggestion about what *should not* be done within the probe.
Mathieu
Quoted 16 lines
Karim
----- KRYPTIVA SIGNED MESSAGE -----
This email claims to have been packaged by Kryptiva. To process this email and authenticate its origin, get the free plugin from:
http://www.kryptiva.com/downloads----- KRYPTIVA SIGNATURE START ----- AvWVqAAAAAIAAAABAAAAAAAATiACAQAAAAC3AQAIAAAAAgAAAAECABTXxT4xHdR4/1uU1hL2 +TaPrqNB0wMAFNa8GHXZWJH5Dz+D76vfh6JhvWLvBAAUpuIZcCAkCC+ldyaBuoAWxK50HiQF ABRI38gc/foDHQsS6X3W0VP4xTukBwYAFB0lithGcxNZYBHaLDONjp6eo/LoBwAU6OwGS0m1 IVdBt6tKzhaPW8MOfncRABgAAAAAAABOIEXcozcACATMAAAAAAAAABkTAAQAAAAAAAAAggQA mHAJeFbYUzxSX+zkI0DtoVKcqqSp2Ztc9GtY7ZtuLBmeqg5pW0rIbkhutQiztTXlJQ0Ye9bV yzEVWd/m7GhDAgRBmyg3kCOt7g7potr1l5J3X5K8TiqtWXbNo3k6AHRlGZyn0190iIBSvf85 nVh3hKiNPsw8DYs1NKb+KMON+4g=
----- KRYPTIVA SIGNATURE END -----
Signature · 3 lines
Mathieu Desnoyers Computer Engineering Ph.D. Candidate, Ecole Polytechnique de Montreal OpenPGP key fingerprint: 8CD5 52C3 8E3C 4140 715F BA06 3F25 A8FE 3BAE 9A68
Re: [PATCH 05/05] Linux Kernel Markers, non optimized architectures
----- KRYPTIVA PACKAGED MESSAGE -----
PACKAGING TYPE: SIGNED
Quoted 4 lines · Mathieu Desnoyers
The problem with your proposal, I guess, is that people will have to add a supplementary parameter to the macro.
It is not uncommon to have two slightly versions of macros/functions in the kernel (preempt_enable()/preempt_enable_no_resched(), or macros starting with underscores). Normally, the underscore states that the macro does not do the proper locking itself (this is not our case). Therefore, I would suggest using a name that suggests against what the macro is protected. For instance, a marker pointing to the generic version is only needed to protect against the debug trap handler and should only be used on x86 and
x86_64.
I can see your point, to a degree. The difference here is that the variants you mention are actually macros that do something, they aren't stubs for code. IOW, you actually know what's happening underneath a foo() vs. _foo() by its name only. Maybe this applies the same to markers, I don't know. But maybe we want to make it easy for those looking at markers that there's a master kill switch somewhere that all markers go through and through which they can all be disabled very simply (say by using a "#if 0"). While different names *may* be doing that, a same name *does* that. But I don't feel too strongly either way, it's really up to those who maintaining the code to say.
Karim
----- KRYPTIVA SIGNED MESSAGE -----
This email claims to have been packaged by Kryptiva. To process this email and authenticate its origin, get the free plugin from:
http://www.kryptiva.com/downloads
----- KRYPTIVA SIGNATURE START ----- AvWVqAAAAAIAAAABAAAAAAAATiACAQAAAAC3AQAIAAAAAgAAAAECABTXxT4xHdR4/1uU1hL2 +TaPrqNB0wMAFNa8GHXZWJH5Dz+D76vfh6JhvWLvBAAUpuIZcCAkCC+ldyaBuoAWxK50HiQF ABRI38gc/foDHQsS6X3W0VP4xTukBwYAFB0lithGcxNZYBHaLDONjp6eo/LoBwAUpXC6F2jf nElq3fnZQpGW97Fk/2QRABgAAAAAAABOIEXcvqAADJ5wAAAAAAAAAB4TAAQAAAAAAAAAggP/ RQ/W0H9H9bhrZyC67an//DbWC4D38PgLoeMG6Tjvx7jWTpEh79DeQ/+sbb9aYZvbwYwtaVaJ VuPEiRnPZX0mqnOFm+GDzE9jB6202lR0Nzczh1WCifbrrXI7CSEjOwI3ve0jcCoGxTEzZRYj LGxuubV8Hh5HU12zi3Mxgdz031Y=
----- KRYPTIVA SIGNATURE END -----
PATCH 1/1 Linux Kernel Markers - cleanup
Linux Kernel Markers - cleanup
- Keep a positive CONFIG_MARKERS_ENABLE_OPTIMIZATION for Makefile.
- Have CONFIG_MARKERS_DISABLE_OPTIMIZATION depending on EMBEDDED shown in the menus.
- CONFIG_MARKERS_ENABLE_OPTIMIZATION depends on !CONFIG_MARKERS_DISABLE_OPTIMIZATION and defaults to y (hidden) (suggested by Martin Bligh)
- GEN_MARK is now declared in linux/marker.h
- asm-generic/marker.h is now only used as a fallback defining MARK as GEN_MARK
- New MARK_NO_TRAP defined for each architecture.
asm-generic : defined as GEN_MARK
asm-i386 : defined as GEN_MARK
asm-powerpc : defined as MARK (because we don't need to use trap for XMC)
- Remove ugly ifdefs SOME_RANDOM_ARCH in architecture agnostic code
It applies on top of the linux-kernel-markers-architecture-independant-code-license-fix patch.
Compiles on
arm
i686 (markers enabled, markers disabled)
ia64
m68k
mips
mipsel
powerpc 405
powerpc 970
s390
sparc (except link error not related to markers)
sparc64x86_64
arch/i386/kernel/marker.c +2 -2
@@ -56,7 +56,7 @@ static struct notifier_block mark_notify = { .priority = 0x7fffffff, /* we need to be notified first */ }; -int arch_marker_set_ins_enable (void *address,char enable) +int marker_set_ins_enable (void *address,char enable) {char saved_byte;int ret;
@@ -91,4 +91,4 @@ int arch_marker_set_ins_enable(void *address, char enable)flush_icache_range (address, size);return 0 ; } -EXPORT_SYMBOL_GPL (arch_marker_set_ins_enable); +EXPORT_SYMBOL_GPL (marker_set_ins_enable);
arch/powerpc/kernel/Makefile +1 -0
@@ -92,3 +92,4 @@ obj-$(CONFIG_PPC64) += $(obj64-y) extra-$(CONFIG_PPC_FPU) += fpu.o extra-$(CONFIG_PPC64) += entry_64.o +obj-$(CONFIG_MARKERS_ENABLE_OPTIMIZATION) += marker.o
arch/powerpc/kernel/marker.c new file +24 -0
@@ -0,0 +1,24 @@ +/* marker.c +* +* Powerpc optimized marker enabling/disabling. +* +* Mathieu Desnoyers <[email protected]> +*/ + +#include <linux/module.h> +#include <linux/marker.h> +#include <linux/string.h> +#include <asm/cacheflush.h> + +int marker_set_ins_enable (void *address,char enable) +{ +char newi[MARK_ENABLE_IMMEDIATE_OFFSET +1 ]; +int size =MARK_ENABLE_IMMEDIATE_OFFSET +sizeof (MARK_ENABLE_TYPE ); + +memcpy (newi, address, size); +MARK_ENABLE (&newi[0 ]) = enable; +memcpy (address, newi, size); +flush_icache_range ((unsigned long )address, size); +return 0 ; +} +EXPORT_SYMBOL_GPL (marker_set_ins_enable);
include/asm-generic/marker.h +14 -25
@@ -1,3 +1,6 @@ +#ifndef _ASM_GENERIC_MARKER_H +#define _ASM_GENERIC_MARKER_H +/* * marker.h *
@@ -10,31 +13,17 @@* "used" attribute to fix a gcc 4.1.x bug. */ -#ifdef CONFIG_MARKERS - -#define GEN_MARK(name, format, args...) \ - do { \ - static marker_probe_func *__mark_call_##name = \ - __mark_empty_function; \ - static char __marker_enable_##name = 0; \ - static const struct __mark_marker_c __mark_c_##name \ - __attribute__((section(".markers.c"))) = \ - { #name, &__mark_call_##name, format, \ - MARKER_GENERIC } ; \ - static const struct __mark_marker __mark_##name \ - __attribute__((section(".markers"))) = \ - { &__mark_c_##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); \ - preempt_enable(); \ - } \ - } while (0) +#include <linux/errno.h> +#define MARK GEN_MARK +#define MARK_NO_TRAP GEN_MARK +#define MARK_ENABLE_TYPE GEN_MARK_ENABLE_TYPE +#define MARK_ENABLE_IMMEDIATE_OFFSET GEN_MARK_ENABLE_IMMEDIATE_OFFSET +#define MARK_ENABLE GEN_MARK_ENABLE -#define GEN_MARK_ENABLE_IMMEDIATE_OFFSET 0 -#define GEN_MARK_ENABLE_TYPE char +static inline int marker_set_ins_enable (void *address,char enable) +{ +return -ENOSYS ; +} -#endif +#endif /* _ASM_GENERIC_MARKER_H */
include/asm-i386/marker.h +5 -2
@@ -36,12 +36,15 @@ } \ } while (0) +#define MARK_NO_TRAP GEN_MARK/* Offset of the immediate value from the start of the movb instruction, in * bytes. */ #define MARK_ENABLE_IMMEDIATE_OFFSET 1#define MARK_ENABLE_TYPE char -#define MARK_POLYMORPHIC +/* Dereference enable as lvalue from a pointer to its instruction */ +#define MARK_ENABLE (a) \ + *(MARK_ENABLE_TYPE*)((char*)a+MARK_ENABLE_IMMEDIATE_OFFSET) -extern int arch_marker_set_ins_enable (void *address,char enable); +extern int marker_set_ins_enable (void *address,char enable);#endif
include/asm-powerpc/marker.h +6 -1
@@ -40,10 +40,15 @@ } while (0) +#define MARK_NO_TRAP MARK/* Offset of the immediate value from the start of the addi instruction (result * of the li mnemonic), in bytes. */ #define MARK_ENABLE_IMMEDIATE_OFFSET 2#define MARK_ENABLE_TYPE short -#define MARK_POLYMORPHIC +/* Dereference enable as lvalue from a pointer to its instruction */ +#define MARK_ENABLE (a) \ + *(MARK_ENABLE_TYPE*)((char*)a+MARK_ENABLE_IMMEDIATE_OFFSET) + +extern int marker_set_ins_enable (void *address,char enable);#endif
include/linux/marker.h +39 -45
112 lines not on this page · raw message
kernel/Kconfig.marker +8 -4
@@ -7,10 +7,14 @@ config MARKERS Place an empty function call at each marker site. Can be dynamically changed for a probe function. -config MARKERS_ENABLE_OPTIMIZATION - bool "Enable marker optimization" - depends on MARKERS - default y +config MARKERS_DISABLE_OPTIMIZATION + bool "Disable marker optimization" + depends on MARKERS && EMBEDDED + default n help Disable code replacement jump optimisations. Especially useful if your code is in a read-only rom/flash. + +config MARKERS_ENABLE_OPTIMIZATION + def_bool y + depends on MARKERS && !MARKERS_DISABLE_OPTIMIZATION
kernel/module.c +0 -23
@@ -307,29 +307,6 @@ void __mark_empty_function(const char *fmt, ...) }EXPORT_SYMBOL_GPL (__mark_empty_function); -#ifdef MARK_POLYMORPHIC -static int marker_set_ins_enable (void *address,char enable) -{ -#ifdef CONFIG_X86_32 -return arch_marker_set_ins_enable (address, enable); -#else -char newi[MARK_ENABLE_IMMEDIATE_OFFSET +1 ]; -int size =MARK_ENABLE_IMMEDIATE_OFFSET +sizeof (MARK_ENABLE_TYPE ); - -memcpy (newi, address, size); -MARK_ENABLE (&newi[0 ]) = enable; -memcpy (address, newi, size); -flush_icache_range ((unsigned long )address, size); -return 0 ; -#endif //CONFIG_X86_32 -} -#else -static int marker_set_ins_enable (void *address,char enable) -{ -return -EPERM ; -} -#endif //MARK_POLYMORPHIC -static int marker_set_gen_enable (void *address,char enable) {GEN_MARK_ENABLE (address) = enable;
Signature · 3 lines
Mathieu Desnoyers Computer Engineering Ph.D. Candidate, Ecole Polytechnique de Montreal OpenPGP key fingerprint: 8CD5 52C3 8E3C 4140 715F BA06 3F25 A8FE 3BAE 9A68
Quoted 2 lines · On Sun, 11 Feb 2007 15:03:22 -0500 Mathieu Desnoyers…
You will find, in the following posts, the latest revision of the Linux Kernel Markers.
<looks for the documentation>
And what can I do with these markers?
And once I've done it, are there any userspace applications I can use to get the data out in human-usable form?
It seems to me that these patches aren't sequenced correctly - the kernel won't build at each step of the patch sequence. Maybe I'm mistaken in that. We prefer it this way so that people don't hit wont-compile points when doing bisection searches.
Quoted 3 lines · akpm
[...] And what can I do with these markers? And once I've done it, are there any userspace applications I can use to get the data out in human-usable form? [...]
The LTTng user-space programs use it today. Systemtap used to support the earlier marker prototype and will be rapidly ported over to this new API upon acceptance.
- FChE
Quoted 11 lines · On 15 Feb 2007 10:28:57 -0500 [email protected] (Frank Ch. Eigler) wrote:
Quoted 3 lines · akpm
[...] And what can I do with these markers? And once I've done it, are there any userspace applications I can use to get the data out in human-usable form? [...]
The LTTng user-space programs use it today. Systemtap used to support the earlier marker prototype and will be rapidly ported over to this new API upon acceptance.
That's good.
It would be beneficial if some people from those projects could spare the cycles to carefully review and runtime test this code.
Also, I'm not 100% clear on where we ended up with the huge static-vs-dynamic flamewar. Did everyone end up happy? Is this patchset a reasonable compromise? Or do we need a rematch?
Quoted 15 lines · * Andrew Morton ([email protected]) wrote:
Quoted 11 lines · On 15 Feb 2007 10:28:57 -0500 [email protected] (Frank Ch. Eigler) wrote:
Quoted 3 lines · akpm
[...] And what can I do with these markers? And once I've done it, are there any userspace applications I can use to get the data out in human-usable form? [...]
The LTTng user-space programs use it today. Systemtap used to support the earlier marker prototype and will be rapidly ported over to this new API upon acceptance.
Quoted 5 lines
That's good.
It would be beneficial if some people from those projects could spare the cycles to carefully review and runtime test this code.
LTTng is using the marker infrastructure since last november. Me and my users have been very happy with it.
Quoted 3 lines
Also, I'm not 100% clear on where we ended up with the huge static-vs-dynamic flamewar. Did everyone end up happy? Is this patchset a reasonable compromise? Or do we need a rematch?
I think the final agreement was the need for some kind of code marking system, which I tried to implement as best as I could. It gives very good performances while tracing (advantage of static tracing), has a very very minimal performance and binary size impact when disabled (advantage of dynamic tracing) and it can be activated dynamically (advantage of dynamic tracing).
Mathieu
Signature · 3 lines
Mathieu Desnoyers Computer Engineering Ph.D. Candidate, École Polytechnique de Montréal OpenPGP key fingerprint: 8CD5 52C3 8E3C 4140 715F BA06 3F25 A8FE 3BAE 9A68
Quoted 21 lines · Andrew Morton
Quoted 4 lines · On 15 Feb 2007 10:28:57 -0500 [email protected] (Frank Ch. Eigler) wrote:
akpm wrote:
Quoted 11 lines
Quoted 5 lines
[...] And what can I do with these markers? And once I've done it, are there any userspace applications I can use to get the data out in human-usable form? [...]
The LTTng user-space programs use it today. Systemtap used to support the earlier marker prototype and will be rapidly ported over to this new API upon acceptance.
Quoted 6 lines
That's good.
It would be beneficial if some people from those projects could spare the cycles to carefully review and runtime test this code.
Sure, as soon as SystemTap translator supports this new marker mechanism we will give it a spin and report results.
Quoted 5 lines
Also, I'm not 100% clear on where we ended up with the huge static-vs-dynamic flamewar. Did everyone end up happy? Is this patchset a reasonable compromise? Or do we need a rematch?
From my view this is a good compromise. We all realized in that long discussion thread that we need a way to mark the code in the middle of functions that can later be activated dynamically. Mathieu's current implementation meets that goal. I will be happy to see this in.
Thanks,
Vara Prasad
Quoted 7 lines · * Andrew Morton ([email protected]) wrote:
Quoted 2 lines · On Sun, 11 Feb 2007 15:03:22 -0500 Mathieu Desnoyers…
You will find, in the following posts, the latest revision of the Linux Kernel Markers.
<looks for the documentation>
I guess the header of include/linux/marker.h should go into Documentation/marker.txt. Will fix. Will be in the next reply.
Quoted 2 lines
And what can I do with these markers?
You can put markers at important locations in the code. They act as lightweight hooks that can pass an abitrary number of parameters, described in a printk-like format string, to a function.
They can be used for tracing (LTTng, LKET over SystemTAP), overall performance accounting (SystemTAP). They could also be used to implement efficient hooks for SELinux or any other subsystem the would have this kind of need.
Quoted 3 lines
And once I've done it, are there any userspace applications I can use to get the data out in human-usable form?
LTTng and LTTV, SystemTAP (should be updated to the new API).
Quoted 3 lines
It seems to me that these patches aren't sequenced correctly - the kernel won't build at each step of the patch sequence. Maybe I'm mistaken in that. We prefer it this way so that people don't hit wont-compile points when doing bisection searches.
Will fix for the next complete post.
Mathieu
Signature · 3 lines
Mathieu Desnoyers Computer Engineering Ph.D. Candidate, Ecole Polytechnique de Montreal OpenPGP key fingerprint: 8CD5 52C3 8E3C 4140 715F BA06 3F25 A8FE 3BAE 9A68
PATCH 1/1 Linux Kernel Markers Documentation
In reply to Andrew MortonLinux Kernel Markers - Documentation
Here is some documentation explaining what is/how to use the Linux Kernel Markers.
Documentation/marker.txt new file +130 -0
@@ -0,0 +1,130 @@ + Using the Linux Kernel Markers + + Mathieu Desnoyers + + + This document discusses the purpose of markers. It shows some usage +examples of the Linux Kernel Markers : how to insert markers within the kernel +and how to connect probes to a marker. Finally, it has some probe module +examples. This is what connects to a marker. + + +* Purpose of markers + +You can put markers at important locations in the code. They act as +lightweight hooks that can pass an arbitrary number of parameters, +described in a printk-like format string, to a function whenever the marker +code is reached. + +They can be used for tracing (LTTng, LKET over SystemTAP), overall performance +accounting (SystemTAP). They could also be used to implement +efficient hooks for SELinux or any other subsystem the would have this +kind of need. + +Using the markers for system audit (SELinux) would require to pass a +variable by address that would be later checked by the marked routine. + + +* Usage + +MARK(subsystem_event, "%d %s %p[struct task_struct]", + someint, somestring, current); +Where : +- Subsystem is the name of your subsystem. +- event is the name of the event to mark. +- "%d %s %p[struct task_struct]" is the formatted string for (printk-style). +- someint is an integer. +- somestring is a char pointer. +- current is a pointer to a struct task_struct. + +The expression %p[struct task_struct] is a suggested marker definition +standard that could eventually be used for pointer type checking in +sparse. The brackets contain the type to which the pointer refer. + +The marker mechanism supports multiple instances of the same marker. +Markers can be put in inline functions, inlined static functions and +unrolled loops. + +Note : It is safe to put markers within preempt-safe code : preempt_enable() +will not call the scheduler due to the tests in preempt_schedule(). + + +* Optimization for a given architecture + +You will find, in asm-*/marker.h, optimisations for given architectures +(currently i386 and powerpc). They use a load immediate instead of a data read, +which saves a data cache hit, but also requires cross CPU code modification. In +order to support embedded systems which use read-only memory for their code, the +optimization can be disabled through menu options. + + +* Probe example + +------------------------------ CUT ------------------------------------- +/* probe-example.c + * + * Loads a function at a marker call site. + * + * (C) Copyright 2007 Mathieu Desnoyers <[email protected]> + * + * This file is released under the GPLv2. + * See the file COPYING for more details. + */ + +#include <linux/sched.h> +#include <linux/kernel.h> + +#define SUBSYSTEM_EVENT_FORMAT "%d %s %p[struct task_struct]" +void probe_subsystem_event(const char *format, ...) +{ + va_list ap; + /* Declare args */ + unsigned int value; + const char *mystr; + struct task_struct *task; + + /* Assign args */ + va_start(ap, format); + value = va_arg(ap, typeof(value)); + mystr = va_arg(ap, typeof(mystr)); + task = va_arg(ap, typeof(task)); + + /* Call tracer */ + trace_subsystem_event(value, mystr, task); + + /* Or call printk */ + vprintk(format, ap); + + /* or count, check rights... */ + + va_end(ap); +} + +static int __init probe_init(void) +{ + int result; + result = marker_set_probe("subsystem_event", + FS_CLOSE_FORMAT, + probe_fs_close); + if (!result) + goto cleanup; + return 0; + +cleanup: + marker_remove_probe(probe_subsystem_event); + return -EPERM; +} + +static void __exit probe_fini(void) +{ + marker_remove_probe(probe_subsystem_event); +} + +module_init(probe_init); +module_exit(probe_fini); + +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("Mathieu Desnoyers"); +MODULE_DESCRIPTION("SUBSYSTEM Probe"); +------------------------------ CUT ------------------------------------- +
Signature · 3 lines
Mathieu Desnoyers Computer Engineering Ph.D. Candidate, Ecole Polytechnique de Montreal OpenPGP key fingerprint: 8CD5 52C3 8E3C 4140 715F BA06 3F25 A8FE 3BAE 9A68
Re: [PATCH] Linux Kernel Markers Documentation
Quoted 21 lines · On Thu, 15 Feb 2007 20:33:48 -0500 Mathieu Desnoyers wrote:
Linux Kernel Markers - Documentation
Here is some documentation explaining what is/how to use the Linux Kernel Markers.
Signed-off-by Mathieu Desnoyers <[email protected]>Documentation/marker.txt new file +11
-0@@ -0,0 +1,130 @@ + Using the Linux Kernel Markers + + Mathieu Desnoyers + + + This document discusses the purpose of markers. It shows some usage +examples of the Linux Kernel Markers : how to insert markers within the kernel +and how to connect probes to a marker. Finally, it has some probe module +examples. This is what connects to a marker. + +
Documentation/marker.txt line 21
Quoted 10 lines
Documentation/marker.txt new file +10
-0+* Purpose of markers + +You can put markers at important locations in the code. They act as +lightweight hooks that can pass an arbitrary number of parameters, +described in a printk-like format string, to a function whenever the marker +code is reached. + +They can be used for tracing (LTTng, LKET over SystemTAP), overall performance +accounting (SystemTAP). They could also be used to implement +efficient hooks for SELinux or any other subsystem the would have this
that
Documentation/marker.txt line 34
Quoted 13 lines
Documentation/marker.txt new file +13
-0+kind of need. + +Using the markers for system audit (SELinux) would require to pass a +variable by address that would be later checked by the marked routine. + + +* Usage + +MARK(subsystem_event, "%d %s %p[struct task_struct]", + someint, somestring, current); +Where : +- Subsystem is the name of your subsystem. +- event is the name of the event to mark.
so is the MARK() supposed to be:
MARK(subsystem, event, ...
Please make the 2 doc. lines above match the parameters... or the parameters match the text.
Documentation/marker.txt line 42
Quoted 8 lines
Documentation/marker.txt new file +8
-0+- "%d %s %p[struct task_struct]" is the formatted string for (printk-style). +- someint is an integer. +- somestring is a char pointer. +- current is a pointer to a struct task_struct. + +The expression %p[struct task_struct] is a suggested marker definition +standard that could eventually be used for pointer type checking in +sparse. The brackets contain the type to which the pointer refer.
refers.
Quoted 25 lines
Documentation/marker.txt new file +25
-0+ +The marker mechanism supports multiple instances of the same marker. +Markers can be put in inline functions, inlined static functions and +unrolled loops. + +Note : It is safe to put markers within preempt-safe code : preempt_enable() +will not call the scheduler due to the tests in preempt_schedule(). + + +* Optimization for a given architecture + +You will find, in asm-*/marker.h, optimisations for given architectures +(currently i386 and powerpc). They use a load immediate instead of a data read, +which saves a data cache hit, but also requires cross CPU code modification. In +order to support embedded systems which use read-only memory for their code, the +optimization can be disabled through menu options. + + +* Probe example + +------------------------------ CUT ------------------------------------- +/* probe-example.c + * + * Loads a function at a marker call site. + *
Documentation/marker.txt line 77
Quoted 10 lines
Documentation/marker.txt new file +10
-0+ * (C) Copyright 2007 Mathieu Desnoyers <[email protected]> + * + * This file is released under the GPLv2. + * See the file COPYING for more details. + */ + +#include <linux/sched.h> +#include <linux/kernel.h> + +#define SUBSYSTEM_EVENT_FORMAT "%d %s %p[struct task_struct]"
Is SUBSYSTEM_EVENT_FORMAT used implicitly below? or elsewhere?
Quoted 21 lines
Documentation/marker.txt new file +21
-0+void probe_subsystem_event(const char *format, ...) +{ + va_list ap; + /* Declare args */ + unsigned int value; + const char *mystr; + struct task_struct *task; + + /* Assign args */ + va_start(ap, format); + value = va_arg(ap, typeof(value)); + mystr = va_arg(ap, typeof(mystr)); + task = va_arg(ap, typeof(task)); + + /* Call tracer */ + trace_subsystem_event(value, mystr, task); + + /* Or call printk */ + vprintk(format, ap); + + /* or count, check rights... */
Documentation/marker.txt line 108
Quoted 10 lines
Documentation/marker.txt new file +10
-0+ + va_end(ap); +} + +static int __init probe_init(void) +{ + int result; + result = marker_set_probe("subsystem_event", + FS_CLOSE_FORMAT, + probe_fs_close);
Do FS_CLOSE_FORMAT and probe_fs_close() need to be defined here? I.e., is this a complete example?
Quoted 11 lines
Documentation/marker.txt new file +11
-0+ if (!result) + goto cleanup; + return 0; + +cleanup: + marker_remove_probe(probe_subsystem_event); + return -EPERM; +} + +static void __exit probe_fini(void) +{
Documentation/marker.txt line 129
Quoted 10 lines
Documentation/marker.txt new file +10
-0+ marker_remove_probe(probe_subsystem_event); +} + +module_init(probe_init); +module_exit(probe_fini); + +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("Mathieu Desnoyers"); +MODULE_DESCRIPTION("SUBSYSTEM Probe"); +------------------------------ CUT -------------------------------------
---
~Randy
*** Remember to use Documentation/SubmitChecklist when testing your code ***
Re: [PATCH] Linux Kernel Markers Documentation
Hi Randy,
Quoted 6 lines · * Randy Dunlap ([email protected]) wrote:
so is the
MARK()supposed to be:
MARK(subsystem, event, ...Please make the 2 doc. lines above match the parameters... or the parameters match the text.
Fixing the paragraph below.
Quoted 10 lines
Documentation/marker.txt line 42
Quoted 8 lines
+- "%d %s %p[struct task_struct]" is the formatted string for (printk-style). +- someint is an integer. +- somestring is a char pointer. +- current is a pointer to a struct task_struct.Documentation/marker.txt new file +4
-0+ +The expression %p[struct task_struct] is a suggested marker definition +standard that could eventually be used for pointer type checking in +sparse. The brackets contain the type to which the pointer refer.refers.
Quoted 5 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ +#define SUBSYSTEM_EVENT_FORMAT "%d %s %p[struct task_struct]"Is
SUBSYSTEM_EVENT_FORMATused implicitly below? or elsewhere?
Yes, error follows.
Quoted 26 lines
Quoted 26 lines
Documentation/marker.txt new file +26
-0+void probe_subsystem_event(const char *format, ...) +{ + va_list ap; + /* Declare args */ + unsigned int value; + const char *mystr; + struct task_struct *task; + + /* Assign args */ + va_start(ap, format); + value = va_arg(ap, typeof(value)); + mystr = va_arg(ap, typeof(mystr)); + task = va_arg(ap, typeof(task)); + + /* Call tracer */ + trace_subsystem_event(value, mystr, task); + + /* Or call printk */ + vprintk(format, ap); + + /* or count, check rights... */ + + va_end(ap); +} + +static int __init probe_init(void)
Quoted 9 lines
Documentation/marker.txt line 108
Quoted 5 lines
Documentation/marker.txt new file +5
-0+{ + int result; + result = marker_set_probe("subsystem_event", + FS_CLOSE_FORMAT, + probe_fs_close);Do
FS_CLOSE_FORMATandprobe_fs_close()need to be defined here? I.e., is this a complete example?
should be SUBSYSTEM_EVENT_FORMAT. Will fix, thanks.
Regards,
Mathieu
Signature · 3 lines
Mathieu Desnoyers Computer Engineering Ph.D. Candidate, Ecole Polytechnique de Montreal OpenPGP key fingerprint: 8CD5 52C3 8E3C 4140 715F BA06 3F25 A8FE 3BAE 9A68
Re: [PATCH] Linux Kernel Markers Documentation - fix
In reply to Randy DunlapLinux Kernel Markers Documentation - fix
Fixes from Randy's comments.
Documentation/marker.txt +7 -6
@@ -18,7 +18,7 @@ code is reached. They can be used for tracing (LTTng, LKET over SystemTAP), overall performance accounting (SystemTAP). They could also be used to implement -efficient hooks for SELinux or any other subsystem the would have this +efficient hooks for SELinux or any other subsystem that would have this kind of need. Using the markers for system audit (SELinux) would require to pass a
@@ -30,8 +30,9 @@ variable by address that would be later checked by the marked routine. MARK(subsystem_event, "%d %s %p[struct task_struct]", someint, somestring, current); Where : -- Subsystem is the name of your subsystem. -- event is the name of the event to mark. +- subsystem_event is an identifier unique to your event + - subsystem is the name of your subsystem. + - event is the name of the event to mark. - "%d %s %p[struct task_struct]" is the formatted string for (printk-style). - someint is an integer. - somestring is a char pointer.
@@ -39,7 +40,7 @@ Where : The expression %p[struct task_struct] is a suggested marker definition standard that could eventually be used for pointer type checking in -sparse. The brackets contain the type to which the pointer refer. +sparse. The brackets contain the type to which the pointer refers. The marker mechanism supports multiple instances of the same marker. Markers can be put in inline functions, inlined static functions and
@@ -104,8 +105,8 @@ static int __init probe_init(void) { int result; result = marker_set_probe("subsystem_event", - FS_CLOSE_FORMAT, - probe_fs_close); + SUBSYSTEM_EVENT_FORMAT, + probe_subsystem_event); if (!result) goto cleanup; return 0;
Signature · 3 lines
Mathieu Desnoyers Computer Engineering Ph.D. Candidate, Ecole Polytechnique de Montreal OpenPGP key fingerprint: 8CD5 52C3 8E3C 4140 715F BA06 3F25 A8FE 3BAE 9A68