diff options
author | Bjoern B. Brandenburg <bbb@cs.unc.edu> | 2011-07-25 12:42:27 -0400 |
---|---|---|
committer | Christopher Kenna <cjk@cs.unc.edu> | 2011-10-10 17:14:34 -0400 |
commit | 88f2d7fbab4ceba14946cb86c018bc8a2025e876 (patch) | |
tree | c5bdd383f1f3c1b52804324b1f4af7b4e09a38e8 | |
parent | 81d6f2711010d4073e29ea38bc717ee6f4ed3a53 (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 | 20 | ||||
-rw-r--r-- | litmus/locking.c | 16 | ||||
-rw-r--r-- | litmus/trace.c | 24 |
5 files changed, 72 insertions, 1 deletions
diff --git a/include/litmus/litmus.h b/include/litmus/litmus.h index 2112eecd1dc8..a3fd5dd269fc 100644 --- a/include/litmus/litmus.h +++ b/include/litmus/litmus.h | |||
@@ -129,6 +129,16 @@ void srp_ceiling_block(void); | |||
129 | 129 | ||
130 | #define bheap2task(hn) ((struct task_struct*) hn->value) | 130 | #define bheap2task(hn) ((struct task_struct*) hn->value) |
131 | 131 | ||
132 | static inline struct control_page* get_control_page(struct task_struct *t) | ||
133 | { | ||
134 | return tsk_rt(t)->ctrl_page; | ||
135 | } | ||
136 | |||
137 | static inline int has_control_page(struct task_struct* t) | ||
138 | { | ||
139 | return tsk_rt(t)->ctrl_page != NULL; | ||
140 | } | ||
141 | |||
132 | #ifdef CONFIG_NP_SECTION | 142 | #ifdef CONFIG_NP_SECTION |
133 | 143 | ||
134 | static inline int is_kernel_np(struct task_struct *t) | 144 | 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 e6288e8807f0..221edad83d77 100644 --- a/include/litmus/rt_param.h +++ b/include/litmus/rt_param.h | |||
@@ -63,6 +63,9 @@ struct control_page { | |||
63 | * its non-preemptive section? */ | 63 | * its non-preemptive section? */ |
64 | int delayed_preemption; | 64 | int delayed_preemption; |
65 | 65 | ||
66 | /* locking overhead tracing: time stamp prior to system call */ | ||
67 | uint64_t ts_syscall_start; /* Feather-Trace cycles */ | ||
68 | |||
66 | /* to be extended */ | 69 | /* to be extended */ |
67 | }; | 70 | }; |
68 | 71 | ||
diff --git a/include/litmus/trace.h b/include/litmus/trace.h index 05f487263f28..d641375bbb04 100644 --- a/include/litmus/trace.h +++ b/include/litmus/trace.h | |||
@@ -28,7 +28,8 @@ feather_callback void save_timestamp(unsigned long event); | |||
28 | feather_callback void save_timestamp_def(unsigned long event, unsigned long type); | 28 | 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 | 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 | ||
@@ -40,6 +41,12 @@ feather_callback void save_timestamp_cpu(unsigned long event, unsigned long cpu) | |||
40 | #define CTIMESTAMP(id, cpu) \ | 41 | #define CTIMESTAMP(id, cpu) \ |
41 | ft_event1(id, save_timestamp_cpu, (unsigned long) cpu) | 42 | ft_event1(id, save_timestamp_cpu, (unsigned long) cpu) |
42 | 43 | ||
44 | #define LTIMESTAMP(id, task) \ | ||
45 | ft_event1(id, save_task_latency, (unsigned long) task) | ||
46 | |||
47 | #define TIMESTAMP_TIME(id, time_ptr) \ | ||
48 | ft_event1(id, save_timestamp_time, (unsigned long) time_ptr) | ||
49 | |||
43 | #else /* !CONFIG_SCHED_OVERHEAD_TRACE */ | 50 | #else /* !CONFIG_SCHED_OVERHEAD_TRACE */ |
44 | 51 | ||
45 | #define TIMESTAMP(id) /* no tracing */ | 52 | #define TIMESTAMP(id) /* no tracing */ |
@@ -50,6 +57,10 @@ feather_callback void save_timestamp_cpu(unsigned long event, unsigned long cpu) | |||
50 | 57 | ||
51 | #define CTIMESTAMP(id, cpu) /* no tracing */ | 58 | #define CTIMESTAMP(id, cpu) /* no tracing */ |
52 | 59 | ||
60 | #define LTIMESTAMP(id, when_ptr) /* no tracing */ | ||
61 | |||
62 | #define TIMESTAMP_TIME(id, time_ptr) /* no tracing */ | ||
63 | |||
53 | #endif | 64 | #endif |
54 | 65 | ||
55 | 66 | ||
@@ -96,6 +107,13 @@ feather_callback void save_timestamp_cpu(unsigned long event, unsigned long cpu) | |||
96 | #define TS_UNLOCK_START TIMESTAMP(172) | 107 | #define TS_UNLOCK_START TIMESTAMP(172) |
97 | #define TS_UNLOCK_END TIMESTAMP(173) | 108 | #define TS_UNLOCK_END TIMESTAMP(173) |
98 | 109 | ||
110 | #define TS_SYSCALL_IN_START(p) TIMESTAMP_TIME(190, p) | ||
111 | #define TS_SYSCALL_IN_END TIMESTAMP(191) | ||
112 | |||
113 | #define TS_SYSCALL_OUT_START TIMESTAMP(200) | ||
114 | #define TS_SYSCALL_OUT_END TIMESTAMP(201) | ||
115 | |||
116 | |||
99 | #define TS_SEND_RESCHED_START(c) CTIMESTAMP(190, c) | 117 | #define TS_SEND_RESCHED_START(c) CTIMESTAMP(190, c) |
100 | #define TS_SEND_RESCHED_END DTIMESTAMP(191, TSK_UNKNOWN) | 118 | #define TS_SEND_RESCHED_END DTIMESTAMP(191, TSK_UNKNOWN) |
101 | 119 | ||
diff --git a/litmus/locking.c b/litmus/locking.c index 728b56835cf7..cfbc1ba59217 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 |
@@ -69,6 +71,11 @@ asmlinkage long sys_litmus_lock(int lock_od) | |||
69 | struct od_table_entry* entry; | 71 | struct od_table_entry* entry; |
70 | struct litmus_lock* l; | 72 | struct litmus_lock* l; |
71 | 73 | ||
74 | if (has_control_page(current)) | ||
75 | TS_SYSCALL_IN_START(&get_control_page(current)->ts_syscall_start); | ||
76 | |||
77 | TS_SYSCALL_IN_END; | ||
78 | |||
72 | TS_LOCK_START; | 79 | TS_LOCK_START; |
73 | 80 | ||
74 | entry = get_entry_for_od(lock_od); | 81 | entry = get_entry_for_od(lock_od); |
@@ -82,6 +89,8 @@ asmlinkage long sys_litmus_lock(int lock_od) | |||
82 | * this into account when computing overheads. */ | 89 | * this into account when computing overheads. */ |
83 | TS_UNLOCK_END; | 90 | TS_UNLOCK_END; |
84 | 91 | ||
92 | TS_SYSCALL_OUT_START; | ||
93 | |||
85 | return err; | 94 | return err; |
86 | } | 95 | } |
87 | 96 | ||
@@ -91,6 +100,11 @@ asmlinkage long sys_litmus_unlock(int lock_od) | |||
91 | struct od_table_entry* entry; | 100 | struct od_table_entry* entry; |
92 | struct litmus_lock* l; | 101 | struct litmus_lock* l; |
93 | 102 | ||
103 | if (has_control_page(current)) | ||
104 | TS_SYSCALL_IN_START(&get_control_page(current)->ts_syscall_start); | ||
105 | |||
106 | TS_SYSCALL_IN_END; | ||
107 | |||
94 | TS_UNLOCK_START; | 108 | TS_UNLOCK_START; |
95 | 109 | ||
96 | entry = get_entry_for_od(lock_od); | 110 | entry = get_entry_for_od(lock_od); |
@@ -104,6 +118,8 @@ asmlinkage long sys_litmus_unlock(int lock_od) | |||
104 | * account when computing overheads. */ | 118 | * account when computing overheads. */ |
105 | TS_UNLOCK_END; | 119 | TS_UNLOCK_END; |
106 | 120 | ||
121 | TS_SYSCALL_OUT_START; | ||
122 | |||
107 | return err; | 123 | return err; |
108 | } | 124 | } |
109 | 125 | ||
diff --git a/litmus/trace.c b/litmus/trace.c index e7ea1c2ab3e4..23763c19fa6b 100644 --- a/litmus/trace.c +++ b/litmus/trace.c | |||
@@ -37,6 +37,30 @@ static inline void __save_timestamp(unsigned long event, | |||
37 | __save_timestamp_cpu(event, type, raw_smp_processor_id()); | 37 | __save_timestamp_cpu(event, type, raw_smp_processor_id()); |
38 | } | 38 | } |
39 | 39 | ||
40 | static inline uint8_t task_type(struct task_struct* t) | ||
41 | { | ||
42 | if (!t) | ||
43 | return TSK_UNKNOWN; | ||
44 | else | ||
45 | return is_realtime(t) ? TSK_RT : TSK_BE; | ||
46 | } | ||
47 | |||
48 | feather_callback void save_timestamp_time(unsigned long event, unsigned long ptr) | ||
49 | { | ||
50 | uint64_t* time = (uint64_t*) ptr; | ||
51 | unsigned int seq_no; | ||
52 | struct timestamp *ts; | ||
53 | seq_no = fetch_and_inc((int *) &ts_seq_no); | ||
54 | if (ft_buffer_start_write(trace_ts_buf, (void**) &ts)) { | ||
55 | ts->event = event; | ||
56 | ts->timestamp = *time; | ||
57 | ts->seq_no = seq_no; | ||
58 | ts->cpu = raw_smp_processor_id(); | ||
59 | ts->task_type = task_type(current); | ||
60 | ft_buffer_finish_write(trace_ts_buf, ts); | ||
61 | } | ||
62 | } | ||
63 | |||
40 | feather_callback void save_timestamp(unsigned long event) | 64 | feather_callback void save_timestamp(unsigned long event) |
41 | { | 65 | { |
42 | __save_timestamp(event, TSK_UNKNOWN); | 66 | __save_timestamp(event, TSK_UNKNOWN); |