Re: CLOCK_MONOTONIC / CLOCK_UPTIME is not really monotonic between threads

From: Konstantin Belousov <kostikbel_at_gmail.com>
Date: Fri, 3 Jun 2016 20:18:09 +0300
On Fri, Jun 03, 2016 at 08:04:29AM -0700, Maxim Sobolev wrote:
> Konstantin,
> 
> Thanks for taking your time looking into it and sorry for somewhat messy
> problem report. I've been trying to fix that problem all day yesterday
> thinking it's just application logic that is broken and indeed has been
> able to find some bigger issues that were obscuring this one. But it got
> very frustrating when the bug popped out anew at a seemingly lower level
> now. The issue that triggered this is in some high level python code. Which
> makes it quite difficult to narrow and isolate. There is still slight
> chance that it's something about threading within the python that screws
> this up somehow, however I don't quite see how that could lead to a
> consistent result that is just off by few hundred microseconds and not in
> some random garbage.
> 
> So, I take from you message, that high level
> clock_gettime(CLOCK_MONOTONIC*) is supposed to be monotonic with respect to
> the wall time even when called in different threads? I always though it is,
> but was not 100% sure about that and wanted to confirm it before I dive
> deeper into this and spend more time writing a test case to expose this.
Yes, CLOCK_MONOTONIC should be monotonic across all processors.
Until the time travel is made possible, of course.

> The test case you gave me is interesting, but somewhat low-level. What I
> would do if it comes to it, is to make something that uses pthreads and
> plain clock_gettime(2). Should not be too difficult to reproduce if it's
> real issue.
The test I give you verifies clock_gettime() in several threads going
backward.

> 
> P.S. I've also tried kern.timecounter.fast_gettime=0, made no difference.
> Assuming it does not take a reboot to test it. Neither does
> switching kern.timecounter.hardware, I've tested TSC-low(1000)
> ACPI-fast(900) HPET(950) i8254(0), all are the same.
I am almost sure this is app-level issue.

To make me confident, run the test I provided.
Received on Fri Jun 03 2016 - 15:18:17 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:41:05 UTC