From: tip-bot for Xiao Guangrong <xiaoguangrong@cn.fujitsu.com>
To: linux-tip-commits@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, anton@samba.org,
mathieu.desnoyers@polymtl.ca, hpa@zytor.com, mingo@redhat.com,
peterz@infradead.org, zhaolei@cn.fujitsu.com,
xiaoguangrong@cn.fujitsu.com, fweisbec@gmail.com,
rostedt@goodmis.org, tglx@linutronix.de,
kosaki.motohiro@jp.fujitsu.com
Subject: [tip:timers/tracing] itimers: Add tracepoints for itimer
Date: Wed, 2 Sep 2009 12:18:47 GMT [thread overview]
Message-ID: <tip-3f0a525ebf4b8ef041a332bbe4a73aee94bb064b@git.kernel.org> (raw)
In-Reply-To: <4A7F8B6E.2010109@cn.fujitsu.com>
Commit-ID: 3f0a525ebf4b8ef041a332bbe4a73aee94bb064b
Gitweb: http://git.kernel.org/tip/3f0a525ebf4b8ef041a332bbe4a73aee94bb064b
Author: Xiao Guangrong <xiaoguangrong@cn.fujitsu.com>
AuthorDate: Mon, 10 Aug 2009 10:52:30 +0800
Committer: Thomas Gleixner <tglx@linutronix.de>
CommitDate: Sat, 29 Aug 2009 14:10:07 +0200
itimers: Add tracepoints for itimer
Add tracepoints for all itimer variants: ITIMER_REAL, ITIMER_VIRTUAL
and ITIMER_PROF.
[ tglx: Fixed comments and made the output more readable, parseable
and consistent. Replaced pid_vnr by pid_nr because the hrtimer
callback can happen in any namespace ]
Signed-off-by: Xiao Guangrong <xiaoguangrong@cn.fujitsu.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
Cc: Anton Blanchard <anton@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Cc: Zhaolei <zhaolei@cn.fujitsu.com>
LKML-Reference: <4A7F8B6E.2010109@cn.fujitsu.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
include/trace/events/timer.h | 66 ++++++++++++++++++++++++++++++++++++++++++
kernel/itimer.c | 5 +++
kernel/posix-cpu-timers.c | 7 ++++-
3 files changed, 77 insertions(+), 1 deletions(-)
diff --git a/include/trace/events/timer.h b/include/trace/events/timer.h
index df3c07f..1844c48 100644
--- a/include/trace/events/timer.h
+++ b/include/trace/events/timer.h
@@ -270,6 +270,72 @@ TRACE_EVENT(hrtimer_cancel,
TP_printk("hrtimer %p", __entry->timer)
);
+/**
+ * itimer_state - called when itimer is started or canceled
+ * @which: name of the interval timer
+ * @value: the itimers value, itimer is canceled if value->it_value is
+ * zero, otherwise it is started
+ * @expires: the itimers expiry time
+ */
+TRACE_EVENT(itimer_state,
+
+ TP_PROTO(int which, const struct itimerval *const value,
+ cputime_t expires),
+
+ TP_ARGS(which, value, expires),
+
+ TP_STRUCT__entry(
+ __field( int, which )
+ __field( cputime_t, expires )
+ __field( long, value_sec )
+ __field( long, value_usec )
+ __field( long, interval_sec )
+ __field( long, interval_usec )
+ ),
+
+ TP_fast_assign(
+ __entry->which = which;
+ __entry->expires = expires;
+ __entry->value_sec = value->it_value.tv_sec;
+ __entry->value_usec = value->it_value.tv_usec;
+ __entry->interval_sec = value->it_interval.tv_sec;
+ __entry->interval_usec = value->it_interval.tv_usec;
+ ),
+
+ TP_printk("which %d, expires %lu, it_value %lu.%lu, it_interval %lu.%lu",
+ __entry->which, __entry->expires,
+ __entry->value_sec, __entry->value_usec,
+ __entry->interval_sec, __entry->interval_usec)
+);
+
+/**
+ * itimer_expire - called when itimer expires
+ * @which: type of the interval timer
+ * @pid: pid of the process which owns the timer
+ * @now: current time, used to calculate the latency of itimer
+ */
+TRACE_EVENT(itimer_expire,
+
+ TP_PROTO(int which, struct pid *pid, cputime_t now),
+
+ TP_ARGS(which, pid, now),
+
+ TP_STRUCT__entry(
+ __field( int , which )
+ __field( pid_t, pid )
+ __field( cputime_t, now )
+ ),
+
+ TP_fast_assign(
+ __entry->which = which;
+ __entry->now = now;
+ __entry->pid = pid_nr(pid);
+ ),
+
+ TP_printk("which %d, pid %d, now %lu", __entry->which,
+ (int) __entry->pid, __entry->now)
+);
+
#endif /* _TRACE_TIMER_H */
/* This part must be outside protection */
diff --git a/kernel/itimer.c b/kernel/itimer.c
index 8078a32..b03451e 100644
--- a/kernel/itimer.c
+++ b/kernel/itimer.c
@@ -12,6 +12,7 @@
#include <linux/time.h>
#include <linux/posix-timers.h>
#include <linux/hrtimer.h>
+#include <trace/events/timer.h>
#include <asm/uaccess.h>
@@ -122,6 +123,7 @@ enum hrtimer_restart it_real_fn(struct hrtimer *timer)
struct signal_struct *sig =
container_of(timer, struct signal_struct, real_timer);
+ trace_itimer_expire(ITIMER_REAL, sig->leader_pid, 0);
kill_pid_info(SIGALRM, SEND_SIG_PRIV, sig->leader_pid);
return HRTIMER_NORESTART;
@@ -166,6 +168,8 @@ static void set_cpu_itimer(struct task_struct *tsk, unsigned int clock_id,
}
it->expires = nval;
it->incr = ninterval;
+ trace_itimer_state(clock_id == CPUCLOCK_VIRT ?
+ ITIMER_VIRTUAL : ITIMER_PROF, value, nval);
spin_unlock_irq(&tsk->sighand->siglock);
@@ -217,6 +221,7 @@ again:
} else
tsk->signal->it_real_incr.tv64 = 0;
+ trace_itimer_state(ITIMER_REAL, value, 0);
spin_unlock_irq(&tsk->sighand->siglock);
break;
case ITIMER_VIRTUAL:
diff --git a/kernel/posix-cpu-timers.c b/kernel/posix-cpu-timers.c
index 12161f7..5c9dc22 100644
--- a/kernel/posix-cpu-timers.c
+++ b/kernel/posix-cpu-timers.c
@@ -8,6 +8,7 @@
#include <linux/math64.h>
#include <asm/uaccess.h>
#include <linux/kernel_stat.h>
+#include <trace/events/timer.h>
/*
* Called after updating RLIMIT_CPU to set timer expiration if necessary.
@@ -1090,9 +1091,13 @@ static void check_cpu_itimer(struct task_struct *tsk, struct cpu_itimer *it,
cputime_one_jiffy);
it->error -= onecputick;
}
- } else
+ } else {
it->expires = cputime_zero;
+ }
+ trace_itimer_expire(signo == SIGPROF ?
+ ITIMER_PROF : ITIMER_VIRTUAL,
+ tsk->signal->leader_pid, cur_time);
__group_send_sig_info(signo, SEND_SIG_PRIV, tsk);
}
next prev parent reply other threads:[~2009-09-02 12:19 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-08-10 2:48 [PATCH v6 1/3] ftrace: add tracepoint for timer Xiao Guangrong
2009-08-10 2:51 ` [PATCH v6 2/3] ftrace: add tracepoint for hrtimer Xiao Guangrong
2009-09-02 12:18 ` [tip:timers/tracing] hrtimer: Add tracepoint for hrtimers tip-bot for Xiao Guangrong
2009-10-13 3:25 ` Steven Rostedt
2009-10-13 7:08 ` Ingo Molnar
2009-10-13 13:17 ` Steven Rostedt
2009-10-13 13:18 ` Steven Rostedt
2009-10-13 13:26 ` Ingo Molnar
2009-10-13 14:02 ` Steven Rostedt
2009-10-13 15:35 ` [RFC] Trace types registry Mathieu Desnoyers
2009-10-13 18:41 ` [tip:timers/tracing] hrtimer: Add tracepoint for hrtimers Ingo Molnar
2009-10-13 18:56 ` Steven Rostedt
2009-10-13 7:48 ` Peter Zijlstra
2009-08-10 2:52 ` [PATCH v6 3/3] ftrace: add tracepoint for itimer Xiao Guangrong
2009-09-02 12:18 ` tip-bot for Xiao Guangrong [this message]
2009-09-02 12:18 ` [tip:timers/tracing] timers: Add tracepoints for timer_list timers tip-bot for Xiao Guangrong
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=tip-3f0a525ebf4b8ef041a332bbe4a73aee94bb064b@git.kernel.org \
--to=xiaoguangrong@cn.fujitsu.com \
--cc=anton@samba.org \
--cc=fweisbec@gmail.com \
--cc=hpa@zytor.com \
--cc=kosaki.motohiro@jp.fujitsu.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=mathieu.desnoyers@polymtl.ca \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--cc=tglx@linutronix.de \
--cc=zhaolei@cn.fujitsu.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox