mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: john stultz <johnstul@us.ibm.com>
To: Zhaolei <zhaolei@cn.fujitsu.com>
Cc: Steven Rostedt <rostedt@goodmis.org>,
	KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>,
	Frederic Weisbecker <fweisbec@gmail.com>,
	Ingo Molnar <mingo@elte.hu>, LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 2/3] ftrace: add tracepoint for xtime
Date: Wed, 16 Sep 2009 12:56:14 -0700	[thread overview]
Message-ID: <1f1b08da0909161256m376b1292ia4b2f3b2b4e82c34@mail.gmail.com> (raw)
In-Reply-To: <4A939D4A.1020706@cn.fujitsu.com>

On Tue, Aug 25, 2009 at 1:14 AM, Zhaolei <zhaolei@cn.fujitsu.com> wrote:
> From: Xiao Guangrong <xiaoguangrong@cn.fujitsu.com>
>
> This patch can trace current xtime and wall_to_monotonic. Then user can
> use ctime() to convert them to wall time which is easier to be understood,
> especially for flight-recorder which need to get trace event from a kernel
> dump file.
>
> Example of ftrace output:
>          <idle>-0     [000] 20118.489849: gtod_update_xtime: xtime=1243265589.999999824 wall_to_monotonic=3051713268.744158739
>           <...>-4020  [001] 20118.489855: sys_open(filename: bf9e66e0, flags: 98800, mode: bf9e66e0)
>           <...>-4020  [001] 20118.489873: sys_open -> 0xffffffec
>
> ctime(1243265590) = date:Mon May 25 11:33:10 2009
> So we can realize the task with pid 4020 open a file at
> Mon May 25 11:33:10 2009
>
> Changelog:
> v1->v2: Rebased by Zhao Lei <zhaolei@cn.fujitsu.com>
>
> Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com>
> Signed-off-by: Xiao Guangrong <xiaoguangrong@cn.fujitsu.com>
> ---
>  include/trace/events/xtime.h |   38 ++++++++++++++++++++++++++++++++++++++
>  kernel/time/ntp.c            |    4 ++++
>  kernel/time/timekeeping.c    |    6 ++++++
>  3 files changed, 48 insertions(+), 0 deletions(-)
>  create mode 100644 include/trace/events/xtime.h
>
> diff --git a/include/trace/events/xtime.h b/include/trace/events/xtime.h
> new file mode 100644
> index 0000000..398e679
> --- /dev/null
> +++ b/include/trace/events/xtime.h
> @@ -0,0 +1,38 @@
> +#undef TRACE_SYSTEM
> +#define TRACE_SYSTEM xtime
> +
> +#if !defined(_TRACE_XTIME_H) || defined(TRACE_HEADER_MULTI_READ)
> +#define _TRACE_XTIME_H
> +
> +#include <linux/time.h>
> +#include <linux/tracepoint.h>
> +
> +TRACE_EVENT(gtod_update_xtime,
> +
> +       TP_PROTO(struct timespec *xtime, struct timespec *wall_to_monotonic),
> +
> +       TP_ARGS(xtime, wall_to_monotonic),
> +
> +       TP_STRUCT__entry(
> +               __field(        long,   xtime_sec               )
> +               __field(        long,   xtime_nsec              )
> +               __field(        long,   wall_to_monotonic_sec   )
> +               __field(        long,   wall_to_monotonic_nsec  )
> +       ),
> +
> +       TP_fast_assign(
> +               __entry->xtime_sec              = xtime->tv_sec;
> +               __entry->xtime_nsec             = xtime->tv_nsec;
> +               __entry->wall_to_monotonic_sec  = wall_to_monotonic->tv_sec;
> +               __entry->wall_to_monotonic_nsec = wall_to_monotonic->tv_nsec;
> +       ),
> +
> +       TP_printk("xtime=%ld.%09ld wall_to_monotonic=%ld.%09ld",
> +                 __entry->xtime_sec, __entry->xtime_nsec,
> +                 __entry->wall_to_monotonic_sec, __entry->wall_to_monotonic_nsec)
> +);
> +
> +#endif /* _TRACE_XTIME_H */
> +
> +/* This part must be outside protection */
> +#include <trace/define_trace.h>
> diff --git a/kernel/time/ntp.c b/kernel/time/ntp.c
> index 4800f93..fc2f13a 100644
> --- a/kernel/time/ntp.c
> +++ b/kernel/time/ntp.c
> @@ -15,6 +15,8 @@
>  #include <linux/time.h>
>  #include <linux/mm.h>
>
> +#include <trace/events/xtime.h>
> +
>  /*
>  * NTP timekeeping variables:
>  */
> @@ -218,6 +220,8 @@ static enum hrtimer_restart ntp_leap_second(struct hrtimer *timer)
>                break;
>        }
>
> +       trace_gtod_update_xtime(&xtime, &wall_to_monotonic);
> +
>        write_sequnlock(&xtime_lock);
>
>        return res;
> diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
> index 03cbeb3..2e57a87 100644
> --- a/kernel/time/timekeeping.c
> +++ b/kernel/time/timekeeping.c
> @@ -20,6 +20,9 @@
>  #include <linux/tick.h>
>  #include <linux/stop_machine.h>
>
> +#define CREATE_TRACE_POINTS
> +#include <trace/events/xtime.h>
> +
>  /* Structure holding internal timekeeping values. */
>  struct timekeeper {
>        /* Current clocksource used for timekeeping. */
> @@ -338,6 +341,8 @@ int do_settimeofday(struct timespec *tv)
>
>        update_vsyscall(&xtime, timekeeper.clock);
>
> +       trace_gtod_update_xtime(&xtime, &wall_to_monotonic);
> +

So the only thing to watch out on here is that xtime doesn't hold the
current time, but the accumulated time. There is some unaccumulated
time still kept in the clocksource structure.

You probably want (assuming you only need tick granularity time) to
use current_kernel_time().

As an aside, is there a reason you have to have update callbacks and
duplicate the time storage instead of using the existing interfaces?
(ie: Is this due to locking or something else?)

thanks
-john

  parent reply	other threads:[~2009-09-16 20:23 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-07-24 10:40 [PATCH 0/3] Add walltime support for ring-buffer Zhaolei
2009-07-24 10:42 ` [PATCH] " Zhaolei
2009-07-24 10:47   ` Zhaolei
2009-07-24 10:43 ` [RFC PATCH 1/3] " Zhaolei
2009-07-24 10:43 ` [RFC PATCH 2/3] Apply walltime-supporting functions to trace system Zhaolei
2009-07-24 10:44 ` [RFC PATCH 3/3] Make ftrace display walltime in output Zhaolei
2009-07-24 13:05 ` [PATCH 0/3] Add walltime support for ring-buffer Steven Rostedt
2009-07-28  1:43   ` KOSAKI Motohiro
2009-07-28  1:53     ` Frederic Weisbecker
2009-07-28  2:19       ` Steven Rostedt
2009-08-17  9:22         ` [RFC PATCH] Add timer-source of walltime for ftrace Zhaolei
2009-08-17 16:49           ` Frederic Weisbecker
2009-08-18  2:09             ` Zhaolei
2009-08-18 18:52               ` Steven Rostedt
2009-08-18 15:57           ` KOSAKI Motohiro
2009-08-18 18:58             ` Steven Rostedt
2009-08-19  9:16               ` Zhaolei
2009-08-25  8:12               ` [PATCH 0/3] ftrace: " Zhaolei
2009-08-25  8:12                 ` [PATCH 1/3] ftrace: Move setting of clock-source out of options Zhaolei
2009-08-26  2:35                   ` Steven Rostedt
2009-08-26  7:23                   ` [tip:tracing/core] " tip-bot for Zhaolei
2009-08-25  8:14                 ` [PATCH 2/3] ftrace: add tracepoint for xtime Zhaolei
2009-08-26  2:39                   ` Steven Rostedt
2009-09-01  8:03                     ` Zhaolei
2009-09-16 19:56                   ` john stultz [this message]
2009-09-16 19:58                     ` john stultz
2009-09-16 20:32                       ` Steven Rostedt
2009-09-16 20:49                         ` john stultz
2009-09-17  6:34                           ` Zhaolei
2009-08-25  8:15                 ` [PATCH 3/3] ftrace: Add timer-source of walltime for ftrace Zhaolei
2009-08-26  2:52                   ` Steven Rostedt
2009-09-16  5:25                 ` [PATCH v2 0/2] " Zhaolei
2009-09-16  5:27                   ` [PATCH v2 1/2] ftrace: add tracepoint for xtime Zhaolei
2009-09-16 19:33                     ` Steven Rostedt
2009-09-16  5:29                   ` [PATCH v2 2/2] ftrace: Add timer-source of walltime for ftrace Zhaolei
2009-09-16  5:59                     ` Frederic Weisbecker
2009-09-16  6:40                       ` Zhaolei
2009-09-16 19:37                         ` Steven Rostedt
2009-09-17  7:10                           ` Zhaolei
2009-11-04  9:39                             ` [PATCH v3] ftrace: Add timer-source of walltime Zhaolei
2009-11-04  9:39                             ` Zhaolei
2009-11-04  9:41                             ` Zhaolei
2009-07-28  2:23       ` [PATCH 0/3] Add walltime support for ring-buffer KOSAKI Motohiro
2009-08-03  7:22         ` Ingo Molnar
2009-08-03  9:32           ` KOSAKI Motohiro
2009-08-04 14:38             ` Ingo Molnar

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=1f1b08da0909161256m376b1292ia4b2f3b2b4e82c34@mail.gmail.com \
    --to=johnstul@us.ibm.com \
    --cc=fweisbec@gmail.com \
    --cc=kosaki.motohiro@jp.fujitsu.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=rostedt@goodmis.org \
    --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

all inboxes | Powered by JetHome®