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