[libc-commits] [libc] [libc][NFC] Attempt to deflake gettimeofday_test. (PR #69719)

Guillaume Chatelet via libc-commits libc-commits at lists.llvm.org
Fri Oct 20 06:57:43 PDT 2023


================
@@ -15,24 +15,31 @@
 
 namespace cpp = LIBC_NAMESPACE::cpp;
 
+using LIBC_NAMESPACE::testing::tlog;
+
 TEST(LlvmLibcGettimeofday, SmokeTest) {
   using LIBC_NAMESPACE::testing::ErrnoSetterMatcher::Succeeds;
   void *tz = nullptr;
-  timeval tv;
 
   suseconds_t sleep_times[2] = {200, 1000};
----------------
gchatelet wrote:

> I remember awhile ago there were some motherboards whose TSCs would run backwards for some strange reason. I haven't been able to find any indication that this is still a problem, which makes me wonder if there's a different bug here as well. I don't know enough about system clocks, though.

Are you talking about 1. `TSC` (clock internal to the CPU core and read via instruction such as `rdtsc`) or 2. the BIOS `RTC` (clock that runs on battery on the motherboard)?

Possible explanations depending on the answer:
1. the counter wrapped around (hence looking like stepping back) or the process has been migrated to another core (with a different counter value).
2. it can come from background NTP synchronization that resets the clock to a different point in time.

https://github.com/llvm/llvm-project/pull/69719


More information about the libc-commits mailing list