From: Steven Rostedt <rostedt@goodmis.org>
To: Xie XiuQi <xiexiuqi@huawei.com>
Cc: <linux-kernel@vger.kernel.org>, <mingo@redhat.com>,
<tony.luck@intel.com>, <fweisbec@gmail.com>,
<m.chehab@samsung.com>
Subject: Re: [PATCH 1/2] tracing: fix uptime overflow problem
Date: Mon, 30 Jun 2014 11:10:40 -0400 [thread overview]
Message-ID: <20140630111040.58fe70de@gandalf.local.home> (raw)
In-Reply-To: <1403953801-19068-2-git-send-email-xiexiuqi@huawei.com>
On Sat, 28 Jun 2014 19:10:00 +0800
Xie XiuQi <xiexiuqi@huawei.com> wrote:
> /*
> - * trace_jiffy_clock(): Simply use jiffies as a clock counter.
> + * trace_clock_uptime(): Use lockless version __current_kernel_time,
> + * so it's safe in NMI context.
> */
> -u64 notrace trace_clock_jiffies(void)
> +u64 notrace trace_clock_uptime(void)
> {
> - u64 jiffy = jiffies - INITIAL_JIFFIES;
> + struct timespec uptime, now, boottime;
> +
> + /* Does not take xtime_lock, so it's safe in NMI context. */
> + now = __current_kernel_time();
The problem with this patch is that you have a race:
ts.tv_sec = tk->xtime_sec;
ts.tv_nsec = (long)(tk->xtime_nsec >> tk->shift);
There's a chance that gets done between the update of xtime_sec an
xtime_nsec, and make time go backwards.
This call is lockless but is not reliable.
-- Steve
> + getboottime(&boottime);
> + uptime = timespec_sub(now, boottime);
>
> /* Return nsecs */
> - return (u64)jiffies_to_usecs(jiffy) * 1000ULL;
> + return timespec_to_ns(&uptime);
> }
>
> /*
next prev parent reply other threads:[~2014-06-30 15:10 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-28 11:09 [PATCH 0/2] tracing: fix uptime overflow problem Xie XiuQi
2014-06-28 11:10 ` [PATCH 1/2] " Xie XiuQi
2014-06-30 15:10 ` Steven Rostedt [this message]
2014-06-30 18:17 ` [PATCH] tracing: Fix wraparound problems in "uptime" tracer Tony Luck
2014-06-30 18:40 ` Steven Rostedt
2014-06-30 20:31 ` [PATCH-v2] " Tony Luck
2014-07-17 23:02 ` Tony Luck
2014-07-18 2:08 ` Steven Rostedt
2014-07-18 17:05 ` Tony Luck
2014-07-18 17:36 ` Steven Rostedt
2014-07-18 18:43 ` [PATCH] " Tony Luck
2014-07-18 18:47 ` Steven Rostedt
2014-07-18 18:54 ` Tony Luck
2014-06-28 11:10 ` [PATCH 2/2] tracing: update Documentation/trace/ftrace.txt for uptime Xie XiuQi
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=20140630111040.58fe70de@gandalf.local.home \
--to=rostedt@goodmis.org \
--cc=fweisbec@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=m.chehab@samsung.com \
--cc=mingo@redhat.com \
--cc=tony.luck@intel.com \
--cc=xiexiuqi@huawei.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.