[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20140630111040.58fe70de@gandalf.local.home>
Date: Mon, 30 Jun 2014 11:10:40 -0400
From: Steven Rostedt <rostedt@...dmis.org>
To: Xie XiuQi <xiexiuqi@...wei.com>
Cc: <linux-kernel@...r.kernel.org>, <mingo@...hat.com>,
<tony.luck@...el.com>, <fweisbec@...il.com>, <m.chehab@...sung.com>
Subject: Re: [PATCH 1/2] tracing: fix uptime overflow problem
On Sat, 28 Jun 2014 19:10:00 +0800
Xie XiuQi <xiexiuqi@...wei.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);
> }
>
> /*
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists