[PATCH] 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) sparc64 x86_64 Signed-off-by: Mathieu Desnoyers <[EMAIL PROTECTED]> --- a/arch/i386/kernel/marker.c +++ b/arch/i386/kernel/marker.c @@ -56,7 +56,7 @@ static struct notifier_block mark_notify = { .priority = 0x7fff, /* 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); --- a/arch/powerpc/kernel/Makefile +++ b/arch/powerpc/kernel/Makefile @@ -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 --- /dev/null +++ b/arch/powerpc/kernel/marker.c @@ -0,0 +1,24 @@ +/* marker.c + * + * Powerpc optimized marker enabling/disabling. + * + * Mathieu Desnoyers <[EMAIL PROTECTED]> + */ + +#include +#include +#include +#include + +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([0]) = enable; + memcpy(address, newi, size); + flush_icache_range((unsigned long)address, size); + return 0; +} +EXPORT_SYMBOL_GPL(marker_set_ins_enable); --- a/include/asm-generic/marker.h +++ b/include/asm-generic/marker.h @@ -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 +#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_ENABLEGEN_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 */ --- a/include/asm-i386/marker.h +++ b/include/asm-i386/marker.h @@ -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
[PATCH] 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) sparc64 x86_64 Signed-off-by: Mathieu Desnoyers [EMAIL PROTECTED] --- a/arch/i386/kernel/marker.c +++ b/arch/i386/kernel/marker.c @@ -56,7 +56,7 @@ static struct notifier_block mark_notify = { .priority = 0x7fff, /* 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); --- a/arch/powerpc/kernel/Makefile +++ b/arch/powerpc/kernel/Makefile @@ -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 --- /dev/null +++ b/arch/powerpc/kernel/marker.c @@ -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); --- a/include/asm-generic/marker.h +++ b/include/asm-generic/marker.h @@ -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_ENABLEGEN_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 */ --- a/include/asm-i386/marker.h +++ b/include/asm-i386/marker.h @@ -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) \ +