On Sat, 28 Jun 2014 19:10:00 +0800 Xie XiuQi <xiexi...@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); > } > > /* -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/