Messages in this thread | | | Date | Mon, 30 Jun 2014 11:10:40 -0400 | From | Steven Rostedt <> | Subject | Re: [PATCH 1/2] tracing: fix uptime overflow problem |
| |
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); > } > > /*
| |