linux-kernel-markers-powerpc-optimization-flags
PATCH 1/1 linux-kernel-markers-powerpc-optimization-flags
linux-kernel-markers-powerpc-optimization-flags
Add flag support to powerpc optimization
Fix the .section .markers, \"a\", @progbits;\n\t inline assembly :
adding the @progbits seems to remove a warning from the linker (forces the section to DATA, which is the same a what the MARK_GENERIC version does).
Signed-off-by Mathieu Desnoyers <[email protected]>
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 +25 -0
@@ -0,0 +1,25 @@ +/* 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_optimized_set_enable (void *address,char enable) +{ +char newi[MARK_OPTIMIZED_ENABLE_IMMEDIATE_OFFSET +1 ]; +int size =MARK_OPTIMIZED_ENABLE_IMMEDIATE_OFFSET + +sizeof (MARK_OPTIMIZED_ENABLE_TYPE ); + +memcpy (newi, address, size); +MARK_OPTIMIZED_ENABLE (&newi[0 ]) = enable; +memcpy (address, newi, size); +flush_icache_range ((unsigned long )address, size); +return 0 ; +} +EXPORT_SYMBOL_GPL (marker_optimized_set_enable);
include/asm-powerpc/marker.h +22 -6
@@ -14,16 +14,18 @@#ifdef CONFIG_MARKERS -#define MARK(name, format, args...) \ +#define _MF_DEFAULT (_MF_OPTIMIZED | _MF_LOCKDEP | _MF_PRINTK) + +#define MARK_OPTIMIZED(flags, 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 } ; \ + (flags) | _MF_OPTIMIZED } ; \ char condition; \ - asm volatile( ".section .markers, \"a\";\n\t" \ + asm volatile( ".section .markers, \"a\", @progbits;\n\t" \ PPC_LONG "%1, 0f;\n\t" \ ".previous;\n\t" \ ".align 4\n\t" \
@@ -39,11 +41,25 @@ } \ } while (0) +#define _MARK(flags, format, args...) \ +do { \ + if ((flags) & _MF_OPTIMIZED) \ + MARK_OPTIMIZED(flags, format, ## args); \ + else \ + MARK_GENERIC(flags, format, ## args); \ +} while (0) + +#define MARK(format, args...) _MARK(_MF_DEFAULT, format, ## args)/* 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 +#define MARK_OPTIMIZED_ENABLE_IMMEDIATE_OFFSET 2 +#define MARK_OPTIMIZED_ENABLE_TYPE short +/* Dereference enable as lvalue from a pointer to its instruction */ +#define MARK_OPTIMIZED_ENABLE (a) \ + *(MARK_OPTIMIZED_ENABLE_TYPE*) \ + ((char*)a+MARK_OPTIMIZED_ENABLE_IMMEDIATE_OFFSET) + +extern int marker_optimized_set_enable (void *address,char enable);#endif
Signature · 3 lines
Mathieu Desnoyers Computer Engineering Ph.D. Student, Ecole Polytechnique de Montreal OpenPGP key fingerprint: 8CD5 52C3 8E3C 4140 715F BA06 3F25 A8FE 3BAE 9A68