Xiao Guangrong | 2b022e3 | 2009-08-10 10:48:59 +0800 | [diff] [blame] | 1 | #undef TRACE_SYSTEM |
| 2 | #define TRACE_SYSTEM timer |
| 3 | |
| 4 | #if !defined(_TRACE_TIMER_H) || defined(TRACE_HEADER_MULTI_READ) |
| 5 | #define _TRACE_TIMER_H |
| 6 | |
| 7 | #include <linux/tracepoint.h> |
Xiao Guangrong | c6a2a17 | 2009-08-10 10:51:23 +0800 | [diff] [blame] | 8 | #include <linux/hrtimer.h> |
Xiao Guangrong | 2b022e3 | 2009-08-10 10:48:59 +0800 | [diff] [blame] | 9 | #include <linux/timer.h> |
| 10 | |
Li Zefan | 363d0f6 | 2010-05-24 16:23:15 +0800 | [diff] [blame^] | 11 | DECLARE_EVENT_CLASS(timer_class, |
Xiao Guangrong | 2b022e3 | 2009-08-10 10:48:59 +0800 | [diff] [blame] | 12 | |
| 13 | TP_PROTO(struct timer_list *timer), |
| 14 | |
| 15 | TP_ARGS(timer), |
| 16 | |
| 17 | TP_STRUCT__entry( |
| 18 | __field( void *, timer ) |
| 19 | ), |
| 20 | |
| 21 | TP_fast_assign( |
| 22 | __entry->timer = timer; |
| 23 | ), |
| 24 | |
Ingo Molnar | 434a83c | 2009-10-15 11:50:39 +0200 | [diff] [blame] | 25 | TP_printk("timer=%p", __entry->timer) |
Xiao Guangrong | 2b022e3 | 2009-08-10 10:48:59 +0800 | [diff] [blame] | 26 | ); |
| 27 | |
| 28 | /** |
Li Zefan | 363d0f6 | 2010-05-24 16:23:15 +0800 | [diff] [blame^] | 29 | * timer_init - called when the timer is initialized |
| 30 | * @timer: pointer to struct timer_list |
| 31 | */ |
| 32 | DEFINE_EVENT(timer_class, timer_init, |
| 33 | |
| 34 | TP_PROTO(struct timer_list *timer), |
| 35 | |
| 36 | TP_ARGS(timer) |
| 37 | ); |
| 38 | |
| 39 | /** |
Xiao Guangrong | 2b022e3 | 2009-08-10 10:48:59 +0800 | [diff] [blame] | 40 | * timer_start - called when the timer is started |
| 41 | * @timer: pointer to struct timer_list |
| 42 | * @expires: the timers expiry time |
| 43 | */ |
| 44 | TRACE_EVENT(timer_start, |
| 45 | |
| 46 | TP_PROTO(struct timer_list *timer, unsigned long expires), |
| 47 | |
| 48 | TP_ARGS(timer, expires), |
| 49 | |
| 50 | TP_STRUCT__entry( |
| 51 | __field( void *, timer ) |
| 52 | __field( void *, function ) |
| 53 | __field( unsigned long, expires ) |
| 54 | __field( unsigned long, now ) |
| 55 | ), |
| 56 | |
| 57 | TP_fast_assign( |
| 58 | __entry->timer = timer; |
| 59 | __entry->function = timer->function; |
| 60 | __entry->expires = expires; |
| 61 | __entry->now = jiffies; |
| 62 | ), |
| 63 | |
Ingo Molnar | 434a83c | 2009-10-15 11:50:39 +0200 | [diff] [blame] | 64 | TP_printk("timer=%p function=%pf expires=%lu [timeout=%ld]", |
Xiao Guangrong | 2b022e3 | 2009-08-10 10:48:59 +0800 | [diff] [blame] | 65 | __entry->timer, __entry->function, __entry->expires, |
| 66 | (long)__entry->expires - __entry->now) |
| 67 | ); |
| 68 | |
| 69 | /** |
| 70 | * timer_expire_entry - called immediately before the timer callback |
| 71 | * @timer: pointer to struct timer_list |
| 72 | * |
| 73 | * Allows to determine the timer latency. |
| 74 | */ |
| 75 | TRACE_EVENT(timer_expire_entry, |
| 76 | |
| 77 | TP_PROTO(struct timer_list *timer), |
| 78 | |
| 79 | TP_ARGS(timer), |
| 80 | |
| 81 | TP_STRUCT__entry( |
| 82 | __field( void *, timer ) |
| 83 | __field( unsigned long, now ) |
| 84 | ), |
| 85 | |
| 86 | TP_fast_assign( |
| 87 | __entry->timer = timer; |
| 88 | __entry->now = jiffies; |
| 89 | ), |
| 90 | |
Ingo Molnar | 434a83c | 2009-10-15 11:50:39 +0200 | [diff] [blame] | 91 | TP_printk("timer=%p now=%lu", __entry->timer, __entry->now) |
Xiao Guangrong | 2b022e3 | 2009-08-10 10:48:59 +0800 | [diff] [blame] | 92 | ); |
| 93 | |
| 94 | /** |
| 95 | * timer_expire_exit - called immediately after the timer callback returns |
| 96 | * @timer: pointer to struct timer_list |
| 97 | * |
| 98 | * When used in combination with the timer_expire_entry tracepoint we can |
| 99 | * determine the runtime of the timer callback function. |
| 100 | * |
| 101 | * NOTE: Do NOT derefernce timer in TP_fast_assign. The pointer might |
| 102 | * be invalid. We solely track the pointer. |
| 103 | */ |
Li Zefan | 363d0f6 | 2010-05-24 16:23:15 +0800 | [diff] [blame^] | 104 | DEFINE_EVENT(timer_class, timer_expire_exit, |
Xiao Guangrong | 2b022e3 | 2009-08-10 10:48:59 +0800 | [diff] [blame] | 105 | |
| 106 | TP_PROTO(struct timer_list *timer), |
| 107 | |
Li Zefan | 363d0f6 | 2010-05-24 16:23:15 +0800 | [diff] [blame^] | 108 | TP_ARGS(timer) |
Xiao Guangrong | 2b022e3 | 2009-08-10 10:48:59 +0800 | [diff] [blame] | 109 | ); |
| 110 | |
| 111 | /** |
| 112 | * timer_cancel - called when the timer is canceled |
| 113 | * @timer: pointer to struct timer_list |
| 114 | */ |
Li Zefan | 363d0f6 | 2010-05-24 16:23:15 +0800 | [diff] [blame^] | 115 | DEFINE_EVENT(timer_class, timer_cancel, |
Xiao Guangrong | 2b022e3 | 2009-08-10 10:48:59 +0800 | [diff] [blame] | 116 | |
| 117 | TP_PROTO(struct timer_list *timer), |
| 118 | |
Li Zefan | 363d0f6 | 2010-05-24 16:23:15 +0800 | [diff] [blame^] | 119 | TP_ARGS(timer) |
Xiao Guangrong | 2b022e3 | 2009-08-10 10:48:59 +0800 | [diff] [blame] | 120 | ); |
| 121 | |
Xiao Guangrong | c6a2a17 | 2009-08-10 10:51:23 +0800 | [diff] [blame] | 122 | /** |
| 123 | * hrtimer_init - called when the hrtimer is initialized |
| 124 | * @timer: pointer to struct hrtimer |
| 125 | * @clockid: the hrtimers clock |
| 126 | * @mode: the hrtimers mode |
| 127 | */ |
| 128 | TRACE_EVENT(hrtimer_init, |
| 129 | |
Ingo Molnar | 434a83c | 2009-10-15 11:50:39 +0200 | [diff] [blame] | 130 | TP_PROTO(struct hrtimer *hrtimer, clockid_t clockid, |
Xiao Guangrong | c6a2a17 | 2009-08-10 10:51:23 +0800 | [diff] [blame] | 131 | enum hrtimer_mode mode), |
| 132 | |
Ingo Molnar | 434a83c | 2009-10-15 11:50:39 +0200 | [diff] [blame] | 133 | TP_ARGS(hrtimer, clockid, mode), |
Xiao Guangrong | c6a2a17 | 2009-08-10 10:51:23 +0800 | [diff] [blame] | 134 | |
| 135 | TP_STRUCT__entry( |
Ingo Molnar | 434a83c | 2009-10-15 11:50:39 +0200 | [diff] [blame] | 136 | __field( void *, hrtimer ) |
Xiao Guangrong | c6a2a17 | 2009-08-10 10:51:23 +0800 | [diff] [blame] | 137 | __field( clockid_t, clockid ) |
| 138 | __field( enum hrtimer_mode, mode ) |
| 139 | ), |
| 140 | |
| 141 | TP_fast_assign( |
Ingo Molnar | 434a83c | 2009-10-15 11:50:39 +0200 | [diff] [blame] | 142 | __entry->hrtimer = hrtimer; |
Xiao Guangrong | c6a2a17 | 2009-08-10 10:51:23 +0800 | [diff] [blame] | 143 | __entry->clockid = clockid; |
| 144 | __entry->mode = mode; |
| 145 | ), |
| 146 | |
Ingo Molnar | 434a83c | 2009-10-15 11:50:39 +0200 | [diff] [blame] | 147 | TP_printk("hrtimer=%p clockid=%s mode=%s", __entry->hrtimer, |
Xiao Guangrong | c6a2a17 | 2009-08-10 10:51:23 +0800 | [diff] [blame] | 148 | __entry->clockid == CLOCK_REALTIME ? |
| 149 | "CLOCK_REALTIME" : "CLOCK_MONOTONIC", |
| 150 | __entry->mode == HRTIMER_MODE_ABS ? |
| 151 | "HRTIMER_MODE_ABS" : "HRTIMER_MODE_REL") |
| 152 | ); |
| 153 | |
| 154 | /** |
| 155 | * hrtimer_start - called when the hrtimer is started |
| 156 | * @timer: pointer to struct hrtimer |
| 157 | */ |
| 158 | TRACE_EVENT(hrtimer_start, |
| 159 | |
Ingo Molnar | 434a83c | 2009-10-15 11:50:39 +0200 | [diff] [blame] | 160 | TP_PROTO(struct hrtimer *hrtimer), |
Xiao Guangrong | c6a2a17 | 2009-08-10 10:51:23 +0800 | [diff] [blame] | 161 | |
Ingo Molnar | 434a83c | 2009-10-15 11:50:39 +0200 | [diff] [blame] | 162 | TP_ARGS(hrtimer), |
Xiao Guangrong | c6a2a17 | 2009-08-10 10:51:23 +0800 | [diff] [blame] | 163 | |
| 164 | TP_STRUCT__entry( |
Ingo Molnar | 434a83c | 2009-10-15 11:50:39 +0200 | [diff] [blame] | 165 | __field( void *, hrtimer ) |
Xiao Guangrong | c6a2a17 | 2009-08-10 10:51:23 +0800 | [diff] [blame] | 166 | __field( void *, function ) |
| 167 | __field( s64, expires ) |
| 168 | __field( s64, softexpires ) |
| 169 | ), |
| 170 | |
| 171 | TP_fast_assign( |
Ingo Molnar | 434a83c | 2009-10-15 11:50:39 +0200 | [diff] [blame] | 172 | __entry->hrtimer = hrtimer; |
| 173 | __entry->function = hrtimer->function; |
| 174 | __entry->expires = hrtimer_get_expires(hrtimer).tv64; |
| 175 | __entry->softexpires = hrtimer_get_softexpires(hrtimer).tv64; |
Xiao Guangrong | c6a2a17 | 2009-08-10 10:51:23 +0800 | [diff] [blame] | 176 | ), |
| 177 | |
Ingo Molnar | 434a83c | 2009-10-15 11:50:39 +0200 | [diff] [blame] | 178 | TP_printk("hrtimer=%p function=%pf expires=%llu softexpires=%llu", |
| 179 | __entry->hrtimer, __entry->function, |
Xiao Guangrong | c6a2a17 | 2009-08-10 10:51:23 +0800 | [diff] [blame] | 180 | (unsigned long long)ktime_to_ns((ktime_t) { |
| 181 | .tv64 = __entry->expires }), |
| 182 | (unsigned long long)ktime_to_ns((ktime_t) { |
| 183 | .tv64 = __entry->softexpires })) |
| 184 | ); |
| 185 | |
| 186 | /** |
| 187 | * htimmer_expire_entry - called immediately before the hrtimer callback |
| 188 | * @timer: pointer to struct hrtimer |
| 189 | * @now: pointer to variable which contains current time of the |
| 190 | * timers base. |
| 191 | * |
| 192 | * Allows to determine the timer latency. |
| 193 | */ |
| 194 | TRACE_EVENT(hrtimer_expire_entry, |
| 195 | |
Ingo Molnar | 434a83c | 2009-10-15 11:50:39 +0200 | [diff] [blame] | 196 | TP_PROTO(struct hrtimer *hrtimer, ktime_t *now), |
Xiao Guangrong | c6a2a17 | 2009-08-10 10:51:23 +0800 | [diff] [blame] | 197 | |
Ingo Molnar | 434a83c | 2009-10-15 11:50:39 +0200 | [diff] [blame] | 198 | TP_ARGS(hrtimer, now), |
Xiao Guangrong | c6a2a17 | 2009-08-10 10:51:23 +0800 | [diff] [blame] | 199 | |
| 200 | TP_STRUCT__entry( |
Ingo Molnar | 434a83c | 2009-10-15 11:50:39 +0200 | [diff] [blame] | 201 | __field( void *, hrtimer ) |
Xiao Guangrong | c6a2a17 | 2009-08-10 10:51:23 +0800 | [diff] [blame] | 202 | __field( s64, now ) |
| 203 | ), |
| 204 | |
| 205 | TP_fast_assign( |
Ingo Molnar | 434a83c | 2009-10-15 11:50:39 +0200 | [diff] [blame] | 206 | __entry->hrtimer = hrtimer; |
| 207 | __entry->now = now->tv64; |
Xiao Guangrong | c6a2a17 | 2009-08-10 10:51:23 +0800 | [diff] [blame] | 208 | ), |
| 209 | |
Ingo Molnar | 434a83c | 2009-10-15 11:50:39 +0200 | [diff] [blame] | 210 | TP_printk("hrtimer=%p now=%llu", __entry->hrtimer, |
| 211 | (unsigned long long)ktime_to_ns((ktime_t) { .tv64 = __entry->now })) |
Xiao Guangrong | c6a2a17 | 2009-08-10 10:51:23 +0800 | [diff] [blame] | 212 | ); |
| 213 | |
Li Zefan | 363d0f6 | 2010-05-24 16:23:15 +0800 | [diff] [blame^] | 214 | DECLARE_EVENT_CLASS(hrtimer_class, |
Xiao Guangrong | c6a2a17 | 2009-08-10 10:51:23 +0800 | [diff] [blame] | 215 | |
Ingo Molnar | 434a83c | 2009-10-15 11:50:39 +0200 | [diff] [blame] | 216 | TP_PROTO(struct hrtimer *hrtimer), |
Xiao Guangrong | c6a2a17 | 2009-08-10 10:51:23 +0800 | [diff] [blame] | 217 | |
Ingo Molnar | 434a83c | 2009-10-15 11:50:39 +0200 | [diff] [blame] | 218 | TP_ARGS(hrtimer), |
Xiao Guangrong | c6a2a17 | 2009-08-10 10:51:23 +0800 | [diff] [blame] | 219 | |
| 220 | TP_STRUCT__entry( |
Ingo Molnar | 434a83c | 2009-10-15 11:50:39 +0200 | [diff] [blame] | 221 | __field( void *, hrtimer ) |
Xiao Guangrong | c6a2a17 | 2009-08-10 10:51:23 +0800 | [diff] [blame] | 222 | ), |
| 223 | |
| 224 | TP_fast_assign( |
Ingo Molnar | 434a83c | 2009-10-15 11:50:39 +0200 | [diff] [blame] | 225 | __entry->hrtimer = hrtimer; |
Xiao Guangrong | c6a2a17 | 2009-08-10 10:51:23 +0800 | [diff] [blame] | 226 | ), |
| 227 | |
Ingo Molnar | 434a83c | 2009-10-15 11:50:39 +0200 | [diff] [blame] | 228 | TP_printk("hrtimer=%p", __entry->hrtimer) |
Xiao Guangrong | c6a2a17 | 2009-08-10 10:51:23 +0800 | [diff] [blame] | 229 | ); |
| 230 | |
| 231 | /** |
Li Zefan | 363d0f6 | 2010-05-24 16:23:15 +0800 | [diff] [blame^] | 232 | * hrtimer_expire_exit - called immediately after the hrtimer callback returns |
| 233 | * @timer: pointer to struct hrtimer |
| 234 | * |
| 235 | * When used in combination with the hrtimer_expire_entry tracepoint we can |
| 236 | * determine the runtime of the callback function. |
Xiao Guangrong | c6a2a17 | 2009-08-10 10:51:23 +0800 | [diff] [blame] | 237 | */ |
Li Zefan | 363d0f6 | 2010-05-24 16:23:15 +0800 | [diff] [blame^] | 238 | DEFINE_EVENT(hrtimer_class, hrtimer_expire_exit, |
Xiao Guangrong | c6a2a17 | 2009-08-10 10:51:23 +0800 | [diff] [blame] | 239 | |
Ingo Molnar | 434a83c | 2009-10-15 11:50:39 +0200 | [diff] [blame] | 240 | TP_PROTO(struct hrtimer *hrtimer), |
Xiao Guangrong | c6a2a17 | 2009-08-10 10:51:23 +0800 | [diff] [blame] | 241 | |
Li Zefan | 363d0f6 | 2010-05-24 16:23:15 +0800 | [diff] [blame^] | 242 | TP_ARGS(hrtimer) |
| 243 | ); |
Xiao Guangrong | c6a2a17 | 2009-08-10 10:51:23 +0800 | [diff] [blame] | 244 | |
Li Zefan | 363d0f6 | 2010-05-24 16:23:15 +0800 | [diff] [blame^] | 245 | /** |
| 246 | * hrtimer_cancel - called when the hrtimer is canceled |
| 247 | * @hrtimer: pointer to struct hrtimer |
| 248 | */ |
| 249 | DEFINE_EVENT(hrtimer_class, hrtimer_cancel, |
Xiao Guangrong | c6a2a17 | 2009-08-10 10:51:23 +0800 | [diff] [blame] | 250 | |
Li Zefan | 363d0f6 | 2010-05-24 16:23:15 +0800 | [diff] [blame^] | 251 | TP_PROTO(struct hrtimer *hrtimer), |
Xiao Guangrong | c6a2a17 | 2009-08-10 10:51:23 +0800 | [diff] [blame] | 252 | |
Li Zefan | 363d0f6 | 2010-05-24 16:23:15 +0800 | [diff] [blame^] | 253 | TP_ARGS(hrtimer) |
Xiao Guangrong | c6a2a17 | 2009-08-10 10:51:23 +0800 | [diff] [blame] | 254 | ); |
| 255 | |
Xiao Guangrong | 3f0a525 | 2009-08-10 10:52:30 +0800 | [diff] [blame] | 256 | /** |
| 257 | * itimer_state - called when itimer is started or canceled |
| 258 | * @which: name of the interval timer |
| 259 | * @value: the itimers value, itimer is canceled if value->it_value is |
| 260 | * zero, otherwise it is started |
| 261 | * @expires: the itimers expiry time |
| 262 | */ |
| 263 | TRACE_EVENT(itimer_state, |
| 264 | |
| 265 | TP_PROTO(int which, const struct itimerval *const value, |
| 266 | cputime_t expires), |
| 267 | |
| 268 | TP_ARGS(which, value, expires), |
| 269 | |
| 270 | TP_STRUCT__entry( |
| 271 | __field( int, which ) |
| 272 | __field( cputime_t, expires ) |
| 273 | __field( long, value_sec ) |
| 274 | __field( long, value_usec ) |
| 275 | __field( long, interval_sec ) |
| 276 | __field( long, interval_usec ) |
| 277 | ), |
| 278 | |
| 279 | TP_fast_assign( |
| 280 | __entry->which = which; |
| 281 | __entry->expires = expires; |
| 282 | __entry->value_sec = value->it_value.tv_sec; |
| 283 | __entry->value_usec = value->it_value.tv_usec; |
| 284 | __entry->interval_sec = value->it_interval.tv_sec; |
| 285 | __entry->interval_usec = value->it_interval.tv_usec; |
| 286 | ), |
| 287 | |
Thomas Gleixner | e9c0748b | 2009-12-10 13:23:19 +0100 | [diff] [blame] | 288 | TP_printk("which=%d expires=%llu it_value=%ld.%ld it_interval=%ld.%ld", |
| 289 | __entry->which, (unsigned long long)__entry->expires, |
Xiao Guangrong | 3f0a525 | 2009-08-10 10:52:30 +0800 | [diff] [blame] | 290 | __entry->value_sec, __entry->value_usec, |
| 291 | __entry->interval_sec, __entry->interval_usec) |
| 292 | ); |
| 293 | |
| 294 | /** |
| 295 | * itimer_expire - called when itimer expires |
| 296 | * @which: type of the interval timer |
| 297 | * @pid: pid of the process which owns the timer |
| 298 | * @now: current time, used to calculate the latency of itimer |
| 299 | */ |
| 300 | TRACE_EVENT(itimer_expire, |
| 301 | |
| 302 | TP_PROTO(int which, struct pid *pid, cputime_t now), |
| 303 | |
| 304 | TP_ARGS(which, pid, now), |
| 305 | |
| 306 | TP_STRUCT__entry( |
| 307 | __field( int , which ) |
| 308 | __field( pid_t, pid ) |
| 309 | __field( cputime_t, now ) |
| 310 | ), |
| 311 | |
| 312 | TP_fast_assign( |
| 313 | __entry->which = which; |
| 314 | __entry->now = now; |
| 315 | __entry->pid = pid_nr(pid); |
| 316 | ), |
| 317 | |
Thomas Gleixner | e9c0748b | 2009-12-10 13:23:19 +0100 | [diff] [blame] | 318 | TP_printk("which=%d pid=%d now=%llu", __entry->which, |
| 319 | (int) __entry->pid, (unsigned long long)__entry->now) |
Xiao Guangrong | 3f0a525 | 2009-08-10 10:52:30 +0800 | [diff] [blame] | 320 | ); |
| 321 | |
Xiao Guangrong | 2b022e3 | 2009-08-10 10:48:59 +0800 | [diff] [blame] | 322 | #endif /* _TRACE_TIMER_H */ |
| 323 | |
| 324 | /* This part must be outside protection */ |
| 325 | #include <trace/define_trace.h> |