Re: clock_gettime_ns

From: Andy Lutomirski
Date: Wed Sep 04 2013 - 14:52:05 EST


I think that most of the hangup was a lack of agreement on how the API
should work wrt leap seconds.

I've always thought that the Right Way to represent a UTC time is
nanoseconds since some epoch, where every potential leap second
counts.

Pros:
- Unambiguously convertible to and from
year/month/day/hour/minute/second/nanosecond.
- Monotonic
- Compact

Cons:
- Computing differences between timestamps requires a table. (Note:
y/m/d/h/m/s/ns has the same problem.)
- Weird: no one does this
- If you naively subtract times, you end up with jumps forward. (But
jumps forward are much less likely to break things than jumps
backwards.)
- Almost, but not quite, compatible with timespec, so it could cause confusion.

If someone wants a hard problem, find a way to implement clock_gettime
that almost never spins or otherwise block and is continuous. I've
thought about it a bit and have something that almost works.

--Andy

On Wed, Sep 4, 2013 at 2:18 AM, Arun Sharma <asharma@xxxxxx> wrote:
> A couple of years ago Andy posted this patch series:
>
> http://thread.gmane.org/gmane.linux.kernel/1233209/
>
> These patches have been in use at facebook for a couple of years and along
> with a vDSO implementation of thread_cpu_time(), they have proven useful for
> our profilers.
>
> I didn't see any arguments against this patch series. Did I miss some
> discussion on the topic?
>
> -Arun



--
Andy Lutomirski
AMA Capital Management, LLC
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/