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