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