diff options
author | Bjoern B. Brandenburg <bbb@cs.unc.edu> | 2011-07-25 12:42:27 -0400 |
---|---|---|
committer | Bjoern B. Brandenburg <bbb@cs.unc.edu> | 2011-07-25 12:42:27 -0400 |
commit | a55f6ec8f509ddecaeb153d16065ab256bb8086a (patch) | |
tree | f3165f5bf3d7409a1d10f8b34c6a4e2686c1dcdb | |
parent | 038e435397bb5c2913a9a5796982d6843fc8d4ea (diff) |
locking: trace system call entry/exit cost
-rw-r--r-- | include/litmus/litmus.h | 10 | ||||
-rw-r--r-- | include/litmus/rt_param.h | 3 | ||||
-rw-r--r-- | include/litmus/trace.h | 13 | ||||
-rw-r--r-- | litmus/locking.c | 16 | ||||
-rw-r--r-- | litmus/trace.c | 24 |
5 files changed, 66 insertions, 0 deletions
diff --git a/include/litmus/litmus.h b/include/litmus/litmus.h index b5d8abb4aea5..5883a67c5750 100644 --- a/include/litmus/litmus.h +++ b/include/litmus/litmus.h | |||
@@ -127,6 +127,16 @@ void srp_ceiling_block(void); | |||
127 | 127 | ||
128 | #define bheap2task(hn) ((struct task_struct*) hn->value) | 128 | #define bheap2task(hn) ((struct task_struct*) hn->value) |
129 | 129 | ||
130 | static inline struct control_page* get_control_page(struct task_struct *t) | ||
131 | { | ||
132 | return tsk_rt(t)->ctrl_page; | ||
133 | } | ||
134 | |||
135 | static inline int has_control_page(struct task_struct* t) | ||
136 | { | ||
137 | return tsk_rt(t)->ctrl_page != NULL; | ||
138 | } | ||
139 | |||
130 | #ifdef CONFIG_NP_SECTION | 140 | #ifdef CONFIG_NP_SECTION |
131 | 141 | ||
132 | static inline int is_kernel_np(struct task_struct *t) | 142 | static inline int is_kernel_np(struct task_struct *t) |
diff --git a/include/litmus/rt_param.h b/include/litmus/rt_param.h index 3fb3c76225f2..57496662afde 100644 --- a/include/litmus/rt_param.h +++ b/include/litmus/rt_param.h | |||
@@ -66,6 +66,9 @@ struct control_page { | |||
66 | * its non-preemptive section? */ | 66 | * its non-preemptive section? */ |
67 | int delayed_preemption; | 67 | int delayed_preemption; |
68 | 68 | ||
69 | /* locking overhead tracing: time stamp prior to system call */ | ||
70 | uint64_t ts_syscall_start; /* Feather-Trace cycles */ | ||
71 | |||
69 | /* to be extended */ | 72 | /* to be extended */ |
70 | }; | 73 | }; |
71 | 74 | ||
diff --git a/include/litmus/trace.h b/include/litmus/trace.h index 3f0743ec9063..5aba68f18893 100644 --- a/include/litmus/trace.h +++ b/include/litmus/trace.h | |||
@@ -29,6 +29,7 @@ feather_callback void save_timestamp_def(unsigned long event, unsigned long type | |||
29 | feather_callback void save_timestamp_task(unsigned long event, unsigned long t_ptr); | 29 | feather_callback void save_timestamp_task(unsigned long event, unsigned long t_ptr); |
30 | feather_callback void save_timestamp_cpu(unsigned long event, unsigned long cpu); | 30 | feather_callback void save_timestamp_cpu(unsigned long event, unsigned long cpu); |
31 | feather_callback void save_task_latency(unsigned long event, unsigned long when_ptr); | 31 | feather_callback void save_task_latency(unsigned long event, unsigned long when_ptr); |
32 | feather_callback void save_timestamp_time(unsigned long event, unsigned long time_ptr); | ||
32 | 33 | ||
33 | #define TIMESTAMP(id) ft_event0(id, save_timestamp) | 34 | #define TIMESTAMP(id) ft_event0(id, save_timestamp) |
34 | 35 | ||
@@ -43,6 +44,9 @@ feather_callback void save_task_latency(unsigned long event, unsigned long when_ | |||
43 | #define LTIMESTAMP(id, task) \ | 44 | #define LTIMESTAMP(id, task) \ |
44 | ft_event1(id, save_task_latency, (unsigned long) task) | 45 | ft_event1(id, save_task_latency, (unsigned long) task) |
45 | 46 | ||
47 | #define TIMESTAMP_TIME(id, time_ptr) \ | ||
48 | ft_event1(id, save_timestamp_time, (unsigned long) time_ptr) | ||
49 | |||
46 | #else /* !CONFIG_SCHED_OVERHEAD_TRACE */ | 50 | #else /* !CONFIG_SCHED_OVERHEAD_TRACE */ |
47 | 51 | ||
48 | #define TIMESTAMP(id) /* no tracing */ | 52 | #define TIMESTAMP(id) /* no tracing */ |
@@ -55,6 +59,8 @@ feather_callback void save_task_latency(unsigned long event, unsigned long when_ | |||
55 | 59 | ||
56 | #define LTIMESTAMP(id, when_ptr) /* no tracing */ | 60 | #define LTIMESTAMP(id, when_ptr) /* no tracing */ |
57 | 61 | ||
62 | #define TIMESTAMP_TIME(id, time_ptr) /* no tracing */ | ||
63 | |||
58 | #endif | 64 | #endif |
59 | 65 | ||
60 | 66 | ||
@@ -106,6 +112,13 @@ feather_callback void save_task_latency(unsigned long event, unsigned long when_ | |||
106 | #define TS_UNLOCK_START TIMESTAMP(180) | 112 | #define TS_UNLOCK_START TIMESTAMP(180) |
107 | #define TS_UNLOCK_END TIMESTAMP(181) | 113 | #define TS_UNLOCK_END TIMESTAMP(181) |
108 | 114 | ||
115 | #define TS_SYSCALL_IN_START(p) TIMESTAMP_TIME(190, p) | ||
116 | #define TS_SYSCALL_IN_END TIMESTAMP(191) | ||
117 | |||
118 | #define TS_SYSCALL_OUT_START TIMESTAMP(200) | ||
119 | #define TS_SYSCALL_OUT_END TIMESTAMP(201) | ||
120 | |||
121 | |||
109 | #define TS_SEND_RESCHED_START(c) CTIMESTAMP(190, c) | 122 | #define TS_SEND_RESCHED_START(c) CTIMESTAMP(190, c) |
110 | #define TS_SEND_RESCHED_END DTIMESTAMP(191, TSK_UNKNOWN) | 123 | #define TS_SEND_RESCHED_END DTIMESTAMP(191, TSK_UNKNOWN) |
111 | 124 | ||
diff --git a/litmus/locking.c b/litmus/locking.c index cea3191f6ed4..c164ca3ab6cb 100644 --- a/litmus/locking.c +++ b/litmus/locking.c | |||
@@ -1,3 +1,5 @@ | |||
1 | #include <linux/sched.h> | ||
2 | #include <litmus/litmus.h> | ||
1 | #include <litmus/fdso.h> | 3 | #include <litmus/fdso.h> |
2 | 4 | ||
3 | #ifdef CONFIG_LITMUS_LOCKING | 5 | #ifdef CONFIG_LITMUS_LOCKING |
@@ -70,6 +72,11 @@ asmlinkage long sys_litmus_lock(int lock_od) | |||
70 | struct od_table_entry* entry; | 72 | struct od_table_entry* entry; |
71 | struct litmus_lock* l; | 73 | struct litmus_lock* l; |
72 | 74 | ||
75 | if (has_control_page(current)) | ||
76 | TS_SYSCALL_IN_START(&get_control_page(current)->ts_syscall_start); | ||
77 | |||
78 | TS_SYSCALL_IN_END; | ||
79 | |||
73 | TS_LOCK_START; | 80 | TS_LOCK_START; |
74 | 81 | ||
75 | entry = get_entry_for_od(lock_od); | 82 | entry = get_entry_for_od(lock_od); |
@@ -83,6 +90,8 @@ asmlinkage long sys_litmus_lock(int lock_od) | |||
83 | * this into account when computing overheads. */ | 90 | * this into account when computing overheads. */ |
84 | TS_UNLOCK_END; | 91 | TS_UNLOCK_END; |
85 | 92 | ||
93 | TS_SYSCALL_OUT_START; | ||
94 | |||
86 | return err; | 95 | return err; |
87 | } | 96 | } |
88 | 97 | ||
@@ -92,6 +101,11 @@ asmlinkage long sys_litmus_unlock(int lock_od) | |||
92 | struct od_table_entry* entry; | 101 | struct od_table_entry* entry; |
93 | struct litmus_lock* l; | 102 | struct litmus_lock* l; |
94 | 103 | ||
104 | if (has_control_page(current)) | ||
105 | TS_SYSCALL_IN_START(&get_control_page(current)->ts_syscall_start); | ||
106 | |||
107 | TS_SYSCALL_IN_END; | ||
108 | |||
95 | TS_UNLOCK_START; | 109 | TS_UNLOCK_START; |
96 | 110 | ||
97 | entry = get_entry_for_od(lock_od); | 111 | entry = get_entry_for_od(lock_od); |
@@ -105,6 +119,8 @@ asmlinkage long sys_litmus_unlock(int lock_od) | |||
105 | * account when computing overheads. */ | 119 | * account when computing overheads. */ |
106 | TS_UNLOCK_END; | 120 | TS_UNLOCK_END; |
107 | 121 | ||
122 | TS_SYSCALL_OUT_START; | ||
123 | |||
108 | return err; | 124 | return err; |
109 | } | 125 | } |
110 | 126 | ||
diff --git a/litmus/trace.c b/litmus/trace.c index 5d77806da647..1288e2e252c2 100644 --- a/litmus/trace.c +++ b/litmus/trace.c | |||
@@ -50,6 +50,30 @@ static inline void __save_timestamp(unsigned long event, | |||
50 | __save_timestamp_cpu(event, type, raw_smp_processor_id()); | 50 | __save_timestamp_cpu(event, type, raw_smp_processor_id()); |
51 | } | 51 | } |
52 | 52 | ||
53 | static inline uint8_t task_type(struct task_struct* t) | ||
54 | { | ||
55 | if (!t) | ||
56 | return TSK_UNKNOWN; | ||
57 | else | ||
58 | return is_realtime(t) ? TSK_RT : TSK_BE; | ||
59 | } | ||
60 | |||
61 | feather_callback void save_timestamp_time(unsigned long event, unsigned long ptr) | ||
62 | { | ||
63 | uint64_t* time = (uint64_t*) ptr; | ||
64 | unsigned int seq_no; | ||
65 | struct timestamp *ts; | ||
66 | seq_no = fetch_and_inc((int *) &ts_seq_no); | ||
67 | if (ft_buffer_start_write(trace_ts_buf, (void**) &ts)) { | ||
68 | ts->event = event; | ||
69 | ts->timestamp = *time; | ||
70 | ts->seq_no = seq_no; | ||
71 | ts->cpu = raw_smp_processor_id(); | ||
72 | ts->task_type = task_type(current); | ||
73 | ft_buffer_finish_write(trace_ts_buf, ts); | ||
74 | } | ||
75 | } | ||
76 | |||
53 | feather_callback void save_timestamp(unsigned long event) | 77 | feather_callback void save_timestamp(unsigned long event) |
54 | { | 78 | { |
55 | __save_timestamp(event, TSK_UNKNOWN); | 79 | __save_timestamp(event, TSK_UNKNOWN); |