From d653db32f295e4a9d5fd53961f384ea427989dd5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Tue, 23 Jul 2019 14:40:22 +0300 Subject: MDEV-14154: Make ut_time_ms(), ut_time_us() monotonic This is motivated by PS-5221 in percona/percona-server@2817c561fce9e20a83b13272ac45fd333467715d The coarser-precision ut_time() will still refer to the system clock, meaning that bad things can happen if the real time clock is adjusted backwards. --- storage/innobase/ut/ut0ut.cc | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) (limited to 'storage/innobase/ut') diff --git a/storage/innobase/ut/ut0ut.cc b/storage/innobase/ut/ut0ut.cc index b108fd7002e..92250bf0ebf 100644 --- a/storage/innobase/ut/ut0ut.cc +++ b/storage/innobase/ut/ut0ut.cc @@ -1,6 +1,7 @@ /***************************************************************************** Copyright (c) 1994, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2019, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -165,12 +166,7 @@ ut_time_us( /*=======*/ ullint* tloc) /*!< out: us since epoch, if non-NULL */ { - struct timeval tv; - ullint us; - - ut_gettimeofday(&tv, NULL); - - us = (ullint) tv.tv_sec * 1000000 + tv.tv_usec; + ullint us = my_interval_timer() / 1000; if (tloc != NULL) { *tloc = us; @@ -189,11 +185,7 @@ ulint ut_time_ms(void) /*============*/ { - struct timeval tv; - - ut_gettimeofday(&tv, NULL); - - return((ulint) tv.tv_sec * 1000 + tv.tv_usec / 1000); + return static_cast(my_interval_timer() / 1000000); } #endif /* !UNIV_HOTBACKUP */ -- cgit v1.2.1 From c385d80abd8fd0f1aa1d514e046da96dc2011175 Mon Sep 17 00:00:00 2001 From: Laurynas Biveinis Date: Wed, 30 Jan 2019 10:16:55 +0200 Subject: Fix PS-5388 (Enable hardware CRC32 under Valgrind) Valgrind started supporting CRC32 instruction starting with version 3.6.1, released in 2011. Thus remove the fallback to software implementation in case running under Valgrind. --- storage/innobase/ut/ut0crc32.cc | 19 ------------------- 1 file changed, 19 deletions(-) (limited to 'storage/innobase/ut') diff --git a/storage/innobase/ut/ut0crc32.cc b/storage/innobase/ut/ut0crc32.cc index cdf036e9d50..4d2d311ff48 100644 --- a/storage/innobase/ut/ut0crc32.cc +++ b/storage/innobase/ut/ut0crc32.cc @@ -316,26 +316,7 @@ ut_crc32_init() ut_cpuid(vend, &model, &family, &stepping, &features_ecx, &features_edx); - /* Valgrind does not understand the CRC32 instructions: - - vex amd64->IR: unhandled instruction bytes: 0xF2 0x48 0xF 0x38 0xF0 0xA - valgrind: Unrecognised instruction at address 0xad3db5. - Your program just tried to execute an instruction that Valgrind - did not recognise. There are two possible reasons for this. - 1. Your program has a bug and erroneously jumped to a non-code - location. If you are running Memcheck and you just saw a - warning about a bad jump, it's probably your program's fault. - 2. The instruction is legitimate but Valgrind doesn't handle it, - i.e. it's Valgrind's fault. If you think this is the case or - you are not sure, please let us know and we'll try to fix it. - Either way, Valgrind will now raise a SIGILL signal which will - probably kill your program. - - */ -#ifndef UNIV_DEBUG_VALGRIND ut_crc32_sse2_enabled = (features_ecx >> 20) & 1; -#endif /* UNIV_DEBUG_VALGRIND */ - #endif /* defined(__GNUC__) && defined(__x86_64__) */ #if defined(__linux__) && defined(__powerpc__) && defined(AT_HWCAP2) \ -- cgit v1.2.1 From 97055e6b11508b53203aaadfe4618f543891c575 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Tue, 23 Jul 2019 17:13:00 +0300 Subject: MDEV-14154: Remove ut_time_us() Use microsecond_interval_timer() or my_interval_timer() [in nanoseconds] instead. --- storage/innobase/ut/ut0ut.cc | 19 ------------------- 1 file changed, 19 deletions(-) (limited to 'storage/innobase/ut') diff --git a/storage/innobase/ut/ut0ut.cc b/storage/innobase/ut/ut0ut.cc index a0d51a178ca..aa73ee010fc 100644 --- a/storage/innobase/ut/ut0ut.cc +++ b/storage/innobase/ut/ut0ut.cc @@ -144,25 +144,6 @@ ut_usectime( return(ret); } -/**********************************************************//** -Returns the number of microseconds since epoch. Similar to -time(3), the return value is also stored in *tloc, provided -that tloc is non-NULL. -@return us since epoch */ -uintmax_t -ut_time_us( -/*=======*/ - uintmax_t* tloc) /*!< out: us since epoch, if non-NULL */ -{ - uintmax_t us = my_interval_timer() / 1000; - - if (tloc != NULL) { - *tloc = us; - } - - return(us); -} - /**********************************************************//** Returns the number of milliseconds since some epoch. The value may wrap around. It should only be used for heuristic -- cgit v1.2.1