From: "Frédéric Weisbecker" <fweisbec@gmail.com>
To: Anton Blanchard <anton@samba.org>
Cc: rostedt@goodmis.org, mingo@elte.hu, tzanussi@gmail.com,
jbaron@redhat.com, tglx@linutronix.de,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] tracing/events: Add timer and high res timer tracepoints
Date: Thu, 21 May 2009 02:01:20 +0200 [thread overview]
Message-ID: <c62985530905201701i36527eblae479c07eec06515@mail.gmail.com> (raw)
In-Reply-To: <20090520101334.GA23442@kryten>
2009/5/20 Anton Blanchard <anton@samba.org>:
>
> Add tracepoints for timer and high res timer execution. We add entry and
> exit tracepoints so we can calculate timer latency.
>
> Example ftrace output:
>
> <idle>-0 [000] 264.040506: hrtimer_entry: func=.tick_sched_timer+0x0/0xf0
> <idle>-0 [000] 264.040508: hrtimer_exit: func=.tick_sched_timer+0x0/0xf0 restart=HRTIMER_RESTART
> <idle>-0 [000] 264.040530: timer_entry: func=.e1000_watchdog+0x0/0x8fc
> <idle>-0 [000] 264.040728: timer_exit: func=.e1000_watchdog+0x0/0x8fc
>
> Here we can see e1000_watchdog is taking 0.2ms - it might make sense to
> move this into a workqueue or kernel thread.
>
> Signed-off-by: Anton Blanchard <anton@samba.org>
> ---
>
> Index: linux-2.6-tracing/kernel/hrtimer.c
> ===================================================================
> --- linux-2.6-tracing.orig/kernel/hrtimer.c 2009-05-20 17:11:50.000000000 +1000
> +++ linux-2.6-tracing/kernel/hrtimer.c 2009-05-20 17:11:52.000000000 +1000
> @@ -46,6 +46,8 @@
>
> #include <asm/uaccess.h>
>
> +#include <trace/events/timer.h>
> +
> /**
> * ktime_get - get the monotonic time in ktime_t format
> *
> @@ -1161,7 +1163,9 @@
> * the timer base.
> */
> spin_unlock(&cpu_base->lock);
> + trace_hrtimer_entry(timer);
> restart = fn(timer);
> + trace_hrtimer_exit(timer, restart);
> spin_lock(&cpu_base->lock);
>
> /*
> Index: linux-2.6-tracing/kernel/timer.c
> ===================================================================
> --- linux-2.6-tracing.orig/kernel/timer.c 2009-05-20 17:11:50.000000000 +1000
> +++ linux-2.6-tracing/kernel/timer.c 2009-05-20 17:11:52.000000000 +1000
> @@ -44,6 +44,9 @@
> #include <asm/timex.h>
> #include <asm/io.h>
>
> +#define CREATE_TRACE_POINTS
> +#include <trace/events/timer.h>
> +
> u64 jiffies_64 __cacheline_aligned_in_smp = INITIAL_JIFFIES;
>
> EXPORT_SYMBOL(jiffies_64);
> @@ -946,7 +949,9 @@
> */
> lock_map_acquire(&lockdep_map);
>
> + trace_timer_entry(timer);
> fn(data);
> + trace_timer_exit(timer);
>
> lock_map_release(&lockdep_map);
>
> Index: linux-2.6-tracing/include/trace/events/timer.h
> ===================================================================
> --- /dev/null 1970-01-01 00:00:00.000000000 +0000
> +++ linux-2.6-tracing/include/trace/events/timer.h 2009-05-20 17:15:41.000000000 +1000
> @@ -0,0 +1,116 @@
> +#if !defined(_TRACE_TIMER_H) || defined(TRACE_HEADER_MULTI_READ)
> +#define _TRACE_TIMER_H
> +
> +#include <linux/tracepoint.h>
> +#include <linux/timer.h>
> +#include <linux/hrtimer.h>
> +
> +#undef TRACE_SYSTEM
> +#define TRACE_SYSTEM timer
> +
> +/**
> + * timer_entry - called immediately before the timer
> + * @timer: pointer to struct timer_list
> + *
> + * When used in combination with the timer_exit tracepoint we can
> + * determine the timer latency.
> + */
> +TRACE_EVENT(timer_entry,
> +
> + TP_PROTO(struct timer_list *timer),
> +
> + TP_ARGS(timer),
> +
> + TP_STRUCT__entry(
> + __field(void *, function)
void * won't make the filtering easier.
It would require the raw address whereas it would be nice to filter
by function name.
But saving the address instead of the resolved name is faster.
I guess we should add a filter feature to resolve a function name to
its address.
> + ),
> +
> + TP_fast_assign(
> + __entry->function = timer->function;
> + ),
> +
> + TP_printk("func=%pF", __entry->function)
Please use %pf which only prints the function name and ignore the
offsets and so... These overload
the trace in such case.
Thanks,
Frederic.
> +);
> +
> +/**
> + * timer_exit - called immediately after the timer returns
> + * @timer: pointer to struct timer_list
> + *
> + * When used in combination with the timer_entry tracepoint we can
> + * determine the timer latency.
> + */
> +TRACE_EVENT(timer_exit,
> +
> + TP_PROTO(struct timer_list *timer),
> +
> + TP_ARGS(timer),
> +
> + TP_STRUCT__entry(
> + __field(void *, function)
> + ),
> +
> + TP_fast_assign(
> + __entry->function = timer->function;
> + ),
> +
> + TP_printk("func=%pF", __entry->function)
> +);
> +
> +/**
> + * hrtimer_entry - called immediately before the high res timer
> + * @timer: pointer to struct hrtimer
> + *
> + * When used in combination with the hrtimer_exit tracepoint we can
> + * determine the high res timer latency.
> + */
> +TRACE_EVENT(hrtimer_entry,
> +
> + TP_PROTO(struct hrtimer *timer),
> +
> + TP_ARGS(timer),
> +
> + TP_STRUCT__entry(
> + __field(void *, function)
> + ),
> +
> + TP_fast_assign(
> + __entry->function = timer->function;
> + ),
> +
> + TP_printk("func=%pF", __entry->function)
> +);
> +
> +/**
> + * hrtimer_exit - called immediately after the high res timer returns
> + * @timer: pointer to struct hrtimer
> + * @restart: high res timer return value
> + *
> + * High res timer will restart if @restart is set to HRTIMER_RESTART.
> + * When used in combination with the hrtimer_entry tracepoint we can
> + * determine the high res timer latency.
> + */
> +TRACE_EVENT(hrtimer_exit,
> +
> + TP_PROTO(struct hrtimer *timer, int restart),
> +
> + TP_ARGS(timer, restart),
> +
> + TP_STRUCT__entry(
> + __field(void *, function)
> + __field(int, restart)
> + ),
> +
> + TP_fast_assign(
> + __entry->function = timer->function;
> + __entry->restart = restart;
> + ),
> +
> + TP_printk("func=%pF restart=%s", __entry->function,
> + (__entry->restart == HRTIMER_RESTART) ?
> + "HRTIMER_RESTART" : "HRTIMER_NORESTART")
> +);
> +
> +#endif /* _TRACE_TIMER_H */
> +
> +/* This part must be outside protection */
> +#include <trace/define_trace.h>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
>
next prev parent reply other threads:[~2009-05-21 0:01 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-05-20 10:13 Anton Blanchard
2009-05-20 10:25 ` KOSAKI Motohiro
2009-05-20 10:31 ` Thomas Gleixner
2009-05-21 0:01 ` Frédéric Weisbecker [this message]
2009-05-21 0:13 ` Steven Rostedt
2009-05-21 12:38 ` Anton Blanchard
2009-05-25 20:00 ` Frederic Weisbecker
2009-05-26 4:26 ` Anton Blanchard
2009-05-26 4:31 ` [PATCH] tracing/events: Rename worklet_execute to worklet_entry and worklet_complete to worklet_exit Anton Blanchard
2009-05-26 4:32 ` [PATCH] tracing/events: Use %pf in workqueue trace events Anton Blanchard
2009-05-26 4:36 ` tracing/events: Add tasklet tracepoints Anton Blanchard
2009-05-29 13:16 ` [PATCH] tracing/events: Rename worklet_execute to worklet_entry and worklet_complete to worklet_exit Frédéric Weisbecker
2009-05-26 4:55 ` [PATCH v3] tracing/events: Add timer and high res timer tracepoints Anton Blanchard
2009-05-26 18:06 ` [PATCH] " Frederic Weisbecker
2009-05-27 9:28 ` Xiao Guangrong
2009-05-27 14:22 ` Thomas Gleixner
2009-05-27 14:48 ` Frederic Weisbecker
2009-05-29 0:55 ` [PATCH] tracing/events: Add timer and high res timertracepoints Zhaolei
2009-05-27 13:46 ` [PATCH] tracing/events: Add timer and high res timer tracepoints Thomas Gleixner
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=c62985530905201701i36527eblae479c07eec06515@mail.gmail.com \
--to=fweisbec@gmail.com \
--cc=anton@samba.org \
--cc=jbaron@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=rostedt@goodmis.org \
--cc=tglx@linutronix.de \
--cc=tzanussi@gmail.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
all inboxes | Powered by JetHome®