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
  11DECLARE_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 */
  32DEFINE_EVENT(timer_class, timer_init,
  33
  34        TP_PROTO(struct timer_list *timer),
  35
  36        TP_ARGS(timer)
  37);
  38
  39#define decode_timer_flags(flags)                       \
  40        __print_flags(flags, "|",                       \
  41                {  TIMER_MIGRATING,     "M" },          \
  42                {  TIMER_DEFERRABLE,    "D" },          \
  43                {  TIMER_PINNED,        "P" },          \
  44                {  TIMER_IRQSAFE,       "I" })
  45
  46/**
  47 * timer_start - called when the timer is started
  48 * @timer:      pointer to struct timer_list
  49 * @expires:    the timers expiry time
  50 */
  51TRACE_EVENT(timer_start,
  52
  53        TP_PROTO(struct timer_list *timer,
  54                unsigned long expires,
  55                unsigned int flags),
  56
  57        TP_ARGS(timer, expires, flags),
  58
  59        TP_STRUCT__entry(
  60                __field( void *,        timer           )
  61                __field( void *,        function        )
  62                __field( unsigned long, expires         )
  63                __field( unsigned long, now             )
  64                __field( unsigned int,  flags           )
  65        ),
  66
  67        TP_fast_assign(
  68                __entry->timer          = timer;
  69                __entry->function       = timer->function;
  70                __entry->expires        = expires;
  71                __entry->now            = jiffies;
  72                __entry->flags          = flags;
  73        ),
  74
  75        TP_printk("timer=%p function=%pf expires=%lu [timeout=%ld] cpu=%u idx=%u flags=%s",
  76                  __entry->timer, __entry->function, __entry->expires,
  77                  (long)__entry->expires - __entry->now,
  78                  __entry->flags & TIMER_CPUMASK,
  79                  __entry->flags >> TIMER_ARRAYSHIFT,
  80                  decode_timer_flags(__entry->flags & TIMER_TRACE_FLAGMASK))
  81);
  82
  83/**
  84 * timer_expire_entry - called immediately before the timer callback
  85 * @timer:      pointer to struct timer_list
  86 *
  87 * Allows to determine the timer latency.
  88 */
  89TRACE_EVENT(timer_expire_entry,
  90
  91        TP_PROTO(struct timer_list *timer),
  92
  93        TP_ARGS(timer),
  94
  95        TP_STRUCT__entry(
  96                __field( void *,        timer   )
  97                __field( unsigned long, now     )
  98                __field( void *,        function)
  99        ),
 100
 101        TP_fast_assign(
 102                __entry->timer          = timer;
 103                __entry->now            = jiffies;
 104                __entry->function       = timer->function;
 105        ),
 106
 107        TP_printk("timer=%p function=%pf now=%lu", __entry->timer, __entry->function,__entry->now)
 108);
 109
 110/**
 111 * timer_expire_exit - called immediately after the timer callback returns
 112 * @timer:      pointer to struct timer_list
 113 *
 114 * When used in combination with the timer_expire_entry tracepoint we can
 115 * determine the runtime of the timer callback function.
 116 *
 117 * NOTE: Do NOT derefernce timer in TP_fast_assign. The pointer might
 118 * be invalid. We solely track the pointer.
 119 */
 120DEFINE_EVENT(timer_class, timer_expire_exit,
 121
 122        TP_PROTO(struct timer_list *timer),
 123
 124        TP_ARGS(timer)
 125);
 126
 127/**
 128 * timer_cancel - called when the timer is canceled
 129 * @timer:      pointer to struct timer_list
 130 */
 131DEFINE_EVENT(timer_class, timer_cancel,
 132
 133        TP_PROTO(struct timer_list *timer),
 134
 135        TP_ARGS(timer)
 136);
 137
 138/**
 139 * hrtimer_init - called when the hrtimer is initialized
 140 * @hrtimer:    pointer to struct hrtimer
 141 * @clockid:    the hrtimers clock
 142 * @mode:       the hrtimers mode
 143 */
 144TRACE_EVENT(hrtimer_init,
 145
 146        TP_PROTO(struct hrtimer *hrtimer, clockid_t clockid,
 147                 enum hrtimer_mode mode),
 148
 149        TP_ARGS(hrtimer, clockid, mode),
 150
 151        TP_STRUCT__entry(
 152                __field( void *,                hrtimer         )
 153                __field( clockid_t,             clockid         )
 154                __field( enum hrtimer_mode,     mode            )
 155        ),
 156
 157        TP_fast_assign(
 158                __entry->hrtimer        = hrtimer;
 159                __entry->clockid        = clockid;
 160                __entry->mode           = mode;
 161        ),
 162
 163        TP_printk("hrtimer=%p clockid=%s mode=%s", __entry->hrtimer,
 164                  __entry->clockid == CLOCK_REALTIME ?
 165                        "CLOCK_REALTIME" : "CLOCK_MONOTONIC",
 166                  __entry->mode == HRTIMER_MODE_ABS ?
 167                        "HRTIMER_MODE_ABS" : "HRTIMER_MODE_REL")
 168);
 169
 170/**
 171 * hrtimer_start - called when the hrtimer is started
 172 * @hrtimer: pointer to struct hrtimer
 173 */
 174TRACE_EVENT(hrtimer_start,
 175
 176        TP_PROTO(struct hrtimer *hrtimer),
 177
 178        TP_ARGS(hrtimer),
 179
 180        TP_STRUCT__entry(
 181                __field( void *,        hrtimer         )
 182                __field( void *,        function        )
 183                __field( s64,           expires         )
 184                __field( s64,           softexpires     )
 185        ),
 186
 187        TP_fast_assign(
 188                __entry->hrtimer        = hrtimer;
 189                __entry->function       = hrtimer->function;
 190                __entry->expires        = hrtimer_get_expires(hrtimer);
 191                __entry->softexpires    = hrtimer_get_softexpires(hrtimer);
 192        ),
 193
 194        TP_printk("hrtimer=%p function=%pf expires=%llu softexpires=%llu",
 195                  __entry->hrtimer, __entry->function,
 196                  (unsigned long long) __entry->expires,
 197                  (unsigned long long) __entry->softexpires)
 198);
 199
 200/**
 201 * hrtimer_expire_entry - called immediately before the hrtimer callback
 202 * @hrtimer:    pointer to struct hrtimer
 203 * @now:        pointer to variable which contains current time of the
 204 *              timers base.
 205 *
 206 * Allows to determine the timer latency.
 207 */
 208TRACE_EVENT(hrtimer_expire_entry,
 209
 210        TP_PROTO(struct hrtimer *hrtimer, ktime_t *now),
 211
 212        TP_ARGS(hrtimer, now),
 213
 214        TP_STRUCT__entry(
 215                __field( void *,        hrtimer )
 216                __field( s64,           now     )
 217                __field( void *,        function)
 218        ),
 219
 220        TP_fast_assign(
 221                __entry->hrtimer        = hrtimer;
 222                __entry->now            = *now;
 223                __entry->function       = hrtimer->function;
 224        ),
 225
 226        TP_printk("hrtimer=%p function=%pf now=%llu", __entry->hrtimer, __entry->function,
 227                  (unsigned long long) __entry->now)
 228);
 229
 230DECLARE_EVENT_CLASS(hrtimer_class,
 231
 232        TP_PROTO(struct hrtimer *hrtimer),
 233
 234        TP_ARGS(hrtimer),
 235
 236        TP_STRUCT__entry(
 237                __field( void *,        hrtimer )
 238        ),
 239
 240        TP_fast_assign(
 241                __entry->hrtimer        = hrtimer;
 242        ),
 243
 244        TP_printk("hrtimer=%p", __entry->hrtimer)
 245);
 246
 247/**
 248 * hrtimer_expire_exit - called immediately after the hrtimer callback returns
 249 * @hrtimer:    pointer to struct hrtimer
 250 *
 251 * When used in combination with the hrtimer_expire_entry tracepoint we can
 252 * determine the runtime of the callback function.
 253 */
 254DEFINE_EVENT(hrtimer_class, hrtimer_expire_exit,
 255
 256        TP_PROTO(struct hrtimer *hrtimer),
 257
 258        TP_ARGS(hrtimer)
 259);
 260
 261/**
 262 * hrtimer_cancel - called when the hrtimer is canceled
 263 * @hrtimer:    pointer to struct hrtimer
 264 */
 265DEFINE_EVENT(hrtimer_class, hrtimer_cancel,
 266
 267        TP_PROTO(struct hrtimer *hrtimer),
 268
 269        TP_ARGS(hrtimer)
 270);
 271
 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 */
 279TRACE_EVENT(itimer_state,
 280
 281        TP_PROTO(int which, const struct itimerval *const value,
 282                 unsigned long long expires),
 283
 284        TP_ARGS(which, value, expires),
 285
 286        TP_STRUCT__entry(
 287                __field(        int,                    which           )
 288                __field(        unsigned long long,     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
 304        TP_printk("which=%d expires=%llu it_value=%ld.%ld it_interval=%ld.%ld",
 305                  __entry->which, __entry->expires,
 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 */
 316TRACE_EVENT(itimer_expire,
 317
 318        TP_PROTO(int which, struct pid *pid, unsigned long long now),
 319
 320        TP_ARGS(which, pid, now),
 321
 322        TP_STRUCT__entry(
 323                __field( int ,                  which   )
 324                __field( pid_t,                 pid     )
 325                __field( unsigned long long,    now     )
 326        ),
 327
 328        TP_fast_assign(
 329                __entry->which  = which;
 330                __entry->now    = now;
 331                __entry->pid    = pid_nr(pid);
 332        ),
 333
 334        TP_printk("which=%d pid=%d now=%llu", __entry->which,
 335                  (int) __entry->pid, __entry->now)
 336);
 337
 338#ifdef CONFIG_NO_HZ_COMMON
 339
 340#define TICK_DEP_NAMES                                  \
 341                tick_dep_mask_name(NONE)                \
 342                tick_dep_name(POSIX_TIMER)              \
 343                tick_dep_name(PERF_EVENTS)              \
 344                tick_dep_name(SCHED)                    \
 345                tick_dep_name_end(CLOCK_UNSTABLE)
 346
 347#undef tick_dep_name
 348#undef tick_dep_mask_name
 349#undef tick_dep_name_end
 350
 351/* The MASK will convert to their bits and they need to be processed too */
 352#define tick_dep_name(sdep) TRACE_DEFINE_ENUM(TICK_DEP_BIT_##sdep); \
 353        TRACE_DEFINE_ENUM(TICK_DEP_MASK_##sdep);
 354#define tick_dep_name_end(sdep)  TRACE_DEFINE_ENUM(TICK_DEP_BIT_##sdep); \
 355        TRACE_DEFINE_ENUM(TICK_DEP_MASK_##sdep);
 356/* NONE only has a mask defined for it */
 357#define tick_dep_mask_name(sdep) TRACE_DEFINE_ENUM(TICK_DEP_MASK_##sdep);
 358
 359TICK_DEP_NAMES
 360
 361#undef tick_dep_name
 362#undef tick_dep_mask_name
 363#undef tick_dep_name_end
 364
 365#define tick_dep_name(sdep) { TICK_DEP_MASK_##sdep, #sdep },
 366#define tick_dep_mask_name(sdep) { TICK_DEP_MASK_##sdep, #sdep },
 367#define tick_dep_name_end(sdep) { TICK_DEP_MASK_##sdep, #sdep }
 368
 369#define show_tick_dep_name(val)                         \
 370        __print_symbolic(val, TICK_DEP_NAMES)
 371
 372TRACE_EVENT(tick_stop,
 373
 374        TP_PROTO(int success, int dependency),
 375
 376        TP_ARGS(success, dependency),
 377
 378        TP_STRUCT__entry(
 379                __field( int ,          success )
 380                __field( int ,          dependency )
 381        ),
 382
 383        TP_fast_assign(
 384                __entry->success        = success;
 385                __entry->dependency     = dependency;
 386        ),
 387
 388        TP_printk("success=%d dependency=%s",  __entry->success, \
 389                        show_tick_dep_name(__entry->dependency))
 390);
 391#endif
 392
 393#endif /*  _TRACE_TIMER_H */
 394
 395/* This part must be outside protection */
 396#include <trace/define_trace.h>
 397