Date: Fri, 3 Jun 2016 20:18:09 +0300 From: Konstantin Belousov <kostikbel@gmail.com> To: Maxim Sobolev <sobomax@freebsd.org> Cc: FreeBSD Current <freebsd-current@freebsd.org> Subject: Re: CLOCK_MONOTONIC / CLOCK_UPTIME is not really monotonic between threads Message-ID: <20160603171809.GX38613@kib.kiev.ua> In-Reply-To: <CAH7qZftZ3oHAhsfmoZncorBN7Nr_wXn3MK6Q7YfG_eh_bZJnqQ@mail.gmail.com> References: <CAH7qZfsBLM_wqdTXiiyVvevwU%2Bu257dX9JvZFftfntduUaZDMw@mail.gmail.com> <20160603050628.GV38613@kib.kiev.ua> <CAH7qZftZ3oHAhsfmoZncorBN7Nr_wXn3MK6Q7YfG_eh_bZJnqQ@mail.gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
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.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20160603171809.GX38613>