aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBjoern B. Brandenburg <bbb@cs.unc.edu>2010-05-31 12:52:35 -0400
committerBjoern B. Brandenburg <bbb@cs.unc.edu>2010-06-01 10:43:11 -0400
commit753fb14dfb0662e1d38758ffc6876c0ab1c7bd9e (patch)
treed03e024cfd3d815e039a4c2d55f7c35108271af8
parent62c186fde48926a30f4e61332a805430dc1325cd (diff)
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.
-rw-r--r--arch/x86/kernel/ft_event.c3
-rw-r--r--include/litmus/feather_trace.h14
-rw-r--r--litmus/Kconfig9
-rw-r--r--litmus/ft_event.c2
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 @@
6 * exclusive access to the event table 6 * exclusive access to the event table
7 */ 7 */
8 8
9#ifndef CONFIG_DEBUG_RODATA
9 10
10#define BYTE_JUMP 0xeb 11#define BYTE_JUMP 0xeb
11#define BYTE_JUMP_LEN 0x02 12#define BYTE_JUMP_LEN 0x02
@@ -106,3 +107,5 @@ int ft_is_event_enabled(unsigned long id)
106 } 107 }
107 return 0; 108 return 0;
108} 109}
110
111#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)
19 return atomic_sub_return(1, (atomic_t*) val) + 1; 19 return atomic_sub_return(1, (atomic_t*) val) + 1;
20} 20}
21 21
22#ifdef CONFIG_ARCH_HAS_FEATHER_TRACE 22/* Don't use rewriting implementation if kernel text pages are read-only.
23 * Ftrace gets around this by using the identity mapping, but that's more
24 * effort that is warrented right now for Feather-Trace.
25 * Eventually, it may make sense to replace Feather-Trace with ftrace.
26 */
27#if defined(CONFIG_ARCH_HAS_FEATHER_TRACE) && !defined(CONFIG_DEBUG_RODATA)
23 28
24#include <asm/feather_trace.h> 29#include <asm/feather_trace.h>
25 30
@@ -27,6 +32,13 @@ static inline int fetch_and_dec(int *val)
27 32
28/* provide default implementation */ 33/* provide default implementation */
29 34
35#include <asm/timex.h> /* for get_cycles() */
36
37static inline unsigned long long ft_timestamp(void)
38{
39 return get_cycles();
40}
41
30#define feather_callback 42#define feather_callback
31 43
32#define MAX_EVENTS 1024 44#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
80 Feather-Trace basic tracing infrastructure. Includes device file 80 Feather-Trace basic tracing infrastructure. Includes device file
81 driver and instrumentation point support. 81 driver and instrumentation point support.
82 82
83 There are actually two implementations of Feather-Trace.
84 1) A slower, but portable, default implementation.
85 2) Architecture-specific implementations that rewrite kernel .text at runtime.
86
87 If enabled, Feather-Trace will be based on 2) if available (currently only for x86).
88 However, if DEBUG_RODATA=y, then Feather-Trace will choose option 1) in any case
89 to avoid problems with write-protected .text pages.
90
91 Bottom line: to avoid increased overheads, choose DEBUG_RODATA=n.
83 92
84config SCHED_TASK_TRACE 93config SCHED_TASK_TRACE
85 bool "Trace real-time tasks" 94 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 @@
2 2
3#include <litmus/feather_trace.h> 3#include <litmus/feather_trace.h>
4 4
5#ifndef CONFIG_ARCH_HAS_FEATHER_TRACE 5#if !defined(CONFIG_ARCH_HAS_FEATHER_TRACE) || defined(CONFIG_DEBUG_RODATA)
6/* provide dummy implementation */ 6/* provide dummy implementation */
7 7
8int ft_events[MAX_EVENTS]; 8int ft_events[MAX_EVENTS];