1 From: Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
2 Subject: LTTng instrumentation - timer
5 LTTng instrumentation - timer
7 Instrument timer activity (timer set, expired, current time updates) to keep
8 information about the "real time" flow within the kernel. It can be used by a
9 trace analysis tool to synchronize information coming from various sources, e.g.
10 to merge traces with system logs.
12 Those tracepoints are used by LTTng.
14 About the performance impact of tracepoints (which is comparable to markers),
15 even without immediate values optimizations, tests done by Hideo Aoki on ia64
16 show no regression. His test case was using hackbench on a kernel where
17 scheduler instrumentation (about 5 events in code scheduler code) was added.
18 See the "Tracepoints" patch header for performance result detail.
20 Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
21 CC: 'Ingo Molnar' <mingo@elte.hu>
22 CC: "David S. Miller" <davem@davemloft.net>
23 CC: Masami Hiramatsu <mhiramat@redhat.com>
24 CC: 'Peter Zijlstra' <peterz@infradead.org>
25 CC: "Frank Ch. Eigler" <fche@redhat.com>
26 CC: 'Hideo AOKI' <haoki@redhat.com>
27 CC: Takashi Nishiie <t-nishiie@np.css.fujitsu.com>
28 CC: 'Steven Rostedt' <rostedt@goodmis.org>
29 CC: Eduard - Gabriel Munteanu <eduard.munteanu@linux360.ro>
31 Acked-by: Jan Blunck <jblunck@suse.de>
34 include/trace/timer.h | 24 ++++++++++++++++++++++++
35 kernel/itimer.c | 5 +++++
36 kernel/timer.c | 8 +++++++-
37 3 files changed, 36 insertions(+), 1 deletion(-)
40 +++ b/include/trace/timer.h
42 +#ifndef _TRACE_TIMER_H
43 +#define _TRACE_TIMER_H
45 +#include <linux/tracepoint.h>
47 +DEFINE_TRACE(timer_itimer_expired,
48 + TPPROTO(struct signal_struct *sig),
50 +DEFINE_TRACE(timer_itimer_set,
51 + TPPROTO(int which, struct itimerval *value),
52 + TPARGS(which, value));
53 +DEFINE_TRACE(timer_set,
54 + TPPROTO(struct timer_list *timer),
57 + * xtime_lock is taken when kernel_timer_update_time tracepoint is reached.
59 +DEFINE_TRACE(timer_update_time,
60 + TPPROTO(struct timespec *_xtime, struct timespec *_wall_to_monotonic),
61 + TPARGS(_xtime, _wall_to_monotonic));
62 +DEFINE_TRACE(timer_timeout,
63 + TPPROTO(struct task_struct *p),
69 #include <linux/time.h>
70 #include <linux/posix-timers.h>
71 #include <linux/hrtimer.h>
72 +#include <trace/timer.h>
74 #include <asm/uaccess.h>
76 @@ -132,6 +133,8 @@ enum hrtimer_restart it_real_fn(struct h
77 struct signal_struct *sig =
78 container_of(timer, struct signal_struct, real_timer);
80 + trace_timer_itimer_expired(sig);
82 kill_pid_info(SIGALRM, SEND_SIG_PRIV, sig->leader_pid);
84 return HRTIMER_NORESTART;
85 @@ -157,6 +160,8 @@ int do_setitimer(int which, struct itime
86 !timeval_valid(&value->it_interval))
89 + trace_timer_itimer_set(which, value);
97 #include <linux/delay.h>
98 #include <linux/tick.h>
99 #include <linux/kallsyms.h>
100 +#include <trace/timer.h>
102 #include <asm/uaccess.h>
103 #include <asm/unistd.h>
104 #include <asm/div64.h>
105 #include <asm/timex.h>
107 +#include <asm/irq_regs.h>
109 u64 jiffies_64 __cacheline_aligned_in_smp = INITIAL_JIFFIES;
111 @@ -357,6 +359,7 @@ static void internal_add_timer(struct tv
112 i = (expires >> (TVR_BITS + 3 * TVN_BITS)) & TVN_MASK;
113 vec = base->tv5.vec + i;
115 + trace_timer_set(timer);
119 @@ -1135,6 +1138,7 @@ void do_timer(unsigned long ticks)
123 + trace_timer_update_time(&xtime, &wall_to_monotonic);
126 #ifdef __ARCH_WANT_SYS_ALARM
127 @@ -1216,7 +1220,9 @@ SYSCALL_DEFINE0(getegid)
129 static void process_timeout(unsigned long __data)
131 - wake_up_process((struct task_struct *)__data);
132 + struct task_struct *task = (struct task_struct *)__data;
133 + trace_timer_timeout(task);
134 + wake_up_process(task);