From 753fb14dfb0662e1d38758ffc6876c0ab1c7bd9e Mon Sep 17 00:00:00 2001 From: "Bjoern B. Brandenburg" Date: Mon, 31 May 2010 12:52:35 -0400 Subject: Make platform-specific Feather-Trace depend on !CONFIG_DEBUG_RODATA Feather-Trace rewrites instructions in the kernel's .text segment. This segment may be write-protected if CONFIG_DEBUG_RODATA is selected. In this case, fall back to the default flag-based Feather-Trace implementation. In the future, we could either adopt the ftrace method of rewriting .text addresses using non-.text mappings or we could consider replacing Feather-Trace with ftrace altogether. For now, this patch avoids unexpected runtime errors. --- arch/x86/kernel/ft_event.c | 3 +++ include/litmus/feather_trace.h | 14 +++++++++++++- litmus/Kconfig | 9 +++++++++ litmus/ft_event.c | 2 +- 4 files changed, 26 insertions(+), 2 deletions(-) diff --git a/arch/x86/kernel/ft_event.c b/arch/x86/kernel/ft_event.c index da9b3ccb7259..6552e2741ecf 100644 --- a/arch/x86/kernel/ft_event.c +++ b/arch/x86/kernel/ft_event.c @@ -6,6 +6,7 @@ * exclusive access to the event table */ +#ifndef CONFIG_DEBUG_RODATA #define BYTE_JUMP 0xeb #define BYTE_JUMP_LEN 0x02 @@ -106,3 +107,5 @@ int ft_is_event_enabled(unsigned long id) } return 0; } + +#endif diff --git a/include/litmus/feather_trace.h b/include/litmus/feather_trace.h index f3bbfa0935ef..028dfb206fb0 100644 --- a/include/litmus/feather_trace.h +++ b/include/litmus/feather_trace.h @@ -19,7 +19,12 @@ static inline int fetch_and_dec(int *val) return atomic_sub_return(1, (atomic_t*) val) + 1; } -#ifdef CONFIG_ARCH_HAS_FEATHER_TRACE +/* Don't use rewriting implementation if kernel text pages are read-only. + * Ftrace gets around this by using the identity mapping, but that's more + * effort that is warrented right now for Feather-Trace. + * Eventually, it may make sense to replace Feather-Trace with ftrace. + */ +#if defined(CONFIG_ARCH_HAS_FEATHER_TRACE) && !defined(CONFIG_DEBUG_RODATA) #include @@ -27,6 +32,13 @@ static inline int fetch_and_dec(int *val) /* provide default implementation */ +#include /* for get_cycles() */ + +static inline unsigned long long ft_timestamp(void) +{ + return get_cycles(); +} + #define feather_callback #define MAX_EVENTS 1024 diff --git a/litmus/Kconfig b/litmus/Kconfig index 1c0a96d54992..f3aa7478faf7 100644 --- a/litmus/Kconfig +++ b/litmus/Kconfig @@ -80,6 +80,15 @@ config FEATHER_TRACE Feather-Trace basic tracing infrastructure. Includes device file driver and instrumentation point support. + There are actually two implementations of Feather-Trace. + 1) A slower, but portable, default implementation. + 2) Architecture-specific implementations that rewrite kernel .text at runtime. + + If enabled, Feather-Trace will be based on 2) if available (currently only for x86). + However, if DEBUG_RODATA=y, then Feather-Trace will choose option 1) in any case + to avoid problems with write-protected .text pages. + + Bottom line: to avoid increased overheads, choose DEBUG_RODATA=n. config SCHED_TASK_TRACE bool "Trace real-time tasks" diff --git a/litmus/ft_event.c b/litmus/ft_event.c index 58124fe0ad90..399a07becca5 100644 --- a/litmus/ft_event.c +++ b/litmus/ft_event.c @@ -2,7 +2,7 @@ #include -#ifndef CONFIG_ARCH_HAS_FEATHER_TRACE +#if !defined(CONFIG_ARCH_HAS_FEATHER_TRACE) || defined(CONFIG_DEBUG_RODATA) /* provide dummy implementation */ int ft_events[MAX_EVENTS]; -- cgit v1.2.2